From 40bc52b4b197328632ff7a23dda62f5394bce81e Mon Sep 17 00:00:00 2001
From: Mathieu Faverge <mathieu.faverge@inria.fr>
Date: Sat, 2 Mar 2019 08:47:17 -0800
Subject: [PATCH] Move the error about chameleon ncuda to the init function
 instead of doing it in timings

---
 control/control.c |  7 +++++++
 timing/timing.c   | 10 +---------
 2 files changed, 8 insertions(+), 9 deletions(-)

diff --git a/control/control.c b/control/control.c
index 08765ca2d..aafb2d268 100644
--- a/control/control.c
+++ b/control/control.c
@@ -103,6 +103,13 @@ int __chameleon_initpar(int ncpus, int ncudas, int nthreads_per_worker)
 #  endif
 #endif
 
+#if !defined(CHAMELEON_USE_CUDA)
+    if ( ncudas != 0 ) {
+        chameleon_warning("CHAMELEON_Init", "CHAMELEON_USE_CUDA is not defined, ncudas is forced to 0");
+        ncudas = 0;
+    }
+#endif
+
     RUNTIME_init( chamctxt, ncpus, ncudas, nthreads_per_worker );
 
 #if defined(CHAMELEON_USE_MPI)
diff --git a/timing/timing.c b/timing/timing.c
index 8ce10c992..771173b24 100644
--- a/timing/timing.c
+++ b/timing/timing.c
@@ -730,20 +730,12 @@ main(int argc, char *argv[]) {
     int stop  = 5000;
     int step  =  500;
     int iparam[IPARAM_SIZEOF];
+    int return_code;
 
     set_iparam_default(iparam);
 
     parse_arguments(&argc, &argv, iparam, &start, &stop, &step);
 
-#if !defined(CHAMELEON_USE_CUDA)
-    if (iparam[IPARAM_NCUDAS] != 0){
-        fprintf(stderr, "ERROR: CHAMELEON_USE_CUDA is not defined. "
-                "The number of CUDA devices must be set to 0 (--gpus=0).\n");
-        return EXIT_FAILURE;
-    }
-#endif
-    int return_code;
-
     /* Initialize CHAMELEON */
     CHAMELEON_Init( iparam[IPARAM_THRDNBR],
                     iparam[IPARAM_NCUDAS] );
-- 
GitLab