topology.h 1.9 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475
  1. /*
  2. * StarPU
  3. * Copyright (C) INRIA 2008-2009 (see AUTHORS file)
  4. *
  5. * This program 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. * This program 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. #include <stdio.h>
  19. #include <stdlib.h>
  20. #include <stdint.h>
  21. #include <unistd.h>
  22. #include <string.h>
  23. #include <pthread.h>
  24. #include <common/config.h>
  25. #include <common/list.h>
  26. #include <common/fxt.h>
  27. #include <starpu.h>
  28. /* TODO actually move this struct into this header */
  29. struct starpu_machine_config_s;
  30. /* This structure is "inspired" by the hwloc project
  31. * (see http://www.open-mpi.org/projects/hwloc/) */
  32. struct starpu_topo_obj_t {
  33. /* global position */
  34. unsigned level;
  35. unsigned number;
  36. /* father */
  37. struct starpu_topo_obj_t *father;
  38. unsigned index;
  39. /* children */
  40. unsigned arity;
  41. struct starpu_topo_obj **children;
  42. struct starpu_topo_obj *first_child;
  43. struct starpu_topo_obj *last_child;
  44. /* cousins */
  45. struct topo_obj *next_cousin;
  46. struct topo_obj *prev_cousin;
  47. /* for the convenience of the scheduler */
  48. void *sched_data;
  49. /* flags */
  50. unsigned is_a_worker;
  51. struct starpu_worker_s *worker; /* (ignored if !is_a_worker) */
  52. };
  53. int _starpu_build_topology(struct starpu_machine_config_s *config);
  54. void _starpu_destroy_topology(struct starpu_machine_config_s *config);
  55. /* returns the number of physical cpus */
  56. unsigned _starpu_topology_get_nhwcpu(struct starpu_machine_config_s *config);
  57. void _starpu_bind_thread_on_cpu(struct starpu_machine_config_s *config, unsigned cpuid);
  58. #endif // __TOPOLOGY_H__