starpu-task.h 4.0 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151
  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. /* should the task be automatically liberated once executed ? */
  73. int cleanup;
  74. /* this is private to StarPU, do not modify */
  75. void *starpu_private;
  76. };
  77. #ifdef USE_CUDA
  78. /* CUDA specific codelets */
  79. typedef struct starpu_cuda_module_s {
  80. CUmodule module;
  81. char *module_path;
  82. unsigned is_loaded[MAXCUDADEVS];
  83. } starpu_cuda_module_t;
  84. typedef struct starpu_cuda_function_s {
  85. struct starpu_cuda_module_s *module;
  86. CUfunction function;
  87. char *symbol;
  88. unsigned is_loaded[MAXCUDADEVS];
  89. } starpu_cuda_function_t;
  90. typedef struct starpu_cuda_codelet_s {
  91. /* which function to execute on the card ? */
  92. struct starpu_cuda_function_s *func;
  93. /* grid and block shapes */
  94. unsigned gridx;
  95. unsigned gridy;
  96. unsigned blockx;
  97. unsigned blocky;
  98. unsigned shmemsize;
  99. void *stack; /* arguments */
  100. size_t stack_size;
  101. } starpu_cuda_codelet_t;
  102. void starpu_init_cuda_module(struct starpu_cuda_module_s *module, char *path);
  103. void starpu_load_cuda_module(int devid, struct starpu_cuda_module_s *module);
  104. void starpu_init_cuda_function(struct starpu_cuda_function_s *func,
  105. struct starpu_cuda_module_s *module,
  106. char *symbol);
  107. void starpu_load_cuda_function(int devid, struct starpu_cuda_function_s *function);
  108. #endif // USE_CUDA
  109. /* handle task dependencies: it is possible to associate a task with a unique
  110. * "tag" and to express dependencies among tasks by the means of those tags */
  111. void starpu_tag_remove(starpu_tag_t id);
  112. void starpu_tag_declare_deps_array(starpu_tag_t id, unsigned ndeps, starpu_tag_t *array);
  113. void starpu_tag_declare_deps(starpu_tag_t id, unsigned ndeps, ...);
  114. void starpu_tag_wait(starpu_tag_t id);
  115. void starpu_tag_wait_array(unsigned ntags, starpu_tag_t *id);
  116. struct starpu_task *starpu_task_create(void);
  117. int starpu_submit_task(struct starpu_task *task);
  118. #endif // __STARPU_TASK_H__