Skip to content

Commit 12835db

Browse files
committed
progress
1 parent 4884c35 commit 12835db

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

46 files changed

+1378
-946
lines changed

cmake/FindFFTW3.cmake

Lines changed: 8 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -31,25 +31,27 @@ if(FFTW3_INCLUDE_DIR)
3131
endif(FFTW3_INCLUDE_DIR)
3232

3333
find_path(FFTW3_INCLUDE_DIR fftw3.h)
34-
find_library(FFTW3_LIBRARIES NAMES fftw3)
34+
find_library(FFTW3_LIBRARIES fftw3)
35+
find_library(FFTW3F_LIBRARIES fftw3f)
3536
find_path(FFTW3_MPI_INCLUDE_DIR fftw3-mpi.h)
36-
find_library(FFTW3_MPI_LIBRARIES NAMES fftw3_mpi)
37+
find_library(FFTW3_MPI_LIBRARIES fftw3_mpi)
38+
find_library(FFTW3F_MPI_LIBRARIES fftw3f_mpi)
3739

3840
# handle the QUIETLY and REQUIRED arguments and set FFTW3_FOUND to TRUE if all
3941
# listed variables are TRUE
4042
include(FindPackageHandleStandardArgs)
41-
find_package_handle_standard_args(FFTW3 DEFAULT_MSG FFTW3_LIBRARIES
43+
find_package_handle_standard_args(FFTW3 DEFAULT_MSG FFTW3_LIBRARIES FFTW3F_LIBRARIES
4244
FFTW3_INCLUDE_DIR)
4345
set(FPHSA_NAME_MISMATCHED 1)
44-
find_package_handle_standard_args(FFTW3_MPI DEFAULT_MSG FFTW3_MPI_LIBRARIES
46+
find_package_handle_standard_args(FFTW3_MPI DEFAULT_MSG FFTW3_MPI_LIBRARIES FFTW3F_MPI_LIBRARIES
4547
FFTW3_MPI_INCLUDE_DIR)
4648
unset(FPHSA_NAME_MISMATCHED)
4749

48-
mark_as_advanced(FFTW3_LIBRARIES FFTW3_INCLUDE_DIR FFTW3_MPI_LIBRARIES FFTW3_MPI_INCLUDE_DIR)
50+
mark_as_advanced(FFTW3_LIBRARIES FFTW3F_LIBRARIES FFTW3_INCLUDE_DIR FFTW3_MPI_LIBRARIES FFTW3F_MPI_LIBRARIES FFTW3_MPI_INCLUDE_DIR)
4951

5052

5153
if(FFTW3_FOUND AND NOT TARGET FFTW3::FFTW3)
5254
add_library(FFTW3::FFTW3 INTERFACE IMPORTED)
5355
target_include_directories(FFTW3::FFTW3 INTERFACE "${FFTW3_INCLUDE_DIR}")
54-
target_link_libraries(FFTW3::FFTW3 INTERFACE "${FFTW3_LIBRARIES}")
56+
target_link_libraries(FFTW3::FFTW3 INTERFACE "${FFTW3_LIBRARIES}" "${FFTW3F_LIBRARIES}")
5557
endif()

src/core/electrostatics/CMakeLists.txt

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -24,6 +24,5 @@ target_sources(
2424
${CMAKE_CURRENT_SOURCE_DIR}/mmm1d.cpp
2525
${CMAKE_CURRENT_SOURCE_DIR}/mmm-modpsi.cpp
2626
${CMAKE_CURRENT_SOURCE_DIR}/p3m.cpp
27-
${CMAKE_CURRENT_SOURCE_DIR}/p3m_gpu.cpp
2827
${CMAKE_CURRENT_SOURCE_DIR}/scafacos_impl.cpp
2928
${CMAKE_CURRENT_SOURCE_DIR}/specfunc.cpp)

src/core/electrostatics/coulomb.cpp

Lines changed: 0 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -207,11 +207,6 @@ struct LongRangeForce {
207207
void operator()(std::shared_ptr<CoulombP3M> const &actor) const {
208208
actor->add_long_range_forces(m_particles);
209209
}
210-
#ifdef CUDA
211-
void operator()(std::shared_ptr<CoulombP3MGPU> const &actor) const {
212-
actor->add_long_range_forces(m_particles);
213-
}
214-
#endif // CUDA
215210
void
216211
operator()(std::shared_ptr<ElectrostaticLayerCorrection> const &actor) const {
217212
actor->add_long_range_forces(m_particles);

src/core/electrostatics/coulomb.hpp

Lines changed: 0 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -32,7 +32,6 @@
3232
#include "electrostatics/icc.hpp"
3333
#include "electrostatics/mmm1d.hpp"
3434
#include "electrostatics/p3m.hpp"
35-
#include "electrostatics/p3m_gpu.hpp"
3635
#include "electrostatics/reaction_field.hpp"
3736
#include "electrostatics/scafacos.hpp"
3837

@@ -49,9 +48,6 @@ using ElectrostaticsActor =
4948
std::variant<std::shared_ptr<DebyeHueckel>,
5049
#ifdef P3M
5150
std::shared_ptr<CoulombP3M>,
52-
#ifdef CUDA
53-
std::shared_ptr<CoulombP3MGPU>,
54-
#endif // CUDA
5551
std::shared_ptr<ElectrostaticLayerCorrection>,
5652
#endif // P3M
5753
std::shared_ptr<CoulombMMM1D>,

src/core/electrostatics/elc.cpp

Lines changed: 25 additions & 25 deletions
Original file line numberDiff line numberDiff line change
@@ -27,7 +27,6 @@
2727

2828
#include "electrostatics/coulomb.hpp"
2929
#include "electrostatics/p3m.hpp"
30-
#include "electrostatics/p3m_gpu.hpp"
3130

3231
#include "BoxGeometry.hpp"
3332
#include "Particle.hpp"
@@ -1111,31 +1110,28 @@ static void p3m_assign_image_charge(elc_data const &elc, CoulombP3M &p3m,
11111110
double q, Utils::Vector3d const &pos) {
11121111
if (pos[2] < elc.space_layer) {
11131112
auto const q_eff = elc.delta_mid_bot * q;
1114-
p3m.assign_charge(q_eff, {pos[0], pos[1], -pos[2]});
1113+
p3m.assign_charge(q_eff, {pos[0], pos[1], -pos[2]}, true);
11151114
}
11161115
if (pos[2] > (elc.box_h - elc.space_layer)) {
11171116
auto const q_eff = elc.delta_mid_top * q;
1118-
p3m.assign_charge(q_eff, {pos[0], pos[1], 2. * elc.box_h - pos[2]});
1117+
p3m.assign_charge(q_eff, {pos[0], pos[1], 2. * elc.box_h - pos[2]}, true);
11191118
}
11201119
}
11211120

11221121
template <ChargeProtocol protocol, typename combined_ranges>
11231122
void charge_assign(elc_data const &elc, CoulombP3M &solver,
11241123
combined_ranges const &p_q_pos_range) {
1125-
if (protocol == ChargeProtocol::BOTH or protocol == ChargeProtocol::IMAGE) {
1126-
solver.p3m.inter_weights.reset(solver.p3m.params.cao);
1127-
}
1128-
/* prepare local FFT mesh */
1129-
for (int i = 0; i < solver.p3m.local_mesh.size; i++)
1130-
solver.p3m.mesh.rs_scalar[i] = 0.;
1124+
1125+
solver.assign_charge_prepare_elc(protocol == ChargeProtocol::BOTH or
1126+
protocol == ChargeProtocol::IMAGE);
11311127

11321128
for (auto zipped : p_q_pos_range) {
11331129
auto const p_q = boost::get<0>(zipped);
11341130
auto const &p_pos = boost::get<1>(zipped);
11351131
if (p_q != 0.) {
11361132
if (protocol == ChargeProtocol::BOTH or
11371133
protocol == ChargeProtocol::REAL) {
1138-
solver.assign_charge(p_q, p_pos, solver.p3m.inter_weights);
1134+
solver.assign_charge(p_q, p_pos);
11391135
}
11401136
if (protocol == ChargeProtocol::BOTH or
11411137
protocol == ChargeProtocol::IMAGE) {
@@ -1149,7 +1145,9 @@ template <ChargeProtocol protocol, typename combined_range>
11491145
void modify_p3m_sums(elc_data const &elc, CoulombP3M &solver,
11501146
combined_range const &p_q_pos_range) {
11511147

1152-
Utils::Vector3d node_sums{};
1148+
auto local_n = 0;
1149+
auto local_q2 = 0.0;
1150+
auto local_q = 0.0;
11531151
for (auto zipped : p_q_pos_range) {
11541152
auto const p_q = boost::get<0>(zipped);
11551153
auto const &p_pos = boost::get<1>(zipped);
@@ -1158,33 +1156,35 @@ void modify_p3m_sums(elc_data const &elc, CoulombP3M &solver,
11581156

11591157
if (protocol == ChargeProtocol::BOTH or
11601158
protocol == ChargeProtocol::REAL) {
1161-
node_sums[0] += 1.;
1162-
node_sums[1] += Utils::sqr(p_q);
1163-
node_sums[2] += p_q;
1159+
local_n++;
1160+
local_q2 += Utils::sqr(p_q);
1161+
local_q += p_q;
11641162
}
11651163

11661164
if (protocol == ChargeProtocol::BOTH or
11671165
protocol == ChargeProtocol::IMAGE) {
11681166
if (p_z < elc.space_layer) {
1169-
node_sums[0] += 1.;
1170-
node_sums[1] += Utils::sqr(elc.delta_mid_bot * p_q);
1171-
node_sums[2] += elc.delta_mid_bot * p_q;
1167+
local_n++;
1168+
local_q2 += Utils::sqr(elc.delta_mid_bot * p_q);
1169+
local_q += elc.delta_mid_bot * p_q;
11721170
}
11731171

11741172
if (p_z > (elc.box_h - elc.space_layer)) {
1175-
node_sums[0] += 1.;
1176-
node_sums[1] += Utils::sqr(elc.delta_mid_top * p_q);
1177-
node_sums[2] += elc.delta_mid_top * p_q;
1173+
local_n++;
1174+
local_q2 += Utils::sqr(elc.delta_mid_top * p_q);
1175+
local_q += elc.delta_mid_top * p_q;
11781176
}
11791177
}
11801178
}
11811179
}
11821180

1183-
auto const tot_sums =
1184-
boost::mpi::all_reduce(comm_cart, node_sums, std::plus<>());
1185-
solver.p3m.sum_qpart = static_cast<int>(tot_sums[0] + 0.1);
1186-
solver.p3m.sum_q2 = tot_sums[1];
1187-
solver.p3m.square_sum_q = Utils::sqr(tot_sums[2]);
1181+
auto global_n = 0;
1182+
auto global_q2 = 0.;
1183+
auto global_q = 0.;
1184+
boost::mpi::all_reduce(comm_cart, local_n, global_n, std::plus<>());
1185+
boost::mpi::all_reduce(comm_cart, local_q2, global_q2, std::plus<>());
1186+
boost::mpi::all_reduce(comm_cart, local_q, global_q, std::plus<>());
1187+
solver.count_charged_particles_elc(global_n, global_q2, Utils::sqr(global_q));
11881188
}
11891189

11901190
double ElectrostaticLayerCorrection::long_range_energy(

src/core/electrostatics/elc.hpp

Lines changed: 2 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -37,13 +37,13 @@
3737
#include "actor/traits.hpp"
3838

3939
#include "electrostatics/p3m.hpp"
40-
#include "electrostatics/p3m_gpu.hpp"
4140

4241
#include "BoxGeometry.hpp"
4342
#include "Particle.hpp"
4443
#include "ParticleRange.hpp"
4544

4645
#include <utils/Vector.hpp>
46+
#include <utils/math/sqr.hpp>
4747

4848
#include <memory>
4949
#include <optional>
@@ -166,11 +166,7 @@ struct elc_data {
166166

167167
struct ElectrostaticLayerCorrection
168168
: public Coulomb::Actor<ElectrostaticLayerCorrection> {
169-
using BaseSolver = std::variant<
170-
#ifdef CUDA
171-
std::shared_ptr<CoulombP3MGPU>,
172-
#endif // CUDA
173-
std::shared_ptr<CoulombP3M>>;
169+
using BaseSolver = std::variant<std::shared_ptr<CoulombP3M>>;
174170

175171
elc_data elc;
176172
BoxGeometry *m_box_geo;

src/core/electrostatics/icc.cpp

Lines changed: 7 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -40,6 +40,8 @@
4040
#include "communication.hpp"
4141
#include "electrostatics/coulomb.hpp"
4242
#include "electrostatics/coulomb_inline.hpp"
43+
#include "electrostatics/p3m.hpp"
44+
#include "electrostatics/p3m.impl.hpp"
4345
#include "errorhandling.hpp"
4446
#include "integrators/Propagation.hpp"
4547
#include "system/System.hpp"
@@ -248,8 +250,11 @@ struct SanityChecksICC {
248250
template <typename T> void operator()(std::shared_ptr<T> const &) const {}
249251
#ifdef P3M
250252
#ifdef CUDA
251-
[[noreturn]] void operator()(std::shared_ptr<CoulombP3MGPU> const &) const {
252-
throw std::runtime_error("ICC does not work with P3MGPU");
253+
void operator()(std::shared_ptr<CoulombP3M> const &p) const {
254+
if (dynamic_cast<CoulombP3MImpl<float, Arch::GPU> *>(p.get()) != nullptr or
255+
dynamic_cast<CoulombP3MImpl<double, Arch::GPU> *>(p.get()) != nullptr) {
256+
throw std::runtime_error("ICC does not work with P3MGPU");
257+
}
253258
}
254259
#endif // CUDA
255260
void

0 commit comments

Comments
 (0)