From a3481c8e95c8fc47833422c970350a318a2b8495 Mon Sep 17 00:00:00 2001
From: Samuel Thibault <samuel.thibault@ens-lyon.org>
Date: Fri, 3 Mar 2017 17:59:02 +0100
Subject: [PATCH] Rather use iteration_push/pop

---
 CMakeLists.txt                           |  8 +++---
 compute/pzgelqf.c                        |  4 ++-
 compute/pzgelqfrh.c                      |  4 ++-
 compute/pzgeqrf.c                        |  4 ++-
 compute/pzgeqrfrh.c                      |  4 ++-
 compute/pzgetrf_incpiv.c                 |  4 ++-
 compute/pzgetrf_nopiv.c                  |  4 ++-
 compute/pzhetrd_he2hb.c                  |  8 ++++--
 compute/pzpotrf.c                        |  7 ++++--
 compute/pzpotrimm.c                      | 32 ++++++++++++++++++------
 compute/pzsytrf.c                        |  8 ++++--
 compute/pztpgqrt.c                       |  4 ++-
 compute/pztpqrt.c                        |  4 ++-
 compute/pztrtri.c                        |  8 ++++--
 compute/pzunglq.c                        |  4 ++-
 compute/pzunglqrh.c                      |  4 ++-
 compute/pzungqr.c                        |  4 ++-
 compute/pzungqrrh.c                      |  4 ++-
 compute/pzunmlq.c                        | 16 +++++++++---
 compute/pzunmlqrh.c                      | 16 +++++++++---
 compute/pzunmqr.c                        | 16 +++++++++---
 compute/pzunmqrrh.c                      | 16 +++++++++---
 control/config.h.in                      |  2 +-
 include/runtime.h                        |  4 +--
 runtime/parsec/control/runtime_control.c |  4 +--
 runtime/quark/control/runtime_control.c  |  4 +--
 runtime/starpu/control/runtime_control.c | 12 ++++-----
 27 files changed, 148 insertions(+), 61 deletions(-)

diff --git a/CMakeLists.txt b/CMakeLists.txt
index 38788dd4c..b7f5f8383 100644
--- a/CMakeLists.txt
+++ b/CMakeLists.txt
@@ -706,10 +706,10 @@ if( CHAMELEON_SCHED_STARPU )
             set(HAVE_STARPU_IDLE_PREFETCH 1)
             message("-- ${Blue}Add definition HAVE_STARPU_IDLE_PREFETCH${ColourReset}")
         endif()
-        check_function_exists(starpu_set_iteration STARPU_SET_ITERATION_FOUND)
-        if ( STARPU_SET_ITERATION_FOUND )
-            set(HAVE_STARPU_SET_ITERATION 1)
-            message("-- ${Blue}Add definition HAVE_STARPU_SET_ITERATION${ColourReset}")
+        check_function_exists(starpu_iteration_push STARPU_ITERATION_PUSH_FOUND)
+        if ( STARPU_ITERATION_PUSH_FOUND )
+            set(HAVE_STARPU_ITERATION_PUSH 1)
+            message("-- ${Blue}Add definition HAVE_STARPU_ITERATION_PUSH${ColourReset}")
         endif()
         check_function_exists(starpu_data_wont_use STARPU_DATA_WONT_USE_FOUND)
         if ( STARPU_DATA_WONT_USE_FOUND )
diff --git a/compute/pzgelqf.c b/compute/pzgelqf.c
index 8a49e0627..712ded8af 100644
--- a/compute/pzgelqf.c
+++ b/compute/pzgelqf.c
@@ -115,7 +115,7 @@ void morse_pzgelqf(MORSE_desc_t *A, MORSE_desc_t *T,
 #endif
 
     for (k = 0; k < minMNT; k++) {
-        RUNTIME_set_iteration(morse, k);
+        RUNTIME_iteration_push(morse, k);
 
         tempkm = k == A->mt-1 ? A->m-k*A->mb : A->mb;
         tempkn = k == A->nt-1 ? A->n-k*A->nb : A->nb;
@@ -173,6 +173,8 @@ void morse_pzgelqf(MORSE_desc_t *A, MORSE_desc_t *T,
                     T(k, n), T->mb);
             }
         }
+
+        RUNTIME_iteration_pop(morse);
     }
     RUNTIME_options_ws_free(&options);
     RUNTIME_options_finalize(&options, morse);
diff --git a/compute/pzgelqfrh.c b/compute/pzgelqfrh.c
index 46cc88668..b24b6db89 100644
--- a/compute/pzgelqfrh.c
+++ b/compute/pzgelqfrh.c
@@ -119,7 +119,7 @@ void morse_pzgelqfrh(MORSE_desc_t *A, MORSE_desc_t *T, int BS,
 #endif
 
     for (k = 0; k < chameleon_min(A->mt, A->nt); k++) {
-        RUNTIME_set_iteration(morse, k);
+        RUNTIME_iteration_push(morse, k);
 
         tempkm = k == A->mt-1 ? A->m-k*A->mb : A->mb;
         ldak = BLKLDD(A, k);
@@ -205,6 +205,8 @@ void morse_pzgelqfrh(MORSE_desc_t *A, MORSE_desc_t *T, int BS,
                 }
             }
         }
+
+        RUNTIME_iteration_pop(morse);
     }
     RUNTIME_options_ws_free(&options);
     RUNTIME_options_finalize(&options, morse);
