From f47cf24a4c6bc8409d9f7a1b41ed4d53c07d4032 Mon Sep 17 00:00:00 2001
From: Florent Pruvost <florent.pruvost@inria.fr>
Date: Wed, 27 Sep 2023 14:34:02 +0200
Subject: [PATCH] Add macosx and windows jobs for build and test. Reorganize ci
 jobs for readibility.

---
 .gitlab-ci-env.sh                           |  83 ++++++-----
 .gitlab-ci.yml                              |   7 +-
 .gitlab/bench_plafrim.yml                   |  21 +++
 .gitlab/build.sh                            |  49 ++++---
 .gitlab/build.yml                           | 115 +++++++++++----
 .gitlab/common.yml                          |  54 ++-----
 .gitlab/coverage.yml                        |  29 +++-
 .gitlab/coverity.yml                        |  12 +-
 .gitlab/pages.yml                           |   2 +-
 .gitlab/preliminary.yml                     |   2 +-
 .gitlab/sonarqube.yml                       |  50 ++++---
 .gitlab/test.sh                             |  29 ++--
 .gitlab/test_hmat.yml                       |  24 +--
 .gitlab/test_openmp.yml                     |  60 +++-----
 .gitlab/test_parsec.yml                     |  96 +++---------
 .gitlab/test_quark.yml                      |  60 +++-----
 .gitlab/test_starpu.yml                     | 153 +++++++++-----------
 .gitlab/test_starpu_simgrid.yml             |  24 +--
 .gitlab/validate.sh                         |  58 ++++++++
 .gitlab/validate.yml                        |  12 ++
 CMakeLists.txt                              |   2 +-
 cmake_modules/gitlab-ci-initial-cache.cmake |   2 +-
 cmake_modules/morse_cmake                   |   2 +-
 doc/CMakeLists.txt                          |   2 +-
 doc/dev/CMakeLists.txt                      |   2 +-
 doc/user/CMakeLists.txt                     |   2 +-
 example/link_chameleon/CMakeLists.txt       |   2 +-
 runtime/openmp/CMakeLists.txt               |   2 +-
 runtime/parsec/CMakeLists.txt               |   2 +-
 runtime/quark/CMakeLists.txt                |   2 +-
 runtime/starpu/CMakeLists.txt               |   2 +-
 testing/values.c                            |   1 +
 tools/analysis.sh                           |  15 +-
 tools/coverage.sh                           |   3 +-
 34 files changed, 499 insertions(+), 482 deletions(-)
 create mode 100755 .gitlab/validate.sh
 create mode 100644 .gitlab/validate.yml

diff --git a/.gitlab-ci-env.sh b/.gitlab-ci-env.sh
index e57ebda1d..e05586148 100755
--- a/.gitlab-ci-env.sh
+++ b/.gitlab-ci-env.sh
@@ -14,40 +14,49 @@ export STARPU_SILENT=1
 export STARPU_MPI_NOBIND=1
 export STARPU_WORKERS_NOBIND=1
 
-# initialize empty to get just what we need
-export PKG_CONFIG_PATH=""
-
-# define the starpu dir depending on the build variant
-STARPU_VARIANT=""
-if [ ! -z "$1" ]
-then
-   STARPU_VARIANT="-$1"
-fi
-export STARPU_DIR=/home/gitlab/install/starpu${STARPU_VARIANT}
-
-# add additional env. var. depending on the starpu variant
-case $STARPU_VARIANT in
-  -hip )
-    export CMAKE_PREFIX_PATH=$STARPU_DIR:/opt/rocm
-    export LD_LIBRARY_PATH=/opt/rocm/lib
-    ;;
-  -hipcuda )
-    export CMAKE_PREFIX_PATH=$STARPU_DIR:$HIPCUDA_DIR
-    export LD_LIBRARY_PATH=$HIPCUDA_DIR/lib
-    export HIP_PLATFORM=nvidia
-    export HIP_PATH=$HIPCUDA_DIR
-    ;;
-  * )
-    ;;
-esac
-
-# for build: better to rely on pkg-config than to guess libraries with the env. var.
-export PKG_CONFIG_PATH=$PARSEC_DIR/lib/pkgconfig:$PKG_CONFIG_PATH
-export PKG_CONFIG_PATH=$STARPU_DIR/lib/pkgconfig:$PKG_CONFIG_PATH
-export PKG_CONFIG_PATH=$SIMGRID_DIR/lib/pkgconfig:$PKG_CONFIG_PATH
-
-# for ctest: we need this at runtime
-export LD_LIBRARY_PATH=$PARSEC_DIR/lib:$LD_LIBRARY_PATH
-export LD_LIBRARY_PATH=$QUARK_DIR/lib:$LD_LIBRARY_PATH
-export LD_LIBRARY_PATH=$STARPU_DIR/lib:$LD_LIBRARY_PATH
-export LD_LIBRARY_PATH=$SIMGRID_DIR/lib:$LD_LIBRARY_PATH
+if [[ "$SYSTEM" == "linux" ]]; then
+  # initialize empty to get just what we need
+  export PKG_CONFIG_PATH=""
+
+  # define the starpu dir depending on the build variant
+  STARPU_VARIANT=""
+  if [ ! -z "$1" ]
+  then
+     STARPU_VARIANT="-$1"
+  fi
+  export STARPU_DIR=/home/gitlab/install/starpu${STARPU_VARIANT}
+
+  # add additional env. var. depending on the starpu variant
+  case $STARPU_VARIANT in
+    -hip )
+      export CMAKE_PREFIX_PATH=$STARPU_DIR:/opt/rocm
+      export LD_LIBRARY_PATH=/opt/rocm/lib
+      ;;
+    -hipcuda )
+      export CMAKE_PREFIX_PATH=$STARPU_DIR:$HIPCUDA_DIR
+      export LD_LIBRARY_PATH=$HIPCUDA_DIR/lib
+      export HIP_PLATFORM=nvidia
+      export HIP_PATH=$HIPCUDA_DIR
+      ;;
+    * )
+      ;;
+  esac
+
+  # for build: better to rely on pkg-config than to guess libraries with the env. var.
+  export PKG_CONFIG_PATH=$PARSEC_DIR/lib/pkgconfig:$PKG_CONFIG_PATH
+  export PKG_CONFIG_PATH=$STARPU_DIR/lib/pkgconfig:$PKG_CONFIG_PATH
+  export PKG_CONFIG_PATH=$SIMGRID_DIR/lib/pkgconfig:$PKG_CONFIG_PATH
+
+  # for ctest: we need this at runtime
+  export LD_LIBRARY_PATH=$PARSEC_DIR/lib:$LD_LIBRARY_PATH
+  export LD_LIBRARY_PATH=$QUARK_DIR/lib:$LD_LIBRARY_PATH
+  export LD_LIBRARY_PATH=$STARPU_DIR/lib:$LD_LIBRARY_PATH
+  export LD_LIBRARY_PATH=$SIMGRID_DIR/lib:$LD_LIBRARY_PATH
+
+elif [[ "$SYSTEM" == "windows" ]]; then
+
+  # this is required with BUILD_SHARED_LIBS=ON
+  export PATH="/c/Windows/WinSxS/x86_microsoft-windows-m..namespace-downlevel_31bf3856ad364e35_10.0.19041.1_none_21374cb0681a6320":$PATH
+  export PATH=$PWD:$PWD/compute:$PWD/hqr/src:$PWD/lapack_api:$PWD/:$PWD/:$PWD/:$PATH
+
+fi
\ No newline at end of file
diff --git a/.gitlab-ci.yml b/.gitlab-ci.yml
index 38622491e..da9d013d9 100644
--- a/.gitlab-ci.yml
+++ b/.gitlab-ci.yml
@@ -3,7 +3,9 @@ stages:
   - pre
   - build
   - test
-  - analyse
+  - coverage
+  - analyze
+  - validate
   - deploy
 
 # git config --global ahev been added to get around the issue related in
@@ -16,8 +18,6 @@ before_script:
   - git config --global --add safe.directory $CI_PROJECT_DIR/hqr
   - git config --global --add safe.directory $CI_PROJECT_DIR/testing/test_fembem
   - git submodule update --init --recursive
-  - source .gitlab-ci-env.sh $CHAM_CI_ENV_ARG
-  - mkdir -p build-$VERSION
 
 include:
   - .gitlab/preliminary.yml
