starpu.h 4.5 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136
  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. #include <starpu_util.h>
  30. #include <starpu_data.h>
  31. #include <starpu_perfmodel.h>
  32. #include <starpu_task.h>
  33. #include <starpu_task_list.h>
  34. #include <starpu_scheduler.h>
  35. #include <starpu_expert.h>
  36. #ifdef __cplusplus
  37. extern "C" {
  38. #endif
  39. struct starpu_conf {
  40. /* which scheduling policy should be used ? (NULL for default) */
  41. const char *sched_policy_name;
  42. struct starpu_sched_policy_s *sched_policy;
  43. /* number of CPU workers (-1 for default) */
  44. int ncpus;
  45. /* number of CUDA GPU workers (-1 for default) */
  46. int ncuda;
  47. /* number of GPU OpenCL device workers (-1 for default) */
  48. int nopencl;
  49. /* number of Cell's SPUs (-1 for default) */
  50. int nspus;
  51. unsigned use_explicit_workers_bindid;
  52. unsigned workers_bindid[STARPU_NMAXWORKERS];
  53. unsigned use_explicit_workers_cuda_gpuid;
  54. unsigned workers_cuda_gpuid[STARPU_NMAXWORKERS];
  55. unsigned use_explicit_workers_opencl_gpuid;
  56. unsigned workers_opencl_gpuid[STARPU_NMAXWORKERS];
  57. /* calibrate performance models, if any (-1 for default) */
  58. int calibrate;
  59. };
  60. /* Initialize a starpu_conf structure with default values. */
  61. int starpu_conf_init(struct starpu_conf *conf);
  62. /* Initialization method: it must be called prior to any other StarPU call
  63. * Default configuration is used if NULL is passed as argument.
  64. */
  65. int starpu_init(struct starpu_conf *conf);
  66. /* Shutdown method: note that statistics are only generated once StarPU is
  67. * shutdown */
  68. void starpu_shutdown(void);
  69. /* This function returns the number of workers (ie. processing units executing
  70. * StarPU tasks). The returned value should be at most STARPU_NMAXWORKERS. */
  71. unsigned starpu_worker_get_count(void);
  72. unsigned starpu_combined_worker_get_count(void);
  73. unsigned starpu_cpu_worker_get_count(void);
  74. unsigned starpu_cuda_worker_get_count(void);
  75. unsigned starpu_spu_worker_get_count(void);
  76. unsigned starpu_opencl_worker_get_count(void);
  77. /* Return the identifier of the thread in case this is associated to a worker.
  78. * This will return -1 if this function is called directly from the application
  79. * or if it is some SPU worker where a single thread controls different SPUs. */
  80. int starpu_worker_get_id(void);
  81. int starpu_combined_worker_get_id(void);
  82. int starpu_combined_worker_get_size(void);
  83. int starpu_combined_worker_get_rank(void);
  84. enum starpu_archtype {
  85. STARPU_CPU_WORKER, /* CPU core */
  86. STARPU_CUDA_WORKER, /* NVIDIA CUDA device */
  87. STARPU_OPENCL_WORKER, /* OpenCL CUDA device */
  88. STARPU_GORDON_WORKER /* Cell SPU */
  89. };
  90. /* This function returns the type of worker associated to an identifier (as
  91. * returned by the starpu_worker_get_id function). The returned value indicates
  92. * the architecture of the worker: STARPU_CPU_WORKER for a CPU core,
  93. * STARPU_CUDA_WORKER for a CUDA device, and STARPU_GORDON_WORKER for a Cell
  94. * SPU. The value returned for an invalid identifier is unspecified. */
  95. enum starpu_archtype starpu_worker_get_type(int id);
  96. /* StarPU associates a unique human readable string to each processing unit.
  97. * This function copies at most the "maxlen" first bytes of the unique
  98. * string associated to a worker identified by its identifier "id" into
  99. * the "dst" buffer. The caller is responsible for ensuring that the
  100. * "dst" is a valid pointer to a buffer of "maxlen" bytes at least.
  101. * Calling this function on an invalid identifier results in an unspecified
  102. * behaviour. */
  103. void starpu_worker_get_name(int id, char *dst, size_t maxlen);
  104. /* This functions returns the device id of the worker associated to an
  105. * identifier (as returned by the starpu_worker_get_id() function)
  106. */
  107. int starpu_worker_get_devid(int id);
  108. #ifdef __cplusplus
  109. }
  110. #endif
  111. #endif // __STARPU_H__