From a5ea93af42a02f1c1b320df01873cf7d852d783a Mon Sep 17 00:00:00 2001 From: Michael Schellenberger Costa Date: Thu, 25 Apr 2024 10:32:49 +0200 Subject: [PATCH] Fix include issues --- .../cuda/__memory_resource/cuda_memory_pool.h | 33 +++++++++++++++++ .../include/cuda/std/__cuda/api_wrapper.h | 35 +------------------ 2 files changed, 34 insertions(+), 34 deletions(-) diff --git a/libcudacxx/include/cuda/__memory_resource/cuda_memory_pool.h b/libcudacxx/include/cuda/__memory_resource/cuda_memory_pool.h index b7f0c9fb27..dcbee5fefa 100644 --- a/libcudacxx/include/cuda/__memory_resource/cuda_memory_pool.h +++ b/libcudacxx/include/cuda/__memory_resource/cuda_memory_pool.h @@ -41,6 +41,39 @@ _LIBCUDACXX_BEGIN_NAMESPACE_CUDA_MR +/** + * @brief Checks whether the current device supports cudaMallocAsync + * @param __device_id The device id of the current device + * @throws cuda_error if cudaDeviceGetAttribute failed + * @returns true if cudaDevAttrMemoryPoolsSupported is not zero + */ +_CCCL_NODISCARD inline bool __device_supports_pools(const int __device_id) +{ + int __pool_is_supported = 0; + _CCCL_TRY_CUDA_API( + ::cudaDeviceGetAttribute, + "Failed to call cudaDeviceGetAttribute", + &__pool_is_supported, + ::cudaDevAttrMemoryPoolsSupported, + __device_id); + return __pool_is_supported != 0; +} + +/** + * @brief Returns the default cudaMemPool_t from the current device + * @param __device_id The device id of the current device + * @throws cuda_error if retrieving the default cudaMemPool_t fails + * @returns The default memory pool of the current device + */ +_CCCL_NODISCARD inline cudaMemPool_t __get_default_mem_pool(const int __device_id) +{ + _LIBCUDACXX_ASSERT(_CUDA_VMR::__device_supports_pools(__device_id), "cudaMallocAsync not supported"); + + ::cudaMemPool_t __pool; + _CCCL_TRY_CUDA_API(::cudaDeviceGetDefaultMemPool, "Failed to call cudaDeviceGetDefaultMemPool", &__pool, __device_id); + return __pool; +} + /** * @brief Internal redefinition of cudaMemAllocationHandleType * diff --git a/libcudacxx/include/cuda/std/__cuda/api_wrapper.h b/libcudacxx/include/cuda/std/__cuda/api_wrapper.h index 0a09b21a39..7ff2e06b06 100644 --- a/libcudacxx/include/cuda/std/__cuda/api_wrapper.h +++ b/libcudacxx/include/cuda/std/__cuda/api_wrapper.h @@ -54,46 +54,13 @@ _LIBCUDACXX_BEGIN_NAMESPACE_CUDA_MR * @throws cuda_error if cudaGetDevice was not successful * @returns The device id */ -_CCCL_NODISCARD static int __get_current_cuda_device() +_CCCL_NODISCARD inline int __get_current_cuda_device() { int __device = -1; _CCCL_TRY_CUDA_API(::cudaGetDevice, "Failed to query current device with cudaGetDevice.", &__device); return __device; } -/** - * @brief Checks whether the current device supports cudaMallocAsync - * @param __device_id The device id of the current device - * @throws cuda_error if cudaDeviceGetAttribute failed - * @returns true if cudaDevAttrMemoryPoolsSupported is not zero - */ -_CCCL_NODISCARD static bool __device_supports_pools(const int __device_id) -{ - int __pool_is_supported = 0; - _CCCL_TRY_CUDA_API( - ::cudaDeviceGetAttribute, - "Failed to call cudaDeviceGetAttribute", - &__pool_is_supported, - ::cudaDevAttrMemoryPoolsSupported, - __device_id); - return __pool_is_supported != 0; -} - -/** - * @brief Returns the default cudaMemPool_t from the current device - * @param __device_id The device id of the current device - * @throws cuda_error if retrieving the default cudaMemPool_t fails - * @returns The default memory pool of the current device - */ -_CCCL_NODISCARD static cudaMemPool_t __get_default_mem_pool(const int __device_id) -{ - _LIBCUDACXX_ASSERT(_CUDA_VMR::__device_supports_pools(__device_id), "cudaMallocAsync not supported"); - - ::cudaMemPool_t __pool; - _CCCL_TRY_CUDA_API(::cudaDeviceGetDefaultMemPool, "Failed to call cudaDeviceGetDefaultMemPool", &__pool, __device_id); - return __pool; -} - _LIBCUDACXX_END_NAMESPACE_CUDA_MR #endif //_CUDA__STD__CUDA_API_WRAPPER_H