Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Removing conflict w/ CUDA_CHECK #378

Merged
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
49 changes: 31 additions & 18 deletions cpp/include/raft/cudart_utils.h
Original file line number Diff line number Diff line change
Expand Up @@ -53,6 +53,7 @@ struct cuda_error : public raft::exception {
* exception detailing the CUDA error that occurred
*
*/
#ifndef CUDA_TRY
#define CUDA_TRY(call) \
do { \
cudaError_t const status = call; \
Expand All @@ -65,7 +66,7 @@ struct cuda_error : public raft::exception {
throw raft::cuda_error(msg); \
} \
} while (0)

#endif
/**
* @brief Debug macro to check for CUDA errors
*
Expand All @@ -86,13 +87,16 @@ struct cuda_error : public raft::exception {
#endif

/** FIXME: temporary alias for cuML compatibility */
#ifndef CUDA_CHECK
#define CUDA_CHECK(call) CUDA_TRY(call)
#endif

///@todo: enable this only after we have added logging support in raft
// /**
// * @brief check for cuda runtime API errors but log error instead of raising
// * exception.
// */
#ifndef CUDA_CHECK_NO_THROW
#define CUDA_CHECK_NO_THROW(call) \
do { \
cudaError_t const status = call; \
Expand All @@ -101,6 +105,15 @@ struct cuda_error : public raft::exception {
__FILE__, __LINE__, cudaGetErrorString(status)); \
} \
} while (0)
#endif

/**
* Alias to raft scope for now.
* TODO: Rename original implementations in 22.04 to fix
* https://github.com/rapidsai/raft/issues/128
*/
#define RAFT_CUDA_CHECK(call) CUDA_CHECK(call)
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I would have done this in reverse. That is, I would have conditionally defined CUDA_CHECK as a call to RAFT_CUDA_CHECK which would make the next change smaller. But this way is fine too.

#define RAFT_CUDA_CHECK_NO_THROW(call) CUDA_CHECK_NO_THROW(call)

namespace raft {

Expand All @@ -121,13 +134,13 @@ class grid_1d_thread_t {
int const num_blocks{0};

/**
* @param overall_num_elements The number of elements the kernel needs to handle/process
* @param num_threads_per_block The grid block size, determined according to the kernel's
* specific features (amount of shared memory necessary, SM functional units use pattern etc.);
* this can't be determined generically/automatically (as opposed to the number of blocks)
* @param elements_per_thread Typically, a single kernel thread processes more than a single
* element; this affects the number of threads the grid must contain
*/
* @param overall_num_elements The number of elements the kernel needs to handle/process
* @param num_threads_per_block The grid block size, determined according to the kernel's
* specific features (amount of shared memory necessary, SM functional units use pattern etc.);
* this can't be determined generically/automatically (as opposed to the number of blocks)
* @param elements_per_thread Typically, a single kernel thread processes more than a single
* element; this affects the number of threads the grid must contain
*/
grid_1d_thread_t(size_t overall_num_elements, size_t num_threads_per_block,
size_t max_num_blocks_1d, size_t elements_per_thread = 1)
: block_size(num_threads_per_block),
Expand All @@ -152,11 +165,11 @@ class grid_1d_warp_t {
int const num_blocks{0};

/**
* @param overall_num_elements The number of elements the kernel needs to handle/process
* @param num_threads_per_block The grid block size, determined according to the kernel's
* specific features (amount of shared memory necessary, SM functional units use pattern etc.);
* this can't be determined generically/automatically (as opposed to the number of blocks)
*/
* @param overall_num_elements The number of elements the kernel needs to handle/process
* @param num_threads_per_block The grid block size, determined according to the kernel's
* specific features (amount of shared memory necessary, SM functional units use pattern etc.);
* this can't be determined generically/automatically (as opposed to the number of blocks)
*/
grid_1d_warp_t(size_t overall_num_elements, size_t num_threads_per_block,
size_t max_num_blocks_1d)
: block_size(num_threads_per_block),
Expand All @@ -180,11 +193,11 @@ class grid_1d_block_t {
int const num_blocks{0};

/**
* @param overall_num_elements The number of elements the kernel needs to handle/process
* @param num_threads_per_block The grid block size, determined according to the kernel's
* specific features (amount of shared memory necessary, SM functional units use pattern etc.);
* this can't be determined generically/automatically (as opposed to the number of blocks)
*/
* @param overall_num_elements The number of elements the kernel needs to handle/process
* @param num_threads_per_block The grid block size, determined according to the kernel's
* specific features (amount of shared memory necessary, SM functional units use pattern etc.);
* this can't be determined generically/automatically (as opposed to the number of blocks)
*/
grid_1d_block_t(size_t overall_num_elements, size_t num_threads_per_block,
size_t max_num_blocks_1d)
: block_size(num_threads_per_block),
Expand Down