issue error if GPU ID is provided with GPU acc. off
authorSzilard Pall <pszilard@cbr.su.se>
Mon, 17 Dec 2012 21:28:28 +0000 (22:28 +0100)
committerSzilard Pall <pszilard@cbr.su.se>
Tue, 18 Dec 2012 20:39:34 +0000 (21:39 +0100)
Manually setting the GPU IDs is an implicit "GPU on" request from the
user, so we need to fail if mdrun in compiled without GPU support.
Additionally, added hint to what content is expected in the GPU ID
string to the respective errors and changed an incorrect collective
fatal.

Change-Id: Iebce58c0626889d047eebebd8e4547d4f1e9ff26

src/gmxlib/gmx_detect_hardware.c

index 21e0c649b92a5c6e8c80c0580e68b7c3aea45c1f..e4fef1fe00021f3d7d061d016d0a5edd431b20ed 100644 (file)
@@ -63,6 +63,9 @@
  * ridiculous number. */
 static unsigned int max_gpu_ids_user = 64;
 
+static const char* invalid_gpuid_hint =
+    "A delimiter-free sequence of valid numeric IDs of available GPUs is expected.";
+
 /* FW decl. */
 void limit_num_gpus_used(gmx_hw_info_t *hwinfo, int count);
 
@@ -173,7 +176,8 @@ static void parse_gpu_id_plain_string(const char *idstr, int *nid, int *idlist)
     {
         if (idstr[i] < '0' || idstr[i] > '9')
         {
-            gmx_fatal(FARGS, "Invalid character in GPU ID string: '%c'\n", idstr[i]);
+            gmx_fatal(FARGS, "Invalid character in GPU ID string: '%c'\n%s\n",
+                      invalid_gpuid_hint, idstr[i]);
         }
         idlist[i] = idstr[i] - '0';
     }
@@ -492,10 +496,15 @@ void gmx_detect_hardware(FILE *fplog, gmx_hw_info_t *hwinfo,
     bGPUBin      = FALSE;
 #endif
 
-    /* Bail if binary is not compiled with GPU on */
+    /* Bail if binary is not compiled with GPU acceleration, but this is either
+     * explicitly (-nb gpu) or implicitly (gpu ID passed) requested. */
     if (bForceUseGPU && !bGPUBin)
     {
-        gmx_fatal_collective(FARGS, cr, NULL, "GPU acceleration requested, but %s was compiled without GPU support!", ShortProgram());
+        gmx_fatal(FARGS, "GPU acceleration requested, but %s was compiled without GPU support!", ShortProgram());
+    }
+    if (gpu_id != NULL && !bGPUBin)
+    {
+        gmx_fatal(FARGS, "GPU ID string set, but %s was compiled without GPU support!", ShortProgram());
     }
 
     /* run the detection if the binary was compiled with GPU support */
@@ -545,7 +554,7 @@ void gmx_detect_hardware(FILE *fplog, gmx_hw_info_t *hwinfo,
 
             if (nid == 0)
             {
-                gmx_fatal(FARGS, "Empty GPU ID string passed\n");
+                gmx_fatal(FARGS, "Empty GPU ID string encountered.\n%s\n", invalid_gpuid_hint);
             }
 
             res = check_select_cuda_gpus(checkres, &hwinfo->gpu_info, gpuid, nid);