123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325 |
- #ifndef __STARPU_TASK_H__
- #define __STARPU_TASK_H__
- #include <starpu.h>
- #include <starpu_data.h>
- #include <starpu_task_bundle.h>
- #include <errno.h>
- #if defined STARPU_USE_CUDA && !defined STARPU_DONT_INCLUDE_CUDA_HEADERS
- # include <cuda.h>
- #endif
- #ifdef __cplusplus
- extern "C"
- {
- #endif
- #define STARPU_CPU ((1ULL)<<1)
- #define STARPU_CUDA ((1ULL)<<3)
- #define STARPU_SPU ((1ULL)<<4),
- #define STARPU_GORDON ((1ULL)<<5)
- #define STARPU_OPENCL ((1ULL)<<6)
- enum starpu_codelet_type
- {
- STARPU_SEQ,
- STARPU_SPMD,
- STARPU_FORKJOIN
- };
- enum starpu_task_status
- {
- STARPU_TASK_INVALID,
- #define STARPU_TASK_INVALID 0
- STARPU_TASK_BLOCKED,
- STARPU_TASK_READY,
- STARPU_TASK_RUNNING,
- STARPU_TASK_FINISHED,
- STARPU_TASK_BLOCKED_ON_TAG,
- STARPU_TASK_BLOCKED_ON_TASK,
- STARPU_TASK_BLOCKED_ON_DATA
- };
- typedef uint64_t starpu_tag_t;
- typedef void (*starpu_cpu_func_t)(void **, void*);
- typedef void (*starpu_cuda_func_t)(void **, void*);
- typedef void (*starpu_opencl_func_t)(void **, void*);
- typedef uint8_t starpu_gordon_func_t;
- #define STARPU_MULTIPLE_CPU_IMPLEMENTATIONS ((starpu_cpu_func_t) -1)
- #define STARPU_MULTIPLE_CUDA_IMPLEMENTATIONS ((starpu_cuda_func_t) -1)
- #define STARPU_MULTIPLE_OPENCL_IMPLEMENTATIONS ((starpu_opencl_func_t) -1)
- #define STARPU_MULTIPLE_GORDON_IMPLEMENTATIONS 255
- struct starpu_task;
- struct starpu_codelet
- {
-
- uint32_t where;
- int (*can_execute)(unsigned workerid, struct starpu_task *task, unsigned nimpl);
- enum starpu_codelet_type type;
- int max_parallelism;
-
- starpu_cuda_func_t cuda_func STARPU_DEPRECATED;
- starpu_cpu_func_t cpu_func STARPU_DEPRECATED;
- starpu_opencl_func_t opencl_func STARPU_DEPRECATED;
- uint8_t gordon_func STARPU_DEPRECATED;
- starpu_cpu_func_t cpu_funcs[STARPU_MAXIMPLEMENTATIONS];
- starpu_cuda_func_t cuda_funcs[STARPU_MAXIMPLEMENTATIONS];
- starpu_opencl_func_t opencl_funcs[STARPU_MAXIMPLEMENTATIONS];
- starpu_gordon_func_t gordon_funcs[STARPU_MAXIMPLEMENTATIONS];
-
- unsigned nbuffers;
-
- enum starpu_access_mode modes[STARPU_NMAXBUFS];
-
- struct starpu_perfmodel *model;
-
- struct starpu_perfmodel *power_model;
-
- unsigned long per_worker_stats[STARPU_NMAXWORKERS];
- const char *name;
- };
- struct starpu_task
- {
- struct starpu_codelet *cl;
-
- struct starpu_buffer_descr buffers[STARPU_NMAXBUFS] STARPU_DEPRECATED;
- starpu_data_handle_t handles[STARPU_NMAXBUFS];
- void *interfaces[STARPU_NMAXBUFS];
-
- void *cl_arg;
-
- size_t cl_arg_size;
-
- void (*callback_func)(void *);
- void *callback_arg;
- unsigned use_tag;
- starpu_tag_t tag_id;
-
- unsigned synchronous;
- int priority;
-
- unsigned execute_on_a_specific_worker;
- unsigned workerid;
-
- starpu_task_bundle_t bundle;
-
- int detach;
-
- int destroy;
-
- int regenerate;
- enum starpu_task_status status;
-
- struct starpu_task_profiling_info *profiling_info;
-
- double predicted;
-
- double predicted_transfer;
-
- struct starpu_task *prev;
- struct starpu_task *next;
- unsigned int mf_skip;
-
- void *starpu_private;
-
- int magic;
- };
- #define STARPU_TASK_INITIALIZER \
- { \
- .cl = NULL, \
- .cl_arg = NULL, \
- .cl_arg_size = 0, \
- .callback_func = NULL, \
- .callback_arg = NULL, \
- .priority = STARPU_DEFAULT_PRIO, \
- .use_tag = 0, \
- .synchronous = 0, \
- .execute_on_a_specific_worker = 0, \
- .bundle = NULL, \
- .detach = 1, \
- .destroy = 0, \
- .regenerate = 0, \
- .status = STARPU_TASK_INVALID, \
- .profiling_info = NULL, \
- .predicted = -1.0, \
- .predicted_transfer = -1.0, \
- .starpu_private = NULL, \
- .magic = 42 \
- }
- void starpu_tag_declare_deps(starpu_tag_t id, unsigned ndeps, ...);
- void starpu_tag_declare_deps_array(starpu_tag_t id, unsigned ndeps, starpu_tag_t *array);
- void starpu_task_declare_deps_array(struct starpu_task *task, unsigned ndeps, struct starpu_task *task_array[]);
- int starpu_tag_wait(starpu_tag_t id);
- int starpu_tag_wait_array(unsigned ntags, starpu_tag_t *id);
- void starpu_tag_notify_from_apps(starpu_tag_t id);
- void starpu_tag_restart(starpu_tag_t id);
- void starpu_tag_remove(starpu_tag_t id);
- void starpu_task_init(struct starpu_task *task);
- void starpu_task_clean(struct starpu_task *task);
- struct starpu_task *starpu_task_create(void);
- void starpu_task_destroy(struct starpu_task *task);
- int starpu_task_submit(struct starpu_task *task) STARPU_WARN_UNUSED_RESULT;
- int starpu_task_wait(struct starpu_task *task) STARPU_WARN_UNUSED_RESULT;
- int starpu_task_wait_for_all(void);
- int starpu_task_wait_for_no_ready(void);
- void starpu_codelet_init(struct starpu_codelet *cl);
- void starpu_display_codelet_stats(struct starpu_codelet *cl);
- struct starpu_task *starpu_task_get_current(void);
- #ifdef __cplusplus
- }
- #endif
- #endif /* __STARPU_TASK_H__ */
|