Unverified Commit 0461599d authored by Axel Kohlmeyer's avatar Axel Kohlmeyer
Browse files

reduce base precision as required when running tests with pppm and FFT_SINGLE

parent 37b2da63
Loading
Loading
Loading
Loading
+4 −1
Original line number Diff line number Diff line
@@ -7,7 +7,7 @@ endif()

set(TEST_INPUT_FOLDER ${CMAKE_CURRENT_SOURCE_DIR}/tests)
add_library(style_tests STATIC yaml_writer.cpp error_stats.cpp test_config_reader.cpp test_main.cpp)
target_compile_definitions(style_tests PRIVATE TEST_INPUT_FOLDER=${TEST_INPUT_FOLDER})
target_compile_definitions(style_tests PRIVATE -DTEST_INPUT_FOLDER=${TEST_INPUT_FOLDER})
target_include_directories(style_tests PRIVATE ${LAMMPS_SOURCE_DIR})
target_link_libraries(style_tests PUBLIC GTest::GTest GTest::GMock Yaml::Yaml)
if(BUILD_MPI)
@@ -32,6 +32,9 @@ add_test(NAME ErrorStats COMMAND test_error_stats)
# pair style tester
add_executable(pair_style pair_style.cpp)
target_link_libraries(pair_style PRIVATE lammps style_tests)
if(FFT_SINGLE)
  target_compile_definitions(pair_style PRIVATE -DFFT_SINGLE)
endif()

# tests for a molecular systems and related pair styles
file(GLOB MOL_PAIR_TESTS LIST_DIRECTORIES false ${TEST_INPUT_FOLDER}/mol-pair-*.yaml)
+28 −6
Original line number Diff line number Diff line
@@ -28,10 +28,12 @@
#include "force.h"
#include "info.h"
#include "input.h"
#include "kspace.h"
#include "lammps.h"
#include "modify.h"
#include "pair.h"
#include "universe.h"
#include "utils.h"

#include <cctype>
#include <cstdio>
@@ -375,6 +377,11 @@ TEST(PairStyle, plain)
    ASSERT_EQ(lmp->atom->natoms, nlocal);

    double epsilon = test_config.epsilon;
    // relax test precision when using pppm and single precision FFTs
#if defined(FFT_SINGLE)
    if (lmp->force->kspace && lmp->force->kspace->compute_flag)
        if (utils::strmatch(lmp->force->kspace_style, "^pppm")) epsilon *= 2.0e8;
#endif
    double **f  = lmp->atom->f;
    tagint *tag = lmp->atom->tag;
    ErrorStats stats;
@@ -647,6 +654,11 @@ TEST(PairStyle, omp)

    // relax error a bit for USER-OMP package
    double epsilon = 5.0 * test_config.epsilon;
    // relax test precision when using pppm and single precision FFTs
#if defined(FFT_SINGLE)
    if (lmp->force->kspace && lmp->force->kspace->compute_flag)
        if (utils::strmatch(lmp->force->kspace_style, "^pppm")) epsilon *= 2.0e8;
#endif
    double **f                        = lmp->atom->f;
    tagint *tag                       = lmp->atom->tag;
    const std::vector<coord_t> &f_ref = test_config.init_forces;
@@ -814,6 +826,11 @@ TEST(PairStyle, intel)

    // relax error a bit for USER-INTEL package
    double epsilon = 7.5 * test_config.epsilon;
    // relax test precision when using pppm and single precision FFTs
#if defined(FFT_SINGLE)
    if (lmp->force->kspace && lmp->force->kspace->compute_flag)
        if (utils::strmatch(lmp->force->kspace_style, "^pppm")) epsilon *= 2.0e8;
#endif

    // we need to relax the epsilon a LOT for tests using long-range
    // coulomb with tabulation. seems more like mixed precision or a bug
@@ -933,6 +950,11 @@ TEST(PairStyle, opt)

    // relax error a bit for OPT package
    double epsilon = 2.0 * test_config.epsilon;
    // relax test precision when using pppm and single precision FFTs
#if defined(FFT_SINGLE)
    if (lmp->force->kspace && lmp->force->kspace->compute_flag)
        if (utils::strmatch(lmp->force->kspace_style, "^pppm")) epsilon *= 2.0e8;
#endif
    double **f                        = lmp->atom->f;
    tagint *tag                       = lmp->atom->tag;
    const std::vector<coord_t> &f_ref = test_config.init_forces;