starpu_driver.h 2.8 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108
  1. /* StarPU --- Runtime system for heterogeneous multicore architectures.
  2. *
  3. * Copyright (C) 2009-2020 Université de Bordeaux, CNRS (LaBRI UMR 5800), Inria
  4. *
  5. * StarPU 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. * StarPU 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_DRIVER_H__
  17. #define __STARPU_DRIVER_H__
  18. #include <starpu_config.h>
  19. #if defined(STARPU_USE_OPENCL) && !defined(__CUDACC__)
  20. #include <starpu_opencl.h>
  21. #endif
  22. #ifdef __cplusplus
  23. extern "C"
  24. {
  25. #endif
  26. /**
  27. @defgroup API_Running_Drivers Running Drivers
  28. @{
  29. */
  30. /**
  31. Pre-initialize drivers
  32. So as to register information on device types, memory types, etc.
  33. */
  34. void starpu_drivers_preinit(void);
  35. /**
  36. structure for designating a given driver
  37. */
  38. struct starpu_driver
  39. {
  40. /**
  41. Type of the driver. Only ::STARPU_CPU_WORKER, ::STARPU_CUDA_WORKER
  42. and ::STARPU_OPENCL_WORKER are currently supported.
  43. */
  44. enum starpu_worker_archtype type;
  45. /**
  46. Identifier of the driver.
  47. */
  48. union
  49. {
  50. unsigned cpu_id;
  51. unsigned cuda_id;
  52. #if defined(STARPU_USE_OPENCL) && !defined(__CUDACC__)
  53. cl_device_id opencl_id;
  54. #else
  55. unsigned opencl_id;
  56. #endif
  57. } id;
  58. };
  59. /**
  60. Initialize the given driver, run it until it receives a request to
  61. terminate, deinitialize it and return 0 on success. Return
  62. <c>-EINVAL</c> if starpu_driver::type is not a valid StarPU device type
  63. (::STARPU_CPU_WORKER, ::STARPU_CUDA_WORKER or ::STARPU_OPENCL_WORKER).
  64. This is the same as using the following functions: calling
  65. starpu_driver_init(), then calling starpu_driver_run_once() in a loop,
  66. and finally starpu_driver_deinit().
  67. */
  68. int starpu_driver_run(struct starpu_driver *d);
  69. /**
  70. Notify all running drivers that they should terminate.
  71. */
  72. void starpu_drivers_request_termination(void);
  73. /**
  74. Initialize the given driver. Return 0 on success, <c>-EINVAL</c>
  75. if starpu_driver::type is not a valid ::starpu_worker_archtype.
  76. */
  77. int starpu_driver_init(struct starpu_driver *d);
  78. /**
  79. Run the driver once, then return 0 on success, <c>-EINVAL</c> if
  80. starpu_driver::type is not a valid ::starpu_worker_archtype.
  81. */
  82. int starpu_driver_run_once(struct starpu_driver *d);
  83. /**
  84. Deinitialize the given driver. Return 0 on success, <c>-EINVAL</c> if
  85. starpu_driver::type is not a valid ::starpu_worker_archtype.
  86. */
  87. int starpu_driver_deinit(struct starpu_driver *d);
  88. /** @} */
  89. #ifdef __cplusplus
  90. }
  91. #endif
  92. #endif /* __STARPU_DRIVER_H__ */