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-2022 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 starpu_worker_list;
158 extern struct starpu_worker_collection starpu_worker_tree;
159 
165 unsigned starpu_worker_get_count(void);
166 
172 
178 
184 
189 
194 
200 
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 
255 
261 
269 
279 void starpu_worker_get_name(int id, char *dst, size_t maxlen);
280 
286 
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 
311 void starpu_worker_get_current_task_exp_end(unsigned workerid, struct timespec *date);
312 
313 unsigned starpu_worker_is_blocked_in_parallel(int workerid);
314 
315 unsigned starpu_worker_is_slave_somewhere(int workerid);
316 
321 
322 int starpu_bindid_get_workerids(int bindid, int **workerids);
323 
324 int starpu_worker_get_devids(enum starpu_worker_archtype type, int *devids, int num);
325 
326 int starpu_worker_get_stream_workerids(unsigned devid, int *workerids, enum starpu_worker_archtype type);
327 
328 unsigned starpu_worker_get_sched_ctx_id_stream(unsigned stream_workerid);
329 
330 #ifdef STARPU_HAVE_HWLOC
337 hwloc_cpuset_t starpu_worker_get_hwloc_cpuset(int workerid);
342 hwloc_obj_t starpu_worker_get_hwloc_obj(int workerid);
343 #endif
344 
345 int starpu_memory_node_get_devid(unsigned node);
346 
351 
356 unsigned starpu_worker_get_memory_node(unsigned workerid);
357 
362 
367 int starpu_memory_node_get_name(unsigned node, char *name, size_t size);
368 
373 
379 
385 
392 enum starpu_node_kind starpu_node_get_kind(unsigned node);
393 
404 
417 
427 
433 
439 void starpu_worker_lock(int workerid);
440 
448 int starpu_worker_trylock(int workerid);
449 
454 void starpu_worker_unlock(int workerid);
455 
460 
465 
466 #ifdef STARPU_WORKER_CALLBACKS
472 void starpu_worker_set_going_to_sleep_callback(void (*callback)(unsigned workerid));
473 
479 void starpu_worker_set_waking_up_callback(void (*callback)(unsigned workerid));
480 #endif
481 
495 unsigned starpu_worker_is_combined_worker(int id);
496 
501 
509 
516 
520 int starpu_combined_worker_assign_workerid(int nworkers, int workerid_array[]);
521 
525 int starpu_combined_worker_get_description(int workerid, int *worker_size, int **combined_workerid);
526 
531 int starpu_combined_worker_can_execute_task(unsigned workerid, struct starpu_task *task, unsigned nimpl);
532 
537 void starpu_parallel_task_barrier_init(struct starpu_task *task, int workerid);
538 
544 void starpu_parallel_task_barrier_init_n(struct starpu_task *task, int worker_size);
545 
548 #ifdef __cplusplus
549 }
550 #endif
551 
552 #endif /* __STARPU_WORKER_H__ */
Definition: starpu_task.h:567
int starpu_combined_worker_assign_workerid(int nworkers, int workerid_array[])
void starpu_parallel_task_barrier_init(struct starpu_task *task, int workerid)
unsigned starpu_combined_worker_get_count(void)
int starpu_combined_worker_get_rank(void)
int starpu_combined_worker_get_size(void)
int starpu_combined_worker_get_description(int workerid, int *worker_size, int **combined_workerid)
int starpu_combined_worker_can_execute_task(unsigned workerid, struct starpu_task *task, unsigned nimpl)
int starpu_combined_worker_get_id(void)
void starpu_parallel_task_barrier_init_n(struct starpu_task *task, int worker_size)
Definition: starpu_tree.h:32
int * workerids
Definition: starpu_worker.h:109
unsigned nworkers
Definition: starpu_worker.h:114
int(* remove)(struct starpu_worker_collection *workers, int worker)
Definition: starpu_worker.h:141
void(* deinit)(struct starpu_worker_collection *workers)
Definition: starpu_worker.h:149
int cursor
Definition: starpu_worker.h:81
unsigned(* has_next)(struct starpu_worker_collection *workers, struct starpu_sched_ctx_iterator *it)
Definition: starpu_worker.h:129
int(* get_next)(struct starpu_worker_collection *workers, struct starpu_sched_ctx_iterator *it)
Definition: starpu_worker.h:133
enum starpu_worker_collection_type type
Definition: starpu_worker.h:125
void(* init)(struct starpu_worker_collection *workers)
Definition: starpu_worker.h:145
int(* add)(struct starpu_worker_collection *workers, int worker)
Definition: starpu_worker.h:137
void(* init_iterator)(struct starpu_worker_collection *workers, struct starpu_sched_ctx_iterator *it)
Definition: starpu_worker.h:153
int starpu_worker_get_devid(int id)
unsigned starpu_opencl_worker_get_count(void)
void starpu_worker_lock(int workerid)
char * starpu_worker_get_type_as_string(enum starpu_worker_archtype type)
starpu_worker_archtype
Definition: starpu_worker.h:63
#define starpu_worker_get_id_check()
Definition: starpu_worker.h:219
int starpu_memory_nodes_numa_id_to_devid(int osid)
int starpu_memory_nodes_get_numa_count(void)
int starpu_worker_get_relax_state(void)
int starpu_worker_trylock(int workerid)
hwloc_obj_t starpu_worker_get_hwloc_obj(int workerid)
void starpu_worker_unlock(int workerid)
void starpu_worker_display_names(FILE *output, enum starpu_worker_archtype type)
void starpu_worker_get_current_task_exp_end(unsigned workerid, struct timespec *date)
int starpu_worker_sched_op_pending(void)
unsigned starpu_worker_get_local_memory_node(void)
enum starpu_worker_archtype starpu_worker_get_type(int id)
unsigned starpu_memory_nodes_get_count(void)
int starpu_memory_nodes_numa_devid_to_id(unsigned id)
int starpu_worker_get_count_by_type(enum starpu_worker_archtype type)
unsigned starpu_worker_get_count(void)
starpu_node_kind
Definition: starpu_worker.h:45
void starpu_worker_unlock_self(void)
unsigned starpu_worker_get_memory_node(unsigned workerid)
starpu_worker_collection_type
Definition: starpu_worker.h:92
unsigned starpu_mic_device_get_count(void)
unsigned starpu_cpu_worker_get_count(void)
void starpu_worker_lock_self(void)
enum starpu_node_kind starpu_node_get_kind(unsigned node)
unsigned starpu_mic_worker_get_count(void)
unsigned starpu_mpi_ms_worker_get_count(void)
int starpu_worker_get_by_type(enum starpu_worker_archtype type, int num)
void starpu_worker_relax_off(void)
int starpu_worker_get_id(void)
unsigned starpu_cuda_worker_get_count(void)
void starpu_worker_set_waking_up_callback(void(*callback)(unsigned workerid))
void starpu_worker_relax_on(void)
#define STARPU_NMAXWORKERS
Definition: starpu_config.h:236
unsigned starpu_worker_get_ids_by_type(enum starpu_worker_archtype type, int *workerids, unsigned maxsize)
void starpu_worker_set_going_to_sleep_callback(void(*callback)(unsigned workerid))
void starpu_worker_get_name(int id, char *dst, size_t maxlen)
int starpu_worker_get_by_devid(enum starpu_worker_archtype type, int devid)
int starpu_memory_node_get_name(unsigned node, char *name, size_t size)
hwloc_cpuset_t starpu_worker_get_hwloc_cpuset(int workerid)
@ STARPU_CUDA_WORKER
Definition: starpu_worker.h:65
@ STARPU_MIC_WORKER
Definition: starpu_worker.h:67
@ STARPU_MPI_MS_WORKER
Definition: starpu_worker.h:68
@ STARPU_CPU_WORKER
Definition: starpu_worker.h:64
@ STARPU_OPENCL_WORKER
Definition: starpu_worker.h:66
@ STARPU_ANY_WORKER
Definition: starpu_worker.h:69
@ STARPU_WORKER_TREE
Definition: starpu_worker.h:93
@ STARPU_WORKER_LIST
Definition: starpu_worker.h:94
Definition: starpu_worker.h:76
Definition: starpu_worker.h:105