From 7eda7bbf268fbaa78c82a839f2876a0904d2fe07 Mon Sep 17 00:00:00 2001
From: Mathieu Faverge <mathieu.faverge@inria.fr>
Date: Tue, 4 Jul 2023 18:42:12 +0200
Subject: [PATCH] starpu/codelets: Use the new function to generate the codelet
 name in tracing

---
 runtime/starpu/codelets/codelet_zgemm.c  | 30 ++++++++----------------
 runtime/starpu/codelets/codelet_zhemm.c  | 28 ++++++++--------------
 runtime/starpu/codelets/codelet_zherk.c  | 13 ++++------
 runtime/starpu/codelets/codelet_zlauum.c | 10 +++-----
 runtime/starpu/codelets/codelet_zpotrf.c | 10 +++-----
 runtime/starpu/codelets/codelet_zsymm.c  | 26 ++++++++------------
 runtime/starpu/codelets/codelet_zsyrk.c  | 12 +++-------
 runtime/starpu/codelets/codelet_ztrmm.c  | 12 ++++------
 runtime/starpu/codelets/codelet_ztrsm.c  | 12 ++++------
 runtime/starpu/codelets/codelet_ztrtri.c |  9 ++-----
 10 files changed, 53 insertions(+), 109 deletions(-)

diff --git a/runtime/starpu/codelets/codelet_zgemm.c b/runtime/starpu/codelets/codelet_zgemm.c
index 20a54f2e1..cf9b4b168 100644
--- a/runtime/starpu/codelets/codelet_zgemm.c
+++ b/runtime/starpu/codelets/codelet_zgemm.c
@@ -188,16 +188,11 @@ void INSERT_TASK_zgemm_Astat( const RUNTIME_option_t *options,
         accessC = STARPU_RW;
     }
 
