starpu.h 5.5 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157
  1. /* StarPU --- Runtime system for heterogeneous multicore architectures.
  2. *
  3. * Copyright (C) 2009, 2010 Université de Bordeaux 1
  4. * Copyright (C) 2010 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_perfmodel.h>
  35. #include <starpu_task.h>
  36. #include <starpu_task_list.h>
  37. #include <starpu_scheduler.h>
  38. #include <starpu_expert.h>
  39. #ifdef __cplusplus
  40. extern "C" {
  41. #endif
  42. struct starpu_conf {
  43. /* which scheduling policy should be used ? (NULL for default) */
  44. const char *sched_policy_name;
  45. struct starpu_sched_policy_s *sched_policy;
  46. /* number of CPU workers (-1 for default) */
  47. int ncpus;
  48. /* number of CUDA GPU workers (-1 for default) */
  49. int ncuda;
  50. /* number of GPU OpenCL device workers (-1 for default) */
  51. int nopencl;
  52. /* number of Cell's SPUs (-1 for default) */
  53. int nspus;
  54. unsigned use_explicit_workers_bindid;
  55. unsigned workers_bindid[STARPU_NMAXWORKERS];
  56. unsigned use_explicit_workers_cuda_gpuid;
  57. unsigned workers_cuda_gpuid[STARPU_NMAXWORKERS];
  58. unsigned use_explicit_workers_opencl_gpuid;
  59. unsigned workers_opencl_gpuid[STARPU_NMAXWORKERS];
  60. /* calibrate performance models, if any (-1 for default) */
  61. int calibrate;
  62. };
  63. /* Initialize a starpu_conf structure with default values. */
  64. int starpu_conf_init(struct starpu_conf *conf);
  65. /* Initialization method: it must be called prior to any other StarPU call
  66. * Default configuration is used if NULL is passed as argument.
  67. */
  68. int starpu_init(struct starpu_conf *conf);
  69. /* Shutdown method: note that statistics are only generated once StarPU is
  70. * shutdown */
  71. void starpu_shutdown(void);
  72. /* This function returns the number of workers (ie. processing units executing
  73. * StarPU tasks). The returned value should be at most STARPU_NMAXWORKERS. */
  74. unsigned starpu_worker_get_count(void);
  75. unsigned starpu_combined_worker_get_count(void);
  76. unsigned starpu_cpu_worker_get_count(void);
  77. unsigned starpu_cuda_worker_get_count(void);
  78. unsigned starpu_spu_worker_get_count(void);
  79. unsigned starpu_opencl_worker_get_count(void);
  80. /* Return the identifier of the thread in case this is associated to a worker.
  81. * This will return -1 if this function is called directly from the application
  82. * or if it is some SPU worker where a single thread controls different SPUs. */
  83. int starpu_worker_get_id(void);
  84. int starpu_combined_worker_get_id(void);
  85. int starpu_combined_worker_get_size(void);
  86. int starpu_combined_worker_get_rank(void);
  87. enum starpu_archtype {
  88. STARPU_CPU_WORKER, /* CPU core */
  89. STARPU_CUDA_WORKER, /* NVIDIA CUDA device */
  90. STARPU_OPENCL_WORKER, /* OpenCL CUDA device */
  91. STARPU_GORDON_WORKER /* Cell SPU */
  92. };
  93. /* This function returns the type of worker associated to an identifier (as
  94. * returned by the starpu_worker_get_id function). The returned value indicates
  95. * the architecture of the worker: STARPU_CPU_WORKER for a CPU core,
  96. * STARPU_CUDA_WORKER for a CUDA device, and STARPU_GORDON_WORKER for a Cell
  97. * SPU. The value returned for an invalid identifier is unspecified. */
  98. enum starpu_archtype starpu_worker_get_type(int id);
  99. /* Returns the number of workers of the type indicated by the argument. A
  100. * positive (or null) value is returned in case of success, -EINVAL indicates
  101. * that the type is not valid otherwise. */
  102. int starpu_worker_get_count_by_type(enum starpu_archtype type);
  103. /* Fill the workerids array with the identifiers of the workers that have the
  104. * type indicated in the first argument. The maxsize argument indicates the
  105. * size of the workids array. The returned value gives the number of
  106. * identifiers that were put in the array. -ERANGE is returned is maxsize is
  107. * lower than the number of workers with the appropriate type: in that case,
  108. * the array is filled with the maxsize first elements. To avoid such
  109. * overflows, the value of maxsize can be chosen by the means of the
  110. * starpu_worker_get_count_by_type function, or by passing a value greater or
  111. * equal to STARPU_NMAXWORKERS. */
  112. int starpu_worker_get_ids_by_type(enum starpu_archtype type, int *workerids, int maxsize);
  113. /* StarPU associates a unique human readable string to each processing unit.
  114. * This function copies at most the "maxlen" first bytes of the unique
  115. * string associated to a worker identified by its identifier "id" into
  116. * the "dst" buffer. The caller is responsible for ensuring that the
  117. * "dst" is a valid pointer to a buffer of "maxlen" bytes at least.
  118. * Calling this function on an invalid identifier results in an unspecified
  119. * behaviour. */
  120. void starpu_worker_get_name(int id, char *dst, size_t maxlen);
  121. /* This functions returns the device id of the worker associated to an
  122. * identifier (as returned by the starpu_worker_get_id() function)
  123. */
  124. int starpu_worker_get_devid(int id);
  125. #ifdef __cplusplus
  126. }
  127. #endif
  128. #endif /* __STARPU_H__ */