diff --git a/compute/pzgeqrf.c b/compute/pzgeqrf.c
index 94e463ec2..a54aa8853 100644
--- a/compute/pzgeqrf.c
+++ b/compute/pzgeqrf.c
@@ -110,7 +110,7 @@ void morse_pzgeqrf(MORSE_desc_t *A, MORSE_desc_t *T,
 #endif
 
     for (k = 0; k < minMNT; k++) {
-        RUNTIME_set_iteration(morse, k);
+        RUNTIME_iteration_push(morse, k);
 
         tempkm = k == A->mt-1 ? A->m-k*A->mb : A->mb;
         tempkn = k == A->nt-1 ? A->n-k*A->nb : A->nb;
@@ -167,6 +167,8 @@ void morse_pzgeqrf(MORSE_desc_t *A, MORSE_desc_t *T,
                     T(m, k), T->mb);
             }
         }
+
+        RUNTIME_iteration_pop(morse);
     }
     RUNTIME_options_ws_free(&options);
     RUNTIME_options_finalize(&options, morse);
diff --git a/compute/pzgeqrfrh.c b/compute/pzgeqrfrh.c
index 5854923a3..a5e828c8b 100644
--- a/compute/pzgeqrfrh.c
+++ b/compute/pzgeqrfrh.c
@@ -118,7 +118,7 @@ void morse_pzgeqrfrh(MORSE_desc_t *A, MORSE_desc_t *T, int BS,
 
     K = chameleon_min(A->mt, A->nt);
     for (k = 0; k < K; k++) {
-        RUNTIME_set_iteration(morse, k);
+        RUNTIME_iteration_push(morse, k);
 
         tempkn = k == A->nt-1 ? A->n-k*A->nb : A->nb;
         for (M = k; M < A->mt; M += BS) {
@@ -204,6 +204,8 @@ void morse_pzgeqrfrh(MORSE_desc_t *A, MORSE_desc_t *T, int BS,
                 }
             }
         }
+
+        RUNTIME_iteration_pop(morse);
     }
     RUNTIME_options_ws_free(&options);
     RUNTIME_options_finalize(&options, morse);
diff --git a/compute/pzgetrf_incpiv.c b/compute/pzgetrf_incpiv.c
index 506cd00df..f960873e6 100644
--- a/compute/pzgetrf_incpiv.c
+++ b/compute/pzgetrf_incpiv.c
@@ -78,7 +78,7 @@ void morse_pzgetrf_incpiv(MORSE_desc_t *A, MORSE_desc_t *L, int *IPIV,
     morse_zdesc_alloc_diag(*DIAG, A->mb, A->nb, chameleon_min(A->m, A->n), A->nb, 0, 0, chameleon_min(A->m, A->n), A->nb, A->p, A->q);
 
     for (k = 0; k < minMNT; k++) {
-        RUNTIME_set_iteration(morse, k);
+        RUNTIME_iteration_push(morse, k);
 
         tempkm = k == A->mt-1 ? A->m-k*A->mb : A->mb;
         tempkn = k == A->nt-1 ? A->n-k*A->nb : A->nb;
@@ -135,6 +135,8 @@ void morse_pzgetrf_incpiv(MORSE_desc_t *A, MORSE_desc_t *L, int *IPIV,
                     IPIV(m, k));
             }
         }
+
+        RUNTIME_iteration_pop(morse);
     }
     RUNTIME_options_ws_free(&options);
     RUNTIME_options_finalize(&options, morse);
diff --git a/compute/pzgetrf_nopiv.c b/compute/pzgetrf_nopiv.c
index 7fbd6bdfa..16150478f 100644
--- a/compute/pzgetrf_nopiv.c
+++ b/compute/pzgetrf_nopiv.c
@@ -54,7 +54,7 @@ void morse_pzgetrf_nopiv(MORSE_desc_t *A,
     ib = MORSE_IB;
 
     for (k = 0; k < chameleon_min(A->mt, A->nt); k++) {
-        RUNTIME_set_iteration(morse, k);
+        RUNTIME_iteration_push(morse, k);
 
         tempkm = k == A->mt-1 ? A->m-k*A->mb : A->mb;
         tempkn = k == A->nt-1 ? A->n-k*A->nb : A->nb;
@@ -100,6 +100,8 @@ void morse_pzgetrf_nopiv(MORSE_desc_t *A,
                     zone,  A(m, n), ldam);
             }
         }
+
+        RUNTIME_iteration_pop(morse);
     }
     RUNTIME_options_finalize(&options, morse);
     MORSE_TASK_dataflush_all();
diff --git a/compute/pzhetrd_he2hb.c b/compute/pzhetrd_he2hb.c
index badde013d..497b574d4 100644
--- a/compute/pzhetrd_he2hb.c
+++ b/compute/pzhetrd_he2hb.c
@@ -137,7 +137,7 @@ void morse_pzhetrd_he2hb(MORSE_enum uplo,
 
     if (uplo == MorseLower) {
        for (k = 0; k < A->nt-1; k++){
-           RUNTIME_set_iteration(morse, k);
+           RUNTIME_iteration_push(morse, k);
 
            tempkm = k+1 == A->mt-1 ? A->m-(k+1)*A->mb : A->mb;
            tempkn = k   == A->nt-1 ? A->n- k   *A->nb : A->nb;
@@ -288,11 +288,13 @@ void morse_pzhetrd_he2hb(MORSE_enum uplo,
                    T(m,   k), T->mb);
                options.priority = 0;
            }
+
+           RUNTIME_iteration_pop(morse);
        }
     }
     else {
        for (k = 0; k < A->nt-1; k++){
-           RUNTIME_set_iteration(morse, k);
+           RUNTIME_iteration_push(morse, k);
 
            tempkn = k+1 == A->nt-1 ? A->n-(k+1)*A->nb : A->nb;
            tempkm = k   == A->mt-1 ? A->m- k   *A->mb : A->mb;
@@ -440,6 +442,8 @@ void morse_pzhetrd_he2hb(MORSE_enum uplo,
                    T(k,   n), T->mb);
            }
            options.priority = 0;
+
+           RUNTIME_iteration_pop(morse);
        }
     }
 
