From a5069068e6fedf71a88da49790f5e703cac53eeb Mon Sep 17 00:00:00 2001
From: Samuel Thibault <samuel.thibault@inria.fr>
Date: Thu, 17 Sep 2015 12:47:28 +0000
Subject: [PATCH] Rename distributed_size/rank into comm_size/rank, and use
 RUNTIME_barrier instead of introducing RUNTIME_distributed_barrier

---
 control/control.c                        | 28 ++++++++++++++++--------
 control/descriptor.c                     |  6 ++---
 example/lapack_to_morse/step6.c          |  2 +-
 include/runtime.h                        |  5 ++---
 runtime/quark/control/runtime_control.c  | 12 ++--------
 runtime/starpu/control/runtime_control.c | 15 ++-----------
 timing/timing.c                          |  2 +-
 7 files changed, 30 insertions(+), 40 deletions(-)

diff --git a/control/control.c b/control/control.c
index 859b5eb24..0263c4eb6 100644
--- a/control/control.c
+++ b/control/control.c
@@ -143,7 +143,7 @@ int MORSE_Finalize(void)
     magma_finalize();
 #endif
     morse_context_destroy();
-    RUNTIME_distributed_barrier();
+    RUNTIME_barrier(morse);
 #if defined(CHAMELEON_USE_MPI)
     if (!morse->mpi_outer_init)
         MPI_Finalize();
@@ -213,7 +213,12 @@ int MORSE_Resume(void)
  *****************************************************************************/
 int MORSE_Distributed_start(void)
 {
-    RUNTIME_distributed_barrier ();
+    MORSE_context_t *morse = morse_context_self();
+    if (morse == NULL) {
+        morse_error("MORSE_Finalize()", "MORSE not initialized");
+        return MORSE_ERR_NOT_INITIALIZED;
+    }
+    RUNTIME_barrier (morse);
     return MORSE_SUCCESS;
 }
 
@@ -231,7 +236,12 @@ int MORSE_Distributed_start(void)
  *****************************************************************************/
 int MORSE_Distributed_stop(void)
 {
-    RUNTIME_distributed_barrier ();
+    MORSE_context_t *morse = morse_context_self();
+    if (morse == NULL) {
+        morse_error("MORSE_Finalize()", "MORSE not initialized");
+        return MORSE_ERR_NOT_INITIALIZED;
+    }
+    RUNTIME_barrier (morse);
     return MORSE_SUCCESS;
 }
 
@@ -239,7 +249,7 @@ int MORSE_Distributed_stop(void)
  *
  * @ingroup Control
  *
- *  MORSE_Distributed_size - Return the size of the distributed computation
+ *  MORSE_Comm_size - Return the size of the distributed computation
  *
  ******************************************************************************
  *
@@ -247,9 +257,9 @@ int MORSE_Distributed_stop(void)
  *          \retval MORSE_SUCCESS successful exit
  *
  *****************************************************************************/
-int MORSE_Distributed_size( int *size )
+int MORSE_Comm_size( int *size )
 {
-    RUNTIME_distributed_size (size);
+    RUNTIME_comm_size (size);
     return MORSE_SUCCESS;
 }
 
@@ -257,7 +267,7 @@ int MORSE_Distributed_size( int *size )
  *
  * @ingroup Control
  *
- *  MORSE_Distributed_rank - Return the rank of the distributed computation
+ *  MORSE_Comm_rank - Return the rank of the distributed computation
  *
  ******************************************************************************
  *
@@ -265,8 +275,8 @@ int MORSE_Distributed_size( int *size )
  *          \retval MORSE_SUCCESS successful exit
  *
  *****************************************************************************/
-int MORSE_Distributed_rank( int *rank )
+int MORSE_Comm_rank( int *rank )
 {
-    RUNTIME_distributed_rank (rank);
+    RUNTIME_comm_rank (rank);
     return MORSE_SUCCESS;
 }
