From 45f55c93cec7cd1677f293c8cfad256a9a45c0bf Mon Sep 17 00:00:00 2001
From: Jean-Baptiste Keck <Jean-Baptiste.Keck@imag.fr>
Date: Wed, 4 Nov 2020 22:32:15 +0100
Subject: [PATCH] test fix checkpoint ci

---
 ci/scripts/test.sh                  | 51 -----------------------------
 hysop/core/tests/test_checkpoint.sh | 10 +++---
 hysop/tools/debug_dumper.py         |  5 +--
 3 files changed, 8 insertions(+), 58 deletions(-)

diff --git a/ci/scripts/test.sh b/ci/scripts/test.sh
index 9726ca639..55b7e18fd 100755
--- a/ci/scripts/test.sh
+++ b/ci/scripts/test.sh
@@ -116,58 +116,7 @@ example_test() {
 }
 
 if [ "$RUN_TESTS" = true ]; then
-    hysop_test "core/arrays/tests/test_array.py"
-    hysop_test "core/graph/tests/test_graph.py"
-    hysop_test "fields/tests/test_fields.py"
-    hysop_test "numerics/tests/test_fft.py"
-    hysop_test "operator/tests/test_analytic.py"
-    hysop_test "operator/tests/test_transpose.py"
-    hysop_test "operator/tests/test_fd_derivative.py"
-    hysop_test "operator/tests/test_absorption.py"
-    hysop_test "operator/tests/test_penalization.py"
-    hysop_test "operator/tests/test_velocity_correction.py"
-    hysop_test "operator/tests/test_restriction_filter.py"
-    hysop_test "operator/tests/test_scales_advection.py"
-    hysop_test "operator/tests/test_bilevel_advection.py"
-    hysop_test "operator/tests/test_directional_advection.py"
-    hysop_test "operator/tests/test_directional_diffusion.py"
-    hysop_test "operator/tests/test_directional_stretching.py"
-    hysop_test "operator/tests/test_custom_symbolic.py"
-    hysop_test "operator/tests/test_spectral_derivative.py"
-    hysop_test "operator/tests/test_spectral_curl.py"
-    hysop_test "operator/tests/test_diffusion.py"
-    hysop_test "operator/tests/test_poisson.py"
-    hysop_test "operator/tests/test_solenoidal_projection.py"
-    hysop_test "operator/tests/test_poisson_curl.py"
-    ${HYSOP_DIR}/fields/tests/test_cartesian.sh
     ${HYSOP_DIR}/core/tests/test_checkpoint.sh
 fi
 
-if [ "${RUN_LONG_TESTS}" = true ]; then
-    hysop_test "backend/device/codegen/kernels/tests/test_directional_advection.py"
-    hysop_test "backend/device/codegen/kernels/tests/test_directional_remesh.py"
-fi
-
-if [ "${RUN_EXAMPLES}" = true ]; then
-    example_test "analytic/analytic.py"
-    example_test "scalar_diffusion/scalar_diffusion.py"
-    example_test "scalar_advection/scalar_advection.py"
-    example_test "scalar_advection/levelset.py"
-    example_test "multiresolution/scalar_advection.py"
-    example_test "shear_layer/shear_layer.py"
-    example_test "taylor_green/taylor_green.py" '-impl python'
-    example_test "taylor_green/taylor_green.py" '-impl opencl'
-    example_test "bubble/periodic_bubble.py"
-    example_test "bubble/periodic_bubble_levelset.py"
-    example_test "bubble/periodic_bubble_levelset_penalization.py" #LLVM bug for DP
-    example_test "bubble/periodic_jet_levelset.py"
-    example_test "particles_above_salt/particles_above_salt_periodic.py"
-    example_test "particles_above_salt/particles_above_salt_symmetrized.py"
-fi
-
-if [ "${HAS_CACHE_DIR}" = true ]; then
-    rsync -rtu "${HYSOP_CACHE_DIR}/" "${CACHE_DIR}/"
-    find "${CACHE_DIR}" -name '*.lock' -delete
-fi
-
 exit 0