diff --git a/compute/pzpotrf.c b/compute/pzpotrf.c
index cff8af13a..44b7d25f5 100644
--- a/compute/pzpotrf.c
+++ b/compute/pzpotrf.c
@@ -71,7 +71,7 @@ void morse_pzpotrf(MORSE_enum uplo, MORSE_desc_t *A,
      */
     if (uplo == MorseLower) {
         for (k = 0; k < A->mt; k++) {
-            RUNTIME_set_iteration(morse, k);
+            RUNTIME_iteration_push(morse, k);
 
             tempkm = k == A->mt-1 ? A->m-k*A->mb : A->mb;
             ldak = BLKLDD(A, k);
@@ -123,6 +123,7 @@ void morse_pzpotrf(MORSE_enum uplo, MORSE_desc_t *A,
                 }
                 MORSE_TASK_dataflush( &options, A(n, k) );
             }
+            RUNTIME_iteration_pop(morse);
         }
     }
     /*
@@ -130,7 +131,7 @@ void morse_pzpotrf(MORSE_enum uplo, MORSE_desc_t *A,
      */
     else {
         for (k = 0; k < A->nt; k++) {
-            RUNTIME_set_iteration(morse, k);
+            RUNTIME_iteration_push(morse, k);
 
             tempkm = k == A->nt-1 ? A->n-k*A->nb : A->nb;
             ldak = BLKLDD(A, k);
@@ -181,6 +182,8 @@ void morse_pzpotrf(MORSE_enum uplo, MORSE_desc_t *A,
                 }
                 MORSE_TASK_dataflush( &options, A(k, m) );
             }
+
+            RUNTIME_iteration_pop(morse);
         }
     }
 
diff --git a/compute/pzpotrimm.c b/compute/pzpotrimm.c
index 50255de57..d1b7323c1 100644
--- a/compute/pzpotrimm.c
+++ b/compute/pzpotrimm.c
@@ -76,7 +76,7 @@ void morse_pzpotrimm(MORSE_enum uplo, MORSE_desc_t *A, MORSE_desc_t *B, MORSE_de
          *  ZPOTRF
          */
         for (k = 0; k < A->mt; k++) {
-            RUNTIME_set_iteration(morse, k);
+            RUNTIME_iteration_push(morse, k);
 
             tempkm = k == A->mt-1 ? A->m-k*A->mb : A->mb;
             ldak = BLKLDD(A, k);
@@ -121,12 +121,14 @@ void morse_pzpotrimm(MORSE_enum uplo, MORSE_desc_t *A, MORSE_desc_t *B, MORSE_de
                 }
                 MORSE_TASK_dataflush( &options, A(n, k) );
             }
+
+            RUNTIME_iteration_pop(morse);
         }
         /*
          *  ZTRTRI
          */
         for (k = 0; k < A->nt; k++) {
-            RUNTIME_set_iteration(morse, A->nt + k);
+            RUNTIME_iteration_push(morse, A->nt + k);
 
             tempkn = k == A->nt-1 ? A->n-k*A->nb : A->nb;
             ldak = BLKLDD(A, k);
@@ -169,12 +171,14 @@ void morse_pzpotrimm(MORSE_enum uplo, MORSE_desc_t *A, MORSE_desc_t *B, MORSE_de
                 uplo, MorseNonUnit,
                 tempkn, A->mb,
                 A(k, k), ldak, A->nb*k);
+
+            RUNTIME_iteration_pop(morse);
         }
         /*
          *  ZLAUUM
          */
         for (k = 0; k < A->mt; k++) {
-            RUNTIME_set_iteration(morse, 2*A->nt + k);
+            RUNTIME_iteration_push(morse, 2*A->nt + k);
 
             tempkm = k == A->mt-1 ? A->m-k*A->mb : A->mb;
             ldak = BLKLDD(A, k);
@@ -212,12 +216,14 @@ void morse_pzpotrimm(MORSE_enum uplo, MORSE_desc_t *A, MORSE_desc_t *B, MORSE_de
                 &options,
                 uplo, tempkm, A->mb,
                 A(k, k), ldak);
+
+            RUNTIME_iteration_pop(morse);
         }
         /*
          *  ZSYMM Right / Lower
          */
         for (k = 0; k < C->nt; k++) {
-            RUNTIME_set_iteration(morse, 3*A->nt + k);
+            RUNTIME_iteration_push(morse, 3*A->nt + k);
 
             tempkn = k == C->nt-1 ? C->n-k*C->nb : C->nb;
             ldak = BLKLDD(A, k);
@@ -267,6 +273,8 @@ void morse_pzpotrimm(MORSE_enum uplo, MORSE_desc_t *A, MORSE_desc_t *B, MORSE_de
             for (n = 0; n <= k; n++) {
                 MORSE_TASK_dataflush( &options, A(k, n) );
             }
+
+            RUNTIME_iteration_pop(morse);
         }
     }
     /*
@@ -277,7 +285,7 @@ void morse_pzpotrimm(MORSE_enum uplo, MORSE_desc_t *A, MORSE_desc_t *B, MORSE_de
          *  ZPOTRF
          */
         for (k = 0; k < A->nt; k++) {
-            RUNTIME_set_iteration(morse, k);
+            RUNTIME_iteration_push(morse, k);
 
             tempkm = k == A->nt-1 ? A->n-k*A->nb : A->nb;
             ldak = BLKLDD(A, k);
@@ -322,12 +330,14 @@ void morse_pzpotrimm(MORSE_enum uplo, MORSE_desc_t *A, MORSE_desc_t *B, MORSE_de
                 }
                 MORSE_TASK_dataflush( &options, A(k, m) );
             }
