Skip to content

Commit

Permalink
fixup
Browse files Browse the repository at this point in the history
  • Loading branch information
jngrad committed Jun 14, 2024
1 parent d4e34a6 commit 320bcf8
Show file tree
Hide file tree
Showing 25 changed files with 46 additions and 55 deletions.
30 changes: 2 additions & 28 deletions src/core/unit_tests/p3m_test.cpp
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
/*
* Copyright (C) 2010-2022 The ESPResSo project
* Copyright (C) 2020-2022 The ESPResSo project
*
* This file is part of ESPResSo.
*
Expand All @@ -17,7 +17,7 @@
* along with this program. If not, see <http://www.gnu.org/licenses/>.
*/

#define BOOST_TEST_MODULE p3m test
#define BOOST_TEST_MODULE "P3M utility functions"
#define BOOST_TEST_DYN_LINK
#include <boost/test/unit_test.hpp>

Expand All @@ -27,8 +27,6 @@

#include <array>
#include <cstddef>
#include <limits>
#include <stdexcept>
#include <vector>

BOOST_AUTO_TEST_CASE(calc_meshift_false) {
Expand Down Expand Up @@ -60,27 +58,3 @@ BOOST_AUTO_TEST_CASE(calc_meshift_true) {
}
}
}

#if defined(P3M) || defined(DP3M)
BOOST_AUTO_TEST_CASE(analytic_cotangent_sum) {
auto constexpr kernel = p3m_analytic_cotangent_sum;
auto constexpr tol = 8. * 100. * std::numeric_limits<double>::epsilon();

// check only trivial cases
for (auto const cao : {1, 2, 3, 4, 5, 6, 7}) {
BOOST_CHECK_CLOSE(kernel(0, 0., cao), 1., tol);
}
BOOST_CHECK_CLOSE(kernel(1, 0.5, 1), 1., tol);
BOOST_CHECK_CLOSE(kernel(1, 0.5, 2), 1. / 3., tol);
BOOST_CHECK_CLOSE(kernel(1, 0.5, 3), 2. / 15., tol);
BOOST_CHECK_CLOSE(kernel(1, 0.5, 4), 17. / 315., tol);
BOOST_CHECK_CLOSE(kernel(1, 0.5, 5), 62. / 2835., tol);
BOOST_CHECK_CLOSE(kernel(1, 0.5, 6), 1382. / 155925., tol);
BOOST_CHECK_CLOSE(kernel(1, 0.5, 7), 21844. / 6081075., tol);

// check assertion
for (auto const invalid_cao : {-1, 0, 8}) {
BOOST_CHECK_THROW(kernel(1, 0., invalid_cao), std::logic_error);
}
}
#endif // defined(P3M) || defined(DP3M)
2 changes: 0 additions & 2 deletions src/utils/tests/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -21,7 +21,6 @@

include(unit_test)

