Skip to content

Commit 56920ec

Browse files
committed
Remove fallback code for ESPRESSO_BUILD_WITH_SHARED_MEMORY_PARALLELISM disabled
find src/core -name '*.hpp' -o -name '*.cpp' -o -name '*.impl.hpp' | \ xargs grep -l ESPRESSO_SHARED_MEMORY_PARALLELISM | \ xargs -I{} unifdef -DESPRESSO_SHARED_MEMORY_PARALLELISM -t {} -o /dev/null
1 parent c1835bc commit 56920ec

27 files changed

Lines changed: 7 additions & 418 deletions

src/core/aosoa_pack.hpp

Lines changed: 0 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -21,8 +21,6 @@
2121

2222
#include <config/config.hpp>
2323

24-
#ifdef ESPRESSO_SHARED_MEMORY_PARALLELISM
25-
2624
#include "cell_system/CellStructure.hpp"
2725

2826
#include <Kokkos_Core.hpp>
@@ -119,5 +117,3 @@ struct CellStructure::AoSoA_pack {
119117

120118
bool has_exclusion(std::size_t i) const { return flags(i) == uint8_t{1}; }
121119
};
122-
123-
#endif // ESPRESSO_SHARED_MEMORY_PARALLELISM

src/core/cell_system/CellStructure.cpp

Lines changed: 0 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -51,12 +51,10 @@
5151

5252
#include <boost/mpi/collectives/all_reduce.hpp>
5353

54-
#ifdef ESPRESSO_SHARED_MEMORY_PARALLELISM
5554
#include <Cabana_Core.hpp>
5655
#include <Cabana_NeighborList.hpp>
5756
#include <Kokkos_Core.hpp>
5857
#include <omp.h>
59-
#endif
6058

6159
#include <algorithm>
6260
#include <cassert>
@@ -77,14 +75,11 @@
7775
#include <vector>
7876

7977
CellStructure::~CellStructure() {
80-
#ifdef ESPRESSO_SHARED_MEMORY_PARALLELISM
8178
clear_local_properties();
8279
// Kokkos handle can only be freed after all Cabana containers have been freed
8380
m_kokkos_handle.reset();
84-
#endif
8581
}
8682

87-
#ifdef ESPRESSO_SHARED_MEMORY_PARALLELISM
8883
void CellStructure::clear_local_properties() {
8984
m_local_force.reset();
9085
#ifdef ESPRESSO_ROTATION
@@ -242,8 +237,6 @@ void CellStructure::set_index_map() {
242237
m_num_local_particles_cached = unique_particles.size();
243238
}
244239

245-
#endif // ESPRESSO_SHARED_MEMORY_PARALLELISM
246-
247240
CellStructure::CellStructure(BoxGeometry const &box)
248241
: m_decomposition{std::make_unique<AtomDecomposition>(box)} {}
249242

@@ -520,7 +513,6 @@ void CellStructure::update_ghosts_and_resort_particle(unsigned data_parts) {
520513
}
521514
}
522515

523-
#ifdef ESPRESSO_SHARED_MEMORY_PARALLELISM
524516
void CellStructure::parallel_for_each_particle_impl(
525517
std::span<Cell *const> cells, ParticleUnaryOp &f) const {
526518
if (cells.size() > 1) {
@@ -536,7 +528,6 @@ void CellStructure::parallel_for_each_particle_impl(
536528
[&](auto part_idx) { f(*(particles.begin() + part_idx)); });
537529
}
538530
}
539-
#endif // ESPRESSO_SHARED_MEMORY_PARALLELISM
540531