+
+            RUNTIME_iteration_pop(morse);
         }
         /*
          *  ZTRTRI
          */
         for (k = 0; k < A->mt; k++) {
-            RUNTIME_set_iteration(morse, A->nt + k);
+            RUNTIME_iteration_push(morse, A->nt + k);
 
             tempkm = k == A->mt-1 ? A->m-k*A->mb : A->mb;
             ldak = BLKLDD(A, k);
@@ -370,12 +380,14 @@ void morse_pzpotrimm(MORSE_enum uplo, MORSE_desc_t *A, MORSE_desc_t *B, MORSE_de
                 uplo, MorseNonUnit,
                 tempkm, A->mb,
                 A(k, k), ldak, A->mb*k);
+
+            RUNTIME_iteration_pop(morse);
         }
         /*
          *  ZLAUUM
          */
         for (k = 0; k < A->mt; k++) {
-            RUNTIME_set_iteration(morse, 2*A->nt + k);
+            RUNTIME_iteration_push(morse, 2*A->nt + k);
 
             tempkn = k == A->nt-1 ? A->n-k*A->nb : A->nb;
             ldak = BLKLDD(A, k);
@@ -415,12 +427,14 @@ void morse_pzpotrimm(MORSE_enum uplo, MORSE_desc_t *A, MORSE_desc_t *B, MORSE_de
                 &options,
                 uplo, tempkn, A->mb,
                 A(k, k), ldak);
+
+            RUNTIME_iteration_pop(morse);
         }
         /*
          *  ZSYMM Right / Upper
          */
         for (k = 0; k < C->nt; k++) {
-            RUNTIME_set_iteration(morse, 3*A->nt + k);
+            RUNTIME_iteration_push(morse, 3*A->nt + k);
 
             tempkn = k == C->nt-1 ? C->n-k*C->nb : C->nb;
             ldak = BLKLDD(A, k);
@@ -470,6 +484,8 @@ void morse_pzpotrimm(MORSE_enum uplo, MORSE_desc_t *A, MORSE_desc_t *B, MORSE_de
             for (m = 0; m <= k; m++) {
                 MORSE_TASK_dataflush( &options, A(m, k) );
             }
+
+            RUNTIME_iteration_pop(morse);
         }
     }
 
diff --git a/compute/pzsytrf.c b/compute/pzsytrf.c
index 22b77f3f2..818ba9625 100644
--- a/compute/pzsytrf.c
+++ b/compute/pzsytrf.c
@@ -60,7 +60,7 @@ void morse_pzsytrf(MORSE_enum uplo, MORSE_desc_t *A,
      */
     if (uplo == MorseLower) {
         for (k = 0; k < A->mt; k++) {
-            RUNTIME_set_iteration(morse, k);
+            RUNTIME_iteration_push(morse, k);
 
             tempkm = k == A->mt-1 ? A->m-k*A->mb : A->mb;
             ldak = BLKLDD(A, k);
@@ -105,6 +105,8 @@ void morse_pzsytrf(MORSE_enum uplo, MORSE_desc_t *A,
                 }
                 MORSE_TASK_dataflush( &options, A(n, k) );
             }
+
+            RUNTIME_iteration_pop(morse);
         }
     }
     /*
@@ -112,7 +114,7 @@ void morse_pzsytrf(MORSE_enum uplo, MORSE_desc_t *A,
      */
     else {
         for (k = 0; k < A->nt; k++) {
-            RUNTIME_set_iteration(morse, k);
+            RUNTIME_iteration_push(morse, k);
 
             tempkm = k == A->nt-1 ? A->n-k*A->nb : A->nb;
             ldak = BLKLDD(A, k);
@@ -157,6 +159,8 @@ void morse_pzsytrf(MORSE_enum uplo, MORSE_desc_t *A,
                 }
                 MORSE_TASK_dataflush( &options, A(k, m) );
             }
+
+            RUNTIME_iteration_pop(morse);
         }
     }
 
diff --git a/compute/pztpgqrt.c b/compute/pztpgqrt.c
index 9d04de6ab..973612e7a 100644
--- a/compute/pztpgqrt.c
+++ b/compute/pztpgqrt.c
@@ -101,7 +101,7 @@ void morse_pztpgqrt( int L,
 #endif
 
     for (k = V1->nt-1; k >= 0; k--) {
-        RUNTIME_set_iteration(morse, k);
+        RUNTIME_iteration_push(morse, k);
 
         tempkm = k == V1->mt-1 ? V1->m-k*V1->mb : V1->mb;
         tempkk = k == V1->nt-1 ? V1->n-k*V1->nb : V1->nb;
@@ -171,6 +171,8 @@ void morse_pztpgqrt( int L,
                 T1(k, k), T1->mb,
                 Q1(k, n), ldqk);
         }
+
+        RUNTIME_iteration_pop(morse);
     }
 
     RUNTIME_options_ws_free(&options);
