From ad10f9be6aad831170e65a97030f70d4255f79e8 Mon Sep 17 00:00:00 2001
From: Mathieu Faverge <mathieu.faverge@inria.fr>
Date: Fri, 15 Mar 2024 10:07:52 +0100
Subject: [PATCH] ipiv: Rename ipiv_init and ipiv_reducek functions as
 INSERT_TASK  and make them match the INSERT_TASK API

---
 compute/pzgetrf.c                             |   8 +-
 include/chameleon/runtime.h                   |  19 ++-
 include/chameleon/tasks.h                     |   6 +-
 runtime/CMakeLists.txt                        |   4 +-
 ...{codelet_ipiv_to_perm.c => codelet_ipiv.c} |  22 ++-
 .../openmp/control/runtime_descriptor_ipiv.c  |  18 +--
 ...{codelet_ipiv_to_perm.c => codelet_ipiv.c} |  22 ++-
 .../parsec/control/runtime_descriptor_ipiv.c  |  18 +--
 ...{codelet_ipiv_to_perm.c => codelet_ipiv.c} |  22 ++-
 .../quark/control/runtime_descriptor_ipiv.c   |  18 +--
 runtime/starpu/codelets/codelet_ipiv.c        | 135 ++++++++++++++++++
 .../starpu/codelets/codelet_ipiv_to_perm.c    |  69 ---------
 .../starpu/control/runtime_descriptor_ipiv.c  |  67 +--------
 13 files changed, 218 insertions(+), 210 deletions(-)
 rename runtime/openmp/codelets/{codelet_ipiv_to_perm.c => codelet_ipiv.c} (68%)
 rename runtime/parsec/codelets/{codelet_ipiv_to_perm.c => codelet_ipiv.c} (79%)
 rename runtime/quark/codelets/{codelet_ipiv_to_perm.c => codelet_ipiv.c} (75%)
 create mode 100644 runtime/starpu/codelets/codelet_ipiv.c
 delete mode 100644 runtime/starpu/codelets/codelet_ipiv_to_perm.c

diff --git a/compute/pzgetrf.c b/compute/pzgetrf.c
index 108c4a201..64552d746 100644
--- a/compute/pzgetrf.c
+++ b/compute/pzgetrf.c
@@ -16,7 +16,7 @@
  * @author Mathieu Faverge
  * @author Emmanuel Agullo
  * @author Matthieu Kuhn
- * @date 2023-09-08
+ * @date 2024-03-16
  * @precisions normal z -> s d c
  *
  */
@@ -147,7 +147,7 @@ chameleon_pzgetrf_panel_facto_percol( struct chameleon_pzgetrf_s *ws,
 
         if ( h < minmn ) {
             /* Reduce globally (between MPI processes) */
-            RUNTIME_ipiv_reducek( options, ipiv, k, h );
+            INSERT_TASK_ipiv_reducek( options, ipiv, k, h );
         }
     }
 
@@ -208,7 +208,7 @@ chameleon_pzgetrf_panel_facto_blocked( struct chameleon_pzgetrf_s *ws,
             assert( j<= minmn );
             if ( j < minmn ) {
                 /* Reduce globally (between MPI processes) */
-                RUNTIME_ipiv_reducek( options, ipiv, k, j );
+                INSERT_TASK_ipiv_reducek( options, ipiv, k, j );
             }
         }
     }
