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-2021 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
44 enum starpu_node_kind
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
62 enum starpu_worker_archtype
63{
64 STARPU_CPU_WORKER=0,
65 STARPU_CUDA_WORKER=1,
66 STARPU_OPENCL_WORKER=2,
67 STARPU_MIC_WORKER=3,
68 STARPU_MPI_MS_WORKER=5,
69 STARPU_ANY_WORKER=6
70};
71
75 struct starpu_sched_ctx_iterator
76{
81 int cursor;
82 void *value;
83 void *possible_value;
84 char visited[STARPU_NMAXWORKERS];
85 int possibly_parallel;
86};
87
91 enum starpu_worker_collection_type
92{
93 STARPU_WORKER_TREE,
94 STARPU_WORKER_LIST
95};
96
104 struct starpu_worker_collection
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];
125 enum starpu_worker_collection_type type;
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);
153 void (*init_iterator)(struct starpu_worker_collection *workers, struct starpu_sched_ctx_iterator *it);
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
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
233 enum starpu_worker_archtype starpu_worker_get_type(int id);
234
240 int starpu_worker_get_count_by_type(enum starpu_worker_archtype type);
241
254 unsigned starpu_worker_get_ids_by_type(enum starpu_worker_archtype type, int *workerids, unsigned maxsize);
255
260 int starpu_worker_get_by_type(enum starpu_worker_archtype type, int num);
261
268 int starpu_worker_get_by_devid(enum starpu_worker_archtype type, int devid);
269
279 void starpu_worker_get_name(int id, char *dst, size_t maxlen);
280
285 void starpu_worker_display_names(FILE *output, enum starpu_worker_archtype type);
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
312 char *starpu_worker_get_type_as_string(enum starpu_worker_archtype type);
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
329hwloc_cpuset_t starpu_worker_get_hwloc_cpuset(int workerid);
334hwloc_obj_t starpu_worker_get_hwloc_obj(int workerid);
335#endif
336
337 int starpu_memory_node_get_devid(unsigned node);
338
342 unsigned starpu_worker_get_local_memory_node(void);
343
348 unsigned starpu_worker_get_memory_node(unsigned workerid);
349
353 unsigned starpu_memory_nodes_get_count(void);
354
359 int starpu_memory_node_get_name(unsigned node, char *name, size_t size);
360
364 int starpu_memory_nodes_get_numa_count(void);
365
370 int starpu_memory_nodes_numa_id_to_devid(int osid);
371
376 int starpu_memory_nodes_numa_devid_to_id(unsigned id);
377
384 enum starpu_node_kind starpu_node_get_kind(unsigned node);
385
395 int starpu_worker_sched_op_pending(void);
396
408 void starpu_worker_relax_on(void);
409
418 void starpu_worker_relax_off(void);
419
424 int starpu_worker_get_relax_state(void);
425
431 void starpu_worker_lock(int workerid);
432
440 int starpu_worker_trylock(int workerid);
441
446 void starpu_worker_unlock(int workerid);
447
451 void starpu_worker_lock_self(void);
452
456 void starpu_worker_unlock_self(void);
457
458#ifdef STARPU_WORKER_CALLBACKS
464 void starpu_worker_set_going_to_sleep_callback(void (*callback)(unsigned workerid));
465
471 void starpu_worker_set_waking_up_callback(void (*callback)(unsigned workerid));
472#endif
473
486 unsigned starpu_combined_worker_get_count(void);
487 unsigned starpu_worker_is_combined_worker(int id);
488
492 int starpu_combined_worker_get_id(void);
493
500 int starpu_combined_worker_get_size(void);
501
507 int starpu_combined_worker_get_rank(void);
508
512 int starpu_combined_worker_assign_workerid(int nworkers, int workerid_array[]);
513
517 int starpu_combined_worker_get_description(int workerid, int *worker_size, int **combined_workerid);
518
523 int starpu_combined_worker_can_execute_task(unsigned workerid, struct starpu_task *task, unsigned nimpl);
524
529 void starpu_parallel_task_barrier_init(struct starpu_task *task, int workerid);
530
536 void starpu_parallel_task_barrier_init_n(struct starpu_task *task, int worker_size);
537
540#ifdef __cplusplus
541}
542#endif
543
544#endif /* __STARPU_WORKER_H__ */
starpu_task
Definition: starpu_task.h:567
starpu_combined_worker_assign_workerid
int starpu_combined_worker_assign_workerid(int nworkers, int workerid_array[])
starpu_parallel_task_barrier_init
void starpu_parallel_task_barrier_init(struct starpu_task *task, int workerid)
starpu_combined_worker_get_count
unsigned starpu_combined_worker_get_count(void)
starpu_combined_worker_get_rank
int starpu_combined_worker_get_rank(void)
starpu_combined_worker_get_size
int starpu_combined_worker_get_size(void)
starpu_combined_worker_get_description
int starpu_combined_worker_get_description(int workerid, int *worker_size, int **combined_workerid)
starpu_combined_worker_can_execute_task
int starpu_combined_worker_can_execute_task(unsigned workerid, struct starpu_task *task, unsigned nimpl)
starpu_combined_worker_get_id
int starpu_combined_worker_get_id(void)
starpu_parallel_task_barrier_init_n
void starpu_parallel_task_barrier_init_n(struct starpu_task *task, int worker_size)
starpu_tree
Definition: starpu_tree.h:32
starpu_worker_collection::workerids
int * workerids
Definition: starpu_worker.h:109
starpu_worker_collection::nworkers
unsigned nworkers
Definition: starpu_worker.h:114
starpu_worker_collection::remove
int(* remove)(struct starpu_worker_collection *workers, int worker)
Definition: starpu_worker.h:141
starpu_worker_collection::deinit
void(* deinit)(struct starpu_worker_collection *workers)
Definition: starpu_worker.h:149
starpu_sched_ctx_iterator::cursor
int cursor
Definition: starpu_worker.h:81
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_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_collection::type
enum starpu_worker_collection_type type
Definition: starpu_worker.h:125
starpu_worker_collection::init
void(* init)(struct starpu_worker_collection *workers)
Definition: starpu_worker.h:145
starpu_worker_collection::add
int(* add)(struct starpu_worker_collection *workers, int worker)
Definition: starpu_worker.h:137
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_worker_get_devid
int starpu_worker_get_devid(int id)
starpu_opencl_worker_get_count
unsigned starpu_opencl_worker_get_count(void)
starpu_worker_lock
void starpu_worker_lock(int workerid)
starpu_worker_archtype
starpu_worker_archtype
Definition: starpu_worker.h:63
starpu_worker_get_id_check
#define starpu_worker_get_id_check()
Definition: starpu_worker.h:219
starpu_memory_nodes_numa_id_to_devid
int starpu_memory_nodes_numa_id_to_devid(int osid)
starpu_memory_nodes_get_numa_count
int starpu_memory_nodes_get_numa_count(void)
starpu_worker_get_relax_state
int starpu_worker_get_relax_state(void)
starpu_worker_trylock
int starpu_worker_trylock(int workerid)
starpu_worker_get_hwloc_obj
hwloc_obj_t starpu_worker_get_hwloc_obj(int workerid)
starpu_worker_unlock
void starpu_worker_unlock(int workerid)
starpu_worker_display_names
void starpu_worker_display_names(FILE *output, enum starpu_worker_archtype type)
starpu_worker_sched_op_pending
int starpu_worker_sched_op_pending(void)
starpu_worker_get_local_memory_node
unsigned starpu_worker_get_local_memory_node(void)
starpu_worker_get_type
enum starpu_worker_archtype starpu_worker_get_type(int id)
starpu_memory_nodes_get_count
unsigned starpu_memory_nodes_get_count(void)
starpu_memory_nodes_numa_devid_to_id
int starpu_memory_nodes_numa_devid_to_id(unsigned id)
starpu_worker_get_count_by_type
int starpu_worker_get_count_by_type(enum starpu_worker_archtype type)
starpu_worker_get_count
unsigned starpu_worker_get_count(void)
starpu_node_kind
starpu_node_kind
Definition: starpu_worker.h:45
starpu_worker_unlock_self
void starpu_worker_unlock_self(void)
starpu_worker_get_memory_node
unsigned starpu_worker_get_memory_node(unsigned workerid)
starpu_worker_collection_type
starpu_worker_collection_type
Definition: starpu_worker.h:92
starpu_mic_device_get_count
unsigned starpu_mic_device_get_count(void)
starpu_cpu_worker_get_count
unsigned starpu_cpu_worker_get_count(void)
starpu_worker_lock_self
void starpu_worker_lock_self(void)
starpu_node_get_kind
enum starpu_node_kind starpu_node_get_kind(unsigned node)
starpu_mic_worker_get_count
unsigned starpu_mic_worker_get_count(void)
starpu_mpi_ms_worker_get_count
unsigned starpu_mpi_ms_worker_get_count(void)
starpu_worker_get_by_type
int starpu_worker_get_by_type(enum starpu_worker_archtype type, int num)
starpu_worker_relax_off
void starpu_worker_relax_off(void)
starpu_worker_get_type_as_string
char * starpu_worker_get_type_as_string(enum starpu_worker_archtype type)
starpu_worker_get_id
int starpu_worker_get_id(void)
starpu_cuda_worker_get_count
unsigned starpu_cuda_worker_get_count(void)
starpu_worker_set_waking_up_callback
void starpu_worker_set_waking_up_callback(void(*callback)(unsigned workerid))
starpu_worker_relax_on
void starpu_worker_relax_on(void)
STARPU_NMAXWORKERS
#define STARPU_NMAXWORKERS
Definition: starpu_config.h:236
starpu_worker_get_ids_by_type
unsigned starpu_worker_get_ids_by_type(enum starpu_worker_archtype type, int *workerids, unsigned maxsize)
starpu_worker_set_going_to_sleep_callback
void starpu_worker_set_going_to_sleep_callback(void(*callback)(unsigned workerid))
starpu_worker_get_name
void starpu_worker_get_name(int id, char *dst, size_t maxlen)
starpu_worker_get_by_devid
int starpu_worker_get_by_devid(enum starpu_worker_archtype type, int devid)
starpu_memory_node_get_name
int starpu_memory_node_get_name(unsigned node, char *name, size_t size)
starpu_worker_get_hwloc_cpuset
hwloc_cpuset_t starpu_worker_get_hwloc_cpuset(int workerid)
STARPU_CUDA_WORKER
@ STARPU_CUDA_WORKER
Definition: starpu_worker.h:65
STARPU_MIC_WORKER
@ STARPU_MIC_WORKER
Definition: starpu_worker.h:67
STARPU_MPI_MS_WORKER
@ STARPU_MPI_MS_WORKER
Definition: starpu_worker.h:68
STARPU_CPU_WORKER
@ STARPU_CPU_WORKER
Definition: starpu_worker.h:64
STARPU_OPENCL_WORKER
@ STARPU_OPENCL_WORKER
Definition: starpu_worker.h:66
STARPU_ANY_WORKER
@ STARPU_ANY_WORKER
Definition: starpu_worker.h:69
STARPU_WORKER_TREE
@ STARPU_WORKER_TREE
Definition: starpu_worker.h:93
STARPU_WORKER_LIST
@ STARPU_WORKER_LIST
Definition: starpu_worker.h:94
starpu_sched_ctx_iterator
Definition: starpu_worker.h:76
starpu_worker_collection
Definition: starpu_worker.h:105
starpu_config.h
starpu_task.h
starpu_thread.h