Improve CUDA error checking 92/4392/2
authorDavid <dhardy@ks.uiuc.edu>
Tue, 24 Jul 2018 17:32:07 +0000 (12:32 -0500)
committerDavid Hardy <dhardy@ks.uiuc.edu>
Tue, 24 Jul 2018 17:41:01 +0000 (12:41 -0500)
Modify cudaCheck() macro to also print line number where error occurs.

Change-Id: I84a6e7afe64c23691d2c15bfdc0ffcc8b034152a

src/CudaUtils.h

index bd2c7be..dcdf093 100644 (file)
@@ -79,8 +79,8 @@ void cudaNAMD_bug(const char *msg);
 #define cudaCheck(stmt) do {                                 \
        cudaError_t err = stmt;                            \
   if (err != cudaSuccess) {                          \
-       char msg[128];  \
-         sprintf(msg, "%s in file %s, function %s\n", #stmt,__FILE__,__FUNCTION__); \
+       char msg[256];  \
+         sprintf(msg, "%s in file %s, function %s, line %d\n", #stmt,__FILE__,__FUNCTION__,__LINE__); \
          cudaDie(msg, err); \
   }                                                  \
 } while(0)