diff --git a/compute/pztpqrt.c b/compute/pztpqrt.c
index 71fad4a20..25af2c85e 100644
--- a/compute/pztpqrt.c
+++ b/compute/pztpqrt.c
@@ -91,7 +91,7 @@ void morse_pztpqrt( int L, MORSE_desc_t *A, MORSE_desc_t *B, MORSE_desc_t *T,
     RUNTIME_options_ws_alloc( &options, ws_worker, ws_host );
 
     for (k = 0; k < A->nt; k++) {
-        RUNTIME_set_iteration(morse, k);
+        RUNTIME_iteration_push(morse, k);
 
         tempkm = k == A->mt-1 ? A->m-k*A->mb : A->mb;
         tempkn = k == A->nt-1 ? A->n-k*A->nb : A->nb;
@@ -122,6 +122,8 @@ void morse_pztpqrt( int L, MORSE_desc_t *A, MORSE_desc_t *B, MORSE_desc_t *T,
         }
 
         maxmt = chameleon_min( B->mt, maxmt+1 );
+
+        RUNTIME_iteration_pop(morse);
     }
     RUNTIME_options_ws_free(&options);
     RUNTIME_options_finalize(&options, morse);
diff --git a/compute/pztrtri.c b/compute/pztrtri.c
index 7a56bb7b6..732659656 100644
--- a/compute/pztrtri.c
+++ b/compute/pztrtri.c
@@ -56,7 +56,7 @@ void morse_pztrtri(MORSE_enum uplo, MORSE_enum diag, MORSE_desc_t *A,
      */
     if (uplo == MorseLower) {
         for (k = 0; k < A->nt; k++) {
-            RUNTIME_set_iteration(morse, k);
+            RUNTIME_iteration_push(morse, k);
 
             tempkn = k == A->nt-1 ? A->n-k*A->nb : A->nb;
             ldak = BLKLDD(A, k);
@@ -99,6 +99,8 @@ void morse_pztrtri(MORSE_enum uplo, MORSE_enum diag, MORSE_desc_t *A,
                 uplo, diag,
                 tempkn, A->mb,
                 A(k, k), ldak, A->nb*k);
+
+            RUNTIME_iteration_pop(morse);
         }
     }
     /*
@@ -106,7 +108,7 @@ void morse_pztrtri(MORSE_enum uplo, MORSE_enum diag, MORSE_desc_t *A,
      */
     else {
         for (k = 0; k < A->mt; k++) {
-            RUNTIME_set_iteration(morse, k);
+            RUNTIME_iteration_push(morse, k);
 
             tempkm = k == A->mt-1 ? A->m-k*A->mb : A->mb;
             ldak = BLKLDD(A, k);
@@ -149,6 +151,8 @@ void morse_pztrtri(MORSE_enum uplo, MORSE_enum diag, MORSE_desc_t *A,
                 uplo, diag,
                 tempkm, A->mb,
                 A(k, k), ldak, A->mb*k);
+
+            RUNTIME_iteration_pop(morse);
         }
     }
     RUNTIME_options_finalize(&options, morse);
diff --git a/compute/pzunglq.c b/compute/pzunglq.c
index 746af6b87..3b50ac59d 100644
--- a/compute/pzunglq.c
+++ b/compute/pzunglq.c
@@ -98,7 +98,7 @@ void morse_pzunglq(MORSE_desc_t *A, MORSE_desc_t *Q, MORSE_desc_t *T,
 #endif
 
     for (k = minMT-1; k >= 0; k--) {
-        RUNTIME_set_iteration(morse, k);
+        RUNTIME_iteration_push(morse, k);
 
         tempAkm  = k == A->mt-1 ? A->m-k*A->mb : A->mb;
         tempAkn  = k == A->nt-1 ? A->n-k*A->nb : A->nb;
@@ -145,6 +145,8 @@ void morse_pzunglq(MORSE_desc_t *A, MORSE_desc_t *Q, MORSE_desc_t *T,
                 T(k, k), T->mb,
                 Q(m, k), ldqm);
         }
+
+        RUNTIME_iteration_pop(morse);
     }
     RUNTIME_options_ws_free(&options);
     RUNTIME_options_finalize(&options, morse);
diff --git a/compute/pzunglqrh.c b/compute/pzunglqrh.c
index fdccc54d9..722613bb4 100644
--- a/compute/pzunglqrh.c
+++ b/compute/pzunglqrh.c
@@ -99,7 +99,7 @@ void morse_pzunglqrh(MORSE_desc_t *A, MORSE_desc_t *Q,
 
     K = chameleon_min(A->mt, A->nt);
     for (k = K-1; k >= 0; k--) {
-        RUNTIME_set_iteration(morse, k);
+        RUNTIME_iteration_push(morse, k);
 
         tempkm = k == A->mt-1 ? A->m-k*A->mb : A->mb;
         ldak = BLKLDD(A, k);
@@ -171,6 +171,8 @@ void morse_pzunglqrh(MORSE_desc_t *A, MORSE_desc_t *Q,
                     Q(m, N), ldqm);
             }
         }
+
+        RUNTIME_iteration_pop(morse);
     }
     RUNTIME_options_ws_free(&options);
     RUNTIME_options_finalize(&options, morse);
diff --git a/compute/pzungqr.c b/compute/pzungqr.c
index e4c02312a..d5a258ac8 100644
--- a/compute/pzungqr.c
+++ b/compute/pzungqr.c
@@ -98,7 +98,7 @@ void morse_pzungqr(MORSE_desc_t *A, MORSE_desc_t *Q, MORSE_desc_t *T,
 #endif
 
     for (k = minMT-1; k >= 0; k--) {
-        RUNTIME_set_iteration(morse, k);
+        RUNTIME_iteration_push(morse, k);
 
         tempAkm  = k == A->mt-1 ? A->m-k*A->mb : A->mb;
         tempAkn  = k == A->nt-1 ? A->n-k*A->nb : A->nb;
@@ -146,6 +146,8 @@ void morse_pzungqr(MORSE_desc_t *A, MORSE_desc_t *Q, MORSE_desc_t *T,
                 T(k, k), T->mb,
                 Q(k, n), ldqk);
         }
+
+        RUNTIME_iteration_pop(morse);
     }
     RUNTIME_options_ws_free(&options);
     RUNTIME_options_finalize(&options, morse);
diff --git a/compute/pzungqrrh.c b/compute/pzungqrrh.c
index 168a56254..7217488af 100644
--- a/compute/pzungqrrh.c
+++ b/compute/pzungqrrh.c
@@ -101,7 +101,7 @@ void morse_pzungqrrh(MORSE_desc_t *A, MORSE_desc_t *Q,
 
     K = chameleon_min(A->mt, A->nt);
     for (k = K-1; k >= 0; k--) {
-        RUNTIME_set_iteration(morse, k);
+        RUNTIME_iteration_push(morse, k);
 
         tempkn = k == A->nt-1 ? A->n-k*A->nb : A->nb;
         lastRD = 0;
@@ -176,6 +176,8 @@ void morse_pzungqrrh(MORSE_desc_t *A, MORSE_desc_t *Q,
                     Q(M, n), ldqM);
             }
         }
+
+        RUNTIME_iteration_pop(morse);
     }
     RUNTIME_options_ws_free(&options);
     RUNTIME_options_finalize(&options, morse);
