topology.h 2.6 KB

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