All Classes Namespaces Functions Enumerations Enumerator Modules Pages
Macros
Utility_error

Macros

#define CUDA_DRIVER_TRY(...)
 Error checking macro for CUDA driver API functions. More...
 
#define CUFILE_TRY(...)
 Error checking macro for cuFile API functions. More...
 
#define KVIKIO_EXPECT(...)    GET_KVIKIO_EXPECT_MACRO(__VA_ARGS__, KVIKIO_EXPECT_3, KVIKIO_EXPECT_2)(__VA_ARGS__)
 Macro for checking pre-conditions or conditions that throws an exception when a condition is violated. More...
 
#define KVIKIO_FAIL(...)    GET_KVIKIO_FAIL_MACRO(__VA_ARGS__, KVIKIO_FAIL_2, KVIKIO_FAIL_1)(__VA_ARGS__)
 Indicates that an erroneous code path has been taken. More...
 

Detailed Description

Macro Definition Documentation

◆ CUDA_DRIVER_TRY

#define CUDA_DRIVER_TRY (   ...)
Value:
GET_CUDA_DRIVER_TRY_MACRO(__VA_ARGS__, CUDA_DRIVER_TRY_2, CUDA_DRIVER_TRY_1) \
(__VA_ARGS__)

Error checking macro for CUDA driver API functions.

Invoke a CUDA driver API function call. If the call does not return CUDA_SUCCESS, throw an exception detailing the CUDA error that occurred.

Example:

// Throws kvikio::CUfileException
CUDA_DRIVER_TRY(cudaAPI::instance().StreamSynchronize(_stream));
// Throws std::runtime_error
CUDA_DRIVER_TRY(cudaAPI::instance().StreamSynchronize(_stream), std::runtime_error);
#define CUDA_DRIVER_TRY(...)
Error checking macro for CUDA driver API functions.
Definition: error.hpp:68
Parameters
...This macro accepts either one or two arguments:
  • The first argument must be a CUDA driver API error code.
  • When given, the second argument is the exception to be thrown. When not specified, defaults to kvikio::CUfileException.

Definition at line 68 of file error.hpp.

◆ CUFILE_TRY

#define CUFILE_TRY (   ...)
Value:
GET_CUFILE_TRY_MACRO(__VA_ARGS__, CUFILE_TRY_2, CUFILE_TRY_1) \
(__VA_ARGS__)

Error checking macro for cuFile API functions.

Invoke a cuFile API function call. If the call does not return CU_FILE_SUCCESS, throw an exception detailing the cuFile error that occurred.

Example:

// Throws kvikio::CUfileException
CUFILE_TRY(cuFileAPI::instance().ReadAsync(...));
// Throws std::runtime_error
CUFILE_TRY(cuFileAPI::instance().ReadAsync(...), std::runtime_error);
#define CUFILE_TRY(...)
Error checking macro for cuFile API functions.
Definition: error.hpp:107
Parameters
...This macro accepts either one or two arguments:
  • The first argument must be a cuFile API error code.
  • When given, the second argument is the exception to be thrown. When not specified, defaults to kvikio::CUfileException.

Definition at line 107 of file error.hpp.

◆ KVIKIO_EXPECT

#define KVIKIO_EXPECT (   ...)     GET_KVIKIO_EXPECT_MACRO(__VA_ARGS__, KVIKIO_EXPECT_3, KVIKIO_EXPECT_2)(__VA_ARGS__)

Macro for checking pre-conditions or conditions that throws an exception when a condition is violated.

Defaults to throwing kvikio::CUfileException, but a custom exception may also be specified.

Example:

// Throws kvikio::CUfileException
KVIKIO_EXPECT(p != nullptr, "Unexpected null pointer");
// Throws std::runtime_error
KVIKIO_EXPECT(p != nullptr, "Unexpected nullptr", std::runtime_error);
#define KVIKIO_EXPECT(...)
Macro for checking pre-conditions or conditions that throws an exception when a condition is violated...
Definition: error.hpp:216
Parameters
...This macro accepts either two or three arguments:
  • The first argument must be an expression that evaluates to true or false, and is the condition being checked.
  • The second argument is a string literal used to construct the what of the exception.
  • When given, the third argument is the exception to be thrown. When not specified, defaults to kvikio::CUfileException.

Definition at line 216 of file error.hpp.

◆ KVIKIO_FAIL

#define KVIKIO_FAIL (   ...)     GET_KVIKIO_FAIL_MACRO(__VA_ARGS__, KVIKIO_FAIL_2, KVIKIO_FAIL_1)(__VA_ARGS__)

Indicates that an erroneous code path has been taken.

Example usage:

// Throws kvikio::CUfileException
KVIKIO_FAIL("Unsupported code path");
// Throws std::runtime_error
KVIKIO_FAIL("Unsupported code path", std::runtime_error);
#define KVIKIO_FAIL(...)
Indicates that an erroneous code path has been taken.
Definition: error.hpp:252
Parameters
...This macro accepts either one or two arguments:
  • The first argument is a string literal used to construct the what of the exception.
  • When given, the second argument is the exception to be thrown. When not specified, defaults to kvikio::CUfileException.

Definition at line 252 of file error.hpp.