From 82dfc6fd30e0fc64f96b4180e5253c7ac51149c3 Mon Sep 17 00:00:00 2001
From: Mathieu Faverge <mathieu.faverge@inria.fr>
Date: Mon, 29 Apr 2024 11:18:45 +0200
Subject: [PATCH] starpu: Add an shm insert task macro and change the data
 conversion tasks to local tasks to avoid issue with tag registrations

---
 runtime/starpu/codelets/codelet_zgered.c     |  4 ++--
 runtime/starpu/codelets/codelet_zgerst.c     |  4 ++--
 runtime/starpu/include/chameleon_starpu.h.in | 10 +++++++++-
 3 files changed, 13 insertions(+), 5 deletions(-)

diff --git a/runtime/starpu/codelets/codelet_zgered.c b/runtime/starpu/codelets/codelet_zgered.c
index 3c5a5f767..11b002cea 100644
--- a/runtime/starpu/codelets/codelet_zgered.c
+++ b/runtime/starpu/codelets/codelet_zgered.c
@@ -75,7 +75,7 @@ void INSERT_TASK_zgered( const RUNTIME_option_t *options,
 #endif
             starpu_cham_tile_register( &handleAout, -1, tileA, ChamComplexHalf );
 
-            rt_starpu_insert_task(
+            rt_shm_starpu_insert_task(
                 &cl_dlag2h,
                 STARPU_VALUE,    &m,                 sizeof(int),
                 STARPU_VALUE,    &n,                 sizeof(int),
@@ -116,7 +116,7 @@ void INSERT_TASK_zgered( const RUNTIME_option_t *options,
 #endif
         starpu_cham_tile_register( &handleAout, -1, tileA, ChamComplexFloat );
 
-        rt_starpu_insert_task(
+        rt_shm_starpu_insert_task(
             &cl_zlag2c,
             STARPU_VALUE,    &m,                 sizeof(int),
             STARPU_VALUE,    &n,                 sizeof(int),
diff --git a/runtime/starpu/codelets/codelet_zgerst.c b/runtime/starpu/codelets/codelet_zgerst.c
index e74ca71f4..ba6b2bb83 100644
--- a/runtime/starpu/codelets/codelet_zgerst.c
+++ b/runtime/starpu/codelets/codelet_zgerst.c
@@ -67,7 +67,7 @@ void INSERT_TASK_zgerst( const RUNTIME_option_t *options,
                  "[%2d] Convert back the tile ( %d, %d ) from half precision\n",
                  A->myrank, Am, An );
 #endif
-        rt_starpu_insert_task(
+        rt_shm_starpu_insert_task(
             &cl_hlag2d,
             STARPU_VALUE,    &m,                 sizeof(int),
             STARPU_VALUE,    &n,                 sizeof(int),
@@ -89,7 +89,7 @@ void INSERT_TASK_zgerst( const RUNTIME_option_t *options,
                  "[%2d] Convert back the tile ( %d, %d ) from half precision\n",
                  A->myrank, Am, An );
 #endif
-        rt_starpu_insert_task(
+        rt_shm_starpu_insert_task(
             &cl_clag2z,
             STARPU_VALUE,    &m,                 sizeof(int),
             STARPU_VALUE,    &n,                 sizeof(int),
diff --git a/runtime/starpu/include/chameleon_starpu.h.in b/runtime/starpu/include/chameleon_starpu.h.in
index b795b4c79..41949dfbb 100644
--- a/runtime/starpu/include/chameleon_starpu.h.in
+++ b/runtime/starpu/include/chameleon_starpu.h.in
@@ -20,7 +20,7 @@
  * @author Loris Lucido
  * @author Terry Cojean
  * @author Matthieu Kuhn
- * @date 2024-03-16
+ * @date 2024-07-17
  *
  */
 #ifndef _chameleon_starpu_h_
@@ -149,6 +149,14 @@ void *RUNTIME_data_getaddr_withconversion( const RUNTIME_option_t *options,
 
 #endif
 
+#if defined(CHAMELEON_RUNTIME_SYNC)
+#define rt_shm_starpu_insert_task( _codelet_, ... )                         \
+    starpu_insert_task( (_codelet_), STARPU_TASK_SYNCHRONOUS, 1, ##__VA_ARGS__ )
+#else
+#define rt_shm_starpu_insert_task( _codelet_, ... )                         \
+    starpu_insert_task( (_codelet_), ##__VA_ARGS__ )
+#endif
+
 /*
  * Enable codelets names
  */
-- 
GitLab