diff --git a/compute/pzunmlq.c b/compute/pzunmlq.c
index bc6086c43..94824c3bc 100644
--- a/compute/pzunmlq.c
+++ b/compute/pzunmlq.c
@@ -105,7 +105,7 @@ void morse_pzunmlq(MORSE_enum side, MORSE_enum trans,
              *  MorseLeft / MorseNoTrans
              */
             for (k = 0; k < minMT; k++) {
-                RUNTIME_set_iteration(morse, k);
+                RUNTIME_iteration_push(morse, k);
 
                 tempkm   = k == B->mt-1 ? B->m-k*B->mb : B->mb;
                 tempkmin = k == minMT-1 ? minM-k*A->nb : A->nb;
@@ -150,6 +150,8 @@ void morse_pzunmlq(MORSE_enum side, MORSE_enum trans,
                             T(k, m), T->mb);
                     }
                 }
+
+                RUNTIME_iteration_pop(morse);
             }
         }
         else {
@@ -157,7 +159,7 @@ void morse_pzunmlq(MORSE_enum side, MORSE_enum trans,
              *  MorseLeft / MorseConjTrans
              */
             for (k = minMT-1; k >= 0; k--) {
-                RUNTIME_set_iteration(morse, k);
+                RUNTIME_iteration_push(morse, k);
 
                 tempkm   = k == B->mt-1 ? B->m-k*B->mb : B->mb;
                 tempkmin = k == minMT-1 ? minM-k*A->nb : A->nb;
@@ -202,6 +204,8 @@ void morse_pzunmlq(MORSE_enum side, MORSE_enum trans,
                         T(k, k), T->mb,
                         B(k, n), ldbk);
                 }
+
+                RUNTIME_iteration_pop(morse);
             }
         }
     }
@@ -211,7 +215,7 @@ void morse_pzunmlq(MORSE_enum side, MORSE_enum trans,
              *  MorseRight / MorseNoTrans
              */
             for (k = minMT-1; k >= 0; k--) {
-                RUNTIME_set_iteration(morse, k);
+                RUNTIME_iteration_push(morse, k);
 
                 tempkn   = k == B->nt -1 ? B->n -k*B->nb : B->nb;
                 tempkmin = k == minMT-1 ? minM-k*A->nb : A->nb;
@@ -256,6 +260,8 @@ void morse_pzunmlq(MORSE_enum side, MORSE_enum trans,
                         T(k, k), T->mb,
                         B(m, k), ldbm);
                 }
+
+                RUNTIME_iteration_pop(morse);
             }
         }
         else {
@@ -263,7 +269,7 @@ void morse_pzunmlq(MORSE_enum side, MORSE_enum trans,
              *  MorseRight / MorseConjTrans
              */
             for (k = 0; k < minMT; k++) {
-                RUNTIME_set_iteration(morse, k);
+                RUNTIME_iteration_push(morse, k);
 
                 tempkn   = k == B->nt -1 ? B->n -k*B->nb : B->nb;
                 tempkmin = k == minMT-1 ? minM-k*A->mb : A->mb;
@@ -308,6 +314,8 @@ void morse_pzunmlq(MORSE_enum side, MORSE_enum trans,
                             T(k, n), T->mb);
                     }
                 }
+
+                RUNTIME_iteration_pop(morse);
             }
         }
     }
diff --git a/compute/pzunmlqrh.c b/compute/pzunmlqrh.c
index 747539398..4c637236d 100644
--- a/compute/pzunmlqrh.c
+++ b/compute/pzunmlqrh.c
@@ -105,7 +105,7 @@ void morse_pzunmlqrh(MORSE_enum side, MORSE_enum trans,
              *  MorseLeft / MorseNoTrans
              */
             for (k = 0; k < K; k++) {
-                RUNTIME_set_iteration(morse, k);
+                RUNTIME_iteration_push(morse, k);
 
                 tempkm = k == A->mt-1 ? A->m-k*A->mb : A->mb;
                 ldak = BLKLDD(A, k);
@@ -174,13 +174,15 @@ void morse_pzunmlqrh(MORSE_enum side, MORSE_enum trans,
                         }
                     }
                 }
+
+                RUNTIME_iteration_pop(morse);
             }
         } else {
             /*
              *  MorseLeft / MorseConjTrans
              */
             for (k = K-1; k >= 0; k--) {
-                RUNTIME_set_iteration(morse, k);
+                RUNTIME_iteration_push(morse, k);
 
                 tempkm = k == A->mt-1 ? A->m-k*A->mb : A->mb;
                 ldak = BLKLDD(A, k);
@@ -252,6 +254,8 @@ void morse_pzunmlqrh(MORSE_enum side, MORSE_enum trans,
                             B(N, n), ldbN);
                     }
                 }
+
+                RUNTIME_iteration_pop(morse);
             }
 
         }
@@ -261,7 +265,7 @@ void morse_pzunmlqrh(MORSE_enum side, MORSE_enum trans,
              *  MorseRight / MorseNoTrans
              */
             for (k = K-1; k >= 0; k--) {
-                RUNTIME_set_iteration(morse, k);
+                RUNTIME_iteration_push(morse, k);
 
                 tempkm = k == A->mt-1 ? A->m-k*A->mb : A->mb;
                 ldak = BLKLDD(A, k);
@@ -332,13 +336,15 @@ void morse_pzunmlqrh(MORSE_enum side, MORSE_enum trans,
                             B(m, N), ldbm);
                     }
                 }