-#if defined(CHAMELEON_KERNELS_TRACE)
-    {
-        char *cl_fullname;
-        chameleon_asprintf( &cl_fullname, "%s( %s, %s, %s )", cl_name,
-                            A->get_blktile( A, Am, An )->name,
-                            B->get_blktile( B, Bm, Bn )->name,
-                            C->get_blktile( C, Cm, Cn )->name );
-        cl_name = cl_fullname;
-    }
-#endif
+    /* Refine name */
+    cl_name = chameleon_codelet_name( cl_name, 3,
+                                      A->get_blktile( A, Am, An ),
+                                      B->get_blktile( B, Bm, Bn ),
+                                      C->get_blktile( C, Cm, Cn ) );
 
     /* Insert the task */
     rt_starpu_insert_task(
@@ -264,16 +259,11 @@ void INSERT_TASK_zgemm( const RUNTIME_option_t *options,
     /* Reduce the C access if needed */
     accessC = ( beta == 0. ) ? STARPU_W : (STARPU_RW | ((beta == 1.) ? STARPU_COMMUTE : 0));
 
-#if defined(CHAMELEON_KERNELS_TRACE)
-    {
-        char *cl_fullname;
-        chameleon_asprintf( &cl_fullname, "%s( %s, %s, %s )", cl_name,
-                            A->get_blktile( A, Am, An )->name,
-                            B->get_blktile( B, Bm, Bn )->name,
-                            C->get_blktile( C, Cm, Cn )->name );
-        cl_name = cl_fullname;
-    }
-#endif
+    /* Refine name */
+    cl_name = chameleon_codelet_name( cl_name, 3,
+                                      A->get_blktile( A, Am, An ),
+                                      B->get_blktile( B, Bm, Bn ),
+                                      C->get_blktile( C, Cm, Cn ) );
 
     /* Insert the task */
     rt_starpu_insert_task(
diff --git a/runtime/starpu/codelets/codelet_zhemm.c b/runtime/starpu/codelets/codelet_zhemm.c
index e26260173..67fe91b28 100644
--- a/runtime/starpu/codelets/codelet_zhemm.c
+++ b/runtime/starpu/codelets/codelet_zhemm.c
@@ -180,16 +180,11 @@ void INSERT_TASK_zhemm_Astat( const RUNTIME_option_t *options,
         accessC = STARPU_RW;
     }
 
-#if defined(CHAMELEON_KERNELS_TRACE)
-    {
-        char *cl_fullname;
-        chameleon_asprintf( &cl_fullname, "%s( %s, %s, %s )", cl_name,
-                            A->get_blktile( A, Am, An )->name,
-                            B->get_blktile( B, Bm, Bn )->name,
-                            C->get_blktile( C, Cm, Cn )->name );
-        cl_name = cl_fullname;
-    }
-#endif
+    /* Refine name */
+    cl_name = chameleon_codelet_name( cl_name, 3,
+                                      A->get_blktile( A, Am, An ),
+                                      B->get_blktile( B, Bm, Bn ),
+                                      C->get_blktile( C, Cm, Cn ) );
 
     /* Insert the task */
     rt_starpu_insert_task(
@@ -255,14 +250,11 @@ void INSERT_TASK_zhemm( const RUNTIME_option_t *options,
     /* Reduce the C access if needed */
     accessC = ( beta == 0. ) ? STARPU_W : (STARPU_RW | ((beta == 1.) ? STARPU_COMMUTE : 0));
 
-#if defined(CHAMELEON_KERNELS_TRACE)
-    if ( clargs != NULL )
-    {
-        char *cl_fullname;
-        chameleon_asprintf( &cl_fullname, "%s( %s, %s, %s )", cl_name, A->get_blktile( A, Am, An )->name, B->get_blktile( B, Bm, Bn )->name, C->get_blktile( C, Cm, Cn )->name );
-        cl_name = cl_fullname;
-    }
-#endif
+    /* Refine name */
+    cl_name = chameleon_codelet_name( cl_name, 3,
+                                      A->get_blktile( A, Am, An ),
+                                      B->get_blktile( B, Bm, Bn ),
+                                      C->get_blktile( C, Cm, Cn ) );
 
     /* Insert the task */
     rt_starpu_insert_task(
diff --git a/runtime/starpu/codelets/codelet_zherk.c b/runtime/starpu/codelets/codelet_zherk.c
index 7d462c00f..c53607f9d 100644
--- a/runtime/starpu/codelets/codelet_zherk.c
+++ b/runtime/starpu/codelets/codelet_zherk.c
@@ -147,15 +147,10 @@ void INSERT_TASK_zherk( const RUNTIME_option_t *options,
     /* Reduce the C access if needed */
     accessC = ( beta == 0. ) ? STARPU_W : STARPU_RW;
 
-#if defined(CHAMELEON_KERNELS_TRACE)
-    {
-        char *cl_fullname;
-        chameleon_asprintf( &cl_fullname, "%s( %s, %s )", cl_name,
-                            A->get_blktile( A, Am, An )->name,
-                            C->get_blktile( C, Cm, Cn )->name );
-        cl_name = cl_fullname;
-    }
-#endif
+    /* Refine name */
+    cl_name = chameleon_codelet_name( cl_name, 2,
+                                      A->get_blktile( A, Am, An ),
+                                      C->get_blktile( C, Cm, Cn ) );
 
     /* Insert the task */
     rt_starpu_insert_task(
diff --git a/runtime/starpu/codelets/codelet_zlauum.c b/runtime/starpu/codelets/codelet_zlauum.c
index e2071f355..bc49ece66 100644
--- a/runtime/starpu/codelets/codelet_zlauum.c
+++ b/runtime/starpu/codelets/codelet_zlauum.c
@@ -74,13 +74,9 @@ void INSERT_TASK_zlauum( const RUNTIME_option_t *options,
     /* Callback fro profiling information */
     callback = options->profiling ? cl_zlauum_callback : NULL;
 
-#if defined(CHAMELEON_KERNELS_TRACE)
-    {
-        char *cl_fullname;
-        chameleon_asprintf( &cl_fullname, "%s( %s )", cl_name, A->get_blktile( A, Am, An )->name );
-        cl_name = cl_fullname;
-    }
-#endif
+    /* Refine name */
+    cl_name = chameleon_codelet_name( cl_name, 1,
+                                      A->get_blktile( A, Am, An ) );
 
     /* Insert the task */
     rt_starpu_insert_task(
diff --git a/runtime/starpu/codelets/codelet_zpotrf.c b/runtime/starpu/codelets/codelet_zpotrf.c
index ae7d91479..b8b18765d 100644
--- a/runtime/starpu/codelets/codelet_zpotrf.c
+++ b/runtime/starpu/codelets/codelet_zpotrf.c
@@ -91,13 +91,9 @@ void INSERT_TASK_zpotrf( const RUNTIME_option_t *options,
     /* Callback fro profiling information */
     callback = options->profiling ? cl_zpotrf_callback : NULL;
 
-#if defined(CHAMELEON_KERNELS_TRACE)
-    {
-        char *cl_fullname;
-        chameleon_asprintf( &cl_fullname, "%s( %s )", cl_name, A->get_blktile( A, Am, An )->name );
-        cl_name = cl_fullname;
-    }
-#endif
+    /* Refine name */
+    cl_name = chameleon_codelet_name( cl_name, 1,
+                                      A->get_blktile( A, Am, An ) );
 
     /* Insert the task */
     rt_starpu_insert_task(
diff --git a/runtime/starpu/codelets/codelet_zsymm.c b/runtime/starpu/codelets/codelet_zsymm.c
index 8420d6c8a..ed8dea80b 100644
--- a/runtime/starpu/codelets/codelet_zsymm.c
+++ b/runtime/starpu/codelets/codelet_zsymm.c
@@ -181,14 +181,11 @@ void INSERT_TASK_zsymm_Astat( const RUNTIME_option_t *options,
         accessC = STARPU_RW;
     }
 
-#if defined(CHAMELEON_KERNELS_TRACE)
-    if ( clargs != NULL )
-    {
-        char *cl_fullname;
-        chameleon_asprintf( &cl_fullname, "%s( %s, %s, %s )", cl_name, A->get_blktile( A, Am, An )->name, B->get_blktile( B, Bm, Bn )->name, C->get_blktile( C, Cm, Cn )->name );
-        cl_name = cl_fullname;
-    }
-#endif
+    /* Refine name */
+    cl_name = chameleon_codelet_name( cl_name, 3,
+                                      A->get_blktile( A, Am, An ),
+                                      B->get_blktile( B, Bm, Bn ),
+                                      C->get_blktile( C, Cm, Cn ) );
 
     /* Insert the task */
     rt_starpu_insert_task(
@@ -254,14 +251,11 @@ void INSERT_TASK_zsymm( const RUNTIME_option_t *options,
     /* Reduce the C access if needed */
     accessC = ( beta == 0. ) ? STARPU_W : (STARPU_RW | ((beta == 1.) ? STARPU_COMMUTE : 0));
 
-#if defined(CHAMELEON_KERNELS_TRACE)
-    if ( clargs != NULL )
-    {
-        char *cl_fullname;
-        chameleon_asprintf( &cl_fullname, "%s( %s, %s, %s )", cl_name, A->get_blktile( A, Am, An )->name, B->get_blktile( B, Bm, Bn )->name, C->get_blktile( C, Cm, Cn )->name );
-        cl_name = cl_fullname;
-    }
-#endif
+    /* Refine name */
+    cl_name = chameleon_codelet_name( cl_name, 3,
+                                      A->get_blktile( A, Am, An ),
+                                      B->get_blktile( B, Bm, Bn ),
+                                      C->get_blktile( C, Cm, Cn ) );
 
     /* Insert the task */
     rt_starpu_insert_task(
diff --git a/runtime/starpu/codelets/codelet_zsyrk.c b/runtime/starpu/codelets/codelet_zsyrk.c
index fb2dde975..f11dd4158 100644
--- a/runtime/starpu/codelets/codelet_zsyrk.c
+++ b/runtime/starpu/codelets/codelet_zsyrk.c
@@ -148,15 +148,9 @@ void INSERT_TASK_zsyrk( const RUNTIME_option_t *options,
     /* Reduce the C access if needed */
     accessC = ( beta == 0. ) ? STARPU_W : STARPU_RW;
 
-#if defined(CHAMELEON_KERNELS_TRACE)
-    {
-        char *cl_fullname;
-        chameleon_asprintf( &cl_fullname, "%s( %s, %s )", cl_name,
-                            A->get_blktile( A, Am, An )->name,
-                            C->get_blktile( C, Cm, Cn )->name );
-        cl_name = cl_fullname;
-    }
-#endif
+    cl_name = chameleon_codelet_name( cl_name, 2,
+                                      A->get_blktile( A, Am, An ),
+                                      C->get_blktile( C, Cm, Cn ) );
 
     /* Insert the task */
     rt_starpu_insert_task(
diff --git a/runtime/starpu/codelets/codelet_ztrmm.c b/runtime/starpu/codelets/codelet_ztrmm.c
index 00b029c8a..36b31640c 100644
--- a/runtime/starpu/codelets/codelet_ztrmm.c
+++ b/runtime/starpu/codelets/codelet_ztrmm.c
@@ -138,14 +138,10 @@ void INSERT_TASK_ztrmm( const RUNTIME_option_t *options,
     /* Callback fro profiling information */
     callback = options->profiling ? cl_ztrmm_callback : NULL;
 
-#if defined(CHAMELEON_KERNELS_TRACE)
-    if ( clargs != NULL )
-    {
-        char *cl_fullname;
-        chameleon_asprintf( &cl_fullname, "%s( %s, %s )", cl_name, A->get_blktile( A, Am, An )->name, B->get_blktile( B, Bm, Bn )->name );
-        cl_name = cl_fullname;
-    }
-#endif
+    /* Refine name */
+    cl_name = chameleon_codelet_name( cl_name, 2,
+                                      A->get_blktile( A, Am, An ),
+                                      B->get_blktile( B, Bm, Bn ) );
 
     /* Insert the task */
     rt_starpu_insert_task(
diff --git a/runtime/starpu/codelets/codelet_ztrsm.c b/runtime/starpu/codelets/codelet_ztrsm.c
index eccb112d3..901eeb780 100644
--- a/runtime/starpu/codelets/codelet_ztrsm.c
+++ b/runtime/starpu/codelets/codelet_ztrsm.c
@@ -142,14 +142,10 @@ void INSERT_TASK_ztrsm( const RUNTIME_option_t *options,
     /* Callback fro profiling information */
     callback = options->profiling ? cl_ztrsm_callback : NULL;
 
-#if defined(CHAMELEON_KERNELS_TRACE)
-    if ( clargs != NULL )
-    {
-        char *cl_fullname;
-        chameleon_asprintf( &cl_fullname, "%s( %s, %s )", cl_name, A->get_blktile( A, Am, An )->name, B->get_blktile( B, Bm, Bn )->name );
-        cl_name = cl_fullname;
-    }
-#endif
+    /* Refine name */
+    cl_name = chameleon_codelet_name( cl_name, 2,
+                                      A->get_blktile( A, Am, An ),
+                                      B->get_blktile( B, Bm, Bn ) );
 
     /* Insert the task */
     rt_starpu_insert_task(
diff --git a/runtime/starpu/codelets/codelet_ztrtri.c b/runtime/starpu/codelets/codelet_ztrtri.c
index 98618b0ca..19499f058 100644
--- a/runtime/starpu/codelets/codelet_ztrtri.c
+++ b/runtime/starpu/codelets/codelet_ztrtri.c
@@ -88,13 +88,8 @@ void INSERT_TASK_ztrtri( const RUNTIME_option_t *options,
     /* Callback fro profiling information */
     callback = options->profiling ? cl_ztrtri_callback : NULL;
 
-#if defined(CHAMELEON_KERNELS_TRACE)
-    {
-        char *cl_fullname;
-        chameleon_asprintf( &cl_fullname, "%s( %s )", cl_name, A->get_blktile( A, Am, An )->name );
-        cl_name = cl_fullname;
-    }
-#endif
+    /* Refine name */
+    cl_name = chameleon_codelet_name( cl_name, 1, A->get_blktile( A, Am, An ) );
 
     /* Insert the task */
     rt_starpu_insert_task(
-- 
GitLab