starpu-task.h 3.9 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146
  1. /*
  2. * StarPU
  3. * Copyright (C) INRIA 2008-2009 (see AUTHORS file)
  4. *
  5. * This program is free software; you can redistribute it and/or modify
  6. * it under the terms of the GNU Lesser General Public License as published by
  7. * the Free Software Foundation; either version 2.1 of the License, or (at
  8. * your option) any later version.
  9. *
  10. * This program is distributed in the hope that it will be useful, but
  11. * WITHOUT ANY WARRANTY; without even the implied warranty of
  12. * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.
  13. *
  14. * See the GNU Lesser General Public License in COPYING.LGPL for more details.
  15. */
  16. #ifndef __STARPU_TASK_H__
  17. #define __STARPU_TASK_H__
  18. #include <starpu_config.h>
  19. /* this is a randomly choosen value ... */
  20. #ifndef MAXCUDADEVS
  21. #define MAXCUDADEVS 4
  22. #endif
  23. #ifdef USE_CUDA
  24. #include <cuda.h>
  25. #endif
  26. #include <starpu-data.h>
  27. #define ANY (~0)
  28. #define CORE ((1ULL)<<1)
  29. #define CUBLAS ((1ULL)<<2)
  30. #define CUDA ((1ULL)<<3)
  31. #define SPU ((1ULL)<<4)
  32. #define GORDON ((1ULL)<<5)
  33. #define MIN_PRIO (-4)
  34. #define MAX_PRIO 5
  35. #define DEFAULT_PRIO 0
  36. typedef uint64_t starpu_tag_t;
  37. /*
  38. * A codelet describes the various function
  39. * that may be called from a worker
  40. */
  41. typedef struct starpu_codelet_t {
  42. /* where can it be performed ? */
  43. uint32_t where;
  44. /* the different implementations of the codelet */
  45. void *cuda_func;
  46. void *cublas_func;
  47. void *core_func;
  48. void *spu_func;
  49. uint8_t gordon_func;
  50. /* how many buffers do the codelet takes as argument ? */
  51. unsigned nbuffers;
  52. struct starpu_perfmodel_t *model;
  53. } starpu_codelet;
  54. struct starpu_task {
  55. struct starpu_codelet_t *cl;
  56. /* arguments managed by the DSM */
  57. struct starpu_buffer_descr_t buffers[NMAXBUFS];
  58. starpu_data_interface_t interface[NMAXBUFS];
  59. /* arguments not managed by the DSM are given as a buffer */
  60. void *cl_arg;
  61. /* in case the argument buffer has to be uploaded explicitely */
  62. size_t cl_arg_size;
  63. /* when the task is done, callback_func(callback_arg) is called */
  64. void (*callback_func)(void *);
  65. void *callback_arg;
  66. unsigned use_tag;
  67. starpu_tag_t tag_id;
  68. /* options for the task execution */
  69. unsigned synchronous; /* if set, a call to push is blocking */
  70. int priority; /* MAX_PRIO = most important
  71. : MIN_PRIO = least important */
  72. /* this is private to StarPU, do not modify */
  73. void *starpu_private;
  74. };
  75. #ifdef USE_CUDA
  76. /* CUDA specific codelets */
  77. typedef struct starpu_cuda_module_s {
  78. CUmodule module;
  79. char *module_path;
  80. unsigned is_loaded[MAXCUDADEVS];
  81. } starpu_cuda_module_t;
  82. typedef struct starpu_cuda_function_s {
  83. struct starpu_cuda_module_s *module;
  84. CUfunction function;
  85. char *symbol;
  86. unsigned is_loaded[MAXCUDADEVS];
  87. } starpu_cuda_function_t;
  88. typedef struct starpu_cuda_codelet_s {
  89. /* which function to execute on the card ? */
  90. struct starpu_cuda_function_s *func;
  91. /* grid and block shapes */
  92. unsigned gridx;
  93. unsigned gridy;
  94. unsigned blockx;
  95. unsigned blocky;
  96. unsigned shmemsize;
  97. void *stack; /* arguments */
  98. size_t stack_size;
  99. } starpu_cuda_codelet_t;
  100. void starpu_init_cuda_module(struct starpu_cuda_module_s *module, char *path);
  101. void starpu_load_cuda_module(int devid, struct starpu_cuda_module_s *module);
  102. void starpu_init_cuda_function(struct starpu_cuda_function_s *func,
  103. struct starpu_cuda_module_s *module,
  104. char *symbol);
  105. void starpu_load_cuda_function(int devid, struct starpu_cuda_function_s *function);
  106. #endif // USE_CUDA
  107. /* handle task dependencies: it is possible to associate a task with a unique
  108. * "tag" and to express dependencies among tasks by the means of those tags */
  109. void starpu_tag_remove(starpu_tag_t id);
  110. void starpu_tag_declare_deps_array(starpu_tag_t id, unsigned ndeps, starpu_tag_t *array);
  111. void starpu_tag_declare_deps(starpu_tag_t id, unsigned ndeps, ...);
  112. void starpu_tag_wait(starpu_tag_t id);
  113. struct starpu_task *starpu_task_create(void);
  114. int starpu_submit_task(struct starpu_task *task);
  115. #endif // __STARPU_TASK_H__