Skip to content

Commit 3784304

Browse files
committed
Work-Around: explicitly have default
... and skip what it stands for.
1 parent 8741b6a commit 3784304

File tree

4 files changed

+59
-21
lines changed

4 files changed

+59
-21
lines changed

src/Particle/ArrayOfStructs.cpp

Lines changed: 13 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -5,6 +5,7 @@
55
*/
66
#include <AMReX_Config.H>
77
#include <AMReX_ArrayOfStructs.H>
8+
#include <AMReX_GpuAllocators.H>
89

910
#include <pybind11/pybind11.h>
1011
#include <pybind11/stl.h>
@@ -124,18 +125,26 @@ template <int NReal, int NInt>
124125
void make_ArrayOfStructs(py::module &m)
125126
{
126127
// see Src/Base/AMReX_GpuContainers.H
128+
// !AMREX_USE_GPU: DefaultAllocator = std::allocator
129+
// AMREX_USE_GPU: DefaultAllocator = amrex::ArenaAllocator
130+
131+
// work-around for https://github.com/pybind/pybind11/pull/4581
132+
//make_ArrayOfStructs<NReal, NInt, std::allocator> (m, "std");
133+
//make_ArrayOfStructs<NReal, NInt, amrex::ArenaAllocator> (m, "arena");
134+
#ifdef AMREX_USE_GPU
127135
make_ArrayOfStructs<NReal, NInt, std::allocator> (m, "std");
136+
make_ArrayOfStructs<NReal, NInt, amrex::DefaultAllocator> (m, "default"); // amrex::ArenaAllocator
137+
#else
138+
make_ArrayOfStructs<NReal, NInt, amrex::DefaultAllocator> (m, "default"); // std::allocator
128139
make_ArrayOfStructs<NReal, NInt, amrex::ArenaAllocator> (m, "arena");
140+
#endif
141+
// end work-around
129142
make_ArrayOfStructs<NReal, NInt, amrex::PinnedArenaAllocator> (m, "pinned");
130143
#ifdef AMREX_USE_GPU
131144
make_ArrayOfStructs<NReal, NInt, amrex::DeviceArenaAllocator> (m, "device");
132145
make_ArrayOfStructs<NReal, NInt, amrex::ManagedArenaAllocator> (m, "managed");
133146
make_ArrayOfStructs<NReal, NInt, amrex::AsyncArenaAllocator> (m, "async");
134147
#endif
135-
#ifdef _WIN32
136-
// work-around for https://github.com/pybind/pybind11/pull/4319
137-
make_ArrayOfStructs<NReal, NInt, amrex::DefaultAllocator> (m, "default");
138-
#endif
139148
}
140149

141150
void init_ArrayOfStructs(py::module& m) {

src/Particle/ParticleContainer.H

Lines changed: 16 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -354,10 +354,24 @@ void make_ParticleContainer_and_Iterators (py::module &m)
354354
// see Src/Base/AMReX_GpuContainers.H
355355
// !AMREX_USE_GPU: DefaultAllocator = std::allocator
356356
// AMREX_USE_GPU: DefaultAllocator = amrex::ArenaAllocator
357+
358+
// work-around for https://github.com/pybind/pybind11/pull/4581
359+
//make_ParticleContainer_and_Iterators<T_NStructReal, T_NStructInt, T_NArrayReal, T_NArrayInt,
360+
// std::allocator>(m, "std"); // CPU DefaultAllocator
361+
//make_ParticleContainer_and_Iterators<T_NStructReal, T_NStructInt, T_NArrayReal, T_NArrayInt,
362+
// amrex::ArenaAllocator>(m, "arena"); // GPU DefaultAllocator
363+
#ifdef AMREX_USE_GPU
364+
make_ParticleContainer_and_Iterators<T_NStructReal, T_NStructInt, T_NArrayReal, T_NArrayInt,
365+
std::allocator>(m, "std");
366+
make_ParticleContainer_and_Iterators<T_NStructReal, T_NStructInt, T_NArrayReal, T_NArrayInt,
367+
amrex::DefaultAllocator>(m, "default"); // amrex::ArenaAllocator
368+
#else
357369
make_ParticleContainer_and_Iterators<T_NStructReal, T_NStructInt, T_NArrayReal, T_NArrayInt,
358-
std::allocator>(m, "std"); // CPU DefaultAllocator
370+
amrex::DefaultAllocator>(m, "default"); // std::allocator
359371
make_ParticleContainer_and_Iterators<T_NStructReal, T_NStructInt, T_NArrayReal, T_NArrayInt,
360-
amrex::ArenaAllocator>(m, "arena"); // GPU DefaultAllocator
372+
amrex::ArenaAllocator>(m, "arena");
373+
#endif
374+
// end work-around
361375
make_ParticleContainer_and_Iterators<T_NStructReal, T_NStructInt, T_NArrayReal, T_NArrayInt,
362376
amrex::PinnedArenaAllocator>(m, "pinned");
363377
#ifdef AMREX_USE_GPU
@@ -368,10 +382,4 @@ void make_ParticleContainer_and_Iterators (py::module &m)
368382
make_ParticleContainer_and_Iterators<T_NStructReal, T_NStructInt, T_NArrayReal, T_NArrayInt,
369383
amrex::AsyncArenaAllocator>(m, "async");
370384
#endif
371-
372-
#ifdef _WIN32
373-
// work-around for https://github.com/pybind/pybind11/pull/4319
374-
make_ParticleContainer_and_Iterators<T_NStructReal, T_NStructInt, T_NArrayReal, T_NArrayInt,
375-
amrex::DefaultAllocator>(m, "default");
376-
#endif
377385
}

