From 68ff2104d6842c395274f59cc019aa61ddabbd00 Mon Sep 17 00:00:00 2001
From: Mathieu Faverge <mathieu.faverge@inria.fr>
Date: Fri, 14 Feb 2025 13:24:55 +0100
Subject: [PATCH] Add myrank field into the sequence structure

---
 control/async.c                        | 3 +++
 include/chameleon/runtime_struct.h     | 3 ++-
 runtime/starpu/control/runtime_async.c | 3 +--
 3 files changed, 6 insertions(+), 3 deletions(-)

diff --git a/control/async.c b/control/async.c
index d933e3817..d877bca7d 100644
--- a/control/async.c
+++ b/control/async.c
@@ -48,6 +48,9 @@ int chameleon_sequence_create(CHAM_context_t *chamctxt, RUNTIME_sequence_t **seq
         return CHAMELEON_ERR_OUT_OF_RESOURCES;
     }
 
+    (*sequence)->comm   = chamctxt->comm;
+    (*sequence)->myrank = RUNTIME_comm_rank( chamctxt );
+
     RUNTIME_sequence_create( chamctxt, *sequence );
 
     (*sequence)->status = CHAMELEON_SUCCESS;
diff --git a/include/chameleon/runtime_struct.h b/include/chameleon/runtime_struct.h
index cbedc48a1..d2122d083 100644
--- a/include/chameleon/runtime_struct.h
+++ b/include/chameleon/runtime_struct.h
@@ -84,9 +84,10 @@ typedef struct runtime_request_s {
  */
 typedef struct runtime_sequence_s {
     int                status;   /**< Return status registered by the tasks for the request     */
+    int                myrank;   /**< MPI Comm rank within the associated communicator          */
     RUNTIME_request_t *request;  /**< Pointer to the request that failed if any, NULL otherwise */
     void              *schedopt; /**< Specific runtime data pointer to handle the sequence      */
-    MPI_Comm           comm;     /**< MPI communicator                                         */
+    MPI_Comm           comm;     /**< MPI communicator                                          */
 } RUNTIME_sequence_t;
 
 /**
diff --git a/runtime/starpu/control/runtime_async.c b/runtime/starpu/control/runtime_async.c
index 790181977..848d0f7aa 100644
--- a/runtime/starpu/control/runtime_async.c
+++ b/runtime/starpu/control/runtime_async.c
@@ -24,11 +24,10 @@
 /**
  *  Create a sequence
  */
-int RUNTIME_sequence_create( CHAM_context_t  *chamctxt,
+int RUNTIME_sequence_create( CHAM_context_t     *chamctxt,
                              RUNTIME_sequence_t *sequence )
 {
     (void)chamctxt;
-    sequence->comm = chamctxt->comm;
     return CHAMELEON_SUCCESS;
 }
 
-- 
GitLab