starpu.h 3.7 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109
  1. /*
  2. * StarPU
  3. * Copyright (C) INRIA 2008-2009 (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. #include <stdint.h>
  20. /* Maximum number of workers supported by StarPU, the actual number of worker
  21. * is given by the startpu_get_worker_count method */
  22. #define STARPU_NMAXWORKERS 32
  23. #include <starpu_config.h>
  24. #include <starpu-util.h>
  25. #include <starpu-data.h>
  26. #include <starpu-perfmodel.h>
  27. #include <starpu-task.h>
  28. #ifdef __cplusplus
  29. extern "C" {
  30. #endif
  31. /* TODO: should either make 0 be the default, or provide an initializer, to
  32. * make future extensions not problematic */
  33. struct starpu_conf {
  34. /* which scheduling policy should be used ? (NULL for default) */
  35. const char *sched_policy;
  36. /* maximum number of CPUs (-1 for default) */
  37. int ncpus;
  38. /* maximum number of CUDA GPUs (-1 for default) */
  39. int ncuda;
  40. /* maximum number of Cell's SPUs (-1 for default) */
  41. int nspus;
  42. unsigned use_explicit_workers_bindid;
  43. unsigned workers_bindid[STARPU_NMAXWORKERS];
  44. unsigned use_explicit_workers_gpuid;
  45. unsigned workers_gpuid[STARPU_NMAXWORKERS];
  46. /* calibrate performance models, if any */
  47. unsigned calibrate;
  48. };
  49. /* Initialization method: it must be called prior to any other StarPU call
  50. * Default configuration is used if NULL is passed as argument.
  51. */
  52. int starpu_init(struct starpu_conf *conf);
  53. /* Shutdown method: note that statistics are only generated once StarPU is
  54. * shutdown */
  55. void starpu_shutdown(void);
  56. /* This function returns the number of workers (ie. processing units executing
  57. * StarPU tasks). The returned value should be at most STARPU_NMAXWORKERS. */
  58. unsigned starpu_get_worker_count(void);
  59. unsigned starpu_get_core_worker_count(void);
  60. unsigned starpu_get_cuda_worker_count(void);
  61. unsigned starpu_get_spu_worker_count(void);
  62. /* Return the identifier of the thread in case this is associated to a worker.
  63. * This will return -1 if this function is called directly from the application
  64. * or if it is some SPU worker where a single thread controls different SPUs. */
  65. int starpu_get_worker_id(void);
  66. enum starpu_archtype {
  67. STARPU_CORE_WORKER, /* CPU core */
  68. STARPU_CUDA_WORKER, /* NVIDIA CUDA device */
  69. STARPU_GORDON_WORKER /* Cell SPU */
  70. };
  71. /* This function returns the type of worker associated to an identifier (as
  72. * returned by the starpu_get_worker_id function). The returned value indicates
  73. * the architecture of the worker: STARPU_CORE_WORKER for a CPU core,
  74. * STARPU_CUDA_WORKER for a CUDA device, and STARPU_GORDON_WORKER for a Cell
  75. * SPU. The value returned for an invalid identifier is unspecified. */
  76. enum starpu_archtype starpu_get_worker_type(int id);
  77. /* StarPU associates a unique human readable string to each processing unit.
  78. * This function copies at most the "maxlen" first bytes of the unique
  79. * string associated to a worker identified by its identifier "id" into
  80. * the "dst" buffer. The caller is responsible for ensuring that the
  81. * "dst" is a valid pointer to a buffer of "maxlen" bytes at least.
  82. * Calling this function on an invalid identifier results in an unspecified
  83. * behaviour. */
  84. void starpu_get_worker_name(int id, char *dst, size_t maxlen);
  85. #ifdef __cplusplus
  86. }
  87. #endif
  88. #endif // __STARPU_H__