@@ -400,7 +400,7 @@ void chameleon_pzgetrf( struct chameleon_pzgetrf_s *ws,
     if ( (ws->alg == ChamGetrfNoPivPerColumn) ||
          (ws->alg == ChamGetrfNoPiv ) )
     {
-        RUNTIME_ipiv_init( IPIV );
+        INSERT_TASK_ipiv_init( &options, IPIV );
     }
 
     RUNTIME_options_finalize( &options, chamctxt );
diff --git a/include/chameleon/runtime.h b/include/chameleon/runtime.h
index dfe7bb3d9..1ee2e2b0b 100644
--- a/include/chameleon/runtime.h
+++ b/include/chameleon/runtime.h
@@ -18,7 +18,7 @@
  * @author Samuel Thibault
  * @author Philippe Swartvagher
  * @author Matthieu Kuhn
- * @date 2023-08-31
+ * @date 2024-03-16
  *
  */
 #ifndef _chameleon_runtime_h_
@@ -707,9 +707,15 @@ void RUNTIME_sdisplay_oneprofile (cham_tasktype_t task);
 
 void RUNTIME_ipiv_create ( CHAM_ipiv_t *ipiv );
 void RUNTIME_ipiv_destroy( CHAM_ipiv_t *ipiv );
-void RUNTIME_ipiv_init   ( CHAM_ipiv_t *ipiv );
 void RUNTIME_ipiv_gather ( CHAM_ipiv_t *desc, int *ipiv, int node );
 
+void RUNTIME_ipiv_flushk( const RUNTIME_sequence_t *sequence,
+                          const CHAM_ipiv_t *ipiv, int m );
+void RUNTIME_ipiv_flush ( const CHAM_ipiv_t *ipiv,
+                          const RUNTIME_sequence_t *sequence );
+void RUNTIME_perm_flushk( const RUNTIME_sequence_t *sequence,
+                          const CHAM_ipiv_t *ipiv, int m );
+
 void *RUNTIME_ipiv_getaddr   ( const CHAM_ipiv_t *ipiv, int m );
 void *RUNTIME_nextpiv_getaddr( const CHAM_ipiv_t *ipiv, int m, int h );
 void *RUNTIME_prevpiv_getaddr( const CHAM_ipiv_t *ipiv, int m, int h );
@@ -726,15 +732,6 @@ RUNTIME_pivot_getaddr( CHAM_ipiv_t *ipiv, int m, int h ) {
     }
 }
 
-void RUNTIME_ipiv_flushk ( const RUNTIME_sequence_t *sequence,
-                           const CHAM_ipiv_t *ipiv, int m );
-void RUNTIME_ipiv_flush  ( const CHAM_ipiv_t *ipiv,
-                           const RUNTIME_sequence_t *sequence );
-void RUNTIME_ipiv_reducek( const RUNTIME_option_t *options,
-                           CHAM_ipiv_t *ws, int k, int h );
-void RUNTIME_perm_flushk( const RUNTIME_sequence_t *sequence,
-                          const CHAM_ipiv_t *ipiv, int m );
-
 /**
  * @}
  */
diff --git a/include/chameleon/tasks.h b/include/chameleon/tasks.h
index b17e6bc32..aa21e99d8 100644
--- a/include/chameleon/tasks.h
+++ b/include/chameleon/tasks.h
@@ -16,7 +16,7 @@
  * @author Cedric Augonnet
  * @author Florent Pruvost
  * @author Matthieu Kuhn
- * @date 2024-03-11
+ * @date 2024-03-16
  *
  */
 #ifndef _chameleon_tasks_h_
@@ -162,6 +162,10 @@ void INSERT_TASK_hgemm( const RUNTIME_option_t *options,
                                                   const CHAM_desc_t *B, int Bm, int Bn,
                         CHAMELEON_Real16_t beta,  const CHAM_desc_t *C, int Cm, int Cn );
 
+void INSERT_TASK_ipiv_init   ( const RUNTIME_option_t *options,
+                               CHAM_ipiv_t *ipiv );
+void INSERT_TASK_ipiv_reducek( const RUNTIME_option_t *options,
+                               CHAM_ipiv_t *ws, int k, int h );
 void INSERT_TASK_ipiv_to_perm( const RUNTIME_option_t *options,
                                int m0, int m, int k,
                                const CHAM_ipiv_t *ipivdesc, int ipivk );
diff --git a/runtime/CMakeLists.txt b/runtime/CMakeLists.txt
index fd220cc89..e83440339 100644
--- a/runtime/CMakeLists.txt
+++ b/runtime/CMakeLists.txt
@@ -24,7 +24,7 @@
 #  @author Florent Pruvost
 #  @author Philippe Virouleau
 #  @author Matthieu Kuhn
-#  @date 2023-09-11
+#  @date 2024-03-16
 #
 ###
 
