From 804bd8194a63de4b50fafbd136d7ffea5553587f Mon Sep 17 00:00:00 2001
From: "Joachim Wuttke (h)" <j.wuttke@fz-juelich.de>
Date: Sun, 12 May 2024 18:38:43 +0200
Subject: [PATCH] + option -B_3ARCH to relax num limits for architecture of
 3rd-party maintainers

---
 CMakeLists.txt                     |  2 +
 Tests/Suite/Common/TestSuite.h     | 78 ++++++++++++++++--------------
 Tests/Suite/Persist/CMakeLists.txt |  3 ++
 3 files changed, 47 insertions(+), 36 deletions(-)

diff --git a/CMakeLists.txt b/CMakeLists.txt
index 4ec59c6f43b..471794ab4d7 100644
--- a/CMakeLists.txt
+++ b/CMakeLists.txt
@@ -51,6 +51,8 @@ option(BA_TIDY "Invokes clang-tidy" OFF)
 option(ALGORITHM_DIAGNOSTIC "Let some algorithms set diagnostic variables" OFF)
 option(BA_APPLE_BUNDLE "Create a MacOS bundle" OFF)
 option(BA_CPP_API "Install header files" OFF)
+option(BA_3ARCH
+    "Reduced tolerance for persistence tests on architectures not covered by maintainer CI" OFF)
 
 # options with non-boolean value
 
diff --git a/Tests/Suite/Common/TestSuite.h b/Tests/Suite/Common/TestSuite.h
index 03c25684830..9548d7da8f6 100644
--- a/Tests/Suite/Common/TestSuite.h
+++ b/Tests/Suite/Common/TestSuite.h
@@ -41,6 +41,12 @@
 #define eps_direct_vs_python(eps_direct, eps_python) eps_python
 #endif
 