541532
bool CellStructure::check_resort_required(
542533
Utils::Vector3d const &additional_offset) const {

src/core/cell_system/CellStructure.hpp

Lines changed: 1 addition & 21 deletions
Original file line numberDiff line numberDiff line change
@@ -62,7 +62,6 @@
6262
#endif
6363

6464
// forward declarations
65-
#ifdef ESPRESSO_SHARED_MEMORY_PARALLELISM
6665
namespace Kokkos {
6766
template <class DataType, class... Properties> class View;
6867
class HostSpace;
@@ -80,7 +79,6 @@ class AoSoA;
8079
struct KokkosHandle;
8180
template <class MemorySpace, class ListAlgorithm, class Layout, class BuildTag>
8281
class CustomVerletList;
83-
#endif // ESPRESSO_SHARED_MEMORY_PARALLELISM
8482

8583
template <typename Callable>
8684
concept ParticleCallback = requires(Callable c, Particle &p) {
@@ -168,7 +166,6 @@ struct EuclidianDistance {
168166
* be stored in separate structures.
169167
*/
170168
class CellStructure : public System::Leaf<CellStructure> {
171-
#ifdef ESPRESSO_SHARED_MEMORY_PARALLELISM
172169
public:
173170
static constexpr auto vector_length = 1;
174171
struct AoSoA_pack;
@@ -179,7 +176,6 @@ class CellStructure : public System::Leaf<CellStructure> {
179176
using ListType =
180177
CustomVerletList<Kokkos::HostSpace, ListAlgorithm, Cabana::VerletLayout2D,
181178
Cabana::TeamVectorOpTag>;
182-
#endif // ESPRESSO_SHARED_MEMORY_PARALLELISM
183179

184180
private:
185181
/** The local id-to-particle index */
@@ -199,7 +195,6 @@ class CellStructure : public System::Leaf<CellStructure> {
199195
/** @brief Verlet list skin. */
200196
double m_verlet_skin = 0.;
201197
double m_verlet_reuse = 0.;
202-
#ifdef ESPRESSO_SHARED_MEMORY_PARALLELISM
203198
int m_cached_max_local_particle_id = 0;
204199
std::size_t m_num_local_particles_cached = 0;
205200
int m_max_id = 0;
@@ -217,7 +212,6 @@ class CellStructure : public System::Leaf<CellStructure> {
217212
/** The local id-to-index for aosoa data */
218213
std::vector<Particle *> m_unique_particles;
219214
std::shared_ptr<KokkosHandle> m_kokkos_handle;
220-
#endif // ESPRESSO_SHARED_MEMORY_PARALLELISM
221215

222216
public:
223217
CellStructure(BoxGeometry const &box);
@@ -354,26 +348,18 @@ class CellStructure : public System::Leaf<CellStructure> {
354348
}
355349

356350
/** @brief whether to use parallel version of @ref for_each_local_particle */
357-
bool use_parallel_for_each_local_particle() const {
358-
#ifdef ESPRESSO_SHARED_MEMORY_PARALLELISM
359-
return true;
360-
#else
361-
return false;
362-
#endif
363-
}
351+
bool use_parallel_for_each_local_particle() const { return true; }
364352

365353
/**
366354
* @brief Run a kernel on all local particles.
367355
* The kernel is assumed to be thread-safe.
368356
*/
369357
void for_each_local_particle(ParticleUnaryOp &&f,
370358
bool parallel = true) const {
371-
#ifdef ESPRESSO_SHARED_MEMORY_PARALLELISM
372359
if (parallel and use_parallel_for_each_local_particle()) {
373360
parallel_for_each_particle_impl(decomposition().local_cells(), f);
374361
return;
375362
}
376-
#endif
377363
for (auto &p : local_particles()) {
378364
f(p);
379365
}
@@ -403,10 +389,8 @@ class CellStructure : public System::Leaf<CellStructure> {
403389
return decomposition().particle_to_cell(p);
404390
}
405391

406-
#ifdef ESPRESSO_SHARED_MEMORY_PARALLELISM
407392
void parallel_for_each_particle_impl(std::span<Cell *const> cells,
408393
ParticleUnaryOp &f) const;
409-
#endif
410394

411395
public:
412396
/**
@@ -456,14 +440,12 @@ class CellStructure : public System::Leaf<CellStructure> {
456440
* this node, or -1 if there are no particles on this node.
457441
*/
458442
int get_max_local_particle_id() const;
459-
#ifdef ESPRESSO_SHARED_MEMORY_PARALLELISM
460443
int get_cached_max_local_particle_id() const {
461444
return m_cached_max_local_particle_id;
462445
}
463446
std::size_t get_num_local_particles_cached() const {
464447
return m_num_local_particles_cached;
465448
}
466-
#endif
467449

468450
/**
469451
* @brief Remove all particles from the cell system.
@@ -728,7 +710,6 @@ class CellStructure : public System::Leaf<CellStructure> {
728710
}
729711
}
730712

731-
#ifdef ESPRESSO_SHARED_MEMORY_PARALLELISM
732713
public:
733714
auto get_max_id() const { return m_max_id; }
734715

@@ -787,7 +768,6 @@ class CellStructure : public System::Leaf<CellStructure> {
787768
inline void cell_list_loop(auto &&kernel) {
788769
kernel(m_decomposition->local_cells(), m_decomposition->box());
789770
}
790-
#endif
791771

792772
private:
793773
/** Non-bonded pair loop with verlet lists.

src/core/cell_system/particle_enumeration.hpp

Lines changed: 0 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -24,9 +24,7 @@
2424
#include "Cell.hpp"
2525
#include "CellStructure.hpp"
2626

27-
#ifdef ESPRESSO_SHARED_MEMORY_PARALLELISM
2827
#include <Kokkos_Core.hpp>
29-
#endif
3028

3129
#include <cstddef>
3230
#include <numeric>
@@ -43,7 +41,6 @@
4341
template <typename Kernel>
4442
inline void enumerate_local_particles(CellStructure const &cs,
4543
Kernel &&kernel) {
46-
#ifdef ESPRESSO_SHARED_MEMORY_PARALLELISM
4744
if (cs.use_parallel_for_each_local_particle()) {
4845
auto const local_cells = cs.decomposition().local_cells();
4946

@@ -66,7 +63,6 @@ inline void enumerate_local_particles(CellStructure const &cs,
6663
});
6764
return;
6865
}
69-
#endif // ESPRESSO_SHARED_MEMORY_PARALLELISM
7066
// Sequential fallback
7167
std::size_t index = 0;
7268
for (auto &p : cs.local_particles()) {

src/core/collision_detection/CollisionDetection.cpp

Lines changed: 0 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -51,9 +51,7 @@ void CollisionDetection::initialize() {
5151
*m_protocol);
5252
}
5353
system.on_short_range_ia_change();
54-
#ifdef ESPRESSO_SHARED_MEMORY_PARALLELISM
5554
system.cell_structure->clear_local_properties();
56-
#endif
5755
}
5856

5957
void CollisionDetection::set_protocol(
@@ -66,9 +64,7 @@ void CollisionDetection::unset_protocol() {
6664
m_protocol = nullptr;
6765
auto &system = get_system();
6866
system.on_short_range_ia_change();
69-
#ifdef ESPRESSO_SHARED_MEMORY_PARALLELISM
7067
system.cell_structure->clear_local_properties();
71-
#endif
7268
}
7369

7470
} // namespace CollisionDetection

src/core/communication.cpp

Lines changed: 0 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -31,11 +31,9 @@
3131
#include <walberla_bridge/walberla_init.hpp>
3232
#endif
3333

34-
#ifdef ESPRESSO_SHARED_MEMORY_PARALLELISM
3534
#include <Cabana_Core.hpp>
3635
#include <Kokkos_Core.hpp>
3736
#include <omp.h>
38-
#endif
3937

4038
#include <utils/Vector.hpp>
4139
#include <utils/mpi/cart_comm.hpp>
@@ -57,19 +55,15 @@
5755
#include <tuple>
5856
#include <utility>
5957

60-
#ifdef ESPRESSO_SHARED_MEMORY_PARALLELISM
6158
struct KokkosHandle {
6259
KokkosHandle() { Kokkos::initialize(); }
6360
~KokkosHandle() { Kokkos::finalize(); }
6461
};
65-
#endif
6662

6763
boost::mpi::communicator comm_cart;
6864
Communicator communicator{};
6965
std::unique_ptr<CommunicationEnvironment> communication_environment{};
70-
#ifdef ESPRESSO_SHARED_MEMORY_PARALLELISM
7166
std::shared_ptr<KokkosHandle> kokkos_handle{};
72-
#endif
7367
int this_node = -1;
7468

7569
[[maybe_unused]] static auto get_env_variable(char const *const name) {
@@ -93,12 +87,10 @@ CommunicationEnvironment::CommunicationEnvironment()
9387
CommunicationEnvironment::CommunicationEnvironment(
9488
std::shared_ptr<boost::mpi::environment> mpi_env)
9589
: m_mpi_env{std::move(mpi_env)} {
96-
#ifdef ESPRESSO_SHARED_MEMORY_PARALLELISM
9790
auto const num_threads_env = get_env_variable("OMP_NUM_THREADS");
9891
if (not num_threads_env or num_threads_env->empty()) {
9992
omp_set_num_threads(1);
10093
}
101-
#endif
10294

10395
m_is_mpi_gpu_aware = false;
10496

@@ -140,16 +132,12 @@ CommunicationEnvironment::CommunicationEnvironment(
140132
fft_on_program_start();
141133
#endif
142134

143-
#ifdef ESPRESSO_SHARED_MEMORY_PARALLELISM
144135
kokkos_handle = std::make_shared<KokkosHandle>();
145-
#endif
146136
}
147137

148138
CommunicationEnvironment::~CommunicationEnvironment() {
149-
#ifdef ESPRESSO_SHARED_MEMORY_PARALLELISM
150139
Kokkos::fence();
151140
kokkos_handle.reset();
152-
#endif
153141

154142
#ifdef ESPRESSO_WALBERLA
155143
walberla::mpi_deinit();

src/core/communication.hpp

Lines changed: 0 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -59,10 +59,8 @@
5959
extern int this_node;
6060
/** The communicator */
6161
extern boost::mpi::communicator comm_cart;
62-
#ifdef ESPRESSO_SHARED_MEMORY_PARALLELISM
6362
struct KokkosHandle;
6463
extern std::shared_ptr<KokkosHandle> kokkos_handle;
65-
#endif
6664

6765
class CommunicationEnvironment {
6866
std::shared_ptr<boost::mpi::environment> m_mpi_env;

src/core/custom_verlet_list.hpp

Lines changed: 0 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -21,8 +21,6 @@
2121

2222
#include <config/config.hpp>
2323

24-
#ifdef ESPRESSO_SHARED_MEMORY_PARALLELISM
25-
2624
#include <Cabana_VerletList.hpp>
2725

2826
#include <algorithm>
@@ -224,5 +222,3 @@ class Cabana::NeighborList<CustomVerletList<MemorySpace, AlgorithmTag,
224222
return list.neighbors(particle_index, count);
225223
}
226224
};
227-
228-
#endif // ESPRESSO_SHARED_MEMORY_PARALLELISM

src/core/electrostatics/elc.cpp

Lines changed: 0 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -39,9 +39,7 @@
3939

4040
#include <utils/math/sqr.hpp>
4141

42-
#ifdef ESPRESSO_SHARED_MEMORY_PARALLELISM
4342
#include <Kokkos_Core.hpp>
44-
#endif
4543

4644
#include <boost/mpi/collectives/all_reduce.hpp>
4745
#include <boost/range/combine.hpp>
@@ -1128,12 +1126,8 @@ void charge_assign(elc_data const &elc, CoulombP3M &solver,
11281126
solver.prepare_fft_mesh(protocol == ChargeProtocol::BOTH or
11291127
protocol == ChargeProtocol::IMAGE);
11301128

1131-
#ifdef ESPRESSO_SHARED_MEMORY_PARALLELISM
11321129
// multi-threading -> cache sizes must be equal to the number of particles
11331130
auto constexpr include_neutral_particles = true;
1134-
#else
1135-
auto constexpr include_neutral_particles = false;
1136-
#endif
11371131

11381132
for (auto zipped : p_q_pos_range) {
11391133
auto const p_q = boost::get<0>(zipped);

src/core/electrostatics/elc.hpp

Lines changed: 0 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -116,7 +116,6 @@ struct elc_data {
116116
/** The space that is finally left. */
117117
double space_box;
118118

119-
#ifdef ESPRESSO_SHARED_MEMORY_PARALLELISM
120119
/// pairwise contributions from lower and upper layers
121120
void dielectric_layers_contribution(BoxGeometry const &box_geo,
122121
std::size_t p1, std::size_t p2,
@@ -140,7 +139,6 @@ struct elc_data {
140139
kernel(q_eff, d);
141140
}
142141
}
143-
#endif // ESPRESSO_SHARED_MEMORY_PARALLELISM
144142

145143
/// pairwise contributions from lower and upper layers
146144
void dielectric_layers_contribution(BoxGeometry const &box_geo,
@@ -281,7 +279,6 @@ struct ElectrostaticLayerCorrection
281279
base_solver);
282280
}
283281

284-
#ifdef ESPRESSO_SHARED_MEMORY_PARALLELISM
285282
/** @brief Calculate short-range pair energy correction. */
286283
double pair_energy_correction(std::size_t p1, std::size_t p2, auto &aosoa,
287284
double q1q2) const {
@@ -307,7 +304,6 @@ struct ElectrostaticLayerCorrection
307304
}
308305
return energy;
309306
}
310-
#endif // ESPRESSO_SHARED_MEMORY_PARALLELISM
311307

312308
/** @brief Calculate short-range pair energy correction. */
313309
double pair_energy_correction(Utils::Vector3d const &pos1,

0 commit comments

Comments
 (0)