starpu_driver.h 2.9 KB

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