fmihpc / vlasiator

Vlasiator - ten letters you can count on
https://www.helsinki.fi/en/researchgroups/vlasiator
Other
45 stars 37 forks source link

Vlasiator results depend on run parameters #84

Closed sandroos closed 3 years ago

sandroos commented 9 years ago

So, I was testing if the poisson branch could be merged to master, i.e., if they would give identical results for a mini-magnetosphere (ABF) test. Of course they don't.

Then I started to test just by using the current master with different run parameters. The results are identical (vlsvdiff) between runs if

The results are different if

For example, here is vlsvdiff between RCB and BLOCK partitioning

#INFO Reading in two directories.
#1   File number in folder
#2   File 1 size
#3   File 1 min
#4   File 1 max
#5   File 1 average
#6   File 1 standard deviation
#7   File 2 size
#8   File 2 min
#9   File 2 max
#10  File 2 average
#11  File 2 standard deviation
#12  absolute infinity-distance
#13  relative infinity-distance
#14  absolute average-shifted infinity-distance
#15  relative average-shifted infinity-distance
#16  absolute 1-distance
#17  relative 1-distance
#18  absolute average-shifted 1-distance
#19  relative average-shifted 1-distance
#20  absolute 2-distance
#21  relative 2-distance
#22  absolute average-shifted 2-distance
#23  relative average-shifted 2-distance

1       2500    0       1e+06   994800  1439.04 2500    0       1e+06   994800  1439.04 0       0       0       0       
2       2500    0       1.00034e+06     994812  1439.06 2500    0       1.00034e+06     994812  1439.06 0.0069799       6.97752e-09     0.0069799       6.97752e-09     
3       2500    0       1.00068e+06     994822  1439.08 2500    0       1.00068e+06     994822  1439.08 0.00761981      7.61462e-09     0.00761981      7.61462e-09     
4       2500    0       1.00102e+06     994834  1439.1  2500    0       1.00102e+06     994834  1439.1  0.0126456       1.26327e-08     0.0126456       1.26327e-08     
5       2500    0       1.00136e+06     994846  1439.12 2500    0       1.00136e+06     994846  1439.12 0.0157983       1.57769e-08     0.0157983       1.57769e-08     
6       2500    0       1.0017e+06      994858  1439.14 2500    0       1.0017e+06      994858  1439.14 0.0209509       2.09154e-08     0.0209509       2.09154e-08     
7       2500    0       1.00204e+06     994871  1439.16 2500    0       1.00204e+06     994871  1439.16 0.0261134       2.60602e-08     0.0261134       2.60602e-08     
8       2500    0       1.00238e+06     994883  1439.18 2500    0       1.00238e+06     994883  1439.18 0.0279943       2.79278e-08     0.0279943       2.79278e-08     
9       2500    0       1.00272e+06     994895  1439.21 2500    0       1.00272e+06     994895  1439.21 0.0297683       2.96875e-08     0.0297683       2.96875e-08     
10      2500    0       1.00306e+06     994907  1439.23 2500    0       1.00306e+06     994907  1439.23 0.0317303       3.16335e-08     0.0317303       3.16335e-08     
11      2500    0       1.0034e+06      994919  1439.26 2500    0       1.0034e+06      994919  1439.26 0.0348824       3.47642e-08     0.0348824       3.47642e-08     
12      2500    0       1.00374e+06     994931  1439.29 2500    0       1.00374e+06     994931  1439.29 0.0386487       3.85047e-08     0.0386487       3.85047e-08     
13      2500    0       1.00408e+06     994943  1439.32 2500    0       1.00408e+06     994943  1439.32 0.0409107       4.07445e-08     0.0409107       4.07445e-08     
14      2500    0       1.00442e+06     994955  1439.35 2500    0       1.00442e+06     994955  1439.35 0.0458208       4.56192e-08     0.0458208       4.56192e-08     
15      2500    0       1.00476e+06     994967  1439.38 2500    0       1.00476e+06     994967  1439.38 0.0504614       5.02224e-08     0.0504614       5.02224e-08     
16      2500    0       1.0051e+06      994979  1439.41 2500    0       1.0051e+06      994979  1439.41 0.0588672       5.85687e-08     0.0588672       5.85687e-08     
17      2500    0       1.00544e+06     994991  1439.44 2500    0       1.00544e+06     994991  1439.44 0.0644025       6.40542e-08     0.0644025       6.40542e-08     

And here is the difference in rho after just 10 timesteps at t=0.1 seconds. The differences are still small but they keep on growing.

visit0000

galfthan commented 9 years ago

What was the floating point precision here, DP SPF? If so the differences seem to be quite small. If you change the partitioning you will change the order of computation which will give rise to some differences.

