cudssRepro/include/util.h

34 lines
1.8 KiB
C

#pragma once
/* ============================================================================
* Logging
* ============================================================================ */
#define LOG(fmt, ...) fprintf(stdout, "[cudss_test] " fmt "\n", ##__VA_ARGS__)
#define LOG_ERROR(fmt, ...) fprintf(stderr, "[cudss_test ERROR] " fmt "\n", ##__VA_ARGS__)
/* ============================================================================
* Error Checking Macros
* ============================================================================ */
#define CUDA_CHECK(call) \
do { \
cudaError_t err = (call); \
if (err != cudaSuccess) { \
LOG_ERROR("CUDA error at %s:%d - %s", __FILE__, __LINE__, \
cudaGetErrorString(err)); \
exit(EXIT_FAILURE); \
} \
} while (0)
#define CUDSS_CHECK(call) \
do { \
cudssStatus_t status = (call); \
if (status != CUDSS_STATUS_SUCCESS) { \
LOG_ERROR("cuDSS error at %s:%d - status %d", __FILE__, __LINE__, \
(int)status); \
exit(EXIT_FAILURE); \
} \
} while (0)