123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123 |
- #include <stdio.h>
- #include <stdint.h>
- #include <starpu.h>
- #define FPRINTF(ofile, fmt, args ...) do { if (!getenv("STARPU_SSILENT")) {fprintf(ofile, fmt, ##args); }} while(0)
- void callback_func(void *callback_arg)
- {
- FPRINTF(stdout, "Callback function got argument %p\n", callback_arg);
- }
- struct params {
- int i;
- float f;
- };
- void cpu_func(void *buffers[], void *cl_arg)
- {
- struct params *params = (struct params *) cl_arg;
- FPRINTF(stdout, "Hello world (params = {%i, %f} )\n", params->i, params->f);
- }
- starpu_codelet cl = {};
- int main(int argc, char **argv)
- {
- struct starpu_task *task;
- struct params params = {1, 2.0f};
-
- starpu_init(NULL);
-
- task = starpu_task_create();
-
- cl.where = STARPU_CPU;
- cl.cpu_func = cpu_func;
-
- cl.nbuffers = 0;
-
- task->cl = &cl;
-
- task->cl_arg = ¶ms;
- task->cl_arg_size = sizeof(params);
-
-
- task->callback_func = callback_func;
- task->callback_arg = (void*) (uintptr_t) 0x42;
-
- task->synchronous = 1;
-
-
- starpu_task_submit(task);
-
- starpu_task_destroy(task);
-
-
- starpu_shutdown();
- return 0;
- }
|