StarPU Handbook
starpu_worker.h
Go to the documentation of this file.
1 /* StarPU --- Runtime system for heterogeneous multicore architectures.
2  *
3  * Copyright (C) 2009-2020 Université de Bordeaux, CNRS (LaBRI UMR 5800), Inria
4  * Copyright (C) 2013 Thibaut Lambert
5  * Copyright (C) 2016 Uppsala University
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 
19 #ifndef __STARPU_WORKER_H__
20 #define __STARPU_WORKER_H__
21 
22 #include <stdlib.h>
23 #include <starpu_config.h>
24 #include <starpu_thread.h>
25 #include <starpu_task.h>
26 
27 #ifdef STARPU_HAVE_HWLOC
28 #include <hwloc.h>
29 #endif
30 
31 #ifdef __cplusplus
32 extern "C"
33 {
34 #endif
35 
45 {
46  STARPU_UNUSED=0,
47  STARPU_CPU_RAM=1,
48  STARPU_CUDA_RAM=2,
49  STARPU_OPENCL_RAM=3,
50  STARPU_DISK_RAM=4,
51  STARPU_MIC_RAM=5,
52  STARPU_MPI_MS_RAM=6
53 };
54 
63 {
70 };
71 
76 {
81  int cursor;
82  void *value;
83  void *possible_value;
84  char visited[STARPU_NMAXWORKERS];
85  int possibly_parallel;
86 };
87 
92 {
95 };
96 
105 {
109  int *workerids;
110  void *collection_private;
114  unsigned nworkers;
115  void *unblocked_workers;
116  unsigned nunblocked_workers;
117  void *masters;
118  unsigned nmasters;
119  char present[STARPU_NMAXWORKERS];
120  char is_unblocked[STARPU_NMAXWORKERS];
121  char is_master[STARPU_NMAXWORKERS];
129  unsigned (*has_next)(struct starpu_worker_collection *workers, struct starpu_sched_ctx_iterator *it);
133  int (*get_next)(struct starpu_worker_collection *workers, struct starpu_sched_ctx_iterator *it);
137  int (*add)(struct starpu_worker_collection *workers, int worker);
141  int (*remove)(struct starpu_worker_collection *workers, int worker);
145  void (*init)(struct starpu_worker_collection *workers);
149  void (*deinit)(struct starpu_worker_collection *workers);
154  void (*init_iterator_for_parallel_tasks)(struct starpu_worker_collection *workers, struct starpu_sched_ctx_iterator *it, struct starpu_task *task);
155 };
156 
157 extern struct starpu_worker_collection worker_list;
158 extern struct starpu_worker_collection worker_tree;
159 
165 unsigned starpu_worker_get_count(void);
166 
171 unsigned starpu_cpu_worker_get_count(void);
172 
177 unsigned starpu_cuda_worker_get_count(void);
178 
183 unsigned starpu_opencl_worker_get_count(void);
184 
188 unsigned starpu_mic_worker_get_count(void);
189 
193 unsigned starpu_mpi_ms_worker_get_count(void);
194 
199 unsigned starpu_mic_device_get_count(void);
200 
208 int starpu_worker_get_id(void);
209 
210 unsigned _starpu_worker_get_id_check(const char *f, int l);
211 
217 unsigned starpu_worker_get_id_check(void);
218 
219 #define starpu_worker_get_id_check() _starpu_worker_get_id_check(__FILE__, __LINE__)
220 int starpu_worker_get_bindid(int workerid);
221 
222 void starpu_sched_find_all_worker_combinations(void);
223 
234 
241 
254 unsigned starpu_worker_get_ids_by_type(enum starpu_worker_archtype type, int *workerids, unsigned maxsize);
255 
261 
269 
279 void starpu_worker_get_name(int id, char *dst, size_t maxlen);
280 
286 
297 int starpu_worker_get_devid(int id);
298 
299 int starpu_worker_get_mp_nodeid(int id);
300 
301 struct starpu_tree* starpu_workers_get_tree(void);
302 
303 unsigned starpu_worker_get_sched_ctx_list(int worker, unsigned **sched_ctx);
304 
305 unsigned starpu_worker_is_blocked_in_parallel(int workerid);
306 
307 unsigned starpu_worker_is_slave_somewhere(int workerid);
308 
313 
314 int starpu_bindid_get_workerids(int bindid, int **workerids);
315 
316 int starpu_worker_get_devids(enum starpu_worker_archtype type, int *devids, int num);
317 
318 int starpu_worker_get_stream_workerids(unsigned devid, int *workerids, enum starpu_worker_archtype type);
319 
320 unsigned starpu_worker_get_sched_ctx_id_stream(unsigned stream_workerid);
321 
322 #ifdef STARPU_HAVE_HWLOC
323 
329 hwloc_cpuset_t starpu_worker_get_hwloc_cpuset(int workerid);
334 hwloc_obj_t starpu_worker_get_hwloc_obj(int workerid);
335 #endif
336 
337 int starpu_memory_node_get_devid(unsigned node);
338 
343 
348 unsigned starpu_worker_get_memory_node(unsigned workerid);
349 
350 unsigned starpu_memory_nodes_get_count(void);
351 int starpu_memory_node_get_name(unsigned node, char *name, size_t size);
352 int starpu_memory_nodes_get_numa_count(void);
353 
359 
364 int starpu_memory_nodes_numa_devid_to_id(unsigned id);
365 
372 enum starpu_node_kind starpu_node_get_kind(unsigned node);
373 
384 
396 void starpu_worker_relax_on(void);
397 
406 void starpu_worker_relax_off(void);
407 
413 
419 void starpu_worker_lock(int workerid);
420 
428 int starpu_worker_trylock(int workerid);
429 
434 void starpu_worker_unlock(int workerid);
435 
439 void starpu_worker_lock_self(void);
440 
444 void starpu_worker_unlock_self(void);
445 
446 #ifdef STARPU_WORKER_CALLBACKS
447 
452 void starpu_worker_set_going_to_sleep_callback(void (*callback)(unsigned workerid));
453 
459 void starpu_worker_set_waking_up_callback(void (*callback)(unsigned workerid));
460 #endif
461 
474 unsigned starpu_combined_worker_get_count(void);
475 unsigned starpu_worker_is_combined_worker(int id);
476 
481 
489 
496 
500 int starpu_combined_worker_assign_workerid(int nworkers, int workerid_array[]);
501 
505 int starpu_combined_worker_get_description(int workerid, int *worker_size, int **combined_workerid);
506 
511 int starpu_combined_worker_can_execute_task(unsigned workerid, struct starpu_task *task, unsigned nimpl);
512 
517 void starpu_parallel_task_barrier_init(struct starpu_task *task, int workerid);
518 
524 void starpu_parallel_task_barrier_init_n(struct starpu_task *task, int worker_size);
525 
528 #ifdef __cplusplus
529 }
530 #endif
531 
532 #endif /* __STARPU_WORKER_H__ */
starpu_worker_collection::get_next
int(* get_next)(struct starpu_worker_collection *workers, struct starpu_sched_ctx_iterator *it)
Definition: starpu_worker.h:133
starpu_worker_display_names
void starpu_worker_display_names(FILE *output, enum starpu_worker_archtype type)
STARPU_OPENCL_WORKER
@ STARPU_OPENCL_WORKER
Definition: starpu_worker.h:66
starpu_worker_get_by_devid
int starpu_worker_get_by_devid(enum starpu_worker_archtype type, int devid)
starpu_worker_set_waking_up_callback
void starpu_worker_set_waking_up_callback(void(*callback)(unsigned workerid))
starpu_worker_get_hwloc_cpuset
hwloc_cpuset_t starpu_worker_get_hwloc_cpuset(int workerid)
starpu_tree
Definition: starpu_tree.h:31
starpu_worker_get_name
void starpu_worker_get_name(int id, char *dst, size_t maxlen)
starpu_combined_worker_get_rank
int starpu_combined_worker_get_rank(void)
starpu_worker_get_memory_node
unsigned starpu_worker_get_memory_node(unsigned workerid)
starpu_worker_get_type_as_string
char * starpu_worker_get_type_as_string(enum starpu_worker_archtype type)
starpu_worker_trylock
int starpu_worker_trylock(int workerid)
starpu_mic_worker_get_count
unsigned starpu_mic_worker_get_count(void)
starpu_worker_lock_self
void starpu_worker_lock_self(void)
starpu_mic_device_get_count
unsigned starpu_mic_device_get_count(void)
starpu_worker_get_ids_by_type
unsigned starpu_worker_get_ids_by_type(enum starpu_worker_archtype type, int *workerids, unsigned maxsize)
starpu_combined_worker_get_id
int starpu_combined_worker_get_id(void)
STARPU_WORKER_LIST
@ STARPU_WORKER_LIST
Definition: starpu_worker.h:94
STARPU_NMAXWORKERS
#define STARPU_NMAXWORKERS
Definition: starpu_config.h:226
starpu_combined_worker_get_size
int starpu_combined_worker_get_size(void)
starpu_memory_nodes_numa_id_to_devid
int starpu_memory_nodes_numa_id_to_devid(int osid)
STARPU_CUDA_WORKER
@ STARPU_CUDA_WORKER
Definition: starpu_worker.h:65
starpu_worker_get_local_memory_node
unsigned starpu_worker_get_local_memory_node(void)
starpu_worker_unlock
void starpu_worker_unlock(int workerid)
starpu_combined_worker_can_execute_task
int starpu_combined_worker_can_execute_task(unsigned workerid, struct starpu_task *task, unsigned nimpl)
starpu_node_kind
starpu_node_kind
Definition: starpu_worker.h:44
starpu_worker_get_type
enum starpu_worker_archtype starpu_worker_get_type(int id)
starpu_cuda_worker_get_count
unsigned starpu_cuda_worker_get_count(void)
starpu_worker_get_count
unsigned starpu_worker_get_count(void)
starpu_combined_worker_get_count
unsigned starpu_combined_worker_get_count(void)
starpu_worker_get_hwloc_obj
hwloc_obj_t starpu_worker_get_hwloc_obj(int workerid)
starpu_worker_set_going_to_sleep_callback
void starpu_worker_set_going_to_sleep_callback(void(*callback)(unsigned workerid))
starpu_parallel_task_barrier_init
void starpu_parallel_task_barrier_init(struct starpu_task *task, int workerid)
starpu_worker_relax_on
void starpu_worker_relax_on(void)
starpu_worker_collection::workerids
int * workerids
Definition: starpu_worker.h:109
starpu_worker_sched_op_pending
int starpu_worker_sched_op_pending(void)
STARPU_MPI_MS_WORKER
@ STARPU_MPI_MS_WORKER
Definition: starpu_worker.h:68
starpu_node_get_kind
enum starpu_node_kind starpu_node_get_kind(unsigned node)
starpu_worker_get_id
int starpu_worker_get_id(void)
starpu_cpu_worker_get_count
unsigned starpu_cpu_worker_get_count(void)
starpu_sched_ctx_iterator::cursor
int cursor
Definition: starpu_worker.h:81
starpu_worker_get_by_type
int starpu_worker_get_by_type(enum starpu_worker_archtype type, int num)
starpu_task
Definition: starpu_task.h:551
starpu_worker_collection::deinit
void(* deinit)(struct starpu_worker_collection *workers)
Definition: starpu_worker.h:149
starpu_worker_collection::remove
int(* remove)(struct starpu_worker_collection *workers, int worker)
Definition: starpu_worker.h:141
starpu_sched_ctx_iterator
Definition: starpu_worker.h:75
starpu_worker_collection::has_next
unsigned(* has_next)(struct starpu_worker_collection *workers, struct starpu_sched_ctx_iterator *it)
Definition: starpu_worker.h:129
starpu_opencl_worker_get_count
unsigned starpu_opencl_worker_get_count(void)
starpu_worker_collection_type
starpu_worker_collection_type
Definition: starpu_worker.h:91
starpu_thread.h
starpu_worker_get_devid
int starpu_worker_get_devid(int id)
starpu_worker_relax_off
void starpu_worker_relax_off(void)
starpu_worker_collection::add
int(* add)(struct starpu_worker_collection *workers, int worker)
Definition: starpu_worker.h:137
STARPU_WORKER_TREE
@ STARPU_WORKER_TREE
Definition: starpu_worker.h:93
starpu_worker_get_relax_state
int starpu_worker_get_relax_state(void)
starpu_parallel_task_barrier_init_n
void starpu_parallel_task_barrier_init_n(struct starpu_task *task, int worker_size)
starpu_task.h
starpu_config.h
starpu_worker_get_count_by_type
int starpu_worker_get_count_by_type(enum starpu_worker_archtype type)
starpu_worker_collection::type
enum starpu_worker_collection_type type
Definition: starpu_worker.h:125
starpu_combined_worker_assign_workerid
int starpu_combined_worker_assign_workerid(int nworkers, int workerid_array[])
starpu_worker_collection::nworkers
unsigned nworkers
Definition: starpu_worker.h:114
starpu_worker_unlock_self
void starpu_worker_unlock_self(void)
STARPU_CPU_WORKER
@ STARPU_CPU_WORKER
Definition: starpu_worker.h:64
starpu_worker_collection
Definition: starpu_worker.h:104
starpu_worker_archtype
starpu_worker_archtype
Definition: starpu_worker.h:62
starpu_worker_get_id_check
#define starpu_worker_get_id_check()
Definition: starpu_worker.h:219
starpu_mpi_ms_worker_get_count
unsigned starpu_mpi_ms_worker_get_count(void)
starpu_memory_nodes_numa_devid_to_id
int starpu_memory_nodes_numa_devid_to_id(unsigned id)
starpu_combined_worker_get_description
int starpu_combined_worker_get_description(int workerid, int *worker_size, int **combined_workerid)
starpu_worker_collection::init
void(* init)(struct starpu_worker_collection *workers)
Definition: starpu_worker.h:145
starpu_worker_lock
void starpu_worker_lock(int workerid)
starpu_worker_collection::init_iterator
void(* init_iterator)(struct starpu_worker_collection *workers, struct starpu_sched_ctx_iterator *it)
Definition: starpu_worker.h:153
STARPU_ANY_WORKER
@ STARPU_ANY_WORKER
Definition: starpu_worker.h:69
STARPU_MIC_WORKER
@ STARPU_MIC_WORKER
Definition: starpu_worker.h:67