Skip to content
GitLab
Menu
Projects
Groups
Snippets
Help
Help
Support
Community forum
Keyboard shortcuts
?
Submit feedback
Contribute to GitLab
Sign in
Toggle navigation
Menu
Open sidebar
MPIBP-Hummer
BioEM
Commits
8bd9be43
Commit
8bd9be43
authored
Jun 23, 2017
by
Luka Stanisic
Browse files
cleaner way to handle CUDA errors
parent
c3c5062f
Changes
1
Hide whitespace changes
Inline
Side-by-side
bioem_cuda.cu
View file @
8bd9be43
...
...
@@ -69,16 +69,11 @@ static const char *cufftGetErrorStrung(cufftResult error)
/* Handing CUDA Driver errors */
// Expand and stringify argument
#define STRINGx(x) #x
#define STRING(x) STRINGx(x)
#define CU_ERROR_CHECK(call) \
#define cuErrorCheck(call) \
do { \
CUresult __error__; \
if ((__error__ = (call)) != CUDA_SUCCESS) { \
printf(STRING(call), __func__, __FILE__, __LINE__, __error__, \
(const char * (*)(int))cuGetError); \
printf("CUDA Driver Error %d / %s (%s %d)\n", __error__, cuGetError(__error__),__FILE__, __LINE__); \
return __error__; \
} \
} while (false)
...
...
@@ -412,13 +407,13 @@ int bioem_cuda::selectCudaDevice()
#else
unsigned
int
free
,
total
;
#endif
CU_ERROR_CHECK
(
cuInit
(
0
));
cuErrorCheck
(
cuInit
(
0
));
CUdevice
tmpDevice
;
CU_ERROR_CHECK
(
cuDeviceGet
(
&
tmpDevice
,
i
));
cuErrorCheck
(
cuDeviceGet
(
&
tmpDevice
,
i
));
CUcontext
tmpContext
;
CU_ERROR_CHECK
(
cuCtxCreate
(
&
tmpContext
,
0
,
tmpDevice
));
cuErrorCheck
(
cuCtxCreate
(
&
tmpContext
,
0
,
tmpDevice
));
if
(
cuMemGetInfo
(
&
free
,
&
total
))
exit
(
1
);
CU_ERROR_CHECK
(
cuCtxDestroy
(
tmpContext
));
cuErrorCheck
(
cuCtxDestroy
(
tmpContext
));
checkCudaErrors
(
cudaGetDeviceProperties
(
&
deviceProp
,
i
));
if
(
DebugOutput
>=
2
&&
mpi_rank
==
0
)
printf
(
"CUDA Device %2d: %s (Rev: %d.%d - Mem Avail %lld / %lld)
\n
"
,
i
,
deviceProp
.
name
,
deviceProp
.
major
,
deviceProp
.
minor
,
(
long
long
int
)
free
,
(
long
long
int
)
deviceProp
.
totalGlobalMem
);
...
...
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
.
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment