starpu.h 7.2 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216
  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. #include <starpu_util.h>
  33. #include <starpu_data.h>
  34. #include <starpu_data_interfaces.h>
  35. #include <starpu_data_filters.h>
  36. #include <starpu_perfmodel.h>
  37. #include <starpu_task.h>
  38. #include <starpu_task_list.h>
  39. #include <starpu_scheduler.h>
  40. #include <starpu_expert.h>
  41. #include <starpu_rand.h>
  42. #ifdef __cplusplus
  43. extern "C"
  44. {
  45. #endif
  46. #if defined(STARPU_USE_OPENCL) && !defined(__CUDACC__)
  47. #include <starpu_opencl.h>
  48. #endif
  49. enum starpu_archtype
  50. {
  51. STARPU_CPU_WORKER, /* CPU core */
  52. STARPU_CUDA_WORKER, /* NVIDIA CUDA device */
  53. STARPU_OPENCL_WORKER, /* OpenCL device */
  54. STARPU_GORDON_WORKER /* Cell SPU */
  55. };
  56. struct starpu_driver
  57. {
  58. enum starpu_archtype type;
  59. union
  60. {
  61. unsigned cuda_id;
  62. #if defined(STARPU_USE_OPENCL) && !defined(__CUDACC__)
  63. cl_device_id opencl_id;
  64. #endif
  65. /*
  66. * TODO: handle CPUs:
  67. * 1) Add a member to this union.
  68. * 2) Edit _starpu_launch_drivers() to make sure the driver is
  69. * not always launched.
  70. * 3) Edit starpu_run_driver() so that it can handle another
  71. * kind of architecture.
  72. * 4) Write _starpu_run_foobar() in the corresponding driver.
  73. * 5) Test the whole thing :)
  74. */
  75. } id;
  76. };
  77. struct starpu_conf
  78. {
  79. /* Will be initialized by starpu_conf_init */
  80. int magic;
  81. /* which scheduling policy should be used ? (NULL for default) */
  82. const char *sched_policy_name;
  83. struct starpu_sched_policy *sched_policy;
  84. /* number of CPU workers (-1 for default) */
  85. int ncpus;
  86. /* number of CUDA GPU workers (-1 for default) */
  87. int ncuda;
  88. /* number of GPU OpenCL device workers (-1 for default) */
  89. int nopencl;
  90. /* number of Cell's SPUs (-1 for default) */
  91. int nspus;
  92. unsigned use_explicit_workers_bindid;
  93. unsigned workers_bindid[STARPU_NMAXWORKERS];
  94. unsigned use_explicit_workers_cuda_gpuid;
  95. unsigned workers_cuda_gpuid[STARPU_NMAXWORKERS];
  96. unsigned use_explicit_workers_opencl_gpuid;
  97. unsigned workers_opencl_gpuid[STARPU_NMAXWORKERS];
  98. /* calibrate performance models, if any (-1 for default) */
  99. int calibrate;
  100. /* Create only one combined worker, containing all CPU workers */
  101. int single_combined_worker;
  102. /* indicate if the asynchronous copies should be disabled */
  103. int disable_asynchronous_copy;
  104. /* Enable CUDA/OpenGL interoperation on these CUDA devices */
  105. int *cuda_opengl_interoperability;
  106. unsigned n_cuda_opengl_interoperability;
  107. /* A driver that the application will run in one of its own threads. */
  108. struct starpu_driver *not_launched_drivers;
  109. unsigned n_not_launched_drivers;
  110. };
  111. /* Initialize a starpu_conf structure with default values. */
  112. int starpu_conf_init(struct starpu_conf *conf);
  113. /* Initialization method: it must be called prior to any other StarPU call
  114. * Default configuration is used if NULL is passed as argument.
  115. */
  116. int starpu_init(struct starpu_conf *conf);// STARPU_WARN_UNUSED_RESULT;
  117. /* Shutdown method: note that statistics are only generated once StarPU is
  118. * shutdown */
  119. void starpu_shutdown(void);
  120. /* This function returns the number of workers (ie. processing units executing
  121. * StarPU tasks). The returned value should be at most STARPU_NMAXWORKERS. */
  122. unsigned starpu_worker_get_count(void);
  123. unsigned starpu_combined_worker_get_count(void);
  124. unsigned starpu_worker_is_combined_worker(int id);
  125. unsigned starpu_cpu_worker_get_count(void);
  126. unsigned starpu_cuda_worker_get_count(void);
  127. unsigned starpu_spu_worker_get_count(void);
  128. unsigned starpu_opencl_worker_get_count(void);
  129. int starpu_asynchronous_copy_disabled();
  130. /* Return the identifier of the thread in case this is associated to a worker.
  131. * This will return -1 if this function is called directly from the application
  132. * or if it is some SPU worker where a single thread controls different SPUs. */
  133. int starpu_worker_get_id(void);
  134. int starpu_combined_worker_get_id(void);
  135. int starpu_combined_worker_get_size(void);
  136. int starpu_combined_worker_get_rank(void);
  137. /* This function returns the type of worker associated to an identifier (as
  138. * returned by the starpu_worker_get_id function). The returned value indicates
  139. * the architecture of the worker: STARPU_CPU_WORKER for a CPU core,
  140. * STARPU_CUDA_WORKER for a CUDA device, and STARPU_GORDON_WORKER for a Cell
  141. * SPU. The value returned for an invalid identifier is unspecified. */
  142. enum starpu_archtype starpu_worker_get_type(int id);
  143. /* Returns the number of workers of the type indicated by the argument. A
  144. * positive (or null) value is returned in case of success, -EINVAL indicates
  145. * that the type is not valid otherwise. */
  146. int starpu_worker_get_count_by_type(enum starpu_archtype type);
  147. /* Fill the workerids array with the identifiers of the workers that have the
  148. * type indicated in the first argument. The maxsize argument indicates the
  149. * size of the workids array. The returned value gives the number of
  150. * identifiers that were put in the array. -ERANGE is returned is maxsize is
  151. * lower than the number of workers with the appropriate type: in that case,
  152. * the array is filled with the maxsize first elements. To avoid such
  153. * overflows, the value of maxsize can be chosen by the means of the
  154. * starpu_worker_get_count_by_type function, or by passing a value greater or
  155. * equal to STARPU_NMAXWORKERS. */
  156. int starpu_worker_get_ids_by_type(enum starpu_archtype type, int *workerids, int maxsize);
  157. /* StarPU associates a unique human readable string to each processing unit.
  158. * This function copies at most the "maxlen" first bytes of the unique
  159. * string associated to a worker identified by its identifier "id" into
  160. * the "dst" buffer. The caller is responsible for ensuring that the
  161. * "dst" is a valid pointer to a buffer of "maxlen" bytes at least.
  162. * Calling this function on an invalid identifier results in an unspecified
  163. * behaviour. */
  164. void starpu_worker_get_name(int id, char *dst, size_t maxlen);
  165. /* This functions returns the device id of the worker associated to an
  166. * identifier (as returned by the starpu_worker_get_id() function)
  167. */
  168. int starpu_worker_get_devid(int id);
  169. void starpu_profiling_init();
  170. void starpu_display_stats();
  171. int starpu_run_driver(struct starpu_driver *);
  172. void starpu_set_end_of_submissions(void);
  173. #ifdef __cplusplus
  174. }
  175. #endif
  176. #if defined(STARPU_USE_DEPRECATED_API)
  177. #include "starpu_deprecated_api.h"
  178. #endif /* STARPU_USE_DEPRECATED_API */
  179. #endif /* __STARPU_H__ */