+
+                RUNTIME_iteration_pop(morse);
             }
         } else {
             /*
              *  MorseRight / MorseConjTrans
              */
             for (k = 0; k < K; k++) {
-                RUNTIME_set_iteration(morse, k);
+                RUNTIME_iteration_push(morse, k);
 
                 tempkm = k == A->mt-1 ? A->m-k*A->mb : A->mb;
                 ldak = BLKLDD(A, k);
@@ -406,6 +412,8 @@ void morse_pzunmlqrh(MORSE_enum side, MORSE_enum trans,
                         }
                     }
                 }
+
+                RUNTIME_iteration_pop(morse);
             }
         }
     }
diff --git a/compute/pzunmqr.c b/compute/pzunmqr.c
index ccd43134e..cdf4cbdd3 100644
--- a/compute/pzunmqr.c
+++ b/compute/pzunmqr.c
@@ -105,7 +105,7 @@ void morse_pzunmqr(MORSE_enum side, MORSE_enum trans,
              *  MorseLeft / MorseConjTrans
              */
             for (k = 0; k < minMT; k++) {
-                RUNTIME_set_iteration(morse, k);
+                RUNTIME_iteration_push(morse, k);
 
                 tempkm   = k == B->mt-1 ? B->m-k*B->mb : B->mb;
                 tempkmin = k == minMT-1 ? minM-k*A->nb : A->nb;
@@ -151,6 +151,8 @@ void morse_pzunmqr(MORSE_enum side, MORSE_enum trans,
                             T(m, k), T->mb);
                     }
                 }
+
+                RUNTIME_iteration_pop(morse);
             }
         }
         /*
@@ -158,7 +160,7 @@ void morse_pzunmqr(MORSE_enum side, MORSE_enum trans,
          */
         else {
             for (k = minMT-1; k >= 0; k--) {
-                RUNTIME_set_iteration(morse, k);
+                RUNTIME_iteration_push(morse, k);
 
                 tempkm = k == B->mt-1 ? B->m-k*B->mb : B->mb;
                 tempkmin = k == minMT-1 ? minM-k*A->nb : A->nb;
@@ -204,6 +206,8 @@ void morse_pzunmqr(MORSE_enum side, MORSE_enum trans,
                         T(k, k), T->mb,
                         B(k, n), ldbk);
                 }
+
+                RUNTIME_iteration_pop(morse);
             }
         }
     }
@@ -213,7 +217,7 @@ void morse_pzunmqr(MORSE_enum side, MORSE_enum trans,
     else {
         if (trans == MorseConjTrans) {
             for (k = minMT-1; k >= 0; k--) {
-                RUNTIME_set_iteration(morse, k);
+                RUNTIME_iteration_push(morse, k);
 
                 tempkn = k == B->nt-1 ? B->n-k*B->nb : B->nb;
                 tempkmin = k == minMT-1 ? minM-k*A->nb : A->nb;
@@ -260,6 +264,8 @@ void morse_pzunmqr(MORSE_enum side, MORSE_enum trans,
                         T(k, k), T->mb,
                         B(m, k), ldbm);
                 }
+
+                RUNTIME_iteration_pop(morse);
             }
         }
         /*
@@ -267,7 +273,7 @@ void morse_pzunmqr(MORSE_enum side, MORSE_enum trans,
          */
         else {
             for (k = 0; k < minMT; k++) {
-                RUNTIME_set_iteration(morse, k);
+                RUNTIME_iteration_push(morse, k);
 
                 tempkn   = k == B->nt-1 ? B->n-k*B->nb : B->nb;
                 tempkmin = k == minMT-1 ? minM-k*A->nb : A->nb;
@@ -313,6 +319,8 @@ void morse_pzunmqr(MORSE_enum side, MORSE_enum trans,
                             T(n, k), T->mb);
                     }
                 }
+
+                RUNTIME_iteration_pop(morse);
             }
         }
     }
diff --git a/compute/pzunmqrrh.c b/compute/pzunmqrrh.c
index fd7acea40..1c6954f67 100644
--- a/compute/pzunmqrrh.c
+++ b/compute/pzunmqrrh.c
@@ -107,7 +107,7 @@ void morse_pzunmqrrh(MORSE_enum side, MORSE_enum trans,
              *  MorseLeft / MorseConjTrans
              */
             for (k = 0; k < K; k++) {
-                RUNTIME_set_iteration(morse, k);
+                RUNTIME_iteration_push(morse, k);
 
                 tempkn = k == A->nt-1 ? A->n-k*A->nb : A->nb;
                 for (M = k; M < A->mt; M += BS) {
@@ -178,13 +178,15 @@ void morse_pzunmqrrh(MORSE_enum side, MORSE_enum trans,
                         }
                     }
                 }
+
+                RUNTIME_iteration_pop(morse);
             }
         } else {
             /*
              *  MorseLeft / MorseNoTrans
              */
             for (k = K-1; k >= 0; k--) {
-                RUNTIME_set_iteration(morse, k);
+                RUNTIME_iteration_push(morse, k);
 
                 tempkn = k == A->nt-1 ? A->n-k*A->nb : A->nb;
                 lastRD = 0;
@@ -258,6 +260,8 @@ void morse_pzunmqrrh(MORSE_enum side, MORSE_enum trans,
                             B(M, n), ldbM);
                     }
                 }
