starpu_worker.h 4.4 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108
  1. /* StarPU --- Runtime system for heterogeneous multicore architectures.
  2. *
  3. * Copyright (C) 2009-2013 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_WORKER_H__
  18. #define __STARPU_WORKER_H__
  19. #include <stdlib.h>
  20. #include <starpu_config.h>
  21. #ifdef __cplusplus
  22. extern "C"
  23. {
  24. #endif
  25. enum starpu_archtype
  26. {
  27. STARPU_ANY_WORKER, /* any worker, used in the hypervisor */
  28. STARPU_CPU_WORKER, /* CPU core */
  29. STARPU_CUDA_WORKER, /* NVIDIA CUDA device */
  30. STARPU_OPENCL_WORKER, /* OpenCL device */
  31. STARPU_GORDON_WORKER /* Cell SPU */
  32. };
  33. /* This function returns the number of workers (ie. processing units executing
  34. * StarPU tasks). The returned value should be at most STARPU_NMAXWORKERS. */
  35. unsigned starpu_worker_get_count(void);
  36. unsigned starpu_combined_worker_get_count(void);
  37. unsigned starpu_worker_is_combined_worker(int id);
  38. unsigned starpu_cpu_worker_get_count(void);
  39. unsigned starpu_cuda_worker_get_count(void);
  40. unsigned starpu_spu_worker_get_count(void);
  41. unsigned starpu_opencl_worker_get_count(void);
  42. /* Return the identifier of the thread in case this is associated to a worker.
  43. * This will return -1 if this function is called directly from the application
  44. * or if it is some SPU worker where a single thread controls different SPUs. */
  45. int starpu_worker_get_id(void);
  46. int starpu_combined_worker_get_id(void);
  47. int starpu_combined_worker_get_size(void);
  48. int starpu_combined_worker_get_rank(void);
  49. /* This function returns the type of worker associated to an identifier (as
  50. * returned by the starpu_worker_get_id function). The returned value indicates
  51. * the architecture of the worker: STARPU_CPU_WORKER for a CPU core,
  52. * STARPU_CUDA_WORKER for a CUDA device, and STARPU_GORDON_WORKER for a Cell
  53. * SPU. The value returned for an invalid identifier is unspecified. */
  54. enum starpu_archtype starpu_worker_get_type(int id);
  55. /* Returns the number of workers of the type indicated by the argument. A
  56. * positive (or null) value is returned in case of success, -EINVAL indicates
  57. * that the type is not valid otherwise. */
  58. int starpu_worker_get_count_by_type(enum starpu_archtype type);
  59. /* Fill the workerids array with the identifiers of the workers that have the
  60. * type indicated in the first argument. The maxsize argument indicates the
  61. * size of the workids array. The returned value gives the number of
  62. * identifiers that were put in the array. -ERANGE is returned is maxsize is
  63. * lower than the number of workers with the appropriate type: in that case,
  64. * the array is filled with the maxsize first elements. To avoid such
  65. * overflows, the value of maxsize can be chosen by the means of the
  66. * starpu_worker_get_count_by_type function, or by passing a value greater or
  67. * equal to STARPU_NMAXWORKERS. */
  68. int starpu_worker_get_ids_by_type(enum starpu_archtype type, int *workerids, int maxsize);
  69. /* Return the identifier of the n-th worker of a specific type */
  70. int starpu_worker_get_by_type(enum starpu_archtype type, int num);
  71. /* Return the identifier of the worker devid of a specific type */
  72. int starpu_worker_get_by_devid(enum starpu_archtype type, int devid);
  73. /* StarPU associates a unique human readable string to each processing unit.
  74. * This function copies at most the "maxlen" first bytes of the unique
  75. * string associated to a worker identified by its identifier "id" into
  76. * the "dst" buffer. The caller is responsible for ensuring that the
  77. * "dst" is a valid pointer to a buffer of "maxlen" bytes at least.
  78. * Calling this function on an invalid identifier results in an unspecified
  79. * behaviour. */
  80. void starpu_worker_get_name(int id, char *dst, size_t maxlen);
  81. /* This functions returns the device id of the worker associated to an
  82. * identifier (as returned by the starpu_worker_get_id() function)
  83. */
  84. int starpu_worker_get_devid(int id);
  85. #ifdef __cplusplus
  86. }
  87. #endif
  88. #endif /* __STARPU_WORKER_H__ */