starpu.h 11 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344
  1. /* StarPU --- Runtime system for heterogeneous multicore architectures.
  2. *
  3. * Copyright (C) 2009-2012 Université de Bordeaux 1
  4. * Copyright (C) 2010, 2011, 2012 Centre National de la Recherche Scientifique
  5. *
  6. * StarPU is free software; you can redistribute it and/or modify
  7. * it under the terms of the GNU Lesser General Public License as published by
  8. * the Free Software Foundation; either version 2.1 of the License, or (at
  9. * your option) any later version.
  10. *
  11. * StarPU is distributed in the hope that it will be useful, but
  12. * WITHOUT ANY WARRANTY; without even the implied warranty of
  13. * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.
  14. *
  15. * See the GNU Lesser General Public License in COPYING.LGPL for more details.
  16. */
  17. #ifndef __STARPU_H__
  18. #define __STARPU_H__
  19. #include <stdlib.h>
  20. #ifndef _MSC_VER
  21. #include <stdint.h>
  22. #else
  23. typedef unsigned char uint8_t;
  24. typedef unsigned short uint16_t;
  25. typedef unsigned long uint32_t;
  26. typedef unsigned long long uint64_t;
  27. #endif
  28. #include <starpu_config.h>
  29. #ifdef STARPU_HAVE_WINDOWS
  30. #include <windows.h>
  31. #endif
  32. #if defined(STARPU_USE_OPENCL) && !defined(__CUDACC__)
  33. #include <starpu_opencl.h>
  34. #endif
  35. #include <starpu_util.h>
  36. #include <starpu_data.h>
  37. #include <starpu_data_interfaces.h>
  38. #include <starpu_data_filters.h>
  39. #include <starpu_perfmodel.h>
  40. #include <starpu_task.h>
  41. #include <starpu_task_list.h>
  42. #ifdef BUILDING_STARPU
  43. #include <util/starpu_task_list_inline.h>
  44. #endif
  45. #include <starpu_task_util.h>
  46. #include <starpu_scheduler.h>
  47. #include <starpu_expert.h>
  48. #include <starpu_rand.h>
  49. #include <starpu_cuda.h>
  50. #include <starpu_cublas.h>
  51. #include <starpu_bound.h>
  52. #include <starpu_hash.h>
  53. #include <starpu_profiling.h>
  54. #include <starpu_top.h>
  55. #include <starpu_fxt.h>
  56. #ifdef __cplusplus
  57. extern "C"
  58. {
  59. #endif
  60. <<<<<<< .working
  61. <<<<<<< .working
  62. enum starpu_archtype
  63. {
  64. STARPU_CPU_WORKER, /* CPU core */
  65. STARPU_CUDA_WORKER, /* NVIDIA CUDA device */
  66. STARPU_OPENCL_WORKER, /* OpenCL device */
  67. STARPU_GORDON_WORKER /* Cell SPU */
  68. };
  69. struct starpu_driver
  70. {
  71. enum starpu_archtype type;
  72. union
  73. {
  74. unsigned cpu_id;
  75. unsigned cuda_id;
  76. #if defined(STARPU_USE_OPENCL) && !defined(__CUDACC__)
  77. cl_device_id opencl_id;
  78. #endif
  79. /*
  80. * HOWTO: add a new kind of device to the starpu_driver structure.
  81. * 1) Add a member to this union.
  82. * 2) Edit _starpu_launch_drivers() to make sure the driver is
  83. * not always launched.
  84. * 3) Edit starpu_driver_run() so that it can handle another
  85. * kind of architecture.
  86. * 4) Write _starpu_run_foobar() in the corresponding driver.
  87. * 5) Test the whole thing :)
  88. */
  89. } id;
  90. };
  91. =======
  92. #if defined(STARPU_USE_OPENCL) && !defined(__CUDACC__)
  93. #include <starpu_opencl.h>
  94. #endif
  95. =======
  96. >>>>>>> .merge-right.r7640
  97. enum starpu_archtype
  98. {
  99. STARPU_CPU_WORKER, /* CPU core */
  100. STARPU_CUDA_WORKER, /* NVIDIA CUDA device */
  101. STARPU_OPENCL_WORKER, /* OpenCL device */
  102. STARPU_GORDON_WORKER /* Cell SPU */
  103. };
  104. struct starpu_driver
  105. {
  106. enum starpu_archtype type;
  107. union
  108. {
  109. unsigned cpu_id;
  110. unsigned cuda_id;
  111. #if defined(STARPU_USE_OPENCL) && !defined(__CUDACC__)
  112. cl_device_id opencl_id;
  113. #endif
  114. /*
  115. * HOWTO: add a new kind of device to the starpu_driver structure.
  116. * 1) Add a member to this union.
  117. * 2) Edit _starpu_launch_drivers() to make sure the driver is
  118. * not always launched.
  119. * 3) Edit starpu_driver_run() so that it can handle another
  120. * kind of architecture.
  121. * 4) Write _starpu_run_foobar() in the corresponding driver.
  122. * 5) Test the whole thing :)
  123. */
  124. } id;
  125. };
  126. >>>>>>> .merge-right.r6541
  127. struct starpu_conf
  128. {
  129. /* Will be initialized by starpu_conf_init */
  130. int magic;
  131. /* which scheduling policy should be used ? (NULL for default) */
  132. const char *sched_policy_name;
  133. struct starpu_sched_policy *sched_policy;
  134. /* number of CPU workers (-1 for default) */
  135. int ncpus;
  136. /* number of CUDA GPU workers (-1 for default) */
  137. int ncuda;
  138. /* number of GPU OpenCL device workers (-1 for default) */
  139. int nopencl;
  140. /* number of Cell's SPUs (-1 for default) */
  141. int nspus;
  142. unsigned use_explicit_workers_bindid;
  143. unsigned workers_bindid[STARPU_NMAXWORKERS];
  144. unsigned use_explicit_workers_cuda_gpuid;
  145. unsigned workers_cuda_gpuid[STARPU_NMAXWORKERS];
  146. unsigned use_explicit_workers_opencl_gpuid;
  147. unsigned workers_opencl_gpuid[STARPU_NMAXWORKERS];
  148. /* calibrate bus (-1 for default) */
  149. int bus_calibrate;
  150. /* calibrate performance models, if any (-1 for default) */
  151. int calibrate;
  152. /* Create only one combined worker, containing all CPU workers */
  153. int single_combined_worker;
  154. /* indicate if all asynchronous copies should be disabled */
  155. int disable_asynchronous_copy;
  156. <<<<<<< .working
  157. /* indicate if asynchronous copies to CUDA devices should be disabled */
  158. int disable_cuda_asynchronous_copy;
  159. /* indicate if asynchronous copies to OpenCL devices should be disabled */
  160. int disable_opencl_asynchronous_copy;
  161. /* Enable CUDA/OpenGL interoperation on these CUDA devices */
  162. int *cuda_opengl_interoperability;
  163. unsigned n_cuda_opengl_interoperability;
  164. /* A driver that the application will run in one of its own threads. */
  165. struct starpu_driver *not_launched_drivers;
  166. unsigned n_not_launched_drivers;
  167. =======
  168. /* Enable CUDA/OpenGL interoperation on these CUDA devices */
  169. int *cuda_opengl_interoperability;
  170. unsigned n_cuda_opengl_interoperability;
  171. /* A driver that the application will run in one of its own threads. */
  172. struct starpu_driver *not_launched_drivers;
  173. unsigned n_not_launched_drivers;
  174. >>>>>>> .merge-right.r6541
  175. };
  176. /* Initialize a starpu_conf structure with default values. */
  177. int starpu_conf_init(struct starpu_conf *conf);
  178. /* Initialization method: it must be called prior to any other StarPU call
  179. * Default configuration is used if NULL is passed as argument.
  180. */
  181. int starpu_init(struct starpu_conf *conf);// STARPU_WARN_UNUSED_RESULT;
  182. /* Shutdown method: note that statistics are only generated once StarPU is
  183. * shutdown */
  184. void starpu_shutdown(void);
  185. /* Print topology configuration */
  186. void starpu_topology_print(FILE *f);
  187. /* This function returns the number of workers (ie. processing units executing
  188. * StarPU tasks). The returned value should be at most STARPU_NMAXWORKERS. */
  189. unsigned starpu_worker_get_count(void);
  190. unsigned starpu_combined_worker_get_count(void);
  191. unsigned starpu_worker_is_combined_worker(int id);
  192. unsigned starpu_cpu_worker_get_count(void);
  193. unsigned starpu_cuda_worker_get_count(void);
  194. unsigned starpu_spu_worker_get_count(void);
  195. unsigned starpu_opencl_worker_get_count(void);
  196. int starpu_asynchronous_copy_disabled(void);
  197. int starpu_asynchronous_cuda_copy_disabled(void);
  198. int starpu_asynchronous_opencl_copy_disabled(void);
  199. /* Return the identifier of the thread in case this is associated to a worker.
  200. * This will return -1 if this function is called directly from the application
  201. * or if it is some SPU worker where a single thread controls different SPUs. */
  202. int starpu_worker_get_id(void);
  203. int starpu_combined_worker_get_id(void);
  204. int starpu_combined_worker_get_size(void);
  205. int starpu_combined_worker_get_rank(void);
  206. <<<<<<< .working
  207. <<<<<<< .working
  208. <<<<<<< .working
  209. enum starpu_archtype
  210. {
  211. STARPU_CPU_WORKER, /* CPU core */
  212. STARPU_CUDA_WORKER, /* NVIDIA CUDA device */
  213. STARPU_OPENCL_WORKER, /* OpenCL CUDA device */
  214. STARPU_GORDON_WORKER, /* Cell SPU */
  215. STARPU_ALL
  216. };
  217. =======
  218. >>>>>>> .merge-right.r6541
  219. =======
  220. >>>>>>> .merge-right.r6541
  221. =======
  222. >>>>>>> .merge-right.r6541
  223. /* This function returns the type of worker associated to an identifier (as
  224. * returned by the starpu_worker_get_id function). The returned value indicates
  225. * the architecture of the worker: STARPU_CPU_WORKER for a CPU core,
  226. * STARPU_CUDA_WORKER for a CUDA device, and STARPU_GORDON_WORKER for a Cell
  227. * SPU. The value returned for an invalid identifier is unspecified. */
  228. enum starpu_archtype starpu_worker_get_type(int id);
  229. /* Returns the number of workers of the type indicated by the argument. A
  230. * positive (or null) value is returned in case of success, -EINVAL indicates
  231. * that the type is not valid otherwise. */
  232. int starpu_worker_get_count_by_type(enum starpu_archtype type);
  233. /* Fill the workerids array with the identifiers of the workers that have the
  234. * type indicated in the first argument. The maxsize argument indicates the
  235. * size of the workids array. The returned value gives the number of
  236. * identifiers that were put in the array. -ERANGE is returned is maxsize is
  237. * lower than the number of workers with the appropriate type: in that case,
  238. * the array is filled with the maxsize first elements. To avoid such
  239. * overflows, the value of maxsize can be chosen by the means of the
  240. * starpu_worker_get_count_by_type function, or by passing a value greater or
  241. * equal to STARPU_NMAXWORKERS. */
  242. int starpu_worker_get_ids_by_type(enum starpu_archtype type, int *workerids, int maxsize);
  243. /* StarPU associates a unique human readable string to each processing unit.
  244. * This function copies at most the "maxlen" first bytes of the unique
  245. * string associated to a worker identified by its identifier "id" into
  246. * the "dst" buffer. The caller is responsible for ensuring that the
  247. * "dst" is a valid pointer to a buffer of "maxlen" bytes at least.
  248. * Calling this function on an invalid identifier results in an unspecified
  249. * behaviour. */
  250. void starpu_worker_get_name(int id, char *dst, size_t maxlen);
  251. /* This functions returns the device id of the worker associated to an
  252. * identifier (as returned by the starpu_worker_get_id() function)
  253. */
  254. int starpu_worker_get_devid(int id);
  255. void starpu_profiling_init();
  256. void starpu_display_stats();
  257. int starpu_driver_run(struct starpu_driver *);
  258. void starpu_set_end_of_submissions(void);
  259. <<<<<<< .working
  260. <<<<<<< .working
  261. <<<<<<< .working
  262. <<<<<<< .working
  263. int starpu_driver_init(struct starpu_driver *d);
  264. int starpu_driver_run_once(struct starpu_driver *d);
  265. int starpu_driver_deinit(struct starpu_driver *d);
  266. =======
  267. int starpu_driver_run(struct starpu_driver *);
  268. void starpu_set_end_of_submissions(void);
  269. =======
  270. int starpu_driver_run(struct starpu_driver *d);
  271. void starpu_drivers_request_termination(void);
  272. >>>>>>> .merge-right.r7640
  273. =======
  274. int starpu_driver_run(struct starpu_driver *d);
  275. void starpu_drivers_request_termination(void);
  276. >>>>>>> .merge-right.r7640
  277. int starpu_driver_init(struct starpu_driver *d);
  278. int starpu_driver_run_once(struct starpu_driver *d);
  279. int starpu_driver_deinit(struct starpu_driver *d);
  280. >>>>>>> .merge-right.r6541
  281. =======
  282. int starpu_driver_run(struct starpu_driver *);
  283. void starpu_set_end_of_submissions(void);
  284. int starpu_driver_init(struct starpu_driver *d);
  285. int starpu_driver_run_once(struct starpu_driver *d);
  286. int starpu_driver_deinit(struct starpu_driver *d);
  287. >>>>>>> .merge-right.r6541
  288. #ifdef __cplusplus
  289. }
  290. #endif
  291. #if defined(STARPU_USE_DEPRECATED_API)
  292. #include "starpu_deprecated_api.h"
  293. #endif /* STARPU_USE_DEPRECATED_API */
  294. #endif /* __STARPU_H__ */