@@ -32,6 +32,7 @@ include:
   - .gitlab/coverage.yml
   - .gitlab/coverity.yml
   - .gitlab/sonarqube.yml
+  - .gitlab/validate.yml
   - .gitlab/bench_plafrim.yml
   - .gitlab/pages.yml
   - .gitlab/release.yml
diff --git a/.gitlab/bench_plafrim.yml b/.gitlab/bench_plafrim.yml
index 4102f3214..d47728d70 100644
--- a/.gitlab/bench_plafrim.yml
+++ b/.gitlab/bench_plafrim.yml
@@ -1,4 +1,25 @@
 ---
+.bench_plafrim_common:
+  rules:
+    - if: $CI_PIPELINE_SOURCE == "schedule"
+  stage: test
+  tags: ['plafrim']
+  timeout: 1 week
+  before_script:
+    - git submodule update --init --recursive
+  script:
+    - ./tools/bench/plafrim/run.sh
+  artifacts:
+    name: "$CI_JOB_NAME-$CI_COMMIT_REF_SLUG"
+    expire_in: 1 week
+    paths:
+      - "chameleon-$NODE-$MPI-$SLURM_NP.err"
+      - "chameleon-$NODE-$MPI-$SLURM_NP.out"
+      - "tools/bench/plafrim/chameleon.csv"
+      - "tools/bench/plafrim/results/$JUBE_ID"
+  variables:
+    PLATFORM: plafrim
+
 bench_plafrim_bora_openmpi:
   variables:
     NODE: bora
