Fixed CUDA error with empty domains
authorBerk Hess <hess@kth.se>
Wed, 13 May 2015 19:54:38 +0000 (21:54 +0200)
committerBerk Hess <hess@kth.se>
Wed, 13 May 2015 19:54:38 +0000 (21:54 +0200)
Recent commit fc8a5624 introduced empty CUDA kernel calls when there
are empty domains. This seems not be allowed by CUDA (we get errors).
Fixed #1734. Refs #1721.

Change-Id: Ifd32a55c8d6756c93a0fcaba29983ae326abc569

src/mdlib/nbnxn_cuda/nbnxn_cuda.cu

index 11a1f43291f4142b98a0d8e898ae48781a363816..31be75dd604a559c0d4183df9f0c3b47cf41775c 100644 (file)
@@ -292,7 +292,8 @@ void nbnxn_cuda_launch_kernel(nbnxn_cuda_ptr_t cu_nb,
        we always call the local kernel, the local x+q copy and later (not in
        this function) the stream wait, local f copyback and the f buffer
        clearing. All these operations, except for the local interaction kernel,
-       are needed for the non-local interactions. */
+       are needed for the non-local interactions. The skip of the local kernel
+       call is taken care of later in this function. */
     if (iloc == eintNonlocal && plist->nsci == 0)
     {
         return;
@@ -343,6 +344,12 @@ void nbnxn_cuda_launch_kernel(nbnxn_cuda_ptr_t cu_nb,
         CU_RET_ERR(stat, "cudaEventRecord failed");
     }
 
+    if (plist->nsci == 0)
+    {
+        /* Don't launch an empty local kernel (not allowed with CUDA) */
+        return;
+    }
+
     /* beginning of timed nonbonded calculation section */
     if (bDoTime)
     {