From 972882360aac09b61db4808c52d057fd8d89bc42 Mon Sep 17 00:00:00 2001
From: Mathieu Faverge <mathieu.faverge@inria.fr>
Date: Mon, 29 May 2023 09:11:41 +0200
Subject: [PATCH] control: store the ncuda field in the options to know at
 insertion time if cuda kernels are enabled or not

---
 CMakeLists.txt                           | 4 ++--
 control/control.c                        | 5 +++--
 include/chameleon/runtime_struct.h       | 5 +++--
 runtime/starpu/control/runtime_options.c | 5 +++--
 4 files changed, 11 insertions(+), 8 deletions(-)

diff --git a/CMakeLists.txt b/CMakeLists.txt
index 796cb3fa2..27bb9597f 100644
--- a/CMakeLists.txt
+++ b/CMakeLists.txt
@@ -17,7 +17,7 @@
 #     Univ. of California Berkeley,
 #     Univ. of Colorado Denver.
 #
-# @version 1.2.0
+# @version 1.3.0
 #  @author Cedric Castagnede
 #  @author Emmanuel Agullo
 #  @author Mathieu Faverge
@@ -30,7 +30,7 @@
 #  @author Alycia Lisito
 #  @author Loris Lucido
 #  @author Nathan Précigout
-#  @date 2023-01-30
+#  @date 2023-07-04
 #
 ###
 cmake_minimum_required(VERSION 3.3)
diff --git a/control/control.c b/control/control.c
index 62762469f..3c9ba6a92 100644
--- a/control/control.c
+++ b/control/control.c
@@ -11,7 +11,7 @@
  *
  * @brief Chameleon control routines
  *
- * @version 1.2.0
+ * @version 1.3.0
  * @author Jakub Kurzak
  * @author Mathieu Faverge
  * @author Cedric Castagnede
@@ -20,7 +20,7 @@
  * @author Samuel Thibault
  * @author Philippe Swartvagher
  * @author Loris Lucido
- * @date 2023-01-30
+ * @date 2023-07-04
  *
  ***
  *
@@ -123,6 +123,7 @@ int __chameleon_initpar(int ncpus, int ngpus, int nthreads_per_worker)
     }
 #endif
 
+    chamctxt->ncudas = ngpus;
     return RUNTIME_init( chamctxt, ncpus, ngpus, nthreads_per_worker );
 }
 
diff --git a/include/chameleon/runtime_struct.h b/include/chameleon/runtime_struct.h
index 59a2ec3cc..4b1727825 100644
--- a/include/chameleon/runtime_struct.h
+++ b/include/chameleon/runtime_struct.h
@@ -11,13 +11,13 @@
  *
  * @brief Runtime structures
  *
- * @version 1.2.0
+ * @version 1.3.0
  * @author Cedric Augonnet
  * @author Mathieu Faverge
  * @author Cedric Castagnede
  * @author Florent Pruvost
  * @author Philippe Virouleau
- * @date 2022-02-22
+ * @date 2023-07-04
  *
  */
 #ifndef _chameleon_runtime_struct_h_
@@ -85,6 +85,7 @@ typedef struct runtime_option_s {
     int                 priority;  /**< Define the submitted task priority                       */
     int                 workerid;  /**< Define the prefered worker id to perform the tasks       */
     int                 forcesub;  /**< Force task submission if true                            */
+    int                 withcuda;  /**< Flag to know if cuda is enabled/disabled                 */
     size_t              ws_wsize;  /**< Define the worker workspace size                         */
     size_t              ws_hsize;  /**< Define the host workspace size for hybrid CPU/GPU kernel */
     void               *ws_worker; /**< Pointer to the worker workspace (structure)              */
diff --git a/runtime/starpu/control/runtime_options.c b/runtime/starpu/control/runtime_options.c
index 6ade7b962..c70f1aa74 100644
--- a/runtime/starpu/control/runtime_options.c
+++ b/runtime/starpu/control/runtime_options.c
@@ -11,12 +11,12 @@
  *
  * @brief Chameleon StarPU options routines
  *
- * @version 1.2.0
+ * @version 1.3.0
  * @author Cedric Augonnet
  * @author Mathieu Faverge
  * @author Cedric Castagnede
  * @author Florent Pruvost
- * @date 2022-02-22
+ * @date 2023-07-04
  *
  */
 #include "chameleon_starpu.h"
@@ -32,6 +32,7 @@ void RUNTIME_options_init( RUNTIME_option_t *options, CHAM_context_t *chamctxt,
     options->priority  = RUNTIME_PRIORITY_MIN;
     options->workerid  = (schedopt == NULL) ? -1 : schedopt->workerid;
     options->forcesub  = 0;
+    options->withcuda  = (chamctxt->ncudas > 0);
     options->ws_wsize  = 0;
     options->ws_hsize  = 0;
     options->ws_worker = NULL;
-- 
GitLab