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

This commit is contained in:
Axel Kohlmeyer
2020-07-04 18:13:55 -04:00
parent 37b2da637d
commit 0461599d0a
2 changed files with 32 additions and 7 deletions

View File

@ -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)

View File

@ -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,8 +377,13 @@ TEST(PairStyle, plain)
ASSERT_EQ(lmp->atom->natoms, nlocal);
double epsilon = test_config.epsilon;
double **f = lmp->atom->f;
tagint *tag = lmp->atom->tag;
// 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;
stats.reset();
const std::vector<coord_t> &f_ref = test_config.init_forces;
@ -646,7 +653,12 @@ TEST(PairStyle, omp)
ASSERT_EQ(lmp->atom->natoms, nlocal);
// relax error a bit for USER-OMP package
double epsilon = 5.0 * test_config.epsilon;
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
@ -932,7 +949,12 @@ TEST(PairStyle, opt)
ASSERT_EQ(lmp->atom->natoms, nlocal);
// relax error a bit for OPT package
double epsilon = 2.0 * test_config.epsilon;
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;
@ -1283,8 +1305,8 @@ TEST(PairStyle, extract)
GTEST_SKIP();
}
void *ptr = nullptr;
int dim = 0;
void *ptr = nullptr;
int dim = 0;
for (auto &extract : test_config.extract) {
ptr = pair->extract(extract.first.c_str(), dim);
EXPECT_NE(ptr, nullptr);