Skip to content

Commit

Permalink
all_wo_vector
Browse files Browse the repository at this point in the history
  • Loading branch information
jngrad committed Jun 14, 2024
1 parent 82743a7 commit e3f0797
Show file tree
Hide file tree
Showing 36 changed files with 155 additions and 56 deletions.
76 changes: 76 additions & 0 deletions .gitlab-ci.yml
Original file line number Diff line number Diff line change
Expand Up @@ -41,6 +41,40 @@ status_pending:
stage: prepare
script: sh maintainer/gh_post_status.sh pending

style:
<<: *global_job_definition
stage: build
dependencies: []
before_script:
- git config --global --add safe.directory ${CI_PROJECT_DIR}
- git submodule deinit .
script:
- sh maintainer/CI/fix_style.sh
tags:
- espresso
- no-cuda
variables:
GIT_SUBMODULE_STRATEGY: none
artifacts:
paths:
- style.patch
expire_in: 1 week
when: on_failure

style_doxygen:
<<: *global_job_definition
stage: build
dependencies: []
script:
- mkdir build
- cd build
- cp ../maintainer/configs/maxset.hpp myconfig.hpp
- cmake .. -D ESPRESSO_BUILD_WITH_CUDA=ON -D ESPRESSO_BUILD_WITH_GSL=ON -D ESPRESSO_BUILD_WITH_HDF5=ON -D ESPRESSO_BUILD_WITH_SCAFACOS=ON -D ESPRESSO_BUILD_WITH_WALBERLA=ON -D ESPRESSO_BUILD_WITH_WALBERLA_FFT=ON -D ESPRESSO_BUILD_WITH_STOKESIAN_DYNAMICS=ON -D ESPRESSO_BUILD_WITH_CALIPER=ON
- sh ../maintainer/CI/dox_warnings.sh
tags:
- espresso
- no-cuda

### Builds without CUDA

default:
Expand Down Expand Up @@ -402,6 +436,29 @@ empty:
- cuda
- numa

check_sphinx:
<<: *global_job_definition
stage: additional_checks
needs:
- cuda12-maxset
when: on_success
script:
- cd ${CI_PROJECT_DIR}/build
- make -t && make sphinx
- make -j2 tutorials
- make check_utils
- bash ${CI_PROJECT_DIR}/maintainer/CI/doc_warnings.sh
- python3 ${CI_PROJECT_DIR}/maintainer/CI/jupyter_warnings.py
artifacts:
paths:
- build/doc/sphinx
expire_in: 1 week
tags:
- espresso
- cuda
- numa
- reuse-artifacts-same-arch

run_tutorials:
<<: *global_job_definition
stage: additional_checks
Expand Down Expand Up @@ -430,6 +487,25 @@ run_tutorials:
only:
- schedules

run_doxygen:
<<: *global_job_definition
stage: additional_checks
needs:
- cuda12-maxset
when: on_success
script:
- cd ${CI_PROJECT_DIR}/build
- make -t && make doxygen
artifacts:
paths:
- build/doc/doxygen
expire_in: 1 week
tags:
- espresso
- no-cuda
- numa
- reuse-artifacts-same-arch

maxset_no_gpu:
<<: *global_job_definition
stage: additional_checks
Expand Down
1 change: 0 additions & 1 deletion maintainer/walberla_kernels/code_generation_context.py
Original file line number Diff line number Diff line change
Expand Up @@ -26,7 +26,6 @@
import pystencils_walberla