src/Particle/ParticleTile.cpp

Lines changed: 17 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -5,6 +5,7 @@
55
*/
66
#include <AMReX_Config.H>
77
#include <AMReX_BoxArray.H>
8+
#include <AMReX_GpuAllocators.H>
89
#include <AMReX_IntVect.H>
910
#include <AMReX_ParticleTile.H>
1011

@@ -112,10 +113,26 @@ void make_ParticleTile(py::module &m)
112113
make_ParticleTileData<NStructReal, NStructInt, NArrayReal, NArrayInt>(m);
113114

114115
// see Src/Base/AMReX_GpuContainers.H
116+
// !AMREX_USE_GPU: DefaultAllocator = std::allocator
117+
// AMREX_USE_GPU: DefaultAllocator = amrex::ArenaAllocator
118+
119+
// work-around for https://github.com/pybind/pybind11/pull/4581
120+
//make_ParticleTile<NStructReal, NStructInt, NArrayReal, NArrayInt,
121+
// std::allocator>(m, "std");
122+
//make_ParticleTile<NStructReal, NStructInt, NArrayReal, NArrayInt,
123+
// amrex::ArenaAllocator>(m, "arena");
124+
#ifdef AMREX_USE_GPU
115125
make_ParticleTile<NStructReal, NStructInt, NArrayReal, NArrayInt,
116126
std::allocator>(m, "std");
127+
make_ParticleTile<NStructReal, NStructInt, NArrayReal, NArrayInt,
128+
amrex::DefaultAllocator>(m, "default"); // amrex::ArenaAllocator
129+
#else
130+
make_ParticleTile<NStructReal, NStructInt, NArrayReal, NArrayInt,
131+
amrex::DefaultAllocator>(m, "default"); // std::allocator
117132
make_ParticleTile<NStructReal, NStructInt, NArrayReal, NArrayInt,
118133
amrex::ArenaAllocator>(m, "arena");
134+
#endif
135+
// end work-around
119136
make_ParticleTile<NStructReal, NStructInt, NArrayReal, NArrayInt,
120137
amrex::PinnedArenaAllocator>(m, "pinned");
121138
#ifdef AMREX_USE_GPU
@@ -126,11 +143,6 @@ void make_ParticleTile(py::module &m)
126143
make_ParticleTile<NStructReal, NStructInt, NArrayReal, NArrayInt,
127144
amrex::AsyncArenaAllocator>(m, "async");
128145
#endif
129-
#ifdef _WIN32
130-
// work-around for https://github.com/pybind/pybind11/pull/4319
131-
make_ParticleTile<NStructReal, NStructInt, NArrayReal, NArrayInt,
132-
amrex::DefaultAllocator>(m, "default");
133-
#endif
134146
}
135147

136148
void init_ParticleTile(py::module& m) {

src/Particle/StructOfArrays.cpp

Lines changed: 13 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -4,6 +4,7 @@
44
* License: BSD-3-Clause-LBNL
55
*/
66
#include <AMReX_Config.H>
7+
#include <AMReX_GpuAllocators.H>
78
#include <AMReX_StructOfArrays.H>
89

910
#include <pybind11/pybind11.h>
@@ -46,18 +47,26 @@ template <int NReal, int NInt>
4647
void make_StructOfArrays(py::module &m)
4748
{
4849
// see Src/Base/AMReX_GpuContainers.H
50+
// !AMREX_USE_GPU: DefaultAllocator = std::allocator
51+
// AMREX_USE_GPU: DefaultAllocator = amrex::ArenaAllocator
52+
53+
// work-around for https://github.com/pybind/pybind11/pull/4581
54+
//make_StructOfArrays<NReal, NInt, std::allocator>(m, "std");
55+
//make_StructOfArrays<NReal, NInt, amrex::ArenaAllocator>(m, "arena");
56+
#ifdef AMREX_USE_GPU
4957
make_StructOfArrays<NReal, NInt, std::allocator>(m, "std");
58+
make_StructOfArrays<NReal, NInt, amrex::DefaultAllocator> (m, "default"); // amrex::ArenaAllocator
59+
#else
60+
make_StructOfArrays<NReal, NInt, amrex::DefaultAllocator> (m, "default"); // std::allocator
5061
make_StructOfArrays<NReal, NInt, amrex::ArenaAllocator>(m, "arena");
62+
#endif
63+
// end work-around
5164
make_StructOfArrays<NReal, NInt, amrex::PinnedArenaAllocator>(m, "pinned");
5265
#ifdef AMREX_USE_GPU
5366
make_StructOfArrays<NReal, NInt, amrex::DeviceArenaAllocator>(m, "device");
5467
make_StructOfArrays<NReal, NInt, amrex::ManagedArenaAllocator>(m, "managed");
5568
make_StructOfArrays<NReal, NInt, amrex::AsyncArenaAllocator>(m, "async");
5669
#endif
57-
#ifdef _WIN32
58-
// work-around for https://github.com/pybind/pybind11/pull/4319
59-
make_StructOfArrays<NReal, NInt, amrex::DefaultAllocator>(m, "default");
60-
#endif
6170
}
6271

6372
void init_StructOfArrays(py::module& m) {

0 commit comments

Comments
 (0)