In the case of 1 or 2 hyperthreads I guess you mean the number of processes identical and change the numbers of threads?

sandroos commented 9 years ago

vlsvdiff used here in now in branch https://github.com/fmihpc/vlasiator/tree/vlsvdiff_output

sandroos commented 9 years ago

DP SPF, yes.

And yes, these differences are still quite small, but this is literally after 10 time steps (0.1 seconds). I've usually checked the results after 20 seconds.

galfthan commented 9 years ago

How about DP DPF, did you test that?

sandroos commented 9 years ago

DP DPF:

sandroos commented 9 years ago

poisson vs master results are different with DP DPF, derp.

sandroos commented 9 years ago

On my laptop the difference between identical runs (but different # MPI processes) is

sandroos@sandroos12k:~/Codes/vlasiator$ ./vlsvdiff_DP fullf.0000010.vlsv ../d/fullf.0000010.vlsv avgs 0
INFO Reading in two files.
File names: fullf.0000010.vlsv & ../d/fullf.0000010.vlsv
NonIdenticalBlocks:      0
IdenticalBlocks:         704
Absolute_Error:          1.67023e-16
Mean-Absolute-Error:     2.6596e-19
Max-Absolute-Error:      1.38778e-17
Absolute-log-Error:      7.56468e-06
Mean-Absolute-log-Error: 1.20457e-08

With the same #MPI processes I get identical results according to vlsvdiff. The max value of f is ~2e-10, so those differences are in the sixth decimal. I guess this is in-line with what we are seeing in Voima.

sandroos commented 9 years ago

Now that test_trans is mostly working, I ran some tests with master and varied the run parameters (#MPI and OMP threads). I used a single-core run (1 MPI, 1 OMP) as a reference solution.

The box is too small to tell how the differences really behave, but the differences are in the 7th decimal in rho (rho ~1e-4). Runs with one MPI process seem to produce identical results, irrespective of the number of OMP threads, so the caused by something related to MPI parallelization.

differences

sandroos commented 9 years ago

This addition will reduce accuracy since it is done using floats (realf) instead of doubles (Real) right?

https://github.com/fmihpc/vlasiator/blob/master/vlasovsolver/cpu_trans_map.hpp#L712

(Didn't change test_trans results though)

sandroos commented 9 years ago

I'll ask this here:

what are the compiler flags used for the test package reference results? I don't seem to be able to reproduce the reference values with master.

I assume they are DP, DPF, VEC4D_AGNER, but what are the exact CXXFLAGS and MATHFLAGS ?

galfthan commented 9 years ago

DP, DPF, VEC4D_AGNE, and -O2 instead of -O3 and -ffast-math

I tested and got bitidentical results for master. This is the diff of makefiles:

diff --git a/MAKE/Makefile.voima b/MAKE/Makefile.voima
index 28293cc..c370f2c 100644
--- a/MAKE/Makefile.voima
+++ b/MAKE/Makefile.voima
@@ -20,10 +20,10 @@ FLAGS =
 CC_BRAND = gcc
 CC_BRAND_VERSION = 4.8.1
 #CXXFLAGS += -O3 -fopenmp -funroll-loops -std=c++0x -W -Wall -Wno-unused -fabi-version=0 -mavx 
-CXXFLAGS += -O3 -fopenmp -funroll-loops -std=c++0x -fabi-version=0 -mavx 
+CXXFLAGS += -O2 -fopenmp -funroll-loops -std=c++0x -fabi-version=0 -mavx 

-MATHFLAGS = -ffast-math
+MATHFLAGS = 
 LDFLAGS = 
 LIB_MPI = -lgomp

diff --git a/Makefile b/Makefile
index 9250242..fdeb1ea 100644
--- a/Makefile
+++ b/Makefile
@@ -6,10 +6,10 @@ include MAKE/Makefile.${ARCH}
 FP_PRECISION = DP

 #Set floating point precision for distribution function to SPF (single) or DPF (double)
-DISTRIBUTION_FP_PRECISION = SPF
+DISTRIBUTION_FP_PRECISION = DPF

 #Set vector backend type for vlasov solvers, sets precision and length. Options: VEC4D_AGNER, VEC4F_AGNER, VEC8F_AGNER, VEC4D_FALLBACK, VEC4F_FALLBACK
-CXXFLAGS += -DVEC8F_AGNER
+CXXFLAGS += -DVEC4D_AGNER

 #set a default archive utility, can also be set in Makefile.arch
 AR ?= ar
sandroos commented 9 years ago

I added a testpackage Makefile target, the flags are set in Makefile (and not in architecture-specific Makefile.arch).

ykempf commented 3 years ago

This was fixed then, and looked into quite a lot during our 2020 AMR debugging campaign.