From a283a1c3893f18d55d3ea79e219d48c2e62cba48 Mon Sep 17 00:00:00 2001
From: Nathalie Furmento <nathalie.furmento@labri.fr>
Date: Wed, 5 Feb 2020 14:29:07 +0100
Subject: [PATCH 1/5] add substitution rules for check_X functions

---
 cmake_modules/local_subs.py | 1 +
 1 file changed, 1 insertion(+)

diff --git a/cmake_modules/local_subs.py b/cmake_modules/local_subs.py
index 56ab5e985..27be0cb14 100644
--- a/cmake_modules/local_subs.py
+++ b/cmake_modules/local_subs.py
@@ -78,6 +78,7 @@ subs = {
         ('testing_p',            'testing_s',            'testing_d',            'testing_c',            'testing_z'           ),
         ('timing_p',             'timing_s',             'timing_d',             'timing_c',             'timing_z'            ),
         ('workspace_p',          'workspace_s',          'workspace_d',          'workspace_c',          'workspace_z'         ),
+        ('check_p',              'check_s',              'check_d',              'check_c',              'check_z'             ),
 #        ('CORE_P',               'CORE_S',               'CORE_D',               'CORE_C',               'CORE_Z'              ),
 #        ('vec_p',                'vec_s',                'vec_d',                'vec_c',                'vec_z'               ),
 
-- 
GitLab


From f3ca9c802c48eadc3ba73067861f542913eb20d7 Mon Sep 17 00:00:00 2001
From: Mathieu Faverge <mathieu.faverge@inria.fr>
Date: Wed, 5 Feb 2020 14:33:59 +0100
Subject: [PATCH 2/5] new-testing: remove dependency on coreblas, and implement
 specific random generator functions

---
 new-testing/values.c | 78 ++++++++++++++++++++++++++++++++++++++++----
 1 file changed, 72 insertions(+), 6 deletions(-)

diff --git a/new-testing/values.c b/new-testing/values.c
index 13f711436..fc2b54702 100644
--- a/new-testing/values.c
+++ b/new-testing/values.c
@@ -2,7 +2,7 @@
  *
  * @file values.c
  *
- * @copyright 2019-2019 Bordeaux INP, CNRS (LaBRI UMR 5800), Inria,
+ * @copyright 2019-2020 Bordeaux INP, CNRS (LaBRI UMR 5800), Inria,
  *                      Univ. Bordeaux. All rights reserved.
  ***
  *
@@ -15,7 +15,6 @@
  *
  */
 #include "testings.h"
-#include <coreblas.h>
 
 /**
  * @brief Convert the input string to an integer
@@ -569,6 +568,37 @@ char *sprint_string( val_t val, int human, int nbchar, char *str_in )
     return str_in+rc;
 }
 
+/*
+ Rnd64seed is a global variable but it doesn't spoil thread safety. All matrix
+ generating threads only read Rnd64seed. It is safe to set Rnd64seed before
+ and after any calls to create_tile(). The only problem can be caused if
+ Rnd64seed is changed during the matrix generation time.
+ */
+
+//static unsigned long long int Rnd64seed = 100;
+#define Rnd64_A 6364136223846793005ULL
+#define Rnd64_C 1ULL
+#define RndF_Mul 5.4210108624275222e-20f
+
+static inline unsigned long long int
+testing_Rnd64_jump(unsigned long long int n, unsigned long long int seed ) {
+  unsigned long long int a_k, c_k, ran;
+  int i;
+
+  a_k = Rnd64_A;
+  c_k = Rnd64_C;
+
+  ran = seed;
+  for (i = 0; n; n >>= 1, ++i) {
+    if (n & 1)
+      ran = a_k * ran + c_k;
+    c_k *= (a_k + 1);
+    a_k *= a_k;
+  }
+
+  return ran;
+}
+
 /**
  * @brief Generate a random float
  */
@@ -576,7 +606,14 @@ float
 testing_salea()
 {
     float val;
-    CORE_splrnt( 1, 1, &val, 1, 1, 1, 0, random() );
+    unsigned long long int ran;
+
+    ran = testing_Rnd64_jump( 2, random() );
+
+    /* Real part */
+    val = 0.5f - ran * RndF_Mul;
+    ran  = Rnd64_A * ran + Rnd64_C;
+
     return val;
 }
 
@@ -587,7 +624,14 @@ double
 testing_dalea()
 {
     double val;
-    CORE_dplrnt( 1, 1, &val, 1, 1, 1, 0, random() );
+    unsigned long long int ran;
+
+    ran = testing_Rnd64_jump( 2, random() );
+
+    /* Real part */
+    val = 0.5f - ran * RndF_Mul;
+    ran  = Rnd64_A * ran + Rnd64_C;
+
     return val;
 }
 
@@ -598,7 +642,18 @@ CHAMELEON_Complex32_t
 testing_calea()
 {
     CHAMELEON_Complex32_t val;
-    CORE_cplrnt( 1, 1, &val, 1, 1, 1, 0, random() );
+    unsigned long long int ran;
+
+    ran = testing_Rnd64_jump( 2, random() );
+
+    /* Real part */
+    val = 0.5f - ran * RndF_Mul;
+    ran  = Rnd64_A * ran + Rnd64_C;
+
+    /* Imaginary part */
+    val += I*(0.5f - ran * RndF_Mul);
+    ran  = Rnd64_A * ran + Rnd64_C;
+
     return val;
 }
 
@@ -609,6 +664,17 @@ CHAMELEON_Complex64_t
 testing_zalea()
 {
     CHAMELEON_Complex64_t val;
-    CORE_zplrnt( 1, 1, &val, 1, 1, 1, 0, random() );
+    unsigned long long int ran;
+
+    ran = testing_Rnd64_jump( 2, random() );
+
+    /* Real part */
+    val = 0.5f - ran * RndF_Mul;
+    ran  = Rnd64_A * ran + Rnd64_C;
+
+    /* Imaginary part */
+    val += I*(0.5f - ran * RndF_Mul);
+    ran  = Rnd64_A * ran + Rnd64_C;
+
     return val;
 }
-- 
GitLab


From 033423fc503b908b13533bdd06fcaa1c42955649 Mon Sep 17 00:00:00 2001
From: Nathalie Furmento <nathalie.furmento@labri.fr>
Date: Wed, 5 Feb 2020 14:38:05 +0100
Subject: [PATCH 3/5] new-testing: do not perform check when simulation is
 enabled

---
 new-testing/testing_zcheck.c |  7 ++++++-
 new-testing/testing_zcheck.h | 36 ++++++++++++++++++++++++++++++++++++
 2 files changed, 42 insertions(+), 1 deletion(-)

diff --git a/new-testing/testing_zcheck.c b/new-testing/testing_zcheck.c
index d2f33920e..4a2e6910c 100644
--- a/new-testing/testing_zcheck.c
+++ b/new-testing/testing_zcheck.c
@@ -2,7 +2,7 @@
  *
  * @file testing_zcheck.c
  *
- * @copyright 2019-2019 Bordeaux INP, CNRS (LaBRI UMR 5800), Inria,
+ * @copyright 2019-2020 Bordeaux INP, CNRS (LaBRI UMR 5800), Inria,
  *                      Univ. Bordeaux. All rights reserved.
  *
  ***
@@ -20,6 +20,10 @@
 #include <string.h>
 #include <math.h>
 #include <chameleon.h>
+
+
+#if ! defined(CHAMELEON_SIMULATION)
+
 #include <coreblas/cblas.h>
 #include <coreblas/lapacke.h>
 #include <coreblas.h>
@@ -1878,3 +1882,4 @@ int check_zgels( run_arg_list_t *args, cham_trans_t trans, CHAM_desc_t *descA, C
     return info_solution;
 }
 
+#endif // CHAMELEON_SIMULATION
diff --git a/new-testing/testing_zcheck.h b/new-testing/testing_zcheck.h
index 0afd9af28..5fe892327 100644
--- a/new-testing/testing_zcheck.h
+++ b/new-testing/testing_zcheck.h
@@ -30,6 +30,40 @@
 #define CHECK_TRMM 3
 #define CHECK_TRSM 4
 
+#if defined(CHAMELEON_SIMULATION)
+
+static inline int check_zmatrices     ( run_arg_list_t *args, cham_uplo_t uplo, CHAM_desc_t *descA, CHAM_desc_t *descB ) { return 0; }
+static inline int check_znorm         ( run_arg_list_t *args, cham_mtxtype_t mtxtype, cham_normtype_t norm_type, cham_uplo_t uplo,
+                                        cham_diag_t diag, double norm_cham, CHAM_desc_t *descA ) { return 0; }
+static inline int check_zsum          ( run_arg_list_t *args, cham_uplo_t uplo, cham_trans_t trans, CHAMELEON_Complex64_t alpha, CHAM_desc_t *descA,
+                                        CHAMELEON_Complex64_t beta, CHAM_desc_t *descBref, CHAM_desc_t *descBcham ) { return 0; }
+static inline int check_zscale        ( run_arg_list_t *args, cham_uplo_t uplo, CHAMELEON_Complex64_t alpha, CHAM_desc_t *descA1, CHAM_desc_t *descA2 ) { return 0; }
+static inline int check_zgemm         ( run_arg_list_t *args, cham_trans_t transA, cham_trans_t transB, CHAMELEON_Complex64_t alpha, CHAM_desc_t *descA,
+                                        CHAM_desc_t *descB, CHAMELEON_Complex64_t beta, CHAM_desc_t *descCref, CHAM_desc_t *descC ) { return 0; }
+static inline int check_zsymm         ( run_arg_list_t *args, cham_mtxtype_t mtxtype, cham_side_t side, cham_uplo_t uplo, CHAMELEON_Complex64_t alpha, CHAM_desc_t *descA, CHAM_desc_t *descB,
+                                        CHAMELEON_Complex64_t beta, CHAM_desc_t *descCref, CHAM_desc_t *descC ) { return 0; }
+static inline int check_zsyrk         ( run_arg_list_t *args, cham_mtxtype_t mtxtype, cham_uplo_t uplo, cham_trans_t trans, CHAMELEON_Complex64_t alpha, CHAM_desc_t *descA,
+                                        CHAM_desc_t *descB, CHAMELEON_Complex64_t beta, CHAM_desc_t *descCref, CHAM_desc_t *descC ) { return 0; }
+static inline int check_ztrmm         ( run_arg_list_t *args, int check_func, cham_side_t side, cham_uplo_t uplo, cham_trans_t trans, cham_diag_t diag,
+                                        CHAMELEON_Complex64_t alpha, CHAM_desc_t *descA, CHAM_desc_t *descB, CHAM_desc_t *descBref ) { return 0; }
+static inline int check_zlauum        ( run_arg_list_t *args, cham_uplo_t uplo, CHAM_desc_t *descA1, CHAM_desc_t *descA2 ) { return 0; }
+static inline int check_zxxtrf        ( run_arg_list_t *args, cham_mtxtype_t mtxtype, cham_uplo_t uplo, CHAM_desc_t *descA1, CHAM_desc_t *descA2 ) { return 0; }
+static inline int check_zsolve        ( run_arg_list_t *args, cham_mtxtype_t mtxtype, cham_trans_t trans, cham_uplo_t uplo,
+                                        CHAM_desc_t *descA, CHAM_desc_t *descX, CHAM_desc_t *descB ) { return 0; }
+static inline int check_ztrtri        ( run_arg_list_t *args, cham_mtxtype_t mtxtype, cham_uplo_t uplo, cham_diag_t diag,
+                                        CHAM_desc_t *descA, CHAM_desc_t *descAi ) { return 0; }
+
+/* Using QR factorization */
+static inline int check_zortho        ( run_arg_list_t *args, CHAM_desc_t *descQ ) { return 0; }
+static inline int check_zgeqrf        ( run_arg_list_t *args, CHAM_desc_t *descA, CHAM_desc_t *descAF, CHAM_desc_t *descQ ) { return 0; }
+static inline int check_zgelqf        ( run_arg_list_t *args, CHAM_desc_t *descA, CHAM_desc_t *descAF, CHAM_desc_t *descQ ) { return 0; }
+static inline int check_zgels         ( run_arg_list_t *args, cham_trans_t trans, CHAM_desc_t *descA, CHAM_desc_t *descX, CHAM_desc_t *descB ) { return 0; }
+static inline int check_zgeqrs        ( run_arg_list_t *args, cham_trans_t trans, CHAM_desc_t *descA, double Bnorm, CHAM_desc_t *descR ) { return 0; }
+static inline int check_zgelqs        ( run_arg_list_t *args, cham_trans_t trans, CHAM_desc_t *descA, double Bnorm, CHAM_desc_t *descR ) { return 0; }
+static inline int check_zqc           ( run_arg_list_t *args, cham_side_t side, cham_trans_t trans, CHAM_desc_t *descC, CHAM_desc_t *descQ, CHAM_desc_t *descCC ) { return 0; }
+
+#else // !CHAMELEON_SIMULATION
+
 int check_zmatrices     ( run_arg_list_t *args, cham_uplo_t uplo, CHAM_desc_t *descA, CHAM_desc_t *descB );
 int check_znorm         ( run_arg_list_t *args, cham_mtxtype_t mtxtype, cham_normtype_t norm_type, cham_uplo_t uplo,
                           cham_diag_t diag, double norm_cham, CHAM_desc_t *descA );
@@ -60,5 +94,7 @@ int check_zgeqrs        ( run_arg_list_t *args, cham_trans_t trans, CHAM_desc_t
 int check_zgelqs        ( run_arg_list_t *args, cham_trans_t trans, CHAM_desc_t *descA, double Bnorm, CHAM_desc_t *descR );
 int check_zqc           ( run_arg_list_t *args, cham_side_t side, cham_trans_t trans, CHAM_desc_t *descC, CHAM_desc_t *descQ, CHAM_desc_t *descCC );
 
+#endif // CHAMELEON_SIMULATION
+
 #endif
 
-- 
GitLab


From 7e60e17df8bdcc42b1b59725f92512cc737d8f6a Mon Sep 17 00:00:00 2001
From: Nathalie Furmento <nathalie.furmento@labri.fr>
Date: Wed, 5 Feb 2020 14:40:09 +0100
Subject: [PATCH 4/5] do not disable new-testing when simulation is enabled

---
 CMakeLists.txt             | 18 +++++++-----------
 new-testing/CMakeLists.txt | 11 ++++++-----
 2 files changed, 13 insertions(+), 16 deletions(-)

diff --git a/CMakeLists.txt b/CMakeLists.txt
index 7ad68e424..15ea0144e 100644
--- a/CMakeLists.txt
+++ b/CMakeLists.txt
@@ -4,7 +4,7 @@
 #
 # @copyright 2009-2014 The University of Tennessee and The University of
 #                      Tennessee Research Foundation. All rights reserved.
-# @copyright 2012-2019 Bordeaux INP, CNRS (LaBRI UMR 5800), Inria,
+# @copyright 2012-2020 Bordeaux INP, CNRS (LaBRI UMR 5800), Inria,
 #                      Univ. Bordeaux. All rights reserved.
 #
 ###
@@ -501,13 +501,6 @@ else (NOT CHAMELEON_SIMULATION)
         set(CHAMELEON_ENABLE_EXAMPLE OFF)
         message("-- ${BoldBlue}CHAMELEON_ENABLE_EXAMPLE is set to ON but we turn it OFF.")
     endif ()
-    if (CHAMELEON_ENABLE_TESTING)
-        set(CHAMELEON_ENABLE_TESTING OFF)
-        message("-- ${BoldBlue}CHAMELEON_ENABLE_TESTING is set to ON but we turn it OFF."
-            "\n   Because we are compiling the simulation mode (CHAMELEON_SIMULATION=ON),"
-            "\n   there is no sense in compiling testing drivers that are used to check"
-            "\n   numerical correctness of algorithms and kernels.${ColourReset}")
-    endif ()
 
     # Simulation mode: we depend on SimGrid
     find_package(SIMGRID REQUIRED)
@@ -995,10 +988,13 @@ if(CHAMELEON_ENABLE_EXAMPLE AND NOT CHAMELEON_SIMULATION)
 endif(CHAMELEON_ENABLE_EXAMPLE AND NOT CHAMELEON_SIMULATION)
 
 # Testing executables
-if(CHAMELEON_ENABLE_TESTING AND NOT CHAMELEON_SIMULATION)
-  add_subdirectory(testing)
+if(CHAMELEON_ENABLE_TESTING)
   add_subdirectory(new-testing)
-endif(CHAMELEON_ENABLE_TESTING AND NOT CHAMELEON_SIMULATION)
+endif(CHAMELEON_ENABLE_TESTING)
+
+if(CHAMELEON_ENABLE_EXAMPLE AND NOT CHAMELEON_SIMULATION)
+  add_subdirectory(testing)
+endif(CHAMELEON_ENABLE_EXAMPLE AND NOT CHAMELEON_SIMULATION)
 
 # Timing executables
 if(CHAMELEON_ENABLE_TIMING)
diff --git a/new-testing/CMakeLists.txt b/new-testing/CMakeLists.txt
index b228fe0f1..cafc9d720 100644
--- a/new-testing/CMakeLists.txt
+++ b/new-testing/CMakeLists.txt
@@ -4,7 +4,7 @@
 #
 # @copyright 2009-2014 The University of Tennessee and The University of
 #                      Tennessee Research Foundation. All rights reserved.
-# @copyright 2012-2019 Bordeaux INP, CNRS (LaBRI UMR 5800), Inria,
+# @copyright 2012-2020 Bordeaux INP, CNRS (LaBRI UMR 5800), Inria,
 #                      Univ. Bordeaux. All rights reserved.
 #
 ###
@@ -25,9 +25,6 @@
 #  @date 2014-11-16
 #
 ###
-if (CHAMELEON_SIMULATION)
-  message(ERROR "new-testing directory should not be included when simulation is enabled")
-endif()
 
 # Generate chameleon auxiliary testing sources for all possible precisions
 # --------------------------------------------------------------------
@@ -128,10 +125,14 @@ foreach(_precision ${CHAMELEON_PRECISION} )
     )
   add_dependencies(${_precision}new-testing
     chameleon_include
-    coreblas_include
     control_include
     new-testing_include
     )
+if(NOT CHAMELEON_SIMULATION)
+  add_dependencies(${_precision}new-testing
+    coreblas_include
+    )
+endif(NOT CHAMELEON_SIMULATION)
   set_property(TARGET ${_precision}new-testing PROPERTY LINKER_LANGUAGE Fortran)
   target_link_libraries(${_precision}new-testing ${libs_for_tests})
 
-- 
GitLab


From 81aaf6472cb126290813a32e9ac721b3881948ef Mon Sep 17 00:00:00 2001
From: Mathieu Faverge <mathieu.faverge@inria.fr>
Date: Mon, 10 Feb 2020 09:28:29 +0100
Subject: [PATCH 5/5] Minor

---
 new-testing/testing_zcheck.c |  4 ++--
 new-testing/testing_zcheck.h |  4 ++--
 new-testing/values.c         | 11 +++--------
 3 files changed, 7 insertions(+), 12 deletions(-)

diff --git a/new-testing/testing_zcheck.c b/new-testing/testing_zcheck.c
index 4a2e6910c..66d2289aa 100644
--- a/new-testing/testing_zcheck.c
+++ b/new-testing/testing_zcheck.c
@@ -22,7 +22,7 @@
 #include <chameleon.h>
 
 
-#if ! defined(CHAMELEON_SIMULATION)
+#if !defined(CHAMELEON_SIMULATION)
 
 #include <coreblas/cblas.h>
 #include <coreblas/lapacke.h>
@@ -1882,4 +1882,4 @@ int check_zgels( run_arg_list_t *args, cham_trans_t trans, CHAM_desc_t *descA, C
     return info_solution;
 }
 
-#endif // CHAMELEON_SIMULATION
+#endif /* defined(CHAMELEON_SIMULATION) */
diff --git a/new-testing/testing_zcheck.h b/new-testing/testing_zcheck.h
index 5fe892327..e03346267 100644
--- a/new-testing/testing_zcheck.h
+++ b/new-testing/testing_zcheck.h
@@ -62,7 +62,7 @@ static inline int check_zgeqrs        ( run_arg_list_t *args, cham_trans_t trans
 static inline int check_zgelqs        ( run_arg_list_t *args, cham_trans_t trans, CHAM_desc_t *descA, double Bnorm, CHAM_desc_t *descR ) { return 0; }
 static inline int check_zqc           ( run_arg_list_t *args, cham_side_t side, cham_trans_t trans, CHAM_desc_t *descC, CHAM_desc_t *descQ, CHAM_desc_t *descCC ) { return 0; }
 
-#else // !CHAMELEON_SIMULATION
+#else /* !defined(CHAMELEON_SIMULATION) */
 
 int check_zmatrices     ( run_arg_list_t *args, cham_uplo_t uplo, CHAM_desc_t *descA, CHAM_desc_t *descB );
 int check_znorm         ( run_arg_list_t *args, cham_mtxtype_t mtxtype, cham_normtype_t norm_type, cham_uplo_t uplo,
@@ -94,7 +94,7 @@ int check_zgeqrs        ( run_arg_list_t *args, cham_trans_t trans, CHAM_desc_t
 int check_zgelqs        ( run_arg_list_t *args, cham_trans_t trans, CHAM_desc_t *descA, double Bnorm, CHAM_desc_t *descR );
 int check_zqc           ( run_arg_list_t *args, cham_side_t side, cham_trans_t trans, CHAM_desc_t *descC, CHAM_desc_t *descQ, CHAM_desc_t *descCC );
 
-#endif // CHAMELEON_SIMULATION
+#endif /* defined(CHAMELEON_SIMULATION) */
 
 #endif
 
diff --git a/new-testing/values.c b/new-testing/values.c
index fc2b54702..28f59bff5 100644
--- a/new-testing/values.c
+++ b/new-testing/values.c
@@ -568,18 +568,13 @@ char *sprint_string( val_t val, int human, int nbchar, char *str_in )
     return str_in+rc;
 }
 
-/*
- Rnd64seed is a global variable but it doesn't spoil thread safety. All matrix
- generating threads only read Rnd64seed. It is safe to set Rnd64seed before
- and after any calls to create_tile(). The only problem can be caused if
- Rnd64seed is changed during the matrix generation time.
- */
-
-//static unsigned long long int Rnd64seed = 100;
 #define Rnd64_A 6364136223846793005ULL
 #define Rnd64_C 1ULL
 #define RndF_Mul 5.4210108624275222e-20f
 
+/**
+ * @brief Generate a random number
+ */
 static inline unsigned long long int
 testing_Rnd64_jump(unsigned long long int n, unsigned long long int seed ) {
   unsigned long long int a_k, c_k, ran;
-- 
GitLab