topology.h 3.3 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071727374757677787980818283848586
  1. /* StarPU --- Runtime system for heterogeneous multicore architectures.
  2. *
  3. * Copyright (C) 2009-2020 Université de Bordeaux, CNRS (LaBRI UMR 5800), Inria
  4. *
  5. * StarPU is free software; you can redistribute it and/or modify
  6. * it under the terms of the GNU Lesser General Public License as published by
  7. * the Free Software Foundation; either version 2.1 of the License, or (at
  8. * your option) any later version.
  9. *
  10. * StarPU is distributed in the hope that it will be useful, but
  11. * WITHOUT ANY WARRANTY; without even the implied warranty of
  12. * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.
  13. *
  14. * See the GNU Lesser General Public License in COPYING.LGPL for more details.
  15. */
  16. #ifndef __TOPOLOGY_H__
  17. #define __TOPOLOGY_H__
  18. /** @file */
  19. #include <starpu.h>
  20. #include <common/config.h>
  21. #include <common/list.h>
  22. #include <common/fxt.h>
  23. struct _starpu_machine_config;
  24. #ifndef STARPU_SIMGRID
  25. #ifdef STARPU_HAVE_HWLOC
  26. /** This is allocated for each hwloc object */
  27. struct _starpu_hwloc_userdata
  28. {
  29. struct _starpu_worker_list *worker_list; /** List of workers running on this obj */
  30. unsigned ngpus; /** Number of GPUs sharing this PCI link */
  31. struct _starpu_worker *pu_worker; /** Worker running this PU */
  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. #define STARPU_ACTIVETHREAD -2
  53. #define STARPU_NONACTIVETHREAD -2
  54. /** Bind the current thread on the CPU logically identified by "cpuid". The
  55. * logical ordering of the processors is either that of hwloc (if available),
  56. * or the ordering exposed by the OS. */
  57. int _starpu_bind_thread_on_cpu(int cpuid, int workerid, const char *name);
  58. struct _starpu_combined_worker;
  59. /** Bind the current thread on the set of CPUs for the given combined worker. */
  60. void _starpu_bind_thread_on_cpus(struct _starpu_combined_worker *combined_worker);
  61. struct _starpu_worker *_starpu_get_worker_from_driver(struct starpu_driver *d);
  62. int starpu_memory_nodes_get_numa_count(void);
  63. int starpu_memory_nodes_numa_id_to_hwloclogid(unsigned id);
  64. /** Get the memory node for data number i when task is to be executed on memory node target_node */
  65. int _starpu_task_data_get_node_on_node(struct starpu_task *task, unsigned index, unsigned target_node);
  66. int _starpu_task_data_get_node_on_worker(struct starpu_task *task, unsigned index, unsigned worker);
  67. #endif // __TOPOLOGY_H__