From 17e32254f13af6a74856122acc13582df1776147 Mon Sep 17 00:00:00 2001
From: Mathieu Faverge <mathieu.faverge@inria.fr>
Date: Fri, 4 Feb 2022 16:53:48 +0100
Subject: [PATCH] options: add the workerid and node fields to the options to
 defibetter map the tasks

---
 include/chameleon/runtime_struct.h       |  1 +
 runtime/openmp/control/runtime_options.c | 21 +++++++++++----------
 runtime/parsec/control/runtime_options.c |  1 +
 runtime/quark/control/runtime_options.c  |  1 +
 runtime/starpu/control/runtime_options.c | 22 ++++++++++++----------
 5 files changed, 26 insertions(+), 20 deletions(-)

diff --git a/include/chameleon/runtime_struct.h b/include/chameleon/runtime_struct.h
index ad70f0536..a5ca6e027 100644
--- a/include/chameleon/runtime_struct.h
+++ b/include/chameleon/runtime_struct.h
@@ -83,6 +83,7 @@ typedef struct runtime_option_s {
     int                 profiling; /**< Enable/Disable the profiling of the submitted tasks      */
     int                 parallel;  /**< Enable/Disable the parallel version of submitted tasks   */
     int                 priority;  /**< Define the submitted task priority                       */
+    int                 workerid;  /**< Define the prefered worker id to perform the tasks       */
     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/openmp/control/runtime_options.c b/runtime/openmp/control/runtime_options.c
index 04aaca357..ecda9a1b4 100644
--- a/runtime/openmp/control/runtime_options.c
+++ b/runtime/openmp/control/runtime_options.c
@@ -21,18 +21,19 @@
  */
 #include "chameleon_openmp.h"
 
-void RUNTIME_options_init( RUNTIME_option_t *option, CHAM_context_t *chamctxt,
+void RUNTIME_options_init( RUNTIME_option_t *options, CHAM_context_t *chamctxt,
                            RUNTIME_sequence_t *sequence, RUNTIME_request_t *request )
 {
-    option->sequence  = sequence;
-    option->request   = request;
-    option->profiling = CHAMELEON_PROFILING == CHAMELEON_TRUE;
-    option->parallel  = CHAMELEON_PARALLEL == CHAMELEON_TRUE;
-    option->priority  = RUNTIME_PRIORITY_MIN;
-    option->ws_wsize  = 0;
-    option->ws_hsize  = 0;
-    option->ws_worker = NULL;
-    option->ws_host   = NULL;
+    options->sequence  = sequence;
+    options->request   = request;
+    options->profiling = CHAMELEON_PROFILING == CHAMELEON_TRUE;
+    options->parallel  = CHAMELEON_PARALLEL == CHAMELEON_TRUE;
+    options->priority  = RUNTIME_PRIORITY_MIN;
+    options->workerid  = -1;
+    options->ws_wsize  = 0;
+    options->ws_hsize  = 0;
+    options->ws_worker = NULL;
+    options->ws_host   = NULL;
     return;
 }
 
diff --git a/runtime/parsec/control/runtime_options.c b/runtime/parsec/control/runtime_options.c
index e851318b2..0c56ead88 100644
--- a/runtime/parsec/control/runtime_options.c
+++ b/runtime/parsec/control/runtime_options.c
@@ -27,6 +27,7 @@ void RUNTIME_options_init( RUNTIME_option_t *options, CHAM_context_t *chamctxt,
     options->profiling  = CHAMELEON_PROFILING == CHAMELEON_TRUE;
     options->parallel   = CHAMELEON_PARALLEL == CHAMELEON_TRUE;
     options->priority   = RUNTIME_PRIORITY_MIN;
+    options->workerid  = -1;
     options->ws_wsize   = 0;
     options->ws_hsize   = 0;
     options->ws_worker  = NULL;
diff --git a/runtime/quark/control/runtime_options.c b/runtime/quark/control/runtime_options.c
index bab33ac07..c0b2bbb2b 100644
--- a/runtime/quark/control/runtime_options.c
+++ b/runtime/quark/control/runtime_options.c
@@ -39,6 +39,7 @@ void RUNTIME_options_init( RUNTIME_option_t *options, CHAM_context_t *chamctxt,
     options->profiling  = CHAMELEON_PROFILING == CHAMELEON_TRUE;
     options->parallel   = CHAMELEON_PARALLEL == CHAMELEON_TRUE;
     options->priority   = RUNTIME_PRIORITY_MIN;
+    options->workerid   = -1;
 
     options->ws_wsize   = 0;
     options->ws_hsize   = 0;
diff --git a/runtime/starpu/control/runtime_options.c b/runtime/starpu/control/runtime_options.c
index 6687984b2..d95cbf865 100644
--- a/runtime/starpu/control/runtime_options.c
+++ b/runtime/starpu/control/runtime_options.c
@@ -21,18 +21,20 @@
  */
 #include "chameleon_starpu.h"
 
-void RUNTIME_options_init( RUNTIME_option_t *option, CHAM_context_t *chamctxt,
+void RUNTIME_options_init( RUNTIME_option_t *options, CHAM_context_t *chamctxt,
                            RUNTIME_sequence_t *sequence, RUNTIME_request_t *request )
 {
-    option->sequence   = sequence;
-    option->request    = request;
-    option->profiling  = CHAMELEON_PROFILING == CHAMELEON_TRUE;
-    option->parallel   = CHAMELEON_PARALLEL == CHAMELEON_TRUE;
-    option->priority   = RUNTIME_PRIORITY_MIN;
-    option->ws_wsize   = 0;
-    option->ws_hsize   = 0;
-    option->ws_worker  = NULL;
-    option->ws_host    = NULL;
+    starpu_option_request_t* schedopt = (starpu_option_request_t *)(request->schedopt);
+    options->sequence  = sequence;
+    options->request   = request;
+    options->profiling = CHAMELEON_PROFILING == CHAMELEON_TRUE;
+    options->parallel  = CHAMELEON_PARALLEL == CHAMELEON_TRUE;
+    options->priority  = RUNTIME_PRIORITY_MIN;
+    options->workerid  = (schedopt == NULL) ? -1 : schedopt->workerid;
+    options->ws_wsize  = 0;
+    options->ws_hsize  = 0;
+    options->ws_worker = NULL;
+    options->ws_host   = NULL;
     return;
 }
 
-- 
GitLab