|
|
@ -55,6 +55,12 @@ |
|
|
|
*/ |
|
|
|
*/ |
|
|
|
#define CUDATOOLS_USE_EIGEN |
|
|
|
#define CUDATOOLS_USE_EIGEN |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
/**
|
|
|
|
|
|
|
|
* \def CUDATOOLS_USE_PYTHON |
|
|
|
|
|
|
|
* Compile the CudaTools library with Python support. |
|
|
|
|
|
|
|
*/ |
|
|
|
|
|
|
|
#define CUDATOOLS_USE_PYTHON |
|
|
|
|
|
|
|
|
|
|
|
/**
|
|
|
|
/**
|
|
|
|
* \def KERNEL(call, settings, ...) |
|
|
|
* \def KERNEL(call, settings, ...) |
|
|
|
* Used to call a CUDA kernel. |
|
|
|
* Used to call a CUDA kernel. |
|
|
@ -224,12 +230,13 @@ |
|
|
|
#ifdef DEVICE |
|
|
|
#ifdef DEVICE |
|
|
|
#define CT_ERROR_IF(a, op, b, msg) \ |
|
|
|
#define CT_ERROR_IF(a, op, b, msg) \ |
|
|
|
if (a op b) { \
|
|
|
|
if (a op b) { \
|
|
|
|
printf("[ERROR] %s:%d\n | %s: (" #a ") " #op " (" #b ").\n", __FILE__, __LINE__, msg); \
|
|
|
|
printf("\033[1;31m[CudaTools]\033[0m %s:%d\n | %s: (" #a ") " #op " (" #b ").\n", \
|
|
|
|
|
|
|
|
__FILE__, __LINE__, msg); \
|
|
|
|
} |
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
#define CT_ERROR(a, msg) \ |
|
|
|
#define CT_ERROR(a, msg) \ |
|
|
|
if (a) { \
|
|
|
|
if (a) { \
|
|
|
|
printf("[ERROR] %s:%d\n | %s: " #a ".\n", __FILE__, __LINE__, msg); \
|
|
|
|
printf("\033[1;31m[CudaTools]\033[0m %s:%d\n | %s: " #a ".\n", __FILE__, __LINE__, msg); \
|
|
|
|
} |
|
|
|
} |
|
|
|
#else |
|
|
|
#else |
|
|
|
|
|
|
|
|
|
|
@ -239,14 +246,14 @@ |
|
|
|
std::ostringstream os_b; \
|
|
|
|
std::ostringstream os_b; \
|
|
|
|
os_a << a; \
|
|
|
|
os_a << a; \
|
|
|
|
os_b << b; \
|
|
|
|
os_b << b; \
|
|
|
|
printf("[ERROR] %s:%d\n | %s: (" #a ")%s " #op " (" #b ")%s.\n", __FILE__, __LINE__, msg, \
|
|
|
|
printf("\033[1;31m[CudaTools]\033[0m %s:%d\n | %s: (" #a ")%s " #op " (" #b ")%s.\n", \
|
|
|
|
os_a.str().c_str(), os_b.str().c_str()); \
|
|
|
|
__FILE__, __LINE__, msg, os_a.str().c_str(), os_b.str().c_str()); \
|
|
|
|
throw std::exception(); \
|
|
|
|
throw std::exception(); \
|
|
|
|
} |
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
#define CT_ERROR(a, msg) \ |
|
|
|
#define CT_ERROR(a, msg) \ |
|
|
|
if (a) { \
|
|
|
|
if (a) { \
|
|
|
|
printf("[ERROR] %s:%d\n | %s: " #a ".\n", __FILE__, __LINE__, msg); \
|
|
|
|
printf("\033[1;31m[CudaTools]\033[0m %s:%d\n | %s: " #a ".\n", __FILE__, __LINE__, msg); \
|
|
|
|
throw std::exception(); \
|
|
|
|
throw std::exception(); \
|
|
|
|
} |
|
|
|
} |
|
|
|
#endif |
|
|
|
#endif |
|
|
@ -259,7 +266,8 @@ |
|
|
|
do { \
|
|
|
|
do { \
|
|
|
|
cudaError_t err = (call); \
|
|
|
|
cudaError_t err = (call); \
|
|
|
|
if (err != cudaSuccess) { \
|
|
|
|
if (err != cudaSuccess) { \
|
|
|
|
printf("[CUDA] %s:%d\n | %s\n", __FILE__, __LINE__, cudaGetErrorString(err)); \
|
|
|
|
printf("\033[1;31m[CUDA]\033[0m %s:%d\n | %s\n", __FILE__, __LINE__, \
|
|
|
|
|
|
|
|
cudaGetErrorString(err)); \
|
|
|
|
throw std::exception(); \
|
|
|
|
throw std::exception(); \
|
|
|
|
} \
|
|
|
|
} \
|
|
|
|
} while (0) |
|
|
|
} while (0) |
|
|
@ -268,7 +276,8 @@ |
|
|
|
do { \
|
|
|
|
do { \
|
|
|
|
cublasStatus_t err = (call); \
|
|
|
|
cublasStatus_t err = (call); \
|
|
|
|
if (err != CUBLAS_STATUS_SUCCESS) { \
|
|
|
|
if (err != CUBLAS_STATUS_SUCCESS) { \
|
|
|
|
printf("[cuBLAS] %s:%d\n | %s\n", __FILE__, __LINE__, cublasGetStatusName(err)); \
|
|
|
|
printf("\033[1;31m[cuBLAS]\033[0m %s:%d\n | %s\n", __FILE__, __LINE__, \
|
|
|
|
|
|
|
|
cublasGetStatusName(err)); \
|
|
|
|
throw std::exception(); \
|
|
|
|
throw std::exception(); \
|
|
|
|
} \
|
|
|
|
} \
|
|
|
|
} while (0) |
|
|
|
} while (0) |
|
|
|