StarPU Internal Handbook
topology.h
Go to the documentation of this file.
1 /* StarPU --- Runtime system for heterogeneous multicore architectures.
2  *
3  * Copyright (C) 2009-2023 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 
17 #ifndef __TOPOLOGY_H__
18 #define __TOPOLOGY_H__
19 
22 #include <starpu.h>
23 #include <common/config.h>
24 #include <common/list.h>
25 #include <common/fxt.h>
26 #include <common/uthash.h>
27 
28 #pragma GCC visibility push(hidden)
29 
31 
32 #ifndef STARPU_SIMGRID
33 #ifdef STARPU_HAVE_HWLOC
35 struct _starpu_hwloc_userdata
36 {
38  struct _starpu_worker_list *worker_list;
40  unsigned ngpus;
42  struct _starpu_worker *pu_worker;
43 };
44 #endif
45 #endif
46 
47 struct _starpu_worker_set;
49 
51 int _starpu_build_topology(struct _starpu_machine_config *config, int no_mp_config);
52 
54 void _starpu_initialize_workers_deviceid(int *explicit_workers_gpuid,
55  int *current, int *workers_gpuid,
56  const char *varname, unsigned nhwgpus,
57  enum starpu_worker_archtype type);
58 
61 
64 void _starpu_topology_check_ndevices(int *ndevices, unsigned nhwdevices, int overflow, unsigned max, int reserved, const char *nname, const char *dname, const char *configurename);
65 
73 #define ALLOC_WORKER_SET ((struct _starpu_worker_set*) -1)
74 
76 #define DEVID_PER_WORKER -2
77 
78 void _starpu_topology_configure_workers(struct _starpu_machine_topology *topology,
79  struct _starpu_machine_config *config,
80  enum starpu_worker_archtype type,
81  int devnum, int devid,
82  int homogeneous, int worker_devid,
83  unsigned nworker_per_device,
84  unsigned ncores,
85  struct _starpu_worker_set *worker_set,
86  struct _starpu_worker_set *driver_worker_set);
87 
88 extern unsigned _starpu_may_bind_automatically[STARPU_NARCH];
89 
94 unsigned _starpu_get_next_bindid(struct _starpu_machine_config *config, unsigned flags,
95  unsigned *preferred_binding, unsigned npreferred);
96 
98 void _starpu_destroy_machine_config(struct _starpu_machine_config *config, int no_mp_config);
99 
102 
103 #ifdef STARPU_HAVE_HWLOC
105 hwloc_obj_t _starpu_numa_get_obj(hwloc_obj_t obj);
106 #endif
107 
110 
113 
115 unsigned _starpu_topology_get_nhwpu(struct _starpu_machine_config *config);
116 
119 
122 
124 unsigned _starpu_topology_get_numa_core_binding(struct _starpu_machine_config *config, const unsigned *numa_binding, unsigned nnuma, unsigned *binding, unsigned nbinding);
125 
126 int starpu_memory_nodes_numa_hwloclogid_to_id(int logid);
127 
128 /* This returns the exact NUMA node next to a worker */
129 int _starpu_get_logical_numa_node_worker(unsigned workerid);
130 
132 unsigned _starpu_get_nhyperthreads() STARPU_ATTRIBUTE_VISIBILITY_DEFAULT;
133 
134 #ifdef STARPU_HAVE_HWLOC
136 void _starpu_topology_filter(hwloc_topology_t topology);
137 #endif
138 
139 #define STARPU_NOWORKERID -1
140 #define STARPU_ACTIVETHREAD -2
141 #define STARPU_NONACTIVETHREAD -2
145 int _starpu_bind_thread_on_cpu(int cpuid, int workerid, const char *name);
146 
150 
151 struct _starpu_worker *_starpu_get_worker_from_driver(struct starpu_driver *d);
152 
153 unsigned starpu_memory_nodes_get_numa_count(void) STARPU_ATTRIBUTE_VISIBILITY_DEFAULT;
154 int starpu_memory_nodes_numa_id_to_hwloclogid(unsigned id);
155 
157 int _starpu_task_data_get_node_on_node(struct starpu_task *task, unsigned index, unsigned target_node);
159 int _starpu_task_data_get_node_on_worker(struct starpu_task *task, unsigned index, unsigned worker);
160 
161 #pragma GCC visibility pop
162 
163 #endif // __TOPOLOGY_H__
Definition: starpu_driver.h:49
starpu_worker_archtype
Definition: starpu_worker.h:66
unsigned starpu_memory_nodes_get_numa_count(void)
@ STARPU_NARCH
Definition: starpu_worker.h:74
Definition: workers.h:311
Definition: workers.h:441
Definition: workers.h:352
unsigned nhwdevices[STARPU_NARCH]
Definition: workers.h:388
int devid[STARPU_NARCH][STARPU_NMAXDEVS]
Definition: workers.h:404
unsigned ndevices[STARPU_NARCH]
Definition: workers.h:396
Definition: workers.h:339
Definition: workers.h:155
int _starpu_build_topology(struct _starpu_machine_config *config, int no_mp_config)
int _starpu_get_next_devid(struct _starpu_machine_topology *topology, struct _starpu_machine_config *config, enum starpu_worker_archtype arch)
void _starpu_destroy_topology(struct _starpu_machine_config *config)
int _starpu_task_data_get_node_on_worker(struct starpu_task *task, unsigned index, unsigned worker)
void _starpu_destroy_machine_config(struct _starpu_machine_config *config, int no_mp_config)
unsigned _starpu_get_nhyperthreads() STARPU_ATTRIBUTE_VISIBILITY_DEFAULT
unsigned _starpu_topology_get_nhwnumanodes(struct _starpu_machine_config *config)
void _starpu_topology_check_ndevices(int *ndevices, unsigned nhwdevices, int overflow, unsigned max, int reserved, const char *nname, const char *dname, const char *configurename)
unsigned _starpu_get_next_bindid(struct _starpu_machine_config *config, unsigned flags, unsigned *preferred_binding, unsigned npreferred)
int _starpu_task_data_get_node_on_node(struct starpu_task *task, unsigned index, unsigned target_node)
unsigned _starpu_topology_get_numa_core_binding(struct _starpu_machine_config *config, const unsigned *numa_binding, unsigned nnuma, unsigned *binding, unsigned nbinding)
int _starpu_bind_thread_on_cpu(int cpuid, int workerid, const char *name)
unsigned _starpu_topology_get_nnumanodes(struct _starpu_machine_config *config)
void _starpu_topology_filter(hwloc_topology_t topology)
unsigned _starpu_topology_get_nhwpu(struct _starpu_machine_config *config)
hwloc_obj_t _starpu_numa_get_obj(hwloc_obj_t obj)
void _starpu_initialize_workers_deviceid(int *explicit_workers_gpuid, int *current, int *workers_gpuid, const char *varname, unsigned nhwgpus, enum starpu_worker_archtype type)
void _starpu_bind_thread_on_cpus(struct _starpu_combined_worker *combined_worker)
unsigned _starpu_topology_get_nhwcpu(struct _starpu_machine_config *config)