diff --git a/.gitlab/build.sh b/.gitlab/build.sh
index 4847e3929..ee9deb703 100755
--- a/.gitlab/build.sh
+++ b/.gitlab/build.sh
@@ -7,25 +7,38 @@ fatal() {
 
 set -x
 
-export LOGNAME=chameleon_${VERSION}.log
-echo $LOGNAME
-echo build BUILD_OPTIONS $BUILD_OPTIONS | tee -a ${LOGNAME}
-echo build VERSION       $VERSION       | tee -a ${LOGNAME}
-ls -l *.log
-if [[ -d build-$VERSION ]]
-then
-  cd build-$VERSION
-  if [[ $CI_COMMIT_REF_NAME == $CI_DEFAULT_BRANCH ]]
-  then
-    SCAN="scan-build -plist --intercept-first --exclude CMakeFiles --analyze-headers -o analyzer_reports "
+SCAN=""
+
+if [[ "$SYSTEM" != "windows" ]]; then
+  if [[ "$SYSTEM" == "macosx" ]]; then
+    if brew ls --versions starpu > /dev/null; then
+      echo "Starpu is already installed with brew";
+    else
+      echo "Start installing Starpu with brew";
+      brew install --build-from-source ~/brew-repo/starpu.rb;
+    fi
+    # clang is used on macosx and it is not compatible with MORSE_ENABLE_COVERAGE=ON
+    # to avoid the Accelerate framework and get Openblas we use BLA_PREFER_PKGCONFIG
+    cmake -B build-${VERSION} -S . \
+          -DBUILD_SHARED_LIBS=ON -DCMAKE_INSTALL_PREFIX=$PWD/install-${VERSION} \
+          -DMORSE_ENABLE_COVERAGE=OFF -DBLA_PREFER_PKGCONFIG=ON || fatal
   else
-    SCAN=""
+    source .gitlab-ci-env.sh $CHAM_CI_ENV_ARG || fatal
+    if [[ $CI_COMMIT_REF_NAME == $CI_DEFAULT_BRANCH ]]
+    then
+      SCAN="scan-build -plist --intercept-first --exclude CMakeFiles --analyze-headers -o analyzer_reports "
+    fi
+    eval '${SCAN}cmake -B build-${VERSION} -S . -C cmake_modules/gitlab-ci-initial-cache.cmake $BUILD_OPTIONS' || fatal
   fi
-  eval '${SCAN}cmake -C ../cmake_modules/gitlab-ci-initial-cache.cmake .. $BUILD_OPTIONS' || fatal
-  eval '${SCAN}ctest --no-compress-output -j 5 -V -T Build | tee ../${LOGNAME}' || fatal
-  make install | tee -a ../${LOGNAME} || fatal
-  rm install/ -r || fatal
 else
-  echo "$0: directory build-$VERSION does not exist, exit."
-  exit 1
+  # on windows the mpi_f08 interface is missing, see https://www.scivision.dev/windows-mpi-msys2/
+  # do not use static libraries because executables are too large and the build
+  # directory can reach more than 10Go
+  cmake -GNinja -B build-${VERSION} -S . \
+        -DBUILD_SHARED_LIBS=ON -DCMAKE_INSTALL_PREFIX=$PWD/install-${VERSION} \
+        -DCHAMELEON_USE_MPI=OFF \
+        || fatal
 fi
+eval '${SCAN}cmake --build build-${VERSION} -j 4' || fatal
+cmake --install build-${VERSION} || fatal
+rm -r install-${VERSION} || fatal
diff --git a/.gitlab/build.yml b/.gitlab/build.yml
index f2b8f80ad..b79afef18 100644
--- a/.gitlab/build.yml
+++ b/.gitlab/build.yml
@@ -1,65 +1,122 @@
 ---
+.build_script_linux:
+  stage: build
+  tags: ["docker", "large"]
+  extends: .only-master-mr
+  script:
+    - bash .gitlab/build.sh | tee ${LOGNAME}.log
+  artifacts:
+    name: "$CI_JOB_NAME-$CI_COMMIT_REF_SLUG"
+    expire_in: 180 minutes
+    untracked: true
+    when: always
+
 build_hmat:
-  extends: .build_script_template
+  extends: .build_script_linux
   variables:
-    BUILD_OPTIONS: "-DCHAMELEON_USE_CUDA=OFF -DCHAMELEON_USE_MPI=ON -DCHAMELEON_USE_HMAT=ON"
+    SYSTEM: linux
     VERSION: hmat
+    LOGNAME: "chameleon-build-${SYSTEM}-${VERSION}"
+    BUILD_OPTIONS: "-DCHAMELEON_USE_CUDA=OFF -DCHAMELEON_USE_MPI=ON -DCHAMELEON_USE_HMAT=ON"
 
 build_openmp:
-  extends: .build_script_template
+  extends: .build_script_linux
   variables:
-    BUILD_OPTIONS: "-DCHAMELEON_SCHED=OPENMP"
+    SYSTEM: linux
     VERSION: openmp
+    LOGNAME: "chameleon-build-${SYSTEM}-${VERSION}"
+    BUILD_OPTIONS: "-DCHAMELEON_SCHED=OPENMP"
+
 
 build_parsec:
-  extends: .build_script_template
+  extends: .build_script_linux
   variables:
-    BUILD_OPTIONS: "-DCHAMELEON_SCHED=PARSEC"
+    SYSTEM: linux
     VERSION: parsec
+    LOGNAME: "chameleon-build-${SYSTEM}-${VERSION}"
+    BUILD_OPTIONS: "-DCHAMELEON_SCHED=PARSEC"
 
 build_quark:
-  extends: .build_script_template
+  extends: .build_script_linux
   variables:
-    BUILD_OPTIONS: "-DCHAMELEON_SCHED=QUARK"
+    SYSTEM: linux
     VERSION: quark
+    LOGNAME: "chameleon-build-${SYSTEM}-${VERSION}"
+    BUILD_OPTIONS: "-DCHAMELEON_SCHED=QUARK"
 
 build_starpu:
-  extends: .build_script_template
+  extends: .build_script_linux
   variables:
-    BUILD_OPTIONS: "-DCHAMELEON_USE_CUDA=ON -DCHAMELEON_USE_MPI=ON"
+    SYSTEM: linux
     VERSION: starpu
+    LOGNAME: "chameleon-build-${SYSTEM}-${VERSION}"
+    BUILD_OPTIONS: "-DCHAMELEON_USE_CUDA=ON -DCHAMELEON_USE_MPI=ON"
 
 build_starpu_hip:
-  extends: .build_script_template
+  extends: .build_script_linux
   variables:
+    SYSTEM: linux
+    VERSION: starpu_hip
+    LOGNAME: "chameleon-build-${SYSTEM}-${VERSION}"
     CHAM_CI_ENV_ARG: hip
     BUILD_OPTIONS: "-DCHAMELEON_USE_HIP_ROC=ON -DCHAMELEON_USE_MPI=ON"
-    VERSION: starpu_hip
 
 build_starpu_hipcuda:
-  extends: .build_script_template
+  extends: .build_script_linux
   variables:
+    SYSTEM: linux
+    VERSION: starpu_hipcuda
+    LOGNAME: "chameleon-build-${SYSTEM}-${VERSION}"
     CHAM_CI_ENV_ARG: hipcuda
     BUILD_OPTIONS: "-DCHAMELEON_USE_HIP_CUDA=ON -DCHAMELEON_HIPBLAS_PATH=/home/gitlab/hipcuda/hipblas -DCHAMELEON_USE_MPI=ON"
-    VERSION: starpu_hipcuda
 
 build_starpu_simgrid:
-  extends: .build_script_template
+  extends: .build_script_linux
   variables:
+    SYSTEM: linux
+    VERSION: starpu_simgrid
+    LOGNAME: "chameleon-build-${SYSTEM}-${VERSION}"
     CHAM_CI_ENV_ARG: simgrid
     BUILD_OPTIONS: "-DCHAMELEON_SIMULATION=ON -DCHAMELEON_USE_CUDA=ON -DCHAMELEON_USE_MPI=OFF"
-    VERSION: starpu_simgrid
 
-# build_starpu_macosx:
-#   extends: .only-merge-request
-#   stage: build
-#   tags: ['macosx']
-#   variables:
-#     VERSION: starpu
-#   script:
-#     - tools/build_macosx.sh
-#   artifacts:
-#     name: "$CI_JOB_NAME-$CI_COMMIT_REF_SLUG"
-#     expire_in: 2 days
-#     untracked: true
-#     when: always
+build_starpu_macosx:
+  extends: .only-master-mr
+  stage: build
+  tags: ['macosx']
+  variables:
+    SYSTEM: macosx
+    VERSION: starpu
+    LOGNAME: "chameleon-build-${SYSTEM}-${VERSION}"
+  script:
+    - bash .gitlab/build.sh | tee ${LOGNAME}.log
+  artifacts:
+    name: "$CI_JOB_NAME-$CI_COMMIT_REF_SLUG"
+    expire_in: 180 minutes
+    paths:
+      - ${LOGNAME}.log
+  cache:
+    key: "${SYSTEM}-${VERSION}-$CI_COMMIT_REF_SLUG"
+    untracked: true
+    policy: push
+
+.build_starpu_windows:
+  extends: .only-master-mr
+  stage: build
+  tags: ['windows']
+  variables:
+    SYSTEM: windows
+    CHERE_INVOKING: "yes"
+    MSYSTEM: UCRT64
+    VERSION: starpu
+    LOGNAME: "chameleon-build-${SYSTEM}-${VERSION}"
+  script:
+    - bash -lc .gitlab/build.sh | tee "$env:LOGNAME.log"
+  artifacts:
+    name: "$CI_JOB_NAME-$CI_COMMIT_REF_SLUG"
+    expire_in: 180 minutes
+    paths:
+      - ${LOGNAME}.log
+  cache:
+    key: "${SYSTEM}-${VERSION}-$CI_COMMIT_REF_SLUG"
+    untracked: true
+    policy: push
diff --git a/.gitlab/common.yml b/.gitlab/common.yml
index 496fc815e..fd00a2649 100644
--- a/.gitlab/common.yml
+++ b/.gitlab/common.yml
@@ -7,7 +7,6 @@ default:
   tags: ['ci.inria.fr', 'linux', 'large']
 
 # push event: executed only if the source branch name is master or starts with ci-
-# merge request event: not executed
 # schedule event: not executed
 .only-master:
   interruptible: true
@@ -17,56 +16,25 @@ default:
 # push event: executed only if the source branch name is master or starts with ci-
 # merge request event: executed if the source branch name does not start with notest-
 # schedule event: not executed
-.only-merge-request:
+.only-master-mr:
   interruptible: true
   rules:
     - if: ($CI_COMMIT_BRANCH == $CI_DEFAULT_BRANCH || $CI_COMMIT_BRANCH =~ /^ci-.*$/) && $CI_PIPELINE_SOURCE != "schedule"
-    - if: ($CI_MERGE_REQUEST_IID && $CI_MERGE_REQUEST_SOURCE_BRANCH_NAME !~ /^notest-.*$/) && $CI_PIPELINE_SOURCE != "schedule"
+    - if: ($CI_PIPELINE_SOURCE == "merge_request_event" && $CI_MERGE_REQUEST_SOURCE_BRANCH_NAME !~ /^notest-.*$/)
 
-.build_script_template:
-  stage: build
-  extends: .only-merge-request
-  script:
-    - ./.gitlab/build.sh
-  artifacts:
-    name: "$CI_JOB_NAME-$CI_COMMIT_REF_SLUG"
-    expire_in: 2 days
-    untracked: true
-    when: always
+# merge request event: executed if the source branch name does not start with notest-
+.only-mr:
+  interruptible: true
+  rules:
+    - if: ($CI_PIPELINE_SOURCE == "merge_request_event" && $CI_MERGE_REQUEST_SOURCE_BRANCH_NAME !~ /^notest-.*$/)
 
-.test_script_template:
+.test_script_linux:
   stage: test
   script:
-    - ./.gitlab/test.sh
-  coverage: /^\s*lines......:\s*\d+.\d+\%/
+    - bash .gitlab/test.sh | tee ${LOGNAME}.log
   artifacts:
     name: "$CI_JOB_NAME-$CI_COMMIT_REF_SLUG"
-    expire_in: 2 days
+    expire_in: 180 minutes
     untracked: true
-    when: always
     reports:
-      coverage_report:
-        coverage_format: cobertura
-        path: coverage.xml
-      junit: junit.xml
-
-.bench_plafrim_common:
-  rules:
-    - if: $CI_PIPELINE_SOURCE == "schedule"
-  stage: test
-  tags: ['plafrim']
-  timeout: 1 week
-  before_script:
-    - git submodule update --init --recursive
-  script:
-    - ./tools/bench/plafrim/run.sh
-  artifacts:
-    name: "$CI_JOB_NAME-$CI_COMMIT_REF_SLUG"
-    expire_in: 1 week
-    paths:
-      - "chameleon-$NODE-$MPI-$SLURM_NP.err"
-      - "chameleon-$NODE-$MPI-$SLURM_NP.out"
-      - "tools/bench/plafrim/chameleon.csv"
-      - "tools/bench/plafrim/results/$JUBE_ID"
-  variables:
-    PLATFORM: plafrim
+      junit: ${LOGNAME}-junit.xml
diff --git a/.gitlab/coverage.yml b/.gitlab/coverage.yml
index cc923befb..5f9db28dd 100644
--- a/.gitlab/coverage.yml
+++ b/.gitlab/coverage.yml
@@ -5,19 +5,34 @@
 # Rk: We do not take into account the simgrid lcov file for now, as it is empty with new testings
 #
 ---
-coverage:
-  extends: .only-merge-request
-  interruptible: true
-  stage: analyse
+.coverage:
+  stage: coverage
   script:
     - tools/coverage.sh
   coverage: /^\s*lines......:\s*\d+.\d+\%/
   artifacts:
     name: "$CI_JOB_NAME-$CI_COMMIT_REF_SLUG"
-    expire_in: 2 days
-    untracked: true
+    expire_in: 180 minutes
+    paths:
+      - chameleon-*.lcov
+      - chameleon.lcov
+      - chameleon_coverage.xml
+      - coverage/
     when: always
     reports:
       coverage_report:
         coverage_format: cobertura
-        path: coverage.xml
+        path: chameleon_coverage.xml
+
+coverage_master:
+  extends:
+    - .coverage
+    - .only-master
+  needs: [test_openmp_master,test_parsec_master,test_quark_master,test_starpu_master,test_starpu_simgrid_simu_all]
+
+coverage_mr:
+  extends: .coverage
+  interruptible: true
+  rules:
+    - if: ($CI_PIPELINE_SOURCE == "merge_request_event" && $CI_MERGE_REQUEST_SOURCE_BRANCH_NAME !~ /^notest-.*$/)
+  needs: [test_openmp_mr,test_parsec_mr,test_quark_mr,test_starpu_mr,test_starpu_simgrid_simu_all]
diff --git a/.gitlab/coverity.yml b/.gitlab/coverity.yml
index 593d3e3f1..ddb922212 100644
--- a/.gitlab/coverity.yml
+++ b/.gitlab/coverity.yml
@@ -1,12 +1,18 @@
 ---
 coverity:
-  extends: .only-master
-  stage: analyse
+  stage: analyze
+  tags: ["docker", "large"]
+  interruptible: true
+  rules:
+    - if: ($CI_COMMIT_BRANCH == $CI_DEFAULT_BRANCH || $CI_COMMIT_BRANCH =~ /^ci-.*$/) && $CI_PIPELINE_SOURCE != "schedule"
+    - if: ($CI_PIPELINE_SOURCE == "merge_request_event" && $CI_MERGE_REQUEST_SOURCE_BRANCH_NAME !~ /^notest-.*$/)
+      when: manual
+      allow_failure: true
   dependencies: []
   variables:
     VERSION: coverity
   script:
-    - (cd build-$VERSION &&
+    - (mkdir -p build-$VERSION && cd build-$VERSION &&
        cmake .. -C ../cmake_modules/gitlab-ci-initial-cache.cmake
                 -DCHAMELEON_USE_CUDA=ON -DCHAMELEON_USE_MPI=ON &&
        cov-build --dir ../cov-int make -j 4)
diff --git a/.gitlab/pages.yml b/.gitlab/pages.yml
index e47546195..5299509e3 100644
--- a/.gitlab/pages.yml
+++ b/.gitlab/pages.yml
@@ -2,7 +2,7 @@
 pages:
   stage: deploy
   extends: .only-master
-  dependencies: [coverage]
+  needs: [coverage_master]
   artifacts:
     name: "$CI_JOB_NAME-$CI_COMMIT_REF_SLUG"
     expire_in: 1 week
diff --git a/.gitlab/preliminary.yml b/.gitlab/preliminary.yml
index 8c1a66437..bc1ba9132 100644
--- a/.gitlab/preliminary.yml
+++ b/.gitlab/preliminary.yml
@@ -7,7 +7,7 @@ preliminary_checks:
   interruptible: true
   rules:
     - if: ($CI_COMMIT_BRANCH == $CI_DEFAULT_BRANCH || $CI_COMMIT_BRANCH =~ /^ci-.*$/) && $CI_PIPELINE_SOURCE != "schedule"
-    - if: $CI_MERGE_REQUEST_IID && $CI_PIPELINE_SOURCE != "schedule"
+    - if: ($CI_PIPELINE_SOURCE == "merge_request_event")
   parallel:
     matrix:
       - TEST: [rebase, draft, header]
diff --git a/.gitlab/sonarqube.yml b/.gitlab/sonarqube.yml
index 20f9dab5a..75efd53ca 100644
--- a/.gitlab/sonarqube.yml
+++ b/.gitlab/sonarqube.yml
@@ -1,36 +1,38 @@
 ---
-sonarqube:
-  stage: analyse
-  extends:
-    - .only-master
-  needs: [test_openmp_shm_c,test_openmp_shm_d,test_openmp_shm_s,test_openmp_shm_z,
-          test_parsec_shm_c,test_parsec_shm_d,test_parsec_shm_s,test_parsec_shm_z,
-          test_quark_shm_c,test_quark_shm_d,test_quark_shm_s,test_quark_shm_z,
-          test_starpu_shm_c,test_starpu_shm_d,test_starpu_shm_s,test_starpu_shm_z,
-          test_starpu_mpi_c,test_starpu_mpi_d,test_starpu_mpi_s,test_starpu_mpi_z,
-          test_starpu_simgrid_simu_all]
-  dependencies: [test_openmp_shm_c,test_openmp_shm_d,test_openmp_shm_s,test_openmp_shm_z,
-                 test_parsec_shm_c,test_parsec_shm_d,test_parsec_shm_s,test_parsec_shm_z,
-                 test_quark_shm_c,test_quark_shm_d,test_quark_shm_s,test_quark_shm_z,
-                 test_starpu_shm_c,test_starpu_shm_d,test_starpu_shm_s,test_starpu_shm_z,
-                 test_starpu_mpi_c,test_starpu_mpi_d,test_starpu_mpi_s,test_starpu_mpi_z,
-                 test_starpu_simgrid_simu_all]
+.sonarqube:
+  stage: analyze
+  tags: ["docker", "large"]
   variables:
     VERSION: sonarqube
   script:
+    - ls -l build*/*.json
+    - ls -l chameleon-build*.log
+    - ls -l chameleon-test*junit.xml
+    - ls -l chameleon_coverage.xml
     - cat *.log > chameleon_build.log
     - ./tools/analysis.sh
-  coverage: /^\s*lines:\s*\d+.\d+\%/
   artifacts:
     name: "$CI_JOB_NAME-$CI_COMMIT_REF_SLUG"
-    expire_in: 2 days
+    expire_in: 180 minutes
     when: always
     paths:
-      - coverage.xml
-      - chameleon_coverage.xml
+      - filelist.txt
       - chameleon_cppcheck.xml
+      - sonar-project.properties
       - sonar.log
-    reports:
-      coverage_report:
-        coverage_format: cobertura
-        path: coverage.xml
+    when: always
+
+sonarqube_master:
+  extends:
+    - .sonarqube
+    - .only-master
+  needs: [test_openmp_master,test_parsec_master,test_quark_master,test_starpu_master,test_starpu_simgrid_simu_all,coverage_master]
+
+sonarqube_mr:
+  extends: .sonarqube
+  interruptible: true
+  rules:
+    - if: ($CI_PIPELINE_SOURCE == "merge_request_event" && $CI_MERGE_REQUEST_SOURCE_BRANCH_NAME !~ /^notest-.*$/)
+      when: manual
+      allow_failure: true
+  needs: [test_openmp_mr,test_parsec_mr,test_quark_mr,test_starpu_mr,test_starpu_simgrid_simu_all,coverage_mr]
diff --git a/.gitlab/test.sh b/.gitlab/test.sh
index 677a10162..7b0e43268 100755
--- a/.gitlab/test.sh
+++ b/.gitlab/test.sh
@@ -7,24 +7,13 @@ fatal() {
 
 set -x
 
-export LOGNAME=chameleon_${VERSION}_${CATEGORY}_${PRECISION}
-echo $LOGNAME
-echo test TESTS_RESTRICTION $TESTS_RESTRICTION  | tee -a ${LOGNAME}.log
-echo test VERSION $VERSION     | tee -a ${LOGNAME}.log
-echo test CATEGORY $CATEGORY   | tee -a ${LOGNAME}.log
-echo test PRECISION $PRECISION | tee -a ${LOGNAME}.log
-ls -l *.log
-if [[ -d build-$VERSION ]]
-then
-  cd build-$VERSION
-  eval "ctest --no-compress-output $TESTS_RESTRICTION -T Test --output-junit ../${LOGNAME}.junit | tee -a ../${LOGNAME}.log" || fatal
-  cd $CI_PROJECT_DIR || fatal
-  gcovr --xml-pretty --exclude-unreachable-branches --print-summary -o ${LOGNAME}.cov --root $CI_PROJECT_DIR || fatal
-  lcov --directory build-$VERSION --capture --output-file ${LOGNAME}.lcov || fatal
-  lcov --summary ${LOGNAME}.lcov || fatal
-  cp ${LOGNAME}.junit junit.xml || fatal
-  cp ${LOGNAME}.cov coverage.xml || fatal
-else
-  echo "$0: directory build-$VERSION does not exist, exit."
-  exit 1
+cd build-$VERSION
+source ../.gitlab-ci-env.sh $CHAM_CI_ENV_ARG || fatal
+CTESTCOMMAND=`echo "ctest --output-on-failure --no-compress-output $TESTS_RESTRICTION -T Test --output-junit ../${LOGNAME}-junit.xml"`
+$CTESTCOMMAND || fatal
+if [[ "$SYSTEM" == "linux" ]]; then
+  # clang is used on macosx and it is not compatible with MORSE_ENABLE_COVERAGE=ON
+  # so that we can only make the coverage report on the linux runner with gcc
+  cd ..
+  lcov --directory build-$VERSION --capture --output-file ${LOGNAME}.lcov
 fi
diff --git a/.gitlab/test_hmat.yml b/.gitlab/test_hmat.yml
index 23cc8a5cc..0e00d32db 100644
--- a/.gitlab/test_hmat.yml
+++ b/.gitlab/test_hmat.yml
@@ -1,23 +1,13 @@
 ---
-.test_hmat_template:
-  extends: .test_script_template
-  needs: [build_hmat]
-  dependencies: [build_hmat]
-
-.test_hmat_template_master: &test_hmat_master
-  extends:
-    - .test_hmat_template
-    - .only-master
-
-.test_hmat_template_branches: &test_hmat_branches
-  extends:
-    - .test_hmat_template
-    - .only-merge-request
-
 test_hmat:
-  <<: *test_hmat_branches
+  extends:
+    - .test_script_linux
+    - .only-master-mr
+  needs: [build_hmat]
   variables:
+    SYSTEM: linux
     VERSION: hmat
     CATEGORY: none
     PRECISION: all
-    TESTS_RESTRICTION: "-R \"testBEM_\""
+    LOGNAME: "chameleon-test-${SYSTEM}-${VERSION}-${CATEGORY}-${PRECISION}"
+    TESTS_RESTRICTION: "-R testBEM_"
diff --git a/.gitlab/test_openmp.yml b/.gitlab/test_openmp.yml
index dbb9271bc..cfbb14f3c 100644
--- a/.gitlab/test_openmp.yml
+++ b/.gitlab/test_openmp.yml
@@ -1,47 +1,27 @@
 ---
-.test_openmp_template: &test_openmp
-  extends: .test_script_template
+.test_openmp:
+  extends: .test_script_linux
   needs: [build_openmp]
-  dependencies: [build_openmp]
-
-.test_openmp_template_master: &test_openmp_master
-  extends:
-    - .test_openmp_template
-    - .only-master
-
-.test_openmp_template_branches: &test_openmp_branches
-  extends:
-    - .test_openmp_template
-    - .only-merge-request
-
-test_openmp_shm_s:
-  <<: *test_openmp_master
+  interruptible: true
   variables:
+    SYSTEM: linux
     VERSION: openmp
     CATEGORY: shm
-    PRECISION: s
-    TESTS_RESTRICTION: "-R \"_${CATEGORY}_${PRECISION}\""
+    LOGNAME: "chameleon-test-${SYSTEM}-${VERSION}-${CATEGORY}-${PRECISION}"
+    TESTS_RESTRICTION: "-R _${CATEGORY}_${PRECISION}"
 
-test_openmp_shm_d:
-  <<: *test_openmp_master
-  variables:
-    VERSION: openmp
-    CATEGORY: shm
-    PRECISION: d
-    TESTS_RESTRICTION: "-R \"_${CATEGORY}_${PRECISION}\""
+test_openmp_master:
+  extends: .test_openmp
+  rules:
+    - if: ($CI_COMMIT_BRANCH == $CI_DEFAULT_BRANCH || $CI_COMMIT_BRANCH =~ /^ci-.*$/) && $CI_PIPELINE_SOURCE != "schedule"
+  parallel:
+    matrix:
+      - PRECISION: [s, d, c, z]
 
-test_openmp_shm_c:
-  <<: *test_openmp_master
-  variables:
-    VERSION: openmp
-    CATEGORY: shm
-    PRECISION: c
-    TESTS_RESTRICTION: "-R \"_${CATEGORY}_${PRECISION}\""
-
-test_openmp_shm_z:
-  <<: *test_openmp_branches
-  variables:
-    VERSION: openmp
-    CATEGORY: shm
-    PRECISION: z
-    TESTS_RESTRICTION: "-R \"_${CATEGORY}_${PRECISION}\""
+test_openmp_mr:
+  extends: .test_openmp
+  rules:
+    - if: ($CI_PIPELINE_SOURCE == "merge_request_event" && $CI_MERGE_REQUEST_SOURCE_BRANCH_NAME !~ /^notest-.*$/)
+  parallel:
+    matrix:
+      - PRECISION: [z]
diff --git a/.gitlab/test_parsec.yml b/.gitlab/test_parsec.yml
index 842c7f13f..52764d27b 100644
--- a/.gitlab/test_parsec.yml
+++ b/.gitlab/test_parsec.yml
@@ -1,79 +1,27 @@
 ---
-.test_parsec_template: &test_parsec
-  extends: .test_script_template
+.test_parsec:
+  extends: .test_script_linux
   needs: [build_parsec]
-  dependencies: [build_parsec]
-
-.test_parsec_template_master: &test_parsec_master
-  extends:
-    - .test_parsec_template
-    - .only-master
-
-.test_parsec_template_branches: &test_parsec_branches
-  extends:
-    - .test_parsec_template
-    - .only-merge-request
-
-test_parsec_shm_s:
-  <<: *test_parsec_master
-  variables:
-    VERSION: parsec
-    CATEGORY: shm
-    PRECISION: s
-    TESTS_RESTRICTION: "-R \"_${CATEGORY}_${PRECISION}\""
-
-test_parsec_shm_d:
-  <<: *test_parsec_master
+  interruptible: true
   variables:
+    SYSTEM: linux
     VERSION: parsec
     CATEGORY: shm
-    PRECISION: d
-    TESTS_RESTRICTION: "-R \"_${CATEGORY}_${PRECISION}\""
-
-test_parsec_shm_c:
-  <<: *test_parsec_branches
-  variables:
-    VERSION: parsec
-    CATEGORY: shm
-    PRECISION: c
-    TESTS_RESTRICTION: "-R \"_${CATEGORY}_${PRECISION}\""
-
-test_parsec_shm_z:
-  <<: *test_parsec_master
-  variables:
-    VERSION: parsec
-    CATEGORY: shm
-    PRECISION: z
-    TESTS_RESTRICTION: "-R \"_${CATEGORY}_${PRECISION}\""
-
-# test_parsec_mpi_s:
-#   <<: *test_parsec_branches
-#   variables:
-#     VERSION: parsec
-#     CATEGORY: mpi
-#     PRECISION: s
-#     TESTS_RESTRICTION: "-R \"_${CATEGORY}_${PRECISION}\""
-
-# test_parsec_mpi_d:
-#   <<: *test_parsec_master
-#   variables:
-#     VERSION: parsec
-#     CATEGORY: mpi
-#     PRECISION: d
-#     TESTS_RESTRICTION: "-R \"_${CATEGORY}_${PRECISION}\""
-
-# test_parsec_mpi_c:
-#   <<: *test_parsec_master
-#   variables:
-#     VERSION: parsec
-#     CATEGORY: mpi
-#     PRECISION: c
-#     TESTS_RESTRICTION: "-R \"_${CATEGORY}_${PRECISION}\""
-
-# test_parsec_mpi_z:
-#   <<: *test_parsec_master
-#   variables:
-#     VERSION: parsec
-#     CATEGORY: mpi
-#     PRECISION: z
-#     TESTS_RESTRICTION: "-R \"_${CATEGORY}_${PRECISION}\""
+    LOGNAME: "chameleon-test-${SYSTEM}-${VERSION}-${CATEGORY}-${PRECISION}"
+    TESTS_RESTRICTION: "-R _${CATEGORY}_${PRECISION}"
+
+test_parsec_master:
+  extends: .test_parsec
+  rules:
+    - if: ($CI_COMMIT_BRANCH == $CI_DEFAULT_BRANCH || $CI_COMMIT_BRANCH =~ /^ci-.*$/) && $CI_PIPELINE_SOURCE != "schedule"
+  parallel:
+    matrix:
+      - PRECISION: [s, d, c, z]
+
+test_parsec_mr:
+  extends: .test_parsec
+  rules:
+    - if: ($CI_PIPELINE_SOURCE == "merge_request_event" && $CI_MERGE_REQUEST_SOURCE_BRANCH_NAME !~ /^notest-.*$/)
+  parallel:
+    matrix:
+      - PRECISION: [c]
diff --git a/.gitlab/test_quark.yml b/.gitlab/test_quark.yml
index 29421613e..d1ede5b58 100644
--- a/.gitlab/test_quark.yml
+++ b/.gitlab/test_quark.yml
@@ -1,47 +1,27 @@
 ---
-.test_quark_template: &test_quark
-  extends: .test_script_template
+.test_quark:
+  extends: .test_script_linux
   needs: [build_quark]
-  dependencies: [build_quark]
-
-.test_quark_template_master: &test_quark_master
-  extends:
-    - .test_quark_template
-    - .only-master
-
-.test_quark_template_branches: &test_quark_branches
-  extends:
-    - .test_quark_template
-    - .only-merge-request
-
-test_quark_shm_s:
-  <<: *test_quark_branches
+  interruptible: true
   variables:
+    SYSTEM: linux
     VERSION: quark
     CATEGORY: shm
-    PRECISION: s
-    TESTS_RESTRICTION: "-R \"_${CATEGORY}_${PRECISION}\""
+    LOGNAME: "chameleon-test-${SYSTEM}-${VERSION}-${CATEGORY}-${PRECISION}"
+    TESTS_RESTRICTION: "-R _${CATEGORY}_${PRECISION}"
 
-test_quark_shm_d:
-  <<: *test_quark_master
-  variables:
-    VERSION: quark
-    CATEGORY: shm
-    PRECISION: d
-    TESTS_RESTRICTION: "-R \"_${CATEGORY}_${PRECISION}\""
+test_quark_master:
+  extends: .test_quark
+  rules:
+    - if: ($CI_COMMIT_BRANCH == $CI_DEFAULT_BRANCH || $CI_COMMIT_BRANCH =~ /^ci-.*$/) && $CI_PIPELINE_SOURCE != "schedule"
+  parallel:
+    matrix:
+      - PRECISION: [s, d, c, z]
 
-test_quark_shm_c:
-  <<: *test_quark_master
-  variables:
-    VERSION: quark
-    CATEGORY: shm
-    PRECISION: c
-    TESTS_RESTRICTION: "-R \"_${CATEGORY}_${PRECISION}\""
-
-test_quark_shm_z:
-  <<: *test_quark_master
-  variables:
-    VERSION: quark
-    CATEGORY: shm
-    PRECISION: z
-    TESTS_RESTRICTION: "-R \"_${CATEGORY}_${PRECISION}\""
+test_quark_mr:
+  extends: .test_quark
+  rules:
+    - if: ($CI_PIPELINE_SOURCE == "merge_request_event" && $CI_MERGE_REQUEST_SOURCE_BRANCH_NAME !~ /^notest-.*$/)
+  parallel:
+    matrix:
+      - PRECISION: [s]
diff --git a/.gitlab/test_starpu.yml b/.gitlab/test_starpu.yml
index c22c4bd55..bbb562a63 100644
--- a/.gitlab/test_starpu.yml
+++ b/.gitlab/test_starpu.yml
@@ -1,97 +1,80 @@
 ---
-.test_starpu_template:
-  extends: .test_script_template
+.test_starpu:
+  extends: .test_script_linux
   needs: [build_starpu]
-  dependencies: [build_starpu]
-
-.test_starpu_template_master: &test_starpu_master
-  extends:
-    - .test_starpu_template
-    - .only-master
-
-.test_starpu_template_branches: &test_starpu_branches
-  extends:
-    - .test_starpu_template
-    - .only-merge-request
-
-test_starpu_shm_s:
-  <<: *test_starpu_master
+  interruptible: true
   variables:
+    SYSTEM: linux
     VERSION: starpu
-    CATEGORY: shm
-    PRECISION: s
-    TESTS_RESTRICTION: "-R \"_${CATEGORY}_${PRECISION}\""
+    LOGNAME: "chameleon-test-${SYSTEM}-${VERSION}-${CATEGORY}-${PRECISION}"
+    TESTS_RESTRICTION: "-R _${CATEGORY}_${PRECISION}|example -E sytrf|sysv"
 
-test_starpu_shm_d:
-  <<: *test_starpu_branches
-  variables:
-    VERSION: starpu
-    CATEGORY: shm
-    PRECISION: d
-    TESTS_RESTRICTION: "-R \"_${CATEGORY}_${PRECISION}|example\""
+test_starpu_master:
+  extends: .test_starpu
+  rules:
+    - if: ($CI_COMMIT_BRANCH == $CI_DEFAULT_BRANCH || $CI_COMMIT_BRANCH =~ /^ci-.*$/) && $CI_PIPELINE_SOURCE != "schedule"
+  parallel:
+    matrix:
+      - PRECISION: [s, d, c, z]
+        CATEGORY: [shm, mpi]
 
-test_starpu_shm_c:
-  <<: *test_starpu_master
-  variables:
-    VERSION: starpu
-    CATEGORY: shm
-    PRECISION: c
-    TESTS_RESTRICTION: "-R \"_${CATEGORY}_${PRECISION}\""
+test_starpu_mr:
+  extends: .test_starpu
+  rules:
+    - if: ($CI_PIPELINE_SOURCE == "merge_request_event" && $CI_MERGE_REQUEST_SOURCE_BRANCH_NAME !~ /^notest-.*$/)
+  parallel:
+    matrix:
+      - PRECISION: [d]
+        CATEGORY: [shm]
+      - PRECISION: [s]
+        CATEGORY: [mpi]
 
-test_starpu_shm_z:
-  <<: *test_starpu_master
+test_starpu_macosx:
+  stage: test
+  tags: ['macosx']
+  extends: .only-master-mr
+  needs: [build_starpu_macosx]
   variables:
+    SYSTEM: macosx
     VERSION: starpu
-    CATEGORY: shm
-    PRECISION: z
-    TESTS_RESTRICTION: "-R \"_${CATEGORY}_${PRECISION}\""
+    LOGNAME: "chameleon-test-${SYSTEM}-${VERSION}-example"
+    TESTS_RESTRICTION: "-R example"
+  script:
+    - bash .gitlab/test.sh | tee ${LOGNAME}.log
+  artifacts:
+    name: "$CI_JOB_NAME-$CI_COMMIT_REF_SLUG"
+    expire_in: 180 minutes
+    paths:
+      - ${LOGNAME}.log
+    reports:
+      junit: ${LOGNAME}-junit.xml
+  cache:
+    key: "${SYSTEM}-${VERSION}-$CI_COMMIT_REF_SLUG"
+    untracked: true
+    policy: pull
 
-test_starpu_mpi_s:
-  <<: *test_starpu_branches
+.test_starpu_windows:
+  stage: test
+  tags: ['windows']
+  extends: .only-master-mr
+  needs: [build_starpu_windows]
   variables:
+    SYSTEM: windows
+    CHERE_INVOKING: "yes"
+    MSYSTEM: UCRT64
     VERSION: starpu
-    CATEGORY: mpi
-    PRECISION: s
-    TESTS_RESTRICTION: "-R \"_${CATEGORY}_${PRECISION}\""
-
-test_starpu_mpi_d:
-  <<: *test_starpu_master
-  variables:
-    VERSION: starpu
-    CATEGORY: mpi
-    PRECISION: d
-    TESTS_RESTRICTION: "-R \"_${CATEGORY}_${PRECISION}\""
-
-test_starpu_mpi_c:
-  <<: *test_starpu_master
-  variables:
-    VERSION: starpu
-    CATEGORY: mpi
-    PRECISION: c
-    TESTS_RESTRICTION: "-R \"_${CATEGORY}_${PRECISION}\""
-
-test_starpu_mpi_z:
-  <<: *test_starpu_master
-  variables:
-    VERSION: starpu
-    CATEGORY: mpi
-    PRECISION: z
-    TESTS_RESTRICTION: "-R \"_${CATEGORY}_${PRECISION}\""
-
-# test_starpu_shm_s_macosx:
-#   extends: .only-merge-request
-#   stage: test
-#   tags: ['macosx']
-#   needs: [build_starpu_macosx]
-#   dependencies: [build_starpu_macosx]
-#   variables:
-#     VERSION: starpu
-#   script:
-#     - cd build-starpu && ctest --no-compress-output -R test_shm_s -T Test --output-junit ../chameleon_macosx.junit | tee -a ../chameleon_macosx.log
-#   artifacts:
-#     name: "$CI_JOB_NAME-$CI_COMMIT_REF_SLUG"
-#     expire_in: 2 days
-#     untracked: true
-#     when: always
-#     reports:
-#       junit: chameleon_macosx.junit
+    LOGNAME: "chameleon-test-${SYSTEM}-${VERSION}-example"
+    TESTS_RESTRICTION: "-R example"
+  script:
+    - bash -lc .gitlab/test.sh | tee "$env:LOGNAME.log"
+  artifacts:
+    name: "$CI_JOB_NAME-$CI_COMMIT_REF_SLUG"
+    expire_in: 180 minutes
+    paths:
+      - ${LOGNAME}.log
+    reports:
+      junit: ${LOGNAME}-junit.xml
+  cache:
+    key: "${SYSTEM}-${VERSION}-$CI_COMMIT_REF_SLUG"
+    untracked: true
+    policy: pull
diff --git a/.gitlab/test_starpu_simgrid.yml b/.gitlab/test_starpu_simgrid.yml
index 17ae0afb6..988ada631 100644
--- a/.gitlab/test_starpu_simgrid.yml
+++ b/.gitlab/test_starpu_simgrid.yml
@@ -1,25 +1,15 @@
 ---
-.test_starpu_simgrid_template: &test_starpu_simgrid
-  extends: .test_script_template
-  needs: [build_starpu_simgrid]
-  dependencies: [build_starpu_simgrid]
-
-.test_starpu_simgrid_template_master: &test_starpu_simgrid_master
-  extends:
-    - .test_starpu_simgrid_template
-    - .only-master
-
-.test_starpu_simgrid_template_branches: &test_starpu_simgrid_branches
-  extends:
-    - .test_starpu_simgrid_template
-    - .only-merge-request
-
 test_starpu_simgrid_simu_all:
-  <<: *test_starpu_simgrid_branches
+  extends:
+    - .test_script_linux
+    - .only-master-mr
+  needs: [build_starpu_simgrid]
   variables:
     STARPU_WORKERS_NOBIND: 1
     CHAM_CI_ENV_ARG: simgrid
+    SYSTEM: linux
     VERSION: starpu_simgrid
     CATEGORY: simu
     PRECISION: all
-    TESTS_RESTRICTION: "-R \"_${CATEGORY}\""
+    LOGNAME: "chameleon-test-${SYSTEM}-${VERSION}-${CATEGORY}-${PRECISION}"
+    TESTS_RESTRICTION: "-R _${CATEGORY}"
diff --git a/.gitlab/validate.sh b/.gitlab/validate.sh
new file mode 100755
index 000000000..daf827c2c
--- /dev/null
+++ b/.gitlab/validate.sh
@@ -0,0 +1,58 @@
+#!/usr/bin/env bash
+###
+#
+#  @file validate.sh
+#  @copyright 2023-2023 Bordeaux INP, CNRS (LaBRI UMR 5800), Inria,
+#                       Univ. Bordeaux. All rights reserved.
+#
+#  @version 1.0.0
+#  @author Mathieu Faverge
+#  @author Florent Pruvost
+#  @date 2023-09-22
+#
+###
+
+# Check some metrics on sonarqube (https://sonarqube.inria.fr/sonarqube/)
+# and depending on the value return 0 (success) or 1 (failure).
+
+if [ $# -gt 0 ]; then
+  METRIC=$1
+fi
+METRIC=${METRIC:-BUG}
+
+if [[ -z $CI_MERGE_REQUEST_IID || -z $CI_PROJECT_NAMESPACE || -z $CI_PROJECT_NAME ]]; then
+  echo "One of the variables CI_MERGE_REQUEST_IID, CI_PROJECT_NAMESPACE,
+  CI_PROJECT_NAME is empty. This script must be used during a gitlab merge
+  request only -> Failure."
+  exit 1
+fi
+
+if [[ -z $SONARQUBE_LOGIN ]]; then
+  echo "SONARQUBE_LOGIN is empty, please give a valid sonarqube user's token,
+  with permissions set on the project -> Failure."
+  exit 1
+fi
+
+if [[ $METRIC == "BUG" ]]; then
+  BUG=`curl -u $TOKEN: -X GET "https://sonarqube.inria.fr/sonarqube/api/measures/component?component=${CI_PROJECT_NAMESPACE}%3A${CI_PROJECT_NAME}&pullRequest=${CI_MERGE_REQUEST_IID}&metricKeys=new_bugs" |jq '.component.measures[0].period.value' | sed -e "s#\"##g"`
+  if [[ $BUG > 0 ]]; then
+    echo "%{BUG} new bugs detected by Sonarqube -> Failure."
+    exit 1
+  else
+    echo "No new bugs detected by Sonarqube -> Success."
+    exit 0
+  fi
+elif [[ $METRIC == "COVERAGE" ]]; then
+  COV=`curl -u $TOKEN: -X GET "https://sonarqube.inria.fr/sonarqube/api/measures/component?component=${CI_PROJECT_NAMESPACE}%3A${CI_PROJECT_NAME}&pullRequest=${CI_MERGE_REQUEST_IID}&metricKeys=new_coverage" |jq '.component.measures[0].period.value' | sed -e "s#\"##g"`
+  if [[ $COV == "null" || -z $COV  ]]; then
+    echo "Coverage is empty, certainly that there are no lines of new code (considered during the analysis) to compare -> Success."
+  else
+    if [[ $COV < 80 ]]; then
+      echo "Coverage on new lines is ${COV}%, which is < 80% -> Failure."
+      exit 1
+    else
+      echo "Coverage on new lines is ${COV}%, which is >= 80% -> Success."
+      exit 0
+    fi
+  fi
+fi
diff --git a/.gitlab/validate.yml b/.gitlab/validate.yml
new file mode 100644
index 000000000..9a2dbb5d1
--- /dev/null
+++ b/.gitlab/validate.yml
@@ -0,0 +1,12 @@
+---
+validate:
+  stage: validate
+  tags: ["docker", "large"]
+  extends: .only-mr
+  needs: [sonarqube_mr]
+  parallel:
+    matrix:
+      - METRIC: [BUG, COVERAGE]
+  script:
+    - ./.gitlab/validate.sh $METRIC
+  allow_failure: true
\ No newline at end of file
diff --git a/CMakeLists.txt b/CMakeLists.txt
index 27bb9597f..87a112eb8 100644
--- a/CMakeLists.txt
+++ b/CMakeLists.txt
@@ -33,7 +33,7 @@
 #  @date 2023-07-04
 #
 ###
-cmake_minimum_required(VERSION 3.3)
+cmake_minimum_required(VERSION 3.5)
 project(CHAMELEON Fortran C CXX)
 
 # directly make an error if in-source build
diff --git a/cmake_modules/gitlab-ci-initial-cache.cmake b/cmake_modules/gitlab-ci-initial-cache.cmake
index ce982e303..47dd8110e 100644
--- a/cmake_modules/gitlab-ci-initial-cache.cmake
+++ b/cmake_modules/gitlab-ci-initial-cache.cmake
@@ -1,5 +1,5 @@
 set(BUILD_SHARED_LIBS "ON" CACHE BOOL "")
-set(CMAKE_INSTALL_PREFIX "$ENV{PWD}/install" CACHE PATH "")
+set(CMAKE_INSTALL_PREFIX "$ENV{PWD}/install-$ENV{VERSION}" CACHE PATH "")
 set(CMAKE_VERBOSE_MAKEFILE "ON" CACHE BOOL "")
 
 set(CMAKE_C_FLAGS "-Werror")
diff --git a/cmake_modules/morse_cmake b/cmake_modules/morse_cmake
index 332bf7de0..022397487 160000
--- a/cmake_modules/morse_cmake
+++ b/cmake_modules/morse_cmake
@@ -1 +1 @@
-Subproject commit 332bf7de07c7eaf85cf370236d5a209b83a58dd7
+Subproject commit 022397487f40fb7688e5d0caef2e4708ca4b5fea
diff --git a/doc/CMakeLists.txt b/doc/CMakeLists.txt
index 2c34b5c3b..309124f53 100644
--- a/doc/CMakeLists.txt
+++ b/doc/CMakeLists.txt
@@ -26,7 +26,7 @@
 #
 ###
 
-cmake_minimum_required(VERSION 3.1)
+cmake_minimum_required(VERSION 3.5)
 
 #############################################
 #                                           #
diff --git a/doc/dev/CMakeLists.txt b/doc/dev/CMakeLists.txt
index 049907dac..1bd9185bc 100644
--- a/doc/dev/CMakeLists.txt
+++ b/doc/dev/CMakeLists.txt
@@ -26,7 +26,7 @@
 #
 ###
 
-cmake_minimum_required(VERSION 3.1)
+cmake_minimum_required(VERSION 3.5)
 
 # Looking for doxygen
 # -------------------
diff --git a/doc/user/CMakeLists.txt b/doc/user/CMakeLists.txt
index b0ced19e0..635d662e6 100644
--- a/doc/user/CMakeLists.txt
+++ b/doc/user/CMakeLists.txt
@@ -21,7 +21,7 @@
 #
 ###
 
-cmake_minimum_required(VERSION 3.1)
+cmake_minimum_required(VERSION 3.5)
 
 # Create files in binary dir
 # --------------------------
diff --git a/example/link_chameleon/CMakeLists.txt b/example/link_chameleon/CMakeLists.txt
index dc282bc3b..87d9bd877 100644
--- a/example/link_chameleon/CMakeLists.txt
+++ b/example/link_chameleon/CMakeLists.txt
@@ -22,7 +22,7 @@
 #  @date 2022-02-22
 #
 ###
-cmake_minimum_required(VERSION 3.1)
+cmake_minimum_required(VERSION 3.5)
 project(LINK_CHAMELEON Fortran C CXX)
 
 find_package(CHAMELEON)
diff --git a/runtime/openmp/CMakeLists.txt b/runtime/openmp/CMakeLists.txt
index b9b712e5d..fb5e9cd5e 100644
--- a/runtime/openmp/CMakeLists.txt
+++ b/runtime/openmp/CMakeLists.txt
@@ -26,7 +26,7 @@
 #  @date 2022-02-22
 #
 ###
-cmake_minimum_required(VERSION 3.1)
+cmake_minimum_required(VERSION 3.5)
 
 find_package(OpenMP REQUIRED)
 morse_export_imported_target(OpenMP OpenMP_C openmp chameleon)
diff --git a/runtime/parsec/CMakeLists.txt b/runtime/parsec/CMakeLists.txt
index 573d31d79..fb6cc64bc 100644
--- a/runtime/parsec/CMakeLists.txt
+++ b/runtime/parsec/CMakeLists.txt
@@ -26,7 +26,7 @@
 #  @date 2022-02-22
 #
 ###
-cmake_minimum_required(VERSION 3.1)
+cmake_minimum_required(VERSION 3.5)
 
 find_package( PARSEC REQUIRED )
 morse_export_imported_target(MORSE PARSEC parsec chameleon)
diff --git a/runtime/quark/CMakeLists.txt b/runtime/quark/CMakeLists.txt
index e4acef712..2b8409a1a 100644
--- a/runtime/quark/CMakeLists.txt
+++ b/runtime/quark/CMakeLists.txt
@@ -26,7 +26,7 @@
 #  @date 2022-02-22
 #
 ###
-cmake_minimum_required(VERSION 3.1)
+cmake_minimum_required(VERSION 3.5)
 
 find_package( QUARK REQUIRED COMPONENTS HWLOC )
 morse_export_imported_target(MORSE QUARK quark chameleon)
diff --git a/runtime/starpu/CMakeLists.txt b/runtime/starpu/CMakeLists.txt
index 2107134e1..4d4899569 100644
--- a/runtime/starpu/CMakeLists.txt
+++ b/runtime/starpu/CMakeLists.txt
@@ -29,7 +29,7 @@
 #  @date 2023-08-22
 #
 ###
-cmake_minimum_required(VERSION 3.1)
+cmake_minimum_required(VERSION 3.5)
 
 include(CheckSymbolExists)
 include(CheckStructHasMember)
diff --git a/testing/values.c b/testing/values.c
index 5e4bdda14..31e7e0b74 100644
--- a/testing/values.c
+++ b/testing/values.c
@@ -16,6 +16,7 @@
  *
  */
 #include "testings.h"
+#include <math.h>
 
 /**
  * @brief Convert the input string to an integer
diff --git a/tools/analysis.sh b/tools/analysis.sh
index 445817bdf..e8b21d8da 100755
--- a/tools/analysis.sh
+++ b/tools/analysis.sh
@@ -14,6 +14,8 @@
 
 # Performs an analysis of Chameleon source code:
 # - we consider to be in Chameleon's source code root
+# - we consider having the build *.log files in the root directory
+# - we consider having the test reports *.junit files in the root directory
 # - we consider having the coverage file chameleon_coverage.xml in the root directory
 # - we consider having cppcheck, rats, sonar-scanner programs available in the environment
 
@@ -31,9 +33,6 @@ BUILDDIR=${BUILDDIR:-build}
 TOOLSDIR=$(dirname $0)
 $TOOLSDIR/find_sources.sh
 
-# Generate coverage xml output
-$TOOLSDIR/coverage.sh
-
 # Undefine this because not relevant in our configuration
 export UNDEFINITIONS="-UCHAMELEON_USE_OPENCL -UWIN32 -UWIN64 -U_MSC_EXTENSIONS -U_MSC_VER -U__SUNPRO_C -U__SUNPRO_CC -U__sun -Usun -U__cplusplus"
 
@@ -48,9 +47,6 @@ cppcheck $CPPCHECK_OPT -DPRECISION_z -UPRECISION_s -UPRECISION_d -UPRECISION_c -
 # merge all different compile_commands.json files from build-* directories into one single file for sonarqube
 jq -s 'map(.[])' $PWD/build-*/compile_commands.json > compile_commands.json
 
-# Set the default for the project key
-SONARQUBE_PROJECTKEY=${SONARQUBE_PROJECTKEY:-hiepacs:chameleon:gitlab:$CI_PROJECT_NAMESPACE}
-
 # create the sonarqube config file
 cat > sonar-project.properties << EOF
 sonar.host.url=https://sonarqube.inria.fr/sonarqube
@@ -61,9 +57,9 @@ sonar.links.scm=$CI_REPOSITORY_URL
 sonar.links.ci=$CI_PROJECT_URL/pipelines
 sonar.links.issue=$CI_PROJECT_URL/issues
 
-sonar.projectKey=$SONARQUBE_PROJECTKEY
+sonar.projectKey=${CI_PROJECT_NAMESPACE}:${CI_PROJECT_NAME}
 sonar.projectDescription=Dense linear algebra subroutines for heterogeneous and distributed architectures
-sonar.projectVersion=1.2.0
+sonar.projectVersion=1.3.0
 
 sonar.scm.disabled=false
 sonar.scm.provider=git
@@ -72,14 +68,13 @@ sonar.scm.exclusions.disabled=true
 sonar.sources=build-openmp/runtime/openmp, build-parsec/runtime/parsec, build-quark/runtime/quark, build-starpu, compute, control, coreblas, example, include, runtime, testing
 sonar.inclusions=`cat filelist.txt | sed ':a;N;$!ba;s/\n/, /g'`
 sonar.sourceEncoding=UTF-8
-sonar.cxx.includeDirectories=$(echo | gcc -E -Wp,-v - 2>&1 | grep "^ " | tr '\n' ',').,$(find . -type f -name '*.h' | sed -r 's|/[^/]+$||' |sort |uniq | xargs echo | sed -e 's/ /,/g'),$PARSEC_DIR/include,$QUARK_DIR/include,$STARPU_DIR/include/starpu/1.3,$SIMGRID_DIR/include
 sonar.cxx.file.suffixes=.h,.c
 sonar.cxx.errorRecoveryEnabled=true
 sonar.cxx.gcc.encoding=UTF-8
 sonar.cxx.gcc.regex=(?<file>.*):(?<line>[0-9]+):[0-9]+:\\\x20warning:\\\x20(?<message>.*)\\\x20\\\[(?<id>.*)\\\]
 sonar.cxx.gcc.reportPaths=chameleon_build.log
 sonar.cxx.xunit.reportPaths=*.junit
-sonar.cxx.cobertura.reportPaths=*.cov
+sonar.cxx.cobertura.reportPaths=chameleon_coverage.xml
 sonar.cxx.cppcheck.reportPaths=chameleon_cppcheck.xml
 sonar.cxx.clangsa.reportPaths=build-openmp/analyzer_reports/*/*.plist, build-parsec/analyzer_reports/*/*.plist, build-quark/analyzer_reports/*/*.plist, build-starpu/analyzer_reports/*/*.plist, build-starpu_simgrid/analyzer_reports/*/*.plist
 sonar.cxx.jsonCompilationDatabase=compile_commands.json
diff --git a/tools/coverage.sh b/tools/coverage.sh
index 846c2041f..a76e75d1a 100755
--- a/tools/coverage.sh
+++ b/tools/coverage.sh
@@ -17,7 +17,7 @@
 #
 ###
 INPUT_FILES=""
-for name in $( ls -1 chameleon_*.lcov | grep -v simgrid)
+for name in $( ls -1 chameleon*.lcov | grep -v simgrid)
 do
     INPUT_FILES="$INPUT_FILES -a $name";
 done
@@ -25,4 +25,3 @@ lcov $INPUT_FILES -o chameleon.lcov
 lcov --summary chameleon.lcov
 genhtml -o coverage chameleon.lcov
 lcov_cobertura chameleon.lcov --output chameleon_coverage.xml
-gcovr --xml-pretty --exclude-unreachable-branches --print-summary -o coverage.xml --root ${CI_PROJECT_DIR}
-- 
GitLab