starpu_cuda.h 3.6 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105
  1. /* StarPU --- Runtime system for heterogeneous multicore architectures.
  2. *
  3. * Copyright (C) 2010-2012,2014 Université de Bordeaux
  4. * Copyright (C) 2011 Inria
  5. * Copyright (C) 2010-2013,2015,2017,2019 CNRS
  6. *
  7. * StarPU is free software; you can redistribute it and/or modify
  8. * it under the terms of the GNU Lesser General Public License as published by
  9. * the Free Software Foundation; either version 2.1 of the License, or (at
  10. * your option) any later version.
  11. *
  12. * StarPU is distributed in the hope that it will be useful, but
  13. * WITHOUT ANY WARRANTY; without even the implied warranty of
  14. * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.
  15. *
  16. * See the GNU Lesser General Public License in COPYING.LGPL for more details.
  17. */
  18. #ifndef __STARPU_CUDA_H__
  19. #define __STARPU_CUDA_H__
  20. #include <starpu_config.h>
  21. #if defined STARPU_USE_CUDA && !defined STARPU_DONT_INCLUDE_CUDA_HEADERS
  22. #include <cuda.h>
  23. #include <cuda_runtime.h>
  24. #include <cuda_runtime_api.h>
  25. #ifdef __cplusplus
  26. extern "C"
  27. {
  28. #endif
  29. /**
  30. @defgroup API_CUDA_Extensions CUDA Extensions
  31. @{
  32. */
  33. /**
  34. Report a CUBLAS error.
  35. */
  36. void starpu_cublas_report_error(const char *func, const char *file, int line, int status);
  37. /**
  38. Call starpu_cublas_report_error(), passing the current function, file and line position.
  39. */
  40. #define STARPU_CUBLAS_REPORT_ERROR(status) starpu_cublas_report_error(__starpu_func__, __FILE__, __LINE__, status)
  41. /**
  42. Report a CUDA error.
  43. */
  44. void starpu_cuda_report_error(const char *func, const char *file, int line, cudaError_t status);
  45. /**
  46. Call starpu_cuda_report_error(), passing the current function, file and line position.
  47. */
  48. #define STARPU_CUDA_REPORT_ERROR(status) starpu_cuda_report_error(__starpu_func__, __FILE__, __LINE__, status)
  49. /**
  50. Return the current worker’s CUDA stream. StarPU provides a stream
  51. for every CUDA device controlled by StarPU. This function is only
  52. provided for convenience so that programmers can easily use
  53. asynchronous operations within codelets without having to create a
  54. stream by hand. Note that the application is not forced to use the
  55. stream provided by starpu_cuda_get_local_stream() and may also
  56. create its own streams. Synchronizing with
  57. <c>cudaThreadSynchronize()</c> is allowed, but will reduce the
  58. likelihood of having all transfers overlapped.
  59. */
  60. cudaStream_t starpu_cuda_get_local_stream(void);
  61. /**
  62. Return a pointer to device properties for worker \p workerid
  63. (assumed to be a CUDA worker).
  64. */
  65. const struct cudaDeviceProp *starpu_cuda_get_device_properties(unsigned workerid);
  66. /**
  67. Copy \p ssize bytes from the pointer \p src_ptr on \p src_node
  68. to the pointer \p dst_ptr on \p dst_node. The function first tries to
  69. copy the data asynchronous (unless \p stream is <c>NULL</c>). If the
  70. asynchronous copy fails or if \p stream is <c>NULL</c>, it copies the
  71. data synchronously. The function returns <c>-EAGAIN</c> if the
  72. asynchronous launch was successfull. It returns 0 if the synchronous
  73. copy was successful, or fails otherwise.
  74. */
  75. int starpu_cuda_copy_async_sync(void *src_ptr, unsigned src_node, void *dst_ptr, unsigned dst_node, size_t ssize, cudaStream_t stream, enum cudaMemcpyKind kind);
  76. /**
  77. Call <c>cudaSetDevice(\p devid)</c> or <c>cudaGLSetGLDevice(\p devid)</c>,
  78. according to whether \p devid is among the field
  79. starpu_conf::cuda_opengl_interoperability.
  80. */
  81. void starpu_cuda_set_device(unsigned devid);
  82. /** @} */
  83. #ifdef __cplusplus
  84. }
  85. #endif
  86. #endif /* STARPU_USE_CUDA && !STARPU_DONT_INCLUDE_CUDA_HEADERS */
  87. #endif /* __STARPU_CUDA_H__ */