unit_test(NAME abs_test SRC abs_test.cpp DEPENDS espresso::utils)
unit_test(NAME Vector_test SRC Vector_test.cpp DEPENDS espresso::utils)
unit_test(NAME Factory_test SRC Factory_test.cpp DEPENDS espresso::utils)
unit_test(NAME NumeratedContainer_test SRC NumeratedContainer_test.cpp DEPENDS
Expand All @@ -34,7 +33,6 @@ unit_test(NAME accumulator SRC accumulator.cpp DEPENDS espresso::utils
unit_test(NAME int_pow SRC int_pow_test.cpp DEPENDS espresso::utils)
unit_test(NAME sgn SRC sgn_test.cpp DEPENDS espresso::utils)
unit_test(NAME AS_erfc_part SRC AS_erfc_part_test.cpp DEPENDS espresso::utils)
unit_test(NAME sinc SRC sinc_test.cpp DEPENDS espresso::utils)
unit_test(NAME permute_ifield_test SRC permute_ifield_test.cpp DEPENDS
espresso::utils)
unit_test(NAME vec_rotate SRC vec_rotate_test.cpp DEPENDS espresso::utils)
Expand Down
25 changes: 22 additions & 3 deletions src/utils/tests/Vector_test.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -43,7 +43,8 @@
using Utils::Vector;

/* Number of nontrivial Baxter permutations of length 2n-1. (A001185) */
#define TEST_NUMBERS {0, 1, 1, 7, 21, 112, 456, 2603, 13203}
#define TEST_NUMBERS \
{ 0, 1, 1, 7, 21, 112, 456, 2603, 13203 }

constexpr int test_numbers[] = TEST_NUMBERS;
constexpr std::size_t n_test_numbers = sizeof(test_numbers) / sizeof(int);
Expand All @@ -62,6 +63,17 @@ BOOST_AUTO_TEST_CASE(initializer_list_constructor) {
BOOST_CHECK_THROW(Utils::Vector2d({1., 2., 3.}), std::length_error);
}

BOOST_AUTO_TEST_CASE(span_constructor) {
constexpr static std::array<int, n_test_numbers> values(TEST_NUMBERS);
constexpr auto view = std::span(values);
Vector<int, n_test_numbers> v(view);

BOOST_CHECK(std::equal(v.begin(), v.end(), test_numbers));

BOOST_CHECK_THROW(Utils::Vector3i{view}, std::length_error);
BOOST_CHECK_THROW(Utils::Vector3i{view.subspan(0u, 2u)}, std::length_error);
}

BOOST_AUTO_TEST_CASE(iterator_constructor) {
Vector<int, n_test_numbers> v(std::begin(test_numbers),
std::end(test_numbers));
Expand Down Expand Up @@ -105,8 +117,8 @@ BOOST_AUTO_TEST_CASE(range_constructor_test) {
}

BOOST_AUTO_TEST_CASE(unit_vector_test) {
BOOST_CHECK((Utils::unit_vector<int>(2) == Utils::Vector3i{0, 0, 1}));
BOOST_CHECK_THROW(Utils::unit_vector<double>(3), std::domain_error);
BOOST_CHECK((Utils::unit_vector<int>(2u) == Utils::Vector3i{0, 0, 1}));
BOOST_CHECK_THROW(Utils::unit_vector<double>(3u), std::domain_error);
}

BOOST_AUTO_TEST_CASE(test_norm2) {
Expand Down Expand Up @@ -187,6 +199,13 @@ BOOST_AUTO_TEST_CASE(algebraic_operators) {
BOOST_CHECK(v4 == (v3 /= 2));
}

{
Utils::Vector3i v3{2, 12, 91};
Utils::Vector3i v4{180, 30, 3};
auto v5 = 360 / v3;
BOOST_CHECK(v5 == v4);
}

BOOST_CHECK((sqrt(Utils::Vector3d{1., 2., 3.}) ==
Utils::Vector3d{sqrt(1.), sqrt(2.), sqrt(3.)}));

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -56,7 +56,7 @@ class CollideSweepDoublePrecisionLeesEdwards {
BlockDataID pdfsID_, double grid_size,
double omega_shear, double v_s)
: forceID(forceID_), pdfsID(pdfsID_), grid_size_(grid_size),
omega_shear_(omega_shear), v_s_(v_s) {};
omega_shear_(omega_shear), v_s_(v_s){};

void run(IBlock *block);

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -57,7 +57,7 @@ class CollideSweepDoublePrecisionLeesEdwardsAVX {
double grid_size,
double omega_shear, double v_s)
: forceID(forceID_), pdfsID(pdfsID_), grid_size_(grid_size),
omega_shear_(omega_shear), v_s_(v_s) {};
omega_shear_(omega_shear), v_s_(v_s){};

void run(IBlock *block);

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -59,7 +59,7 @@ class CollideSweepDoublePrecisionLeesEdwardsCUDA {
double grid_size,
double omega_shear, double v_s)
: forceID(forceID_), pdfsID(pdfsID_), grid_size_(grid_size),
omega_shear_(omega_shear), v_s_(v_s) {};
omega_shear_(omega_shear), v_s_(v_s){};

void run(IBlock *block, gpuStream_t stream = nullptr);

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -60,7 +60,7 @@ class CollideSweepDoublePrecisionThermalized {
: forceID(forceID_), pdfsID(pdfsID_), kT_(kT), omega_bulk_(omega_bulk),
omega_even_(omega_even), omega_odd_(omega_odd),
omega_shear_(omega_shear), seed_(seed), time_step_(time_step),
configured_(false) {};
configured_(false){};

void run(IBlock *block);

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -61,7 +61,7 @@ class CollideSweepDoublePrecisionThermalizedAVX {
: forceID(forceID_), pdfsID(pdfsID_), kT_(kT), omega_bulk_(omega_bulk),
omega_even_(omega_even), omega_odd_(omega_odd),
omega_shear_(omega_shear), seed_(seed), time_step_(time_step),
configured_(false) {};
configured_(false){};

void run(IBlock *block);

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -61,7 +61,7 @@ class CollideSweepDoublePrecisionThermalizedCUDA {
: forceID(forceID_), pdfsID(pdfsID_), kT_(kT), omega_bulk_(omega_bulk),
omega_even_(omega_even), omega_odd_(omega_odd),
omega_shear_(omega_shear), seed_(seed), time_step_(time_step),
configured_(false) {};
configured_(false){};

void run(IBlock *block, gpuStream_t stream = nullptr);

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -56,7 +56,7 @@ class CollideSweepSinglePrecisionLeesEdwards {
BlockDataID pdfsID_, float grid_size,
float omega_shear, float v_s)
: forceID(forceID_), pdfsID(pdfsID_), grid_size_(grid_size),
omega_shear_(omega_shear), v_s_(v_s) {};
omega_shear_(omega_shear), v_s_(v_s){};

void run(IBlock *block);

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -57,7 +57,7 @@ class CollideSweepSinglePrecisionLeesEdwardsAVX {
float grid_size, float omega_shear,
float v_s)
: forceID(forceID_), pdfsID(pdfsID_), grid_size_(grid_size),
omega_shear_(omega_shear), v_s_(v_s) {};
omega_shear_(omega_shear), v_s_(v_s){};

void run(IBlock *block);

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -59,7 +59,7 @@ class CollideSweepSinglePrecisionLeesEdwardsCUDA {
float grid_size, float omega_shear,
float v_s)
: forceID(forceID_), pdfsID(pdfsID_), grid_size_(grid_size),
omega_shear_(omega_shear), v_s_(v_s) {};
omega_shear_(omega_shear), v_s_(v_s){};

void run(IBlock *block, gpuStream_t stream = nullptr);

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -60,7 +60,7 @@ class CollideSweepSinglePrecisionThermalized {
: forceID(forceID_), pdfsID(pdfsID_), kT_(kT), omega_bulk_(omega_bulk),
omega_even_(omega_even), omega_odd_(omega_odd),
omega_shear_(omega_shear), seed_(seed), time_step_(time_step),
configured_(false) {};
configured_(false){};

void run(IBlock *block);

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -60,7 +60,7 @@ class CollideSweepSinglePrecisionThermalizedAVX {
: forceID(forceID_), pdfsID(pdfsID_), kT_(kT), omega_bulk_(omega_bulk),
omega_even_(omega_even), omega_odd_(omega_odd),
omega_shear_(omega_shear), seed_(seed), time_step_(time_step),
configured_(false) {};
configured_(false){};

void run(IBlock *block);

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -62,7 +62,7 @@ class CollideSweepSinglePrecisionThermalizedCUDA {
: forceID(forceID_), pdfsID(pdfsID_), kT_(kT), omega_bulk_(omega_bulk),
omega_even_(omega_even), omega_odd_(omega_odd),
omega_shear_(omega_shear), seed_(seed), time_step_(time_step),
configured_(false) {};
configured_(false){};

void run(IBlock *block, gpuStream_t stream = nullptr);

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -55,7 +55,7 @@ class InitialPDFsSetterDoublePrecision {
InitialPDFsSetterDoublePrecision(BlockDataID forceID_, BlockDataID pdfsID_,
BlockDataID velocityID_, double rho_0)
: forceID(forceID_), pdfsID(pdfsID_), velocityID(velocityID_),
rho_0_(rho_0) {};
rho_0_(rho_0){};

void run(IBlock *block);

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -58,7 +58,7 @@ class InitialPDFsSetterDoublePrecisionCUDA {
BlockDataID pdfsID_,
BlockDataID velocityID_, double rho_0)
: forceID(forceID_), pdfsID(pdfsID_), velocityID(velocityID_),
rho_0_(rho_0) {};
rho_0_(rho_0){};

void run(IBlock *block, gpuStream_t stream = nullptr);

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -55,7 +55,7 @@ class InitialPDFsSetterSinglePrecision {
InitialPDFsSetterSinglePrecision(BlockDataID forceID_, BlockDataID pdfsID_,
BlockDataID velocityID_, float rho_0)
: forceID(forceID_), pdfsID(pdfsID_), velocityID(velocityID_),
rho_0_(rho_0) {};
rho_0_(rho_0){};

void run(IBlock *block);

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -58,7 +58,7 @@ class InitialPDFsSetterSinglePrecisionCUDA {
BlockDataID pdfsID_,
BlockDataID velocityID_, float rho_0)
: forceID(forceID_), pdfsID(pdfsID_), velocityID(velocityID_),
rho_0_(rho_0) {};
rho_0_(rho_0){};

void run(IBlock *block, gpuStream_t stream = nullptr);

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -54,7 +54,7 @@ class StreamSweepDoublePrecision {
public:
StreamSweepDoublePrecision(BlockDataID forceID_, BlockDataID pdfsID_,
BlockDataID velocityID_)
: forceID(forceID_), pdfsID(pdfsID_), velocityID(velocityID_) {};
: forceID(forceID_), pdfsID(pdfsID_), velocityID(velocityID_){};

~StreamSweepDoublePrecision() {
for (auto p : cache_pdfs_) {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -54,7 +54,7 @@ class StreamSweepDoublePrecisionAVX {
public:
StreamSweepDoublePrecisionAVX(BlockDataID forceID_, BlockDataID pdfsID_,
BlockDataID velocityID_)
: forceID(forceID_), pdfsID(pdfsID_), velocityID(velocityID_) {};
: forceID(forceID_), pdfsID(pdfsID_), velocityID(velocityID_){};

~StreamSweepDoublePrecisionAVX() {
for (auto p : cache_pdfs_) {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -56,7 +56,7 @@ class StreamSweepDoublePrecisionCUDA {
public:
StreamSweepDoublePrecisionCUDA(BlockDataID forceID_, BlockDataID pdfsID_,
BlockDataID velocityID_)
: forceID(forceID_), pdfsID(pdfsID_), velocityID(velocityID_) {};
: forceID(forceID_), pdfsID(pdfsID_), velocityID(velocityID_){};

~StreamSweepDoublePrecisionCUDA() {
for (auto p : cache_pdfs_) {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -54,7 +54,7 @@ class StreamSweepSinglePrecision {
public:
StreamSweepSinglePrecision(BlockDataID forceID_, BlockDataID pdfsID_,
BlockDataID velocityID_)
: forceID(forceID_), pdfsID(pdfsID_), velocityID(velocityID_) {};
: forceID(forceID_), pdfsID(pdfsID_), velocityID(velocityID_){};

~StreamSweepSinglePrecision() {
for (auto p : cache_pdfs_) {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -54,7 +54,7 @@ class StreamSweepSinglePrecisionAVX {
public:
StreamSweepSinglePrecisionAVX(BlockDataID forceID_, BlockDataID pdfsID_,
BlockDataID velocityID_)
: forceID(forceID_), pdfsID(pdfsID_), velocityID(velocityID_) {};
: forceID(forceID_), pdfsID(pdfsID_), velocityID(velocityID_){};

~StreamSweepSinglePrecisionAVX() {
for (auto p : cache_pdfs_) {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -56,7 +56,7 @@ class StreamSweepSinglePrecisionCUDA {
public:
StreamSweepSinglePrecisionCUDA(BlockDataID forceID_, BlockDataID pdfsID_,
BlockDataID velocityID_)
: forceID(forceID_), pdfsID(pdfsID_), velocityID(velocityID_) {};
: forceID(forceID_), pdfsID(pdfsID_), velocityID(velocityID_){};

~StreamSweepSinglePrecisionCUDA() {
for (auto p : cache_pdfs_) {
Expand Down

0 comments on commit 320bcf8

Please sign in to comment.