+
+                RUNTIME_iteration_pop(morse);
             }
         }
     } else {
@@ -266,7 +270,7 @@ void morse_pzunmqrrh(MORSE_enum side, MORSE_enum trans,
              *  MorseRight / MorseConjTrans
              */
             for (k = K-1; k >= 0; k--) {
-                RUNTIME_set_iteration(morse, k);
+                RUNTIME_iteration_push(morse, k);
 
                 tempkn = k == A->nt-1 ? A->n-k*A->nb : A->nb;
                 lastRD = 0;
@@ -340,13 +344,15 @@ void morse_pzunmqrrh(MORSE_enum side, MORSE_enum trans,
                             B(m, M), ldbm);
                     }
                 }
+
+                RUNTIME_iteration_pop(morse);
             }
         } else {
             /*
              *  MorseRight / MorseNoTrans
              */
             for (k = 0; k < K; k++) {
-                RUNTIME_set_iteration(morse, k);
+                RUNTIME_iteration_push(morse, k);
 
                 tempkn = k == A->nt-1 ? A->n-k*A->nb : A->nb;
                 for (M = k; M < A->mt; M += BS) {
@@ -416,6 +422,8 @@ void morse_pzunmqrrh(MORSE_enum side, MORSE_enum trans,
                         }
                     }
                 }
+
+                RUNTIME_iteration_pop(morse);
             }
         }
     }
diff --git a/control/config.h.in b/control/config.h.in
index a71d517dc..40a4aa172 100644
--- a/control/config.h.in
+++ b/control/config.h.in
@@ -34,7 +34,7 @@
 /* StarPU functions */
 #cmakedefine HAVE_STARPU_FXT_PROFILING
 #cmakedefine HAVE_STARPU_IDLE_PREFETCH
-#cmakedefine HAVE_STARPU_SET_ITERATION
+#cmakedefine HAVE_STARPU_ITERATION_PUSH
 #cmakedefine HAVE_STARPU_DATA_WONT_USE
 #cmakedefine HAVE_STARPU_MALLOC_ON_NODE_SET_DEFAULT_FLAGS
 #cmakedefine HAVE_STARPU_MPI_DATA_REGISTER
diff --git a/include/runtime.h b/include/runtime.h
index ea765e112..5a3e3798b 100644
--- a/include/runtime.h
+++ b/include/runtime.h
@@ -52,8 +52,8 @@ int   RUNTIME_rank               (MORSE_context_t*);
 int   RUNTIME_init_scheduler     (MORSE_context_t*, int, int, int);
 void  RUNTIME_finalize_scheduler (MORSE_context_t*);
 void  RUNTIME_barrier            (MORSE_context_t*);
-void  RUNTIME_set_iteration      (MORSE_context_t*, unsigned long iteration);
-void  RUNTIME_set_subiteration   (MORSE_context_t*, unsigned long subiteration);
+void  RUNTIME_iteration_push     (MORSE_context_t*, unsigned long iteration);
+void  RUNTIME_iteration_pop      (MORSE_context_t*);
 void  RUNTIME_pause              (MORSE_context_t*);
 void  RUNTIME_resume             (MORSE_context_t*);
 void  RUNTIME_comm_rank          (int*);
diff --git a/runtime/parsec/control/runtime_control.c b/runtime/parsec/control/runtime_control.c
index c1d3d9910..4eda96a8c 100644
--- a/runtime/parsec/control/runtime_control.c
+++ b/runtime/parsec/control/runtime_control.c
@@ -70,12 +70,12 @@ void RUNTIME_barrier(MORSE_context_t *morse)
 /*******************************************************************************
  *  Set iteration numbers for traces
  **/
-void RUNTIME_set_iteration( MORSE_context_t *morse, unsigned long iteration )
+void RUNTIME_iteration_push( MORSE_context_t *morse, unsigned long iteration )
 {
     (void)morse;
     return;
 }
-void RUNTIME_set_subiteration( MORSE_context_t *morse, unsigned long subiteration )
+void RUNTIME_iteration_pop( MORSE_context_t *morse )
 {
     (void)morse;
     return;
diff --git a/runtime/quark/control/runtime_control.c b/runtime/quark/control/runtime_control.c
index 3a9be224e..f21358df2 100644
--- a/runtime/quark/control/runtime_control.c
+++ b/runtime/quark/control/runtime_control.c
@@ -71,12 +71,12 @@ void RUNTIME_finalize_scheduler(MORSE_context_t *morse)
 /*******************************************************************************
  *  Set iteration numbers for traces
  **/
-void RUNTIME_set_iteration( MORSE_context_t *morse, unsigned long iteration )
+void RUNTIME_iteration_push( MORSE_context_t *morse, unsigned long iteration )
 {
     (void)morse;
     return;
 }
-void RUNTIME_set_subiteration( MORSE_context_t *morse, unsigned long subiteration )
+void RUNTIME_iteration_pop( MORSE_context_t *morse )
 {
     (void)morse;
     return;
diff --git a/runtime/starpu/control/runtime_control.c b/runtime/starpu/control/runtime_control.c
index b1aba1933..9f861e258 100644
--- a/runtime/starpu/control/runtime_control.c
+++ b/runtime/starpu/control/runtime_control.c
@@ -178,18 +178,18 @@ void RUNTIME_barrier( MORSE_context_t *morse )
 /*******************************************************************************
  *  Set iteration numbers for traces
  **/
-void RUNTIME_set_iteration( MORSE_context_t *morse, unsigned long iteration )
+void RUNTIME_iteration_push( MORSE_context_t *morse, unsigned long iteration )
 {
     (void)morse;
-#if defined(HAVE_STARPU_SET_ITERATION)
-    starpu_set_iteration(iteration);
+#if defined(HAVE_STARPU_ITERATION_PUSH)
+    starpu_iteration_push(iteration);
 #endif
 }
-void RUNTIME_set_subiteration( MORSE_context_t *morse, unsigned long subiteration )
+void RUNTIME_iteration_pop( MORSE_context_t *morse )
 {
     (void)morse;
-#if defined(HAVE_STARPU_SET_ITERATION)
-    starpu_set_subiteration(subiteration);
+#if defined(HAVE_STARPU_ITERATION_PUSH)
+    starpu_iteration_pop();
 #endif
 }
 
-- 
GitLab