def earmark_generated_kernels():
"""
Add an earmark at the beginning of generated kernels to document the
Expand Down
4 changes: 3 additions & 1 deletion maintainer/walberla_kernels/generate_lb_kernels.py
Original file line number Diff line number Diff line change
Expand Up @@ -149,7 +149,9 @@ def paramlist(parameters, keys):
params
)

block_offsets = tuple(ps.TypedSymbol(f"block_offset_{i}", np.uint32) for i in range(3))
block_offsets = tuple(
ps.TypedSymbol(f"block_offset_{i}", np.uint32)
for i in range(3))

# generate thermalized LB
collision_rule_thermalized = lbmpy.creationfunctions.create_lb_collision_rule(
Expand Down
10 changes: 5 additions & 5 deletions maintainer/walberla_kernels/lbmpy_espresso.py
Original file line number Diff line number Diff line change
Expand Up @@ -46,11 +46,11 @@ def data_initialisation(self, direction):
cell_args = [f"it.{direction}() + {bb_vec[i]}".replace('+ -', '-')
for i, direction in enumerate("xyz")]
code = [
"auto const InitialisationAdditionalData = elementInitialiser(",
f"Cell({', '.join(cell_args)}), blocks, *block);",
"element.vel_0 = InitialisationAdditionalData[0];",
"element.vel_1 = InitialisationAdditionalData[1];",
"element.vel_2 = InitialisationAdditionalData[2];",
"auto const InitialisationAdditionalData = elementInitialiser(",
f"Cell({', '.join(cell_args)}), blocks, *block);",
"element.vel_0 = InitialisationAdditionalData[0];",
"element.vel_1 = InitialisationAdditionalData[1];",
"element.vel_2 = InitialisationAdditionalData[2];",
]
return "\n".join(code)

Expand Down
4 changes: 2 additions & 2 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 Down
2 changes: 1 addition & 1 deletion src/shapes/include/shapes/Ellipsoid.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -23,7 +23,7 @@
#define SHAPES_ELLIPSOID_HPP

#include "Shape.hpp"
#include <utils/Array.hpp>

#include <utils/Vector.hpp>

namespace Shapes {
Expand Down
7 changes: 4 additions & 3 deletions src/shapes/src/HollowConicalFrustum.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -20,9 +20,10 @@
#include <shapes/HollowConicalFrustum.hpp>

#include <utils/Vector.hpp>
#include <utils/math/abs.hpp>
#include <utils/math/coordinate_transformation.hpp>

#include <cmath>

namespace Shapes {
void HollowConicalFrustum::calculate_dist(const Utils::Vector3d &pos,
double &dist,
Expand Down Expand Up @@ -70,7 +71,7 @@ void HollowConicalFrustum::calculate_dist(const Utils::Vector3d &pos,
*/

auto endpoint_angle = pos_phi;
if (Utils::abs(pos_phi) < m_central_angle / 2.) {
if (std::fabs(pos_phi) < m_central_angle / 2.) {
// Cannot use Utils::sgn because of pos_phi==0 corner case
endpoint_angle =
pos_phi > 0. ? m_central_angle / 2. : -m_central_angle / 2.;
Expand All @@ -93,7 +94,7 @@ void HollowConicalFrustum::calculate_dist(const Utils::Vector3d &pos,
/* It can be that the projection onto the (infinite) line is outside the
* frustum. In that case, the closest point is actually one of the endpoints.
*/
if (Utils::abs(pos_closest_hcf_frame[2]) > m_length / 2.) {
if (std::fabs(pos_closest_hcf_frame[2]) > m_length / 2.) {
pos_closest_hcf_frame =
pos_closest_hcf_frame[2] > 0. ? r1_endpoint : r2_endpoint;
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -16,13 +16,14 @@
* You should have received a copy of the GNU General Public License
* along with this program. If not, see <http://www.gnu.org/licenses/>.
*/
#ifndef ESPRESSO_CYLINDER_TRANSFORMATION_PARAMETERS_HPP
#define ESPRESSO_CYLINDER_TRANSFORMATION_PARAMETERS_HPP

#pragma once

#include <cmath>
#include <limits>
#include <stdexcept>
#include <string>

#include <utils/math/abs.hpp>
#include <utils/math/orthonormal_vec.hpp>

namespace Utils {
Expand Down Expand Up @@ -63,30 +64,28 @@ class CylindricalTransformationParameters {

private:
void validate() const {
auto constexpr eps = 10 * std::numeric_limits<double>::epsilon();
if (Utils::abs(m_orientation * m_axis) > eps) {
auto constexpr eps = 10. * std::numeric_limits<double>::epsilon();
if (std::fabs(m_orientation * m_axis) > eps) {
throw std::runtime_error(
"CylindricalTransformationParameters: Axis and orientation must be "
"orthogonal. Scalar product is " +
std::to_string(m_orientation * m_axis));
}
if (Utils::abs(m_axis.norm() - 1) > eps) {
if (std::fabs(m_axis.norm() - 1.) > eps) {
throw std::runtime_error("CylindricalTransformationParameters: Axis must "
"be normalized. Norm is " +
std::to_string(m_axis.norm()));
}
if (Utils::abs(m_orientation.norm() - 1) > eps) {
if (std::fabs(m_orientation.norm() - 1.) > eps) {
throw std::runtime_error("CylindricalTransformationParameters: "
"orientation must be normalized. Norm is " +
std::to_string(m_orientation.norm()));
}
}

const Utils::Vector3d m_center{};
const Utils::Vector3d m_axis{0, 0, 1};
const Utils::Vector3d m_orientation{1, 0, 0};
Utils::Vector3d const m_center{};
Utils::Vector3d const m_axis{0., 0., 1.};
Utils::Vector3d const m_orientation{1., 0., 0.};
};

} // namespace Utils

#endif // ESPRESSO_CYLINDER_TRANSFORMATION_PARAMETERS_HPP
2 changes: 2 additions & 0 deletions src/utils/include/utils/math/sqr.hpp
Original file line number Diff line number Diff line change
@@ -1,5 +1,7 @@
/*
* Copyright (C) 2010-2022 The ESPResSo project
* Copyright (C) 2002,2003,2004,2005,2006,2007,2008,2009,2010
* Max-Planck-Institute for Polymer Research, Theory Group
*
* This file is part of ESPResSo.
*
Expand Down
1 change: 1 addition & 0 deletions src/utils/include/utils/quaternion.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -42,6 +42,7 @@
#include "utils/Array.hpp"
#include "utils/Vector.hpp"
#include "utils/matrix.hpp"
#include "utils/serialization/array.hpp"

#include <cassert>
#include <cstddef>
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
6 changes: 3 additions & 3 deletions src/walberla_bridge/src/lattice_boltzmann/LBWalberlaImpl.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -585,9 +585,9 @@ class LBWalberlaImpl : public LBWalberlaBase {
auto const omega_odd = odd_mode_relaxation_rate(omega);
auto const blocks = get_lattice().get_blocks();
m_kT = FloatType_c(kT);
auto obj = CollisionModelThermalized(
m_last_applied_force_field_id, m_pdf_field_id, m_kT, omega, omega,
omega_odd, omega, seed, uint32_t{0u});
auto obj = CollisionModelThermalized(m_last_applied_force_field_id,
m_pdf_field_id, m_kT, omega, omega,
omega_odd, omega, seed, uint32_t{0u});
m_collision_model = std::make_shared<CollisionModel>(std::move(obj));
m_run_collide_sweep = CollideSweepVisitor(blocks);
}
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
Loading

0 comments on commit e3f0797

Please sign in to comment.