diff --git a/control/descriptor.c b/control/descriptor.c
index 364b9220f..74a60b56f 100644
--- a/control/descriptor.c
+++ b/control/descriptor.c
@@ -77,7 +77,7 @@ MORSE_desc_t morse_desc_init(MORSE_enum dtyp, int mb, int nb, int bsiz,
     desc.alloc_mat = 1;
     desc.register_mat = 1;
 
-    RUNTIME_distributed_rank( &(desc.myrank) );
+    RUNTIME_comm_rank( &(desc.myrank) );
 
     // Grid size
     desc.p = p;
@@ -162,7 +162,7 @@ MORSE_desc_t morse_desc_init_diag(MORSE_enum dtyp, int mb, int nb, int bsiz,
     desc.alloc_mat = 1;
     desc.register_mat = 1;
 
-    RUNTIME_distributed_rank( &(desc.myrank) );
+    RUNTIME_comm_rank( &(desc.myrank) );
 
     // Grid size
     desc.p = p;
@@ -250,7 +250,7 @@ MORSE_desc_t morse_desc_init_user(MORSE_enum dtyp, int mb, int nb, int bsiz,
     desc.alloc_mat = 1;
     desc.register_mat = 1;
 
-    RUNTIME_distributed_rank( &(desc.myrank) );
+    RUNTIME_comm_rank( &(desc.myrank) );
 
     // Grid size
     desc.p = p;
diff --git a/example/lapack_to_morse/step6.c b/example/lapack_to_morse/step6.c
index 47fa54577..5723f4a72 100644
--- a/example/lapack_to_morse/step6.c
+++ b/example/lapack_to_morse/step6.c
@@ -110,7 +110,7 @@ int main(int argc, char *argv[]) {
     MORSE_Set(MORSE_INNER_BLOCK_SIZE, iparam[IPARAM_IB] );
 
 #if defined(CHAMELEON_USE_MPI)
-    MORSE_Distributed_size( &NMPIPROC );
+    MORSE_Comm_size( &NMPIPROC );
     /* Check P */
     if ( (iparam[IPARAM_P] > 1) &&
          (NMPIPROC % iparam[IPARAM_P] != 0) ) {
diff --git a/include/runtime.h b/include/runtime.h
index cd4db6e6f..3e56cf562 100644
--- a/include/runtime.h
+++ b/include/runtime.h
@@ -54,9 +54,8 @@ void  RUNTIME_finalize_scheduler (MORSE_context_t*);
 void  RUNTIME_barrier            (MORSE_context_t*);
 void  RUNTIME_pause              (MORSE_context_t*);
 void  RUNTIME_resume             (MORSE_context_t*);
-void  RUNTIME_distributed_rank   (int*);
-void  RUNTIME_distributed_size   (int*);
-void  RUNTIME_distributed_barrier(void);
+void  RUNTIME_comm_rank          (int*);
+void  RUNTIME_comm_size          (int*);
 
 /*******************************************************************************
  * RUNTIME Descriptor
diff --git a/runtime/quark/control/runtime_control.c b/runtime/quark/control/runtime_control.c
index dfacd18bd..2ca4d060c 100644
--- a/runtime/quark/control/runtime_control.c
+++ b/runtime/quark/control/runtime_control.c
@@ -90,7 +90,7 @@ void RUNTIME_resume( MORSE_context_t *morse )
 /*******************************************************************************
  *  This returns the rank of this process
  **/
-void RUNTIME_distributed_rank( int *rank )
+void RUNTIME_comm_rank( int *rank )
 {
     *rank = 0;
     return;
@@ -99,16 +99,8 @@ void RUNTIME_distributed_rank( int *rank )
 /*******************************************************************************
  *  This returns the size of the distributed computation
  **/
-void RUNTIME_distributed_size( int *size )
+void RUNTIME_comm_size( int *size )
 {
     *size = 1;
     return;
 }
-
-/*******************************************************************************
- *  Barrier between processes of the distributed computation
- **/
-void RUNTIME_distributed_barrier( void )
-{
-    return;
-}
diff --git a/runtime/starpu/control/runtime_control.c b/runtime/starpu/control/runtime_control.c
index 16a55300a..5cce2d738 100644
--- a/runtime/starpu/control/runtime_control.c
+++ b/runtime/starpu/control/runtime_control.c
@@ -184,7 +184,7 @@ void RUNTIME_resume( MORSE_context_t *morse )
 /*******************************************************************************
  *  This returns the rank of this process
  **/
-void RUNTIME_distributed_rank( int *rank )
+void RUNTIME_comm_rank( int *rank )
 {
 #if defined(CHAMELEON_USE_MPI)
 #  if defined(HAVE_STARPU_MPI_RANK)
@@ -201,7 +201,7 @@ void RUNTIME_distributed_rank( int *rank )
 /*******************************************************************************
  *  This returns the size of the distributed computation
  **/
-void RUNTIME_distributed_size( int *size )
+void RUNTIME_comm_size( int *size )
 {
 #if defined(CHAMELEON_USE_MPI)
 #  if defined(HAVE_STARPU_MPI_RANK)
@@ -214,14 +214,3 @@ void RUNTIME_distributed_size( int *size )
 #endif
     return;
 }
-
-/*******************************************************************************
- *  Barrier between processes of the distributed computation
- **/
-void RUNTIME_distributed_barrier( void )
-{
-#if defined(CHAMELEON_USE_MPI)
-    starpu_mpi_barrier(MPI_COMM_WORLD);
-#endif
-    return;
-}
diff --git a/timing/timing.c b/timing/timing.c
index c2a1b490e..ae12c4f70 100644
--- a/timing/timing.c
+++ b/timing/timing.c
@@ -622,7 +622,7 @@ main(int argc, char *argv[]) {
         MORSE_Enable(MORSE_ERRORS);
 
 #if defined(CHAMELEON_USE_MPI)
-    MORSE_Distributed_size( &nbnode );
+    MORSE_Comm_size( &nbnode );
     iparam[IPARAM_NMPI] = nbnode;
     /* Check P */
     if ( (iparam[IPARAM_P] > 1) &&
-- 
GitLab