topology.h 2.9 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970717273747576777879
  1. /* StarPU --- Runtime system for heterogeneous multicore architectures.
  2. *
  3. * Copyright (C) 2009-2010, 2012, 2014-2017 Université de Bordeaux
  4. * Copyright (C) 2010, 2015, 2017 CNRS
  5. * Copyright (C) 2017 Inria
  6. *
  7. * StarPU is free software; you can redistribute it and/or modify
  8. * it under the terms of the GNU Lesser General Public License as published by
  9. * the Free Software Foundation; either version 2.1 of the License, or (at
  10. * your option) any later version.
  11. *
  12. * StarPU is distributed in the hope that it will be useful, but
  13. * WITHOUT ANY WARRANTY; without even the implied warranty of
  14. * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.
  15. *
  16. * See the GNU Lesser General Public License in COPYING.LGPL for more details.
  17. */
  18. #ifndef __TOPOLOGY_H__
  19. #define __TOPOLOGY_H__
  20. #include <starpu.h>
  21. #include <common/config.h>
  22. #include <common/list.h>
  23. #include <common/fxt.h>
  24. /* TODO actually move this struct into this header */
  25. struct _starpu_machine_config;
  26. #ifndef STARPU_SIMGRID
  27. #ifdef STARPU_HAVE_HWLOC
  28. /* This is allocated for each hwloc object */
  29. struct _starpu_hwloc_userdata {
  30. struct _starpu_worker_list *worker_list; /* List of workers running on this obj */
  31. unsigned ngpus; /* Number of GPUs sharing this PCI link */
  32. };
  33. #endif
  34. #endif
  35. /* Detect the number of memory nodes and where to bind the different workers. */
  36. int _starpu_build_topology(struct _starpu_machine_config *config, int no_mp_config);
  37. /* Should be called instead of _starpu_destroy_topology when _starpu_build_topology returns a non zero value. */
  38. void _starpu_destroy_machine_config(struct _starpu_machine_config *config);
  39. /* Destroy all resources used to store the topology of the machine. */
  40. void _starpu_destroy_topology(struct _starpu_machine_config *config);
  41. /* returns the number of physical cpus */
  42. unsigned _starpu_topology_get_nhwcpu(struct _starpu_machine_config *config);
  43. /* returns the number of logical cpus */
  44. unsigned _starpu_topology_get_nhwpu(struct _starpu_machine_config *config);
  45. /* returns the number of NUMA nodes */
  46. unsigned _starpu_topology_get_nnumanodes(struct _starpu_machine_config *config);
  47. #ifdef STARPU_HAVE_HWLOC
  48. /* Small convenient function to filter hwloc topology depending on HWLOC API version */
  49. void _starpu_topology_filter(hwloc_topology_t topology);
  50. #endif
  51. #define STARPU_NOWORKERID -1
  52. /* Bind the current thread on the CPU logically identified by "cpuid". The
  53. * logical ordering of the processors is either that of hwloc (if available),
  54. * or the ordering exposed by the OS. */
  55. void _starpu_bind_thread_on_cpu(int cpuid, int workerid);
  56. struct _starpu_combined_worker;
  57. /* Bind the current thread on the set of CPUs for the given combined worker. */
  58. void _starpu_bind_thread_on_cpus(struct _starpu_combined_worker *combined_worker);
  59. struct _starpu_worker *_starpu_get_worker_from_driver(struct starpu_driver *d);
  60. int starpu_memory_nodes_get_numa_count(void);
  61. int starpu_memory_nodes_numa_id_to_hwloclogid(unsigned id);
  62. #endif // __TOPOLOGY_H__