@@ -126,7 +126,7 @@ set(CODELETS_ZSRC
 
 set(CODELETS_SRC
   codelets/codelet_map.c
-  codelets/codelet_ipiv_to_perm.c
+  codelets/codelet_ipiv.c
 )
 
 # Check for the subdirectories
diff --git a/runtime/openmp/codelets/codelet_ipiv_to_perm.c b/runtime/openmp/codelets/codelet_ipiv.c
similarity index 68%
rename from runtime/openmp/codelets/codelet_ipiv_to_perm.c
rename to runtime/openmp/codelets/codelet_ipiv.c
index 11233b976..d6386bb58 100644
--- a/runtime/openmp/codelets/codelet_ipiv_to_perm.c
+++ b/runtime/openmp/codelets/codelet_ipiv.c
@@ -1,6 +1,6 @@
 /**
  *
- * @file openmp/codelet_ipiv_to_perm.c
+ * @file openmp/codelet_ipiv.c
  *
  * @copyright 2012-2024 Bordeaux INP, CNRS (LaBRI UMR 5800), Inria,
  *                      Univ. Bordeaux. All rights reserved.
@@ -12,13 +12,31 @@
  * @version 1.3.0
  * @author Mathieu Faverge
  * @author Matthieu Kuhn
- * @date 2023-08-31
+ * @date 2024-03-16
  *
  */
 #include "chameleon_openmp.h"
 #include "chameleon/tasks.h"
 #include "coreblas.h"
 
+void INSERT_TASK_ipiv_init( const RUNTIME_option_t *options,
+                            CHAM_ipiv_t *ipiv )
+{
+    assert( 0 );
+    (void)options;
+    (void)ipiv;
+}
+
+void INSERT_TASK_ipiv_reducek( const RUNTIME_option_t *options,
+                               CHAM_ipiv_t *ipiv, int k, int h )
+{
+    assert( 0 );
+    (void)options;
+    (void)ipiv;
+    (void)k;
+    (void)h;
+}
+
 void INSERT_TASK_ipiv_to_perm( const RUNTIME_option_t *options,
                                int m0, int m, int k,
                                const CHAM_ipiv_t *ipivdesc, int ipivk )
diff --git a/runtime/openmp/control/runtime_descriptor_ipiv.c b/runtime/openmp/control/runtime_descriptor_ipiv.c
index 0743412c4..32b74e450 100644
--- a/runtime/openmp/control/runtime_descriptor_ipiv.c
+++ b/runtime/openmp/control/runtime_descriptor_ipiv.c
@@ -12,7 +12,7 @@
  * @version 1.3.0
  * @author Mathieu Faverge
  * @author Matthieu Kuhn
- * @date 2023-08-31
+ * @date 2024-03-16
  *
  */
 #include "chameleon_openmp.h"
@@ -97,22 +97,6 @@ void RUNTIME_perm_flushk( const RUNTIME_sequence_t *sequence,
     (void)m;
 }
 
-void RUNTIME_ipiv_reducek( const RUNTIME_option_t *options,
-                           CHAM_ipiv_t *ipiv, int k, int h )
-{
-    assert( 0 );
-    (void)options;
-    (void)ipiv;
-    (void)k;
-    (void)h;
-}
-
-void RUNTIME_ipiv_init( CHAM_ipiv_t *ipiv )
-{
-    assert( 0 );
-    (void)ipiv;
-}
-
 void RUNTIME_ipiv_gather( CHAM_ipiv_t *desc, int *ipiv, int node )
 {
     assert( 0 );
diff --git a/runtime/parsec/codelets/codelet_ipiv_to_perm.c b/runtime/parsec/codelets/codelet_ipiv.c
similarity index 79%
rename from runtime/parsec/codelets/codelet_ipiv_to_perm.c
rename to runtime/parsec/codelets/codelet_ipiv.c
index 275200c6e..b9ac7e054 100644
--- a/runtime/parsec/codelets/codelet_ipiv_to_perm.c
+++ b/runtime/parsec/codelets/codelet_ipiv.c
@@ -1,6 +1,6 @@
 /**
  *
- * @file parsec/codelet_ipiv_to_perm.c
+ * @file parsec/codelet_ipiv.c
  *
  * @copyright 2023-2024 Bordeaux INP, CNRS (LaBRI UMR 5800), Inria,
  *                      Univ. Bordeaux. All rights reserved.
@@ -12,13 +12,31 @@
  * @version 1.3.0
  * @author Mathieu Faverge
  * @author Matthieu Kuhn
- * @date 2023-08-31
+ * @date 2024-03-16
  *
  */
 #include "chameleon_parsec.h"
 #include "chameleon/tasks.h"
 #include "coreblas.h"
 
+void INSERT_TASK_ipiv_init( const RUNTIME_option_t *options,
+                            CHAM_ipiv_t *ipiv )
+{
+    assert( 0 );
+    (void)options;
+    (void)ipiv;
+}
+
+void INSERT_TASK_ipiv_reducek( const RUNTIME_option_t *options,
+                               CHAM_ipiv_t *ipiv, int k, int h )
+{
+    assert( 0 );
+    (void)options;
+    (void)ipiv;
+    (void)k;
+    (void)h;
+}
+
 static inline int
 CORE_ipiv_to_perm_parsec( parsec_execution_stream_t *context,
                           parsec_task_t             *this_task )
diff --git a/runtime/parsec/control/runtime_descriptor_ipiv.c b/runtime/parsec/control/runtime_descriptor_ipiv.c
index 970ad741c..b286df9d2 100644
--- a/runtime/parsec/control/runtime_descriptor_ipiv.c
+++ b/runtime/parsec/control/runtime_descriptor_ipiv.c
@@ -12,7 +12,7 @@
  * @version 1.3.0
  * @author Mathieu Faverge
  * @author Matthieu Kuhn
- * @date 2023-08-31
+ * @date 2024-03-16
  *
  */
 #include "chameleon_parsec.h"
@@ -97,22 +97,6 @@ void RUNTIME_perm_flushk( const RUNTIME_sequence_t *sequence,
     (void)m;
 }
 
-void RUNTIME_ipiv_reducek( const RUNTIME_option_t *options,
-                           CHAM_ipiv_t *ipiv, int k, int h )
-{
-    assert( 0 );
-    (void)options;
-    (void)ipiv;
-    (void)k;
-    (void)h;
-}
-
-void RUNTIME_ipiv_init( CHAM_ipiv_t *ipiv )
-{
-    assert( 0 );
-    (void)ipiv;
-}
-
 void RUNTIME_ipiv_gather( CHAM_ipiv_t *desc, int *ipiv, int node )
 {
     assert( 0 );
diff --git a/runtime/quark/codelets/codelet_ipiv_to_perm.c b/runtime/quark/codelets/codelet_ipiv.c
similarity index 75%
rename from runtime/quark/codelets/codelet_ipiv_to_perm.c
rename to runtime/quark/codelets/codelet_ipiv.c
index 361c58336..ab982faf0 100644
--- a/runtime/quark/codelets/codelet_ipiv_to_perm.c
+++ b/runtime/quark/codelets/codelet_ipiv.c
@@ -1,6 +1,6 @@
 /**
  *
- * @file quark/codelet_ipiv_to_perm.c
+ * @file quark/codelet_ipiv.c
  *
  * @copyright 2023-2024 Bordeaux INP, CNRS (LaBRI UMR 5800), Inria,
  *                      Univ. Bordeaux. All rights reserved.
@@ -12,13 +12,31 @@
  * @version 1.3.0
  * @author Mathieu Faverge
  * @author Matthieu Kuhn
- * @date 2023-08-31
+ * @date 2024-03-16
  *
  */
 #include "chameleon_quark.h"
 #include "chameleon/tasks.h"
 #include "coreblas.h"
 
+void INSERT_TASK_ipiv_init( const RUNTIME_option_t *options,
+                            CHAM_ipiv_t *ipiv )
+{
+    assert( 0 );
+    (void)options;
+    (void)ipiv;
+}
+
+void INSERT_TASK_ipiv_reducek( const RUNTIME_option_t *options,
+                               CHAM_ipiv_t *ipiv, int k, int h )
+{
+    assert( 0 );
+    (void)options;
+    (void)ipiv;
+    (void)k;
+    (void)h;
+}
+
 static inline void
 CORE_ipiv_to_perm_quark( Quark *quark )
 {
diff --git a/runtime/quark/control/runtime_descriptor_ipiv.c b/runtime/quark/control/runtime_descriptor_ipiv.c
index f3ea5a113..6d5208fa2 100644
--- a/runtime/quark/control/runtime_descriptor_ipiv.c
+++ b/runtime/quark/control/runtime_descriptor_ipiv.c
@@ -12,7 +12,7 @@
  * @version 1.3.0
  * @author Mathieu Faverge
  * @author Matthieu Kuhn
- * @date 2023-08-31
+ * @date 2024-03-16
  *
  */
 #include "chameleon_quark.h"
@@ -97,22 +97,6 @@ void RUNTIME_perm_flushk( const RUNTIME_sequence_t *sequence,
     (void)m;
 }
 
-void RUNTIME_ipiv_reducek( const RUNTIME_option_t *options,
-                           CHAM_ipiv_t *ipiv, int k, int h )
-{
-    assert( 0 );
-    (void)options;
-    (void)ipiv;
-    (void)k;
-    (void)h;
-}
-
-void RUNTIME_ipiv_init( CHAM_ipiv_t *ipiv )
-{
-    assert( 0 );
-    (void)ipiv;
-}
-
 void RUNTIME_ipiv_gather( CHAM_ipiv_t *desc, int *ipiv, int node )
 {
     assert( 0 );
diff --git a/runtime/starpu/codelets/codelet_ipiv.c b/runtime/starpu/codelets/codelet_ipiv.c
new file mode 100644
index 000000000..64e603139
--- /dev/null
+++ b/runtime/starpu/codelets/codelet_ipiv.c
@@ -0,0 +1,135 @@
+/**
+ *
+ * @file starpu/codelet_ipiv.c
+ *
+ * @copyright 2012-2024 Bordeaux INP, CNRS (LaBRI UMR 5800), Inria,
+ *                      Univ. Bordeaux. All rights reserved.
+ *
+ ***
+ *
+ * @brief Chameleon StarPU codelets to work with ipiv array
+ *
+ * @version 1.3.0
+ * @author Mathieu Faverge
+ * @author Matthieu Kuhn
+ * @date 2024-03-16
+ *
+ */
+#include "chameleon_starpu.h"
+#include "runtime_codelets.h"
+
+static void cl_ipiv_init_cpu_func(void *descr[], void *cl_arg)
+{
+    int *ipiv = (int *)STARPU_VECTOR_GET_PTR(descr[0]);
+
+#if !defined(CHAMELEON_SIMULATION)
+    {
+        int i, m0, n;
+        starpu_codelet_unpack_args( cl_arg, &m0, &n );
+
+        for( i=0; i<n; i++ ) {
+            ipiv[i] = m0 + i + 1;
+        }
+    }
+#endif
+}
+
+struct starpu_codelet cl_ipiv_init = {
+    .where     = STARPU_CPU,
+    .cpu_func  = cl_ipiv_init_cpu_func,
+    .nbuffers  = 1,
+};
+
+void INSERT_TASK_ipiv_init( const RUNTIME_option_t *options,
+                            CHAM_ipiv_t            *ipiv )
+{
+    int64_t mt = ipiv->mt;
+    int64_t mb = ipiv->mb;
+    int     m;
+
+    for (m = 0; m < mt; m++) {
+        starpu_data_handle_t ipiv_src = RUNTIME_ipiv_getaddr( ipiv, m );
+        int m0 = m * mb;
+        int n  = (m == (mt-1)) ? ipiv->m - m0 : mb;
+
+        rt_starpu_insert_task(
+            &cl_ipiv_init,
+            STARPU_VALUE, &m0, sizeof(int),
+            STARPU_VALUE, &n,  sizeof(int),
+            STARPU_W, ipiv_src,
+            0);
+    }
+}
+
+void INSERT_TASK_ipiv_reducek( const RUNTIME_option_t *options,
+                               CHAM_ipiv_t *ipiv, int k, int h )
+{
+    starpu_data_handle_t prevpiv = RUNTIME_pivot_getaddr( ipiv, k, h-1 );
+
+#if defined(HAVE_STARPU_MPI_REDUX) && defined(CHAMELEON_USE_MPI)
+#if !defined(HAVE_STARPU_MPI_REDUX_WRAPUP)
+    starpu_data_handle_t nextpiv = RUNTIME_pivot_getaddr( ipiv, k, h   );
+    if ( h < ipiv->n ) {
+        starpu_mpi_redux_data_prio_tree( options->sequence->comm, nextpiv,
+                                         options->priority, 2 /* Binary tree */ );
+    }
+#endif
+#endif
+
+    /* Invalidate the previous pivot structure for correct initialization in later reuse */
+    if ( h > 0 ) {
+        starpu_data_invalidate_submit( prevpiv );
+    }
+
+    (void)options;
+}
+
+#if !defined(CHAMELEON_SIMULATION)
+static void cl_ipiv_to_perm_cpu_func( void *descr[], void *cl_arg )
+{
+    int m0, m, k;
+    int *ipiv, *perm, *invp;
+
+    starpu_codelet_unpack_args( cl_arg, &m0, &m, &k );
+
+    ipiv = (int*)STARPU_VECTOR_GET_PTR(descr[0]);
+    perm = (int*)STARPU_VECTOR_GET_PTR(descr[1]);
+    invp = (int*)STARPU_VECTOR_GET_PTR(descr[2]);
+
+    CORE_ipiv_to_perm( m0, m, k, ipiv, perm, invp );
+}
+#endif /* !defined(CHAMELEON_SIMULATION) */
+
+/*
+* Codelet definition
+*/
+static struct starpu_codelet cl_ipiv_to_perm = {
+    .where        = STARPU_CPU,
+#if defined(CHAMELEON_SIMULATION)
+    .cpu_funcs[0] = (starpu_cpu_func_t)1,
+#else
+    .cpu_funcs[0] = cl_ipiv_to_perm_cpu_func,
+#endif
+    .nbuffers     = 3,
+    .model        = NULL,
+    .name         = "ipiv_to_perm"
+};
+
+void INSERT_TASK_ipiv_to_perm( const RUNTIME_option_t *options,
+                               int m0, int m, int k,
+                               const CHAM_ipiv_t *ipivdesc, int ipivk )
+{
+    struct starpu_codelet *codelet = &cl_ipiv_to_perm;
+
+    rt_starpu_insert_task(
+        codelet,
+        STARPU_VALUE,             &m0,  sizeof(int),
+        STARPU_VALUE,             &m,   sizeof(int),
+        STARPU_VALUE,             &k,   sizeof(int),
+        STARPU_R,                 RUNTIME_ipiv_getaddr( ipivdesc, ipivk ),
+        STARPU_W,                 RUNTIME_perm_getaddr( ipivdesc, ipivk ),
+        STARPU_W,                 RUNTIME_invp_getaddr( ipivdesc, ipivk ),
+        STARPU_PRIORITY,          options->priority,
+        STARPU_EXECUTE_ON_WORKER, options->workerid,
+        0 );
+}
diff --git a/runtime/starpu/codelets/codelet_ipiv_to_perm.c b/runtime/starpu/codelets/codelet_ipiv_to_perm.c
deleted file mode 100644
index f615e2304..000000000
--- a/runtime/starpu/codelets/codelet_ipiv_to_perm.c
+++ /dev/null
@@ -1,69 +0,0 @@
-/**
- *
- * @file starpu/codelet_ipiv_to_perm.c
- *
- * @copyright 2012-2024 Bordeaux INP, CNRS (LaBRI UMR 5800), Inria,
- *                      Univ. Bordeaux. All rights reserved.
- *
- ***
- *
- * @brief Chameleon StarPU codelets to convert pivot to permutations
- *
- * @version 1.3.0
- * @author Mathieu Faverge
- * @author Matthieu Kuhn
- * @date 2023-08-31
- *
- */
-#include "chameleon_starpu.h"
-#include "runtime_codelets.h"
-
-#if !defined(CHAMELEON_SIMULATION)
-static void cl_ipiv_to_perm_cpu_func( void *descr[], void *cl_arg )
-{
-    int m0, m, k;
-    int *ipiv, *perm, *invp;
-
-    starpu_codelet_unpack_args( cl_arg, &m0, &m, &k );
-
-    ipiv = (int*)STARPU_VECTOR_GET_PTR(descr[0]);
-    perm = (int*)STARPU_VECTOR_GET_PTR(descr[1]);
-    invp = (int*)STARPU_VECTOR_GET_PTR(descr[2]);
-
-    CORE_ipiv_to_perm( m0, m, k, ipiv, perm, invp );
-}
-#endif /* !defined(CHAMELEON_SIMULATION) */
-
-/*
-* Codelet definition
-*/
-static struct starpu_codelet cl_ipiv_to_perm = {
-    .where        = STARPU_CPU,
-#if defined(CHAMELEON_SIMULATION)
-    .cpu_funcs[0] = (starpu_cpu_func_t)1,
-#else
-    .cpu_funcs[0] = cl_ipiv_to_perm_cpu_func,
-#endif
-    .nbuffers     = 3,
-    .model        = NULL,
-    .name         = "ipiv_to_perm"
-};
-
-void INSERT_TASK_ipiv_to_perm( const RUNTIME_option_t *options,
-                               int m0, int m, int k,
-                               const CHAM_ipiv_t *ipivdesc, int ipivk )
-{
-    struct starpu_codelet *codelet = &cl_ipiv_to_perm;
-
-    rt_starpu_insert_task(
-        codelet,
-        STARPU_VALUE,             &m0,  sizeof(int),
-        STARPU_VALUE,             &m,   sizeof(int),
-        STARPU_VALUE,             &k,   sizeof(int),
-        STARPU_R,                 RUNTIME_ipiv_getaddr( ipivdesc, ipivk ),
-        STARPU_W,                 RUNTIME_perm_getaddr( ipivdesc, ipivk ),
-        STARPU_W,                 RUNTIME_invp_getaddr( ipivdesc, ipivk ),
-        STARPU_PRIORITY,          options->priority,
-        STARPU_EXECUTE_ON_WORKER, options->workerid,
-        0 );
-}
diff --git a/runtime/starpu/control/runtime_descriptor_ipiv.c b/runtime/starpu/control/runtime_descriptor_ipiv.c
index d3a3d82c5..ae4a6f24f 100644
--- a/runtime/starpu/control/runtime_descriptor_ipiv.c
+++ b/runtime/starpu/control/runtime_descriptor_ipiv.c
@@ -12,7 +12,7 @@
  * @version 1.3.0
  * @author Mathieu Faverge
  * @author Matthieu Kuhn
- * @date 2023-08-31
+ * @date 2024-03-16
  *
  */
 #include "chameleon_starpu.h"
@@ -298,71 +298,6 @@ void RUNTIME_perm_flushk( const RUNTIME_sequence_t *sequence,
     (void)m;
 }
 
-void RUNTIME_ipiv_reducek( const RUNTIME_option_t *options,
-                           CHAM_ipiv_t *ipiv, int k, int h )
-{
-    starpu_data_handle_t nextpiv = RUNTIME_pivot_getaddr( ipiv, k, h   );
-    starpu_data_handle_t prevpiv = RUNTIME_pivot_getaddr( ipiv, k, h-1 );
-
-#if defined(HAVE_STARPU_MPI_REDUX) && defined(CHAMELEON_USE_MPI)
-#if !defined(HAVE_STARPU_MPI_REDUX_WRAPUP)
-    if ( h < ipiv->n ) {
-        starpu_mpi_redux_data_prio_tree( MPI_COMM_WORLD, nextpiv,
-                                         options->priority, 2 /* Binary tree */ );
-    }
-#endif
-#endif
-
-    /* Invalidate the previous pivot structure for correct initialization in later reuse */
-    if ( h > 0 ) {
-        starpu_data_invalidate_submit( prevpiv );
-    }
-
-    (void)options;
-}
-
-static void cl_ipiv_init_cpu_func(void *descr[], void *cl_arg)
-{
-    int *ipiv = (int *)STARPU_VECTOR_GET_PTR(descr[0]);
-
-#if !defined(CHAMELEON_SIMULATION)
-    {
-        int i, m0, n;
-        starpu_codelet_unpack_args( cl_arg, &m0, &n );
-
-        for( i=0; i<n; i++ ) {
-            ipiv[i] = m0 + i + 1;
-        }
-    }
-#endif
-}
-
-struct starpu_codelet cl_ipiv_init = {
-    .where     = STARPU_CPU,
-    .cpu_func  = cl_ipiv_init_cpu_func,
-    .nbuffers  = 1,
-};
-
-void RUNTIME_ipiv_init( CHAM_ipiv_t *ipiv )
-{
-    int64_t mt = ipiv->mt;
-    int64_t mb = ipiv->mb;
-    int     m;
-
-    for (m = 0; m < mt; m++) {
-        starpu_data_handle_t ipiv_src = RUNTIME_ipiv_getaddr( ipiv, m );
-        int m0 = m * mb;
-        int n  = (m == (mt-1)) ? ipiv->m - m0 : mb;
-
-        rt_starpu_insert_task(
-            &cl_ipiv_init,
-            STARPU_VALUE, &m0, sizeof(int),
-            STARPU_VALUE, &n,  sizeof(int),
-            STARPU_W, ipiv_src,
-            0);
-    }
-}
-
 void RUNTIME_ipiv_gather( CHAM_ipiv_t *desc, int *ipiv, int node )
 {
     int64_t mt   = desc->mt;
-- 
GitLab