Skip to content

Commit dac9b50

Browse files
committed
WarpX/ImpactX: Compile Only 1 PC
Skip all the other templated PC to save compile and link time.
1 parent 2ae72e8 commit dac9b50

File tree

3 files changed

+40
-33
lines changed

3 files changed

+40
-33
lines changed

src/Particle/ParticleContainer.H

Lines changed: 31 additions & 28 deletions
Original file line numberDiff line numberDiff line change
@@ -505,7 +505,7 @@ void make_ParticleContainer_and_Iterators (py::module &m, std::string allocstr)
505505
/** Create ParticleContainers and Iterators
506506
*/
507507
template <typename T_ParticleType, int T_NArrayReal=0, int T_NArrayInt=0>
508-
void make_ParticleContainer_and_Iterators (py::module &m)
508+
void make_ParticleContainer_and_Iterators (py::module &m, bool only_polymorphic=false)
509509
{
510510
if constexpr (T_ParticleType::is_soa_particle) {
511511
make_Particle<T_NArrayReal, T_NArrayInt>(m);
@@ -532,38 +532,41 @@ void make_ParticleContainer_and_Iterators (py::module &m)
532532
make_ParticleInitData<T_ParticleType, T_NArrayReal, T_NArrayInt>(m);
533533

534534
// first, because used as copy target in methods in containers with other allocators
535-
make_ParticleContainer_and_Iterators<T_ParticleType, T_NArrayReal, T_NArrayInt,
536-
amrex::PinnedArenaAllocator>(m, "pinned");
537-
538-
// see Src/Base/AMReX_GpuContainers.H
539-
// !AMREX_USE_GPU: DefaultAllocator = std::allocator
540-
// AMREX_USE_GPU: DefaultAllocator = amrex::ArenaAllocator
541-
542-
// work-around for https://github.com/pybind/pybind11/pull/4581
543-
//make_ParticleContainer_and_Iterators<T_ParticleType, T_NArrayReal, T_NArrayInt,
544-
// std::allocator>(m, "std"); // CPU DefaultAllocator
545-
//make_ParticleContainer_and_Iterators<T_ParticleType, T_NArrayReal, T_NArrayInt,
546-
// amrex::ArenaAllocator>(m, "arena"); // GPU DefaultAllocator
535+
if (!only_polymorphic) {
536+
make_ParticleContainer_and_Iterators<T_ParticleType, T_NArrayReal, T_NArrayInt,
537+
amrex::PinnedArenaAllocator>(m, "pinned");
538+
539+
// see Src/Base/AMReX_GpuContainers.H
540+
// !AMREX_USE_GPU: DefaultAllocator = std::allocator
541+
// AMREX_USE_GPU: DefaultAllocator = amrex::ArenaAllocator
542+
543+
// work-around for https://github.com/pybind/pybind11/pull/4581
544+
//make_ParticleContainer_and_Iterators<T_ParticleType, T_NArrayReal, T_NArrayInt,
545+
// std::allocator>(m, "std"); // CPU DefaultAllocator
546+
//make_ParticleContainer_and_Iterators<T_ParticleType, T_NArrayReal, T_NArrayInt,
547+
// amrex::ArenaAllocator>(m, "arena"); // GPU DefaultAllocator
547548
#ifdef AMREX_USE_GPU
548-
make_ParticleContainer_and_Iterators<T_ParticleType, T_NArrayReal, T_NArrayInt,
549-
std::allocator>(m, "std");
550-
make_ParticleContainer_and_Iterators<T_ParticleType, T_NArrayReal, T_NArrayInt,
551-
amrex::DefaultAllocator>(m, "default"); // amrex::ArenaAllocator
549+
make_ParticleContainer_and_Iterators<T_ParticleType, T_NArrayReal, T_NArrayInt,
550+
std::allocator>(m, "std");
551+
make_ParticleContainer_and_Iterators<T_ParticleType, T_NArrayReal, T_NArrayInt,
552+
amrex::DefaultAllocator>(m, "default"); // amrex::ArenaAllocator
552553
#else
553-
make_ParticleContainer_and_Iterators<T_ParticleType, T_NArrayReal, T_NArrayInt,
554-
amrex::DefaultAllocator>(m, "default"); // std::allocator
555-
make_ParticleContainer_and_Iterators<T_ParticleType, T_NArrayReal, T_NArrayInt,
556-
amrex::ArenaAllocator>(m, "arena");
554+
make_ParticleContainer_and_Iterators<T_ParticleType, T_NArrayReal, T_NArrayInt,
555+
amrex::DefaultAllocator>(m, "default"); // std::allocator
556+
make_ParticleContainer_and_Iterators<T_ParticleType, T_NArrayReal, T_NArrayInt,
557+
amrex::ArenaAllocator>(m, "arena");
557558
#endif
558-
// end work-around
559+
// end work-around
559560
#ifdef AMREX_USE_GPU
560-
make_ParticleContainer_and_Iterators<T_ParticleType, T_NArrayReal, T_NArrayInt,
561-
amrex::DeviceArenaAllocator>(m, "device");
562-
make_ParticleContainer_and_Iterators<T_ParticleType, T_NArrayReal, T_NArrayInt,
563-
amrex::ManagedArenaAllocator>(m, "managed");
564-
make_ParticleContainer_and_Iterators<T_ParticleType, T_NArrayReal, T_NArrayInt,
565-
amrex::AsyncArenaAllocator>(m, "async");
561+
make_ParticleContainer_and_Iterators<T_ParticleType, T_NArrayReal, T_NArrayInt,
562+
amrex::DeviceArenaAllocator>(m, "device");
563+
make_ParticleContainer_and_Iterators<T_ParticleType, T_NArrayReal, T_NArrayInt,
564+
amrex::ManagedArenaAllocator>(m, "managed");
565+
make_ParticleContainer_and_Iterators<T_ParticleType, T_NArrayReal, T_NArrayInt,
566+
amrex::AsyncArenaAllocator>(m, "async");
566567
#endif
568+
} // if (!only_polymorphic)
569+
567570
make_ParticleContainer_and_Iterators<T_ParticleType, T_NArrayReal, T_NArrayInt,
568571
amrex::PolymorphicArenaAllocator>(m, "polymorphic");
569572
}

src/Particle/ParticleContainer_ImpactX.cpp

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -12,7 +12,9 @@
1212
void init_ParticleContainer_ImpactX(py::module& m) {
1313
using namespace amrex;
1414

15+
bool const only_polymorphic = true;
16+
1517
// TODO: we might need to move all or most of the defines in here into a
1618
// test/example submodule, so they do not collide with downstream projects
17-
make_ParticleContainer_and_Iterators<SoAParticle<8, 0>, 8, 0>(m); // ImpactX 24.03+
19+
make_ParticleContainer_and_Iterators<SoAParticle<8, 0>, 8, 0>(m, only_polymorphic); // ImpactX 24.03+
1820
}

src/Particle/ParticleContainer_WarpX.cpp

Lines changed: 6 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -11,14 +11,16 @@
1111
void init_ParticleContainer_WarpX(py::module& m) {
1212
using namespace amrex;
1313

14+
bool const only_polymorphic = true;
15+
1416
// TODO: we might need to move all or most of the defines in here into a
1517
// test/example submodule, so they do not collide with downstream projects
1618
#if AMREX_SPACEDIM == 1
17-
make_ParticleContainer_and_Iterators<SoAParticle<5, 0>, 5, 0>(m); // WarpX 24.03+ 1D
19+
make_ParticleContainer_and_Iterators<SoAParticle<5, 0>, 5, 0>(m, only_polymorphic); // WarpX 24.03+ 1D
1820
#elif AMREX_SPACEDIM == 2
19-
make_ParticleContainer_and_Iterators<SoAParticle<6, 0>, 6, 0>(m); // WarpX 24.03+ 2D
20-
make_ParticleContainer_and_Iterators<SoAParticle<7, 0>, 7, 0>(m); // WarpX 24.03+ RZ
21+
make_ParticleContainer_and_Iterators<SoAParticle<6, 0>, 6, 0>(m, only_polymorphic); // WarpX 24.03+ 2D
22+
make_ParticleContainer_and_Iterators<SoAParticle<7, 0>, 7, 0>(m, only_polymorphic); // WarpX 24.03+ RZ
2123
#elif AMREX_SPACEDIM == 3
22-
make_ParticleContainer_and_Iterators<SoAParticle<7, 0>, 7, 0>(m); // WarpX 24.03+ 3D
24+
make_ParticleContainer_and_Iterators<SoAParticle<7, 0>, 7, 0>(m, only_polymorphic); // WarpX 24.03+ 3D
2325
#endif
2426
}

0 commit comments

Comments
 (0)