starpu.h 4.2 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127
  1. /*
  2. * StarPU
  3. * Copyright (C) Université Bordeaux 1, CNRS 2008-2010 (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_H__
  17. #define __STARPU_H__
  18. #include <stdlib.h>
  19. #ifndef _MSC_VER
  20. #include <stdint.h>
  21. #else
  22. typedef unsigned char uint8_t;
  23. typedef unsigned short uint16_t;
  24. typedef unsigned long uint32_t;
  25. typedef unsigned long long uint64_t;
  26. #endif
  27. #include <starpu_config.h>
  28. #include <starpu_util.h>
  29. #include <starpu_data.h>
  30. #include <starpu_perfmodel.h>
  31. #include <starpu_task.h>
  32. #include <starpu_expert.h>
  33. #ifdef __cplusplus
  34. extern "C" {
  35. #endif
  36. /* TODO: should either make 0 be the default, or provide an initializer, to
  37. * make future extensions not problematic */
  38. struct starpu_conf {
  39. /* which scheduling policy should be used ? (NULL for default) */
  40. const char *sched_policy_name;
  41. struct starpu_sched_policy_s *sched_policy;
  42. /* maximum number of CPUs (-1 for default) */
  43. int ncpus;
  44. /* maximum number of CUDA GPUs (-1 for default) */
  45. int ncuda;
  46. /* maximum number of OpenCL GPUs (-1 for default) */
  47. int nopencl;
  48. /* maximum number of Cell's SPUs (-1 for default) */
  49. int nspus;
  50. unsigned use_explicit_workers_bindid;
  51. unsigned workers_bindid[STARPU_NMAXWORKERS];
  52. unsigned use_explicit_workers_cuda_gpuid;
  53. unsigned workers_cuda_gpuid[STARPU_NMAXWORKERS];
  54. unsigned use_explicit_workers_opencl_gpuid;
  55. unsigned workers_opencl_gpuid[STARPU_NMAXWORKERS];
  56. /* calibrate performance models, if any (-1 for default) */
  57. int calibrate;
  58. };
  59. /* Initialization method: it must be called prior to any other StarPU call
  60. * Default configuration is used if NULL is passed as argument.
  61. */
  62. int starpu_init(struct starpu_conf *conf);
  63. /* Shutdown method: note that statistics are only generated once StarPU is
  64. * shutdown */
  65. void starpu_shutdown(void);
  66. /* This function returns the number of workers (ie. processing units executing
  67. * StarPU tasks). The returned value should be at most STARPU_NMAXWORKERS. */
  68. unsigned starpu_worker_get_count(void);
  69. unsigned starpu_cpu_worker_get_count(void);
  70. unsigned starpu_cuda_worker_get_count(void);
  71. unsigned starpu_spu_worker_get_count(void);
  72. unsigned starpu_opencl_worker_get_count(void);
  73. /* Return the identifier of the thread in case this is associated to a worker.
  74. * This will return -1 if this function is called directly from the application
  75. * or if it is some SPU worker where a single thread controls different SPUs. */
  76. int starpu_worker_get_id(void);
  77. enum starpu_archtype {
  78. STARPU_CPU_WORKER, /* CPU core */
  79. STARPU_CUDA_WORKER, /* NVIDIA CUDA device */
  80. STARPU_OPENCL_WORKER, /* OpenCL CUDA device */
  81. STARPU_GORDON_WORKER /* Cell SPU */
  82. };
  83. /* This function returns the type of worker associated to an identifier (as
  84. * returned by the starpu_worker_get_id function). The returned value indicates
  85. * the architecture of the worker: STARPU_CPU_WORKER for a CPU core,
  86. * STARPU_CUDA_WORKER for a CUDA device, and STARPU_GORDON_WORKER for a Cell
  87. * SPU. The value returned for an invalid identifier is unspecified. */
  88. enum starpu_archtype starpu_worker_get_type(int id);
  89. /* StarPU associates a unique human readable string to each processing unit.
  90. * This function copies at most the "maxlen" first bytes of the unique
  91. * string associated to a worker identified by its identifier "id" into
  92. * the "dst" buffer. The caller is responsible for ensuring that the
  93. * "dst" is a valid pointer to a buffer of "maxlen" bytes at least.
  94. * Calling this function on an invalid identifier results in an unspecified
  95. * behaviour. */
  96. void starpu_worker_get_name(int id, char *dst, size_t maxlen);
  97. /* This functions returns the device id of the worker associated to an
  98. * identifier (as returned by the starpu_worker_get_id() function)
  99. */
  100. int starpu_worker_get_devid(int id);
  101. #ifdef __cplusplus
  102. }
  103. #endif
  104. #endif // __STARPU_H__