diff --git a/hysop/core/tests/test_checkpoint.sh b/hysop/core/tests/test_checkpoint.sh
index 0872748bc..ab313666c 100755
--- a/hysop/core/tests/test_checkpoint.sh
+++ b/hysop/core/tests/test_checkpoint.sh
@@ -78,7 +78,7 @@ done
 #
 EXAMPLE_FILE="${EXAMPLE_DIR}/scalar_diffusion/scalar_diffusion.py"
 TEST_DIR='/tmp/hysop_tests/checkpoints/scalar_diffusion_mpi'
-COMMON_OPTIONS="-NC -impl opencl -cp fp32 -d64 --debug-dump-target dump -nu 0.02 -niter 20 -te 0.1 --dump-tstart 0.05 --dump-freq 1 "
+COMMON_OPTIONS="-NC -impl opencl -cp fp64 -d64 --debug-dump-target dump -nu 0.02 -niter 20 -te 0.1 --dump-tstart 0.05 --dump-freq 1 "
 
 echo
 echo "TEST SCALAR DIFFUSION CHECKPOINT (MPI)"
@@ -96,7 +96,7 @@ echo "  >debug dumps match"
 compare_files "${TEST_DIR}/run0/dump/run.txt" "${TEST_DIR}/run1/dump/run.txt"
 for f0 in $(find "${TEST_DIR}/run0" -name '*.h5' | sort -n); do
     f1=$(echo "${f0}" | sed 's/run0/run1/')
-    compare_files "${f0}" "${f1}"
+    h5diff -d '1e-15' "${f0}" "${f1}"
     echo "  >$(basename ${f0}) match"
 done
 
@@ -112,9 +112,9 @@ for f0 in $(find "${TEST_DIR}/run2" -name '*.h5' | sort -n); do
     f1=$(echo "${f0}" | sed 's/run2/run3/')
     f2=$(echo "${f0}" | sed 's/run2/run0/')
     f3=$(echo "${f0}" | sed 's/run2/run1/')
-    compare_files "${f0}" "${f1}"
-    compare_files "${f0}" "${f2}"
-    compare_files "${f0}" "${f3}"
+    h5diff -d '1e-15' "${f0}" "${f1}"
+    h5diff -d '1e-15' "${f0}" "${f2}"
+    h5diff -d '1e-15' "${f0}" "${f3}"
     echo "  >$(basename ${f0}) match"
 done
 
diff --git a/hysop/tools/debug_dumper.py b/hysop/tools/debug_dumper.py
index e9ff4e467..9e2a5a181 100644
--- a/hysop/tools/debug_dumper.py
+++ b/hysop/tools/debug_dumper.py
@@ -13,7 +13,7 @@ from hysop.fields.discrete_field import DiscreteScalarFieldView
 
 class DebugDumper(object):
     def __init__(self, name, path, force_overwrite=False,
-                 enable_on_op_apply=False, dump_precision=10,
+                 enable_on_op_apply=False, dump_precision=12,
                  comm=MPI.COMM_WORLD, io_leader=0, dump_data=False):
         assert isinstance(name, str), name
         assert isinstance(path, str), path
@@ -120,7 +120,8 @@ class DebugDumper(object):
                 _min = comm.allreduce(np.nanmin(d),  op=MPI.MIN)
                 _max = comm.allreduce(np.nanmax(d),  op=MPI.MAX)
                 mean = comm.allreduce(np.nanmean(d), op=MPI.SUM) / comm_size
-                variance = comm.allreduce(np.nansum((d-mean)**2)) / comm.allreduce(d.size)
+                size = float(comm.allreduce(d.size))
+                variance = comm.allreduce((d.size/size)*np.nanmean((d-mean)**2))
                 entry = '\n'+self.lformat(id_, iteration, time, tag_, _min, _max,
                                           mean, variance, dtype, shape, description_, self.dump_precision)
 
-- 
GitLab