+#ifdef BA_OTHER_ARCH
+#define ARCH3 true
+#else
+#define ARCH3 false
+#endif
+
 TEST(TESTNAME, FormFactors)
 {
     const double eps = eps_direct_vs_python(2e-13, 8e-9);
@@ -57,7 +63,7 @@ TEST(TESTNAME, FormFactors)
 
 TEST(TESTNAME, FormFactorsWithAbsorption)
 {
-    const double eps = eps_direct_vs_python(8e-13, 8e-9);
+    const double eps = eps_direct_vs_python(ARCH3 ? 3e-10 : 8e-13, 8e-9);
     for (const std::string& ffname : FormFactorComponents().keys()) {
         const IFormFactor* ff = FormFactorComponents().getItem(ffname)->clone();
         ASSERT(ff);
@@ -79,7 +85,7 @@ TEST(TESTNAME, GISASAbsorptiveSLDLayers)
 
 TEST(TESTNAME, CylindersAndPrisms)
 {
-    const double eps = eps_direct_vs_python(5e-13, 8e-9);
+    const double eps = eps_direct_vs_python(ARCH3 ? 3e-10 : 5e-13, 8e-9);
     std::unique_ptr<const MultiLayer> sample(ExemplarySamples::createCylindersAndPrisms());
     auto sim = test::makeSimulation::MiniGISAS(*sample);
     EXPECT_TRUE(runTest("CylindersAndPrisms", *sim, eps));
@@ -87,7 +93,7 @@ TEST(TESTNAME, CylindersAndPrisms)
 
 TEST(TESTNAME, RadialParacrystal)
 {
-    const double eps = eps_direct_vs_python(5e-13, 8e-9);
+    const double eps = eps_direct_vs_python(ARCH3 ? 3e-10 : 5e-13, 8e-9);
     std::unique_ptr<const MultiLayer> sample(ExemplarySamples::createRadialParacrystal());
     auto sim = test::makeSimulation::MiniGISAS(*sample);
     EXPECT_TRUE(runTest("RadialParacrystal", *sim, eps));
@@ -95,7 +101,7 @@ TEST(TESTNAME, RadialParacrystal)
 
 TEST(TESTNAME, HardDisk)
 {
-    const double eps = eps_direct_vs_python(5e-13, 8e-9);
+    const double eps = eps_direct_vs_python(ARCH3 ? 3e-10 : 5e-13, 8e-9);
     std::unique_ptr<const MultiLayer> sample(ExemplarySamples::createHardDisk());
     auto sim = test::makeSimulation::MiniGISAS(*sample);
     EXPECT_TRUE(runTest("HardDisk", *sim, eps));
@@ -103,7 +109,7 @@ TEST(TESTNAME, HardDisk)
 
 TEST(TESTNAME, Basic2DParacrystal)
 {
-    const double eps = eps_direct_vs_python(5e-13, 8e-9);
+    const double eps = eps_direct_vs_python(ARCH3 ? 3e-10 : 5e-13, 8e-9);
     for (const std::string& pdfname : Profile2DComponents().keys()) {
         const IProfile2D* pdf2 = Profile2DComponents().getItem(pdfname)->clone();
         ASSERT(pdf2);
@@ -126,7 +132,7 @@ TEST(TESTNAME, HexParacrystal)
 
 TEST(TESTNAME, Lattice1D)
 {
-    const double eps = eps_direct_vs_python(5e-13, 8e-9);
+    const double eps = eps_direct_vs_python(ARCH3 ? 3e-10 : 5e-13, 8e-9);
     std::unique_ptr<const MultiLayer> sample(ExemplarySamples::createLattice1D());
     auto sim = test::makeSimulation::MiniGISAS(*sample);
     EXPECT_TRUE(runTest("Lattice1D", *sim, eps));
@@ -143,7 +149,7 @@ TEST(TESTNAME, RectParacrystal)
 
 TEST(TESTNAME, CoreShellParticle)
 {
-    const double eps = eps_direct_vs_python(5e-13, 8e-9);
+    const double eps = eps_direct_vs_python(ARCH3 ? 3e-10 : 5e-13, 8e-9);
     std::unique_ptr<const MultiLayer> sample(ExemplarySamples::createCoreShellParticle());
     auto sim = test::makeSimulation::MiniGISAS(*sample);
     EXPECT_TRUE(runTest("CoreShellParticle", *sim, eps));
@@ -151,7 +157,7 @@ TEST(TESTNAME, CoreShellParticle)
 
 TEST(TESTNAME, CoreShellBoxRotateZandY)
 {
-    const double eps = eps_direct_vs_python(5e-13, 8e-9);
+    const double eps = eps_direct_vs_python(ARCH3 ? 3e-10 : 5e-13, 8e-9);
     std::unique_ptr<const MultiLayer> sample(ExemplarySamples::createCoreShellBoxRotateZandY());
     auto sim = test::makeSimulation::MiniGISAS(*sample);
     EXPECT_TRUE(runTest("CoreShellBoxRotateZandY", *sim, eps));
@@ -167,7 +173,7 @@ TEST(TESTNAME, MultiLayerWithRoughness)
 
 TEST(TESTNAME, SquareLattice2D)
 {
-    const double eps = eps_direct_vs_python(5e-13, 8e-9);
+    const double eps = eps_direct_vs_python(ARCH3 ? 3e-10 : 5e-13, 8e-9);
     std::unique_ptr<const MultiLayer> sample(ExemplarySamples::createSquareLattice2D());
     auto sim = test::makeSimulation::MiniGISAS(*sample);
     EXPECT_TRUE(runTest("SquareLattice2D", *sim, eps));
@@ -175,7 +181,7 @@ TEST(TESTNAME, SquareLattice2D)
 
 TEST(TESTNAME, CenteredSquareLattice2D)
 {
-    const double eps = eps_direct_vs_python(5e-13, 8e-9);
+    const double eps = eps_direct_vs_python(ARCH3 ? 3e-10 : 5e-13, 8e-9);
     std::unique_ptr<const MultiLayer> sample(ExemplarySamples::createCenteredSquareLattice2D());
     auto sim = test::makeSimulation::MiniGISAS(*sample);
     EXPECT_TRUE(runTest("CenteredSquareLattice2D", *sim, eps));
@@ -183,7 +189,7 @@ TEST(TESTNAME, CenteredSquareLattice2D)
 
 TEST(TESTNAME, RotatedSquareLattice2D)
 {
-    const double eps = eps_direct_vs_python(5e-13, 8e-9);
+    const double eps = eps_direct_vs_python(ARCH3 ? 3e-10 : 5e-13, 8e-9);
     std::unique_ptr<const MultiLayer> sample(ExemplarySamples::createRotatedSquareLattice2D());
     auto sim = test::makeSimulation::MiniGISAS(*sample);
     EXPECT_TRUE(runTest("RotatedSquareLattice2D", *sim, eps));
@@ -191,7 +197,7 @@ TEST(TESTNAME, RotatedSquareLattice2D)
 
 TEST(TESTNAME, FiniteSquareLattice2D)
 {
-    const double eps = eps_direct_vs_python(5e-13, 8e-9);
+    const double eps = eps_direct_vs_python(ARCH3 ? 3e-10 : 5e-13, 8e-9);
     std::unique_ptr<const MultiLayer> sample(ExemplarySamples::createFiniteSquareLattice2D());
     auto sim = test::makeSimulation::MiniGISAS(*sample);
     EXPECT_TRUE(runTest("FiniteSquareLattice2D", *sim, eps));
@@ -199,7 +205,7 @@ TEST(TESTNAME, FiniteSquareLattice2D)
 
 TEST(TESTNAME, RotatedPyramids)
 {
-    const double eps = eps_direct_vs_python(5e-13, 8e-9);
+    const double eps = eps_direct_vs_python(ARCH3 ? 3e-10 : 5e-13, 8e-9);
     std::unique_ptr<const MultiLayer> sample(ExemplarySamples::createRotatedPyramids());
     auto sim = test::makeSimulation::MiniGISAS(*sample);
     EXPECT_TRUE(runTest("RotatedPyramids", *sim, eps));
@@ -215,7 +221,7 @@ TEST(TESTNAME, ThickAbsorptiveSampleWithRoughness)
 
 TEST(TESTNAME, Compound)
 {
-    const double eps = eps_direct_vs_python(5e-13, 8e-9);
+    const double eps = eps_direct_vs_python(ARCH3 ? 3e-10 : 5e-13, 8e-9);
     std::unique_ptr<const MultiLayer> sample(ExemplarySamples::createCompound());
     auto sim = test::makeSimulation::MiniGISAS(*sample);
     EXPECT_TRUE(runTest("Compound", *sim, eps));
@@ -223,7 +229,7 @@ TEST(TESTNAME, Compound)
 
 TEST(TESTNAME, CompoundPlus)
 {
-    const double eps = eps_direct_vs_python(5e-13, 8e-9);
+    const double eps = eps_direct_vs_python(ARCH3 ? 3e-10 : 5e-13, 8e-9);
     std::unique_ptr<const MultiLayer> sample(ExemplarySamples::createCompoundPlus());
     auto sim = test::makeSimulation::MiniGISAS(*sample);
     EXPECT_TRUE(runTest("CompoundPlus", *sim, eps));
@@ -231,7 +237,7 @@ TEST(TESTNAME, CompoundPlus)
 
 TEST(TESTNAME, BoxCompositionRotateX)
 {
-    const double eps = eps_direct_vs_python(5e-13, 8e-9);
+    const double eps = eps_direct_vs_python(ARCH3 ? 3e-10 : 5e-13, 8e-9);
     std::unique_ptr<const MultiLayer> sample(ExemplarySamples::createBoxCompositionRotateX());
     auto sim = test::makeSimulation::MiniGISAS(*sample);
     EXPECT_TRUE(runTest("BoxCompositionRotateX", *sim, eps));
@@ -239,7 +245,7 @@ TEST(TESTNAME, BoxCompositionRotateX)
 
 TEST(TESTNAME, BoxCompositionRotateY)
 {
-    const double eps = eps_direct_vs_python(5e-13, 8e-9);
+    const double eps = eps_direct_vs_python(ARCH3 ? 3e-10 : 5e-13, 8e-9);
     std::unique_ptr<const MultiLayer> sample(ExemplarySamples::createBoxCompositionRotateY());
     auto sim = test::makeSimulation::MiniGISAS(*sample);
     EXPECT_TRUE(runTest("BoxCompositionRotateY", *sim, eps));
@@ -247,7 +253,7 @@ TEST(TESTNAME, BoxCompositionRotateY)
 
 TEST(TESTNAME, BoxCompositionRotateZ)
 {
-    const double eps = eps_direct_vs_python(6e-13, 8e-9);
+    const double eps = eps_direct_vs_python(ARCH3 ? 3e-10 : 6e-13, 8e-9);
     std::unique_ptr<const MultiLayer> sample(ExemplarySamples::createBoxCompositionRotateZ());
     auto sim = test::makeSimulation::MiniGISAS(*sample);
     EXPECT_TRUE(runTest("BoxCompositionRotateZ", *sim, eps));
@@ -255,7 +261,7 @@ TEST(TESTNAME, BoxCompositionRotateZ)
 
 TEST(TESTNAME, BoxCompositionRotateZandY)
 {
-    const double eps = eps_direct_vs_python(5e-13, 8e-9);
+    const double eps = eps_direct_vs_python(ARCH3 ? 3e-10 : 5e-13, 8e-9);
     std::unique_ptr<const MultiLayer> sample(ExemplarySamples::createBoxCompositionRotateZandY());
     auto sim = test::makeSimulation::MiniGISAS(*sample);
     EXPECT_TRUE(runTest("BoxCompositionRotateZandY", *sim, eps));
@@ -263,7 +269,7 @@ TEST(TESTNAME, BoxCompositionRotateZandY)
 
 TEST(TESTNAME, BoxStackComposition)
 {
-    const double eps = eps_direct_vs_python(5e-13, 8e-9);
+    const double eps = eps_direct_vs_python(ARCH3 ? 3e-10 : 5e-13, 8e-9);
     std::unique_ptr<const MultiLayer> sample(ExemplarySamples::createBoxStackComposition());
     auto sim = test::makeSimulation::MiniGISAS(*sample);
     EXPECT_TRUE(runTest("BoxStackComposition", *sim, eps));
@@ -271,7 +277,7 @@ TEST(TESTNAME, BoxStackComposition)
 
 TEST(TESTNAME, MultipleLayout)
 {
-    const double eps = eps_direct_vs_python(5e-13, 8e-9);
+    const double eps = eps_direct_vs_python(ARCH3 ? 3e-10 : 5e-13, 8e-9);
     std::unique_ptr<const MultiLayer> sample(ExemplarySamples::createMultipleLayout());
     auto sim = test::makeSimulation::MiniGISAS(*sample);
     EXPECT_TRUE(runTest("MultipleLayout", *sim, eps));
@@ -279,7 +285,7 @@ TEST(TESTNAME, MultipleLayout)
 
 TEST(TESTNAME, ApproximationDA)
 {
-    const double eps = eps_direct_vs_python(5e-13, 8e-9);
+    const double eps = eps_direct_vs_python(ARCH3 ? 3e-10 : 5e-13, 8e-9);
     std::unique_ptr<const MultiLayer> sample(ExemplarySamples::createSizeDistributionDAModel());
     auto sim = test::makeSimulation::MiniGISAS(*sample);
     EXPECT_TRUE(runTest("ApproximationDA", *sim, eps));
@@ -287,7 +293,7 @@ TEST(TESTNAME, ApproximationDA)
 
 TEST(TESTNAME, ApproximationLMA)
 {
-    const double eps = eps_direct_vs_python(5e-13, 8e-9);
+    const double eps = eps_direct_vs_python(ARCH3 ? 3e-10 : 5e-13, 8e-9);
     std::unique_ptr<const MultiLayer> sample(ExemplarySamples::createSizeDistributionLMAModel());
     auto sim = test::makeSimulation::MiniGISAS(*sample);
     EXPECT_TRUE(runTest("ApproximationLMA", *sim, eps));
@@ -295,7 +301,7 @@ TEST(TESTNAME, ApproximationLMA)
 
 TEST(TESTNAME, ApproximationSSCA)
 {
-    const double eps = eps_direct_vs_python(5e-13, 8e-9);
+    const double eps = eps_direct_vs_python(ARCH3 ? 3e-10 : 5e-13, 8e-9);
     std::unique_ptr<const MultiLayer> sample(ExemplarySamples::createSizeDistributionSSCAModel());
     auto sim = test::makeSimulation::MiniGISAS(*sample);
     EXPECT_TRUE(runTest("ApproximationSSCA", *sim, eps));
@@ -303,7 +309,7 @@ TEST(TESTNAME, ApproximationSSCA)
 
 TEST(TESTNAME, CosineRipple)
 {
-    const double eps = eps_direct_vs_python(5e-13, 8e-9);
+    const double eps = eps_direct_vs_python(ARCH3 ? 3e-10 : 5e-13, 8e-9);
     std::unique_ptr<const MultiLayer> sample(ExemplarySamples::createCosineRipple());
     auto sim = test::makeSimulation::MiniGISAS(*sample);
     EXPECT_TRUE(runTest("CosineRipple", *sim, eps));
@@ -311,7 +317,7 @@ TEST(TESTNAME, CosineRipple)
 
 TEST(TESTNAME, TriangularRipple)
 {
-    const double eps = eps_direct_vs_python(5e-13, 8e-9);
+    const double eps = eps_direct_vs_python(ARCH3 ? 3e-10 : 5e-13, 8e-9);
     std::unique_ptr<const MultiLayer> sample(ExemplarySamples::createTriangularRipple());
     auto sim = test::makeSimulation::MiniGISAS(*sample);
     EXPECT_TRUE(runTest("TriangularRipple", *sim, eps));
@@ -327,7 +333,7 @@ TEST(TESTNAME, AsymRipple)
 
 TEST(TESTNAME, Mesocrystal)
 {
-    const double eps = eps_direct_vs_python(5e-13, 8e-9);
+    const double eps = eps_direct_vs_python(ARCH3 ? 3e-10 : 5e-13, 8e-9);
     std::unique_ptr<const MultiLayer> sample(ExemplarySamples::createMesocrystal());
     auto sim = test::makeSimulation::MiniGISAS(*sample);
     EXPECT_TRUE(runTest("Mesocrystal", *sim, eps));
@@ -335,7 +341,7 @@ TEST(TESTNAME, Mesocrystal)
 
 TEST(TESTNAME, MesocrystalPlus)
 {
-    const double eps = eps_direct_vs_python(5e-13, 8e-9);
+    const double eps = eps_direct_vs_python(ARCH3 ? 3e-10 : 5e-13, 8e-9);
     std::unique_ptr<const MultiLayer> sample(ExemplarySamples::createMesocrystalPlus());
     auto sim = test::makeSimulation::MiniGISAS(*sample);
     EXPECT_TRUE(runTest("MesocrystalPlus", *sim, eps));
@@ -351,7 +357,7 @@ TEST(TESTNAME, CustomMorphology)
 
 TEST(TESTNAME, TransformBox)
 {
-    const double eps = eps_direct_vs_python(5e-13, 8e-9);
+    const double eps = eps_direct_vs_python(ARCH3 ? 3e-10 : 5e-13, 8e-9);
     std::unique_ptr<const MultiLayer> sample(ExemplarySamples::createTransformBox());
     auto sim = test::makeSimulation::MiniGISAS(*sample);
     EXPECT_TRUE(runTest("TransformBox", *sim, eps));
@@ -359,7 +365,7 @@ TEST(TESTNAME, TransformBox)
 
 TEST(TESTNAME, MagneticParticleZeroField)
 {
-    const double eps = eps_direct_vs_python(5e-13, 8e-9);
+    const double eps = eps_direct_vs_python(ARCH3 ? 3e-10 : 5e-13, 8e-9);
     std::unique_ptr<const MultiLayer> sample(ExemplarySamples::createMagneticParticleZeroField());
     auto sim = test::makeSimulation::MiniGISAS(*sample);
     EXPECT_TRUE(runTest("MagneticParticleZeroField", *sim, eps));
@@ -367,7 +373,7 @@ TEST(TESTNAME, MagneticParticleZeroField)
 
 TEST(TESTNAME, SlicedComposition)
 {
-    const double eps = eps_direct_vs_python(5e-13, 8e-9);
+    const double eps = eps_direct_vs_python(ARCH3 ? 3e-10 : 5e-13, 8e-9);
     std::unique_ptr<const MultiLayer> sample(ExemplarySamples::createSlicedComposition());
     auto sim = test::makeSimulation::MiniGISAS(*sample);
     EXPECT_TRUE(runTest("SlicedComposition", *sim, eps));
@@ -443,7 +449,7 @@ TEST(TESTNAME, DetectorResolution)
 
 TEST(TESTNAME, SimulationWithMasks)
 {
-    const double eps = eps_direct_vs_python(5e-13, 8e-9);
+    const double eps = eps_direct_vs_python(ARCH3 ? 3e-10 : 5e-13, 8e-9);
     std::unique_ptr<const MultiLayer> sample(ExemplarySamples::createCylindersAndPrisms());
     auto sim = test::makeSimulation::GISASWithMasks(*sample);
     EXPECT_TRUE(runTest("SimulationWithMasks", *sim, eps));
@@ -458,7 +464,7 @@ TEST(TESTNAME, LargeCylindersMonteCarlo)
 
 TEST(TESTNAME, RectDetWithRoi)
 {
-    const double eps = eps_direct_vs_python(5e-13, 8e-9);
+    const double eps = eps_direct_vs_python(ARCH3 ? 3e-10 : 5e-13, 8e-9);
     std::unique_ptr<const MultiLayer> sample(ExemplarySamples::createCylindersAndPrisms());
     auto sim = test::makeSimulation::RectDetWithRoi(*sample);
     EXPECT_TRUE(runTest("RectDetWithRoi", *sim, eps));
@@ -466,7 +472,7 @@ TEST(TESTNAME, RectDetWithRoi)
 
 TEST(TESTNAME, BoxesWithSpecular)
 {
-    const double eps = eps_direct_vs_python(5e-13, 8e-9);
+    const double eps = eps_direct_vs_python(ARCH3 ? 3e-10 : 5e-13, 8e-9);
     std::unique_ptr<const MultiLayer> sample(ExemplarySamples::createBoxesSquareLattice2D());
     auto sim = test::makeSimulation::MiniGISASSpecularPeak(*sample);
     EXPECT_TRUE(runTest("BoxesWithSpecular", *sim, eps));
@@ -544,7 +550,7 @@ TEST(TESTNAME, RelativeResolutionTOF)
 
 TEST(TESTNAME, SphericalDetWithRoi)
 {
-    const double eps = eps_direct_vs_python(5e-13, 8e-9);
+    const double eps = eps_direct_vs_python(ARCH3 ? 3e-10 : 5e-13, 8e-9);
     std::unique_ptr<const MultiLayer> sample(ExemplarySamples::createCylindersAndPrisms());
     auto sim = test::makeSimulation::SphericalDetWithRoi(*sample);
     EXPECT_TRUE(runTest("SphericalDetWithRoi", *sim, eps));
@@ -575,7 +581,7 @@ TEST(TESTNAME, DepthprobeSimpleLayer)
 
 TEST(TESTNAME, OffspecResonator)
 {
-    const double eps = eps_direct_vs_python(5e-13, 8e-9);
+    const double eps = eps_direct_vs_python(ARCH3 ? 3e-10 : 5e-13, 8e-9);
     auto* sample = ExemplarySamples::createResonator();
     auto sim = test::makeSimulation::MiniOffspec(*sample);
     EXPECT_TRUE(runTest("OffspecResonator", *sim, eps));
diff --git a/Tests/Suite/Persist/CMakeLists.txt b/Tests/Suite/Persist/CMakeLists.txt
index 3504f9fa8f4..b60293adecc 100644
--- a/Tests/Suite/Persist/CMakeLists.txt
+++ b/Tests/Suite/Persist/CMakeLists.txt
@@ -29,6 +29,9 @@ set(source_files Check.cpp ../Common/RunTest.cpp ${CMAKE_SOURCE_DIR}/Tests/GTest
 
 add_executable(${test} ${source_files})
 target_compile_definitions(${test} PRIVATE -DBORNAGAIN_PYTHON)
+if(BA_3ARCH)
+    target_compile_definitions(${test} PRIVATE -DBA_OTHER_ARCH)
+endif()
 target_compile_definitions(${test} PUBLIC DISABLE_DISTRIBUTION_TESTS -DTESTNAME=Persist)
 target_link_libraries(${test} BornAgainTestSimFactory gtest)
 
-- 
GitLab