Skip to content

Commit

Permalink
Fix include issues
Browse files Browse the repository at this point in the history
  • Loading branch information
miscco committed Apr 25, 2024
1 parent 9d9f85e commit a5ea93a
Show file tree
Hide file tree
Showing 2 changed files with 34 additions and 34 deletions.
33 changes: 33 additions & 0 deletions libcudacxx/include/cuda/__memory_resource/cuda_memory_pool.h
Original file line number Diff line number Diff line change
Expand Up @@ -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
*
Expand Down
35 changes: 1 addition & 34 deletions libcudacxx/include/cuda/std/__cuda/api_wrapper.h
Original file line number Diff line number Diff line change
Expand Up @@ -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

0 comments on commit a5ea93a

Please sign in to comment.