// // Created by ubuntu on 11/3/21. // #ifndef DGTD_DEBUG_HPP #define DGTD_DEBUG_HPP #include #include #include #include #include "string" #include "iostream" #include "Constants.h" void DEBUG_INFO(std::string info); void MEM_USAGE(); void COMPARE_MATRICES(float* data_d2h, float* data, int h, int w, std::string message); void COMPARE_MATRICES(double* data_d2h, double* data, int h, int w, std::string message); void SYSTEM_MEM_USAGE(); void SYSTEM_VIDEO_MEM_USAGE(); #if defined(DGTD_USE_OPENCL) || defined(DGTD_USE_CUDA_OPENCL) #include std::string getErrorString(cl_int error); #define CL_CHECK(RET) \ if(RET != CL_SUCCESS) { \ std::cerr << "OpenCL error " << getErrorString(RET) << " on line " << __LINE__ << std::endl; \ assert(false); \ } #endif #if defined (DGTD_USE_CUDA) || defined(DGTD_USE_CUDA_OPENCL) #define CH_CUDA_SAFE_CALL( call) { \ cudaError err = call; \ if( cudaSuccess != err) { \ fprintf(stderr, "Cuda error in file '%s' in line %i : %s.\n", \ __FILE__, __LINE__, cudaGetErrorString( err) ); \ exit(EXIT_FAILURE); \ } \ } #define CUDA_SAFE_CALL(call) CH_CUDA_SAFE_CALL(call) #endif #if defined (DGTD_USE_CUDA) || defined(DGTD_USE_CUDA_OPENCL) void CUDA_MEM_USAGE(); #endif #endif //DGTD_DEBUG_HPP