starpu_driver.h 2.8 KB

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