aboutsummaryrefslogtreecommitdiff
path: root/Source/Initialization
diff options
context:
space:
mode:
Diffstat (limited to '')
-rw-r--r--Source/Initialization/InjectorDensity.H4
-rw-r--r--Source/Initialization/InjectorDensity.cpp17
-rw-r--r--Source/Initialization/InjectorMomentum.H4
-rw-r--r--Source/Initialization/InjectorMomentum.cpp18
-rw-r--r--Source/Initialization/InjectorPosition.H2
-rw-r--r--Source/Initialization/PlasmaInjector.H9
-rw-r--r--Source/Initialization/PlasmaInjector.cpp8
-rw-r--r--Source/Initialization/WarpXInitData.cpp40
8 files changed, 24 insertions, 78 deletions
diff --git a/Source/Initialization/InjectorDensity.H b/Source/Initialization/InjectorDensity.H
index 4558eeb96..8bb5650ba 100644
--- a/Source/Initialization/InjectorDensity.H
+++ b/Source/Initialization/InjectorDensity.H
@@ -45,7 +45,7 @@ struct InjectorDensityParser
}
// InjectorDensityParser constructs this GpuParser from WarpXParser.
- GpuParser m_parser;
+ GpuParser<3> m_parser;
};
// struct whose getDensity returns local density computed from predefined profile.
@@ -152,8 +152,6 @@ struct InjectorDensity
~InjectorDensity ();
- std::size_t sharedMemoryNeeded () const noexcept;
-
// call getDensity from the object stored in the union
// (the union is called Object, and the instance is called object).
AMREX_GPU_HOST_DEVICE
diff --git a/Source/Initialization/InjectorDensity.cpp b/Source/Initialization/InjectorDensity.cpp
index f59202db9..accadc74a 100644
--- a/Source/Initialization/InjectorDensity.cpp
+++ b/Source/Initialization/InjectorDensity.cpp
@@ -34,23 +34,6 @@ InjectorDensity::~InjectorDensity ()
}
}
-// Compute the amount of memory needed in GPU Shared Memory.
-std::size_t
-InjectorDensity::sharedMemoryNeeded () const noexcept
-{
- switch (type)
- {
- case Type::parser:
- {
- // For parser injector, the 3D position of each particle
- // and time, t, is stored in shared memory.
- return amrex::Gpu::numThreadsPerBlockParallelFor() * sizeof(double) * 4;
- }
- default:
- return 0;
- }
-}
-
InjectorDensityPredefined::InjectorDensityPredefined (
std::string const& a_species_name) noexcept
: profile(Profile::null)
diff --git a/Source/Initialization/InjectorMomentum.H b/Source/Initialization/InjectorMomentum.H
index bb5a70784..1d407508c 100644
--- a/Source/Initialization/InjectorMomentum.H
+++ b/Source/Initialization/InjectorMomentum.H
@@ -223,7 +223,7 @@ struct InjectorMomentumParser
return amrex::XDim3{m_ux_parser(x,y,z),m_uy_parser(x,y,z),m_uz_parser(x,y,z)};
}
- GpuParser m_ux_parser, m_uy_parser, m_uz_parser;
+ GpuParser<3> m_ux_parser, m_uy_parser, m_uz_parser;
};
// Base struct for momentum injector.
@@ -301,8 +301,6 @@ struct InjectorMomentum
~InjectorMomentum ();
- std::size_t sharedMemoryNeeded () const noexcept;
-
// call getMomentum from the object stored in the union
// (the union is called Object, and the instance is called object).
AMREX_GPU_HOST_DEVICE
diff --git a/Source/Initialization/InjectorMomentum.cpp b/Source/Initialization/InjectorMomentum.cpp
index edbba8ac5..0765eb0a3 100644
--- a/Source/Initialization/InjectorMomentum.cpp
+++ b/Source/Initialization/InjectorMomentum.cpp
@@ -28,21 +28,3 @@ InjectorMomentum::~InjectorMomentum ()
}
}
}
-
-// Compute the amount of memory needed in GPU Shared Memory.
-std::size_t
-InjectorMomentum::sharedMemoryNeeded () const noexcept
-{
- switch (type)
- {
- case Type::parser:
- {
- // For parser injector, the 3D position of each particle and time, t,
- // is stored in shared memory.
- return amrex::Gpu::numThreadsPerBlockParallelFor() * sizeof(double) * 4;
- }
- default:
- return 0;
- }
-}
-
diff --git a/Source/Initialization/InjectorPosition.H b/Source/Initialization/InjectorPosition.H
index a8d2200e9..0ef6c0390 100644
--- a/Source/Initialization/InjectorPosition.H
+++ b/Source/Initialization/InjectorPosition.H
@@ -105,8 +105,6 @@ struct InjectorPosition
void operator= (InjectorPosition const&) = delete;
void operator= (InjectorPosition &&) = delete;
- std::size_t sharedMemoryNeeded () const noexcept { return 0; }
-
// call getPositionUnitBox from the object stored in the union
// (the union is called Object, and the instance is called object).
AMREX_GPU_HOST_DEVICE
diff --git a/Source/Initialization/PlasmaInjector.H b/Source/Initialization/PlasmaInjector.H
index 70d99b9a3..308b4121e 100644
--- a/Source/Initialization/PlasmaInjector.H
+++ b/Source/Initialization/PlasmaInjector.H
@@ -83,15 +83,6 @@ public:
InjectorDensity* getInjectorDensity ();
InjectorMomentum* getInjectorMomentum ();
- // When running on GPU, injector for position, momentum and density store
- // particle 3D positions in shared memory IF using the parser.
- std::size_t
- sharedMemoryNeeded () const noexcept {
- return amrex::max(inj_pos->sharedMemoryNeeded(),
- inj_rho->sharedMemoryNeeded(),
- inj_mom->sharedMemoryNeeded());
- }
-
protected:
amrex::Real mass, charge;
diff --git a/Source/Initialization/PlasmaInjector.cpp b/Source/Initialization/PlasmaInjector.cpp
index cacbaab75..5fa82e48f 100644
--- a/Source/Initialization/PlasmaInjector.cpp
+++ b/Source/Initialization/PlasmaInjector.cpp
@@ -201,7 +201,7 @@ void PlasmaInjector::parseDensity (ParmParse& pp)
Store_parserString(pp, "density_function(x,y,z)", str_density_function);
// Construct InjectorDensity with InjectorDensityParser.
inj_rho.reset(new InjectorDensity((InjectorDensityParser*)nullptr,
- makeParser(str_density_function)));
+ makeParser(str_density_function,{"x","y","z"})));
} else {
StringParseAbortMessage("Density profile type", rho_prof_s);
}
@@ -324,9 +324,9 @@ void PlasmaInjector::parseMomentum (ParmParse& pp)
str_momentum_function_uz);
// Construct InjectorMomentum with InjectorMomentumParser.
inj_mom.reset(new InjectorMomentum((InjectorMomentumParser*)nullptr,
- makeParser(str_momentum_function_ux),
- makeParser(str_momentum_function_uy),
- makeParser(str_momentum_function_uz)));
+ makeParser(str_momentum_function_ux,{"x","y","z"}),
+ makeParser(str_momentum_function_uy,{"x","y","z"}),
+ makeParser(str_momentum_function_uz,{"x","y","z"})));
} else {
StringParseAbortMessage("Momentum distribution type", mom_dist_s);
}
diff --git a/Source/Initialization/WarpXInitData.cpp b/Source/Initialization/WarpXInitData.cpp
index 957e22b68..e5571c519 100644
--- a/Source/Initialization/WarpXInitData.cpp
+++ b/Source/Initialization/WarpXInitData.cpp
@@ -319,12 +319,12 @@ WarpX::InitLevelData (int lev, Real time)
Store_parserString(pp, "Bz_external_grid_function(x,y,z)",
str_Bz_ext_grid_function);
- Bxfield_parser.reset(new ParserWrapper(
- makeParser(str_Bx_ext_grid_function)));
- Byfield_parser.reset(new ParserWrapper(
- makeParser(str_By_ext_grid_function)));
- Bzfield_parser.reset(new ParserWrapper(
- makeParser(str_Bz_ext_grid_function)));
+ Bxfield_parser.reset(new ParserWrapper<3>(
+ makeParser(str_Bx_ext_grid_function,{"x","y","z"})));
+ Byfield_parser.reset(new ParserWrapper<3>(
+ makeParser(str_By_ext_grid_function,{"x","y","z"})));
+ Bzfield_parser.reset(new ParserWrapper<3>(
+ makeParser(str_Bz_ext_grid_function,{"x","y","z"})));
// Initialize Bfield_fp with external function
InitializeExternalFieldsOnGridUsingParser(Bfield_fp[lev][0].get(),
@@ -371,12 +371,12 @@ WarpX::InitLevelData (int lev, Real time)
Store_parserString(pp, "Ez_external_grid_function(x,y,z)",
str_Ez_ext_grid_function);
- Exfield_parser.reset(new ParserWrapper(
- makeParser(str_Ex_ext_grid_function)));
- Eyfield_parser.reset(new ParserWrapper(
- makeParser(str_Ey_ext_grid_function)));
- Ezfield_parser.reset(new ParserWrapper(
- makeParser(str_Ez_ext_grid_function)));
+ Exfield_parser.reset(new ParserWrapper<3>(
+ makeParser(str_Ex_ext_grid_function,{"x","y","z"})));
+ Eyfield_parser.reset(new ParserWrapper<3>(
+ makeParser(str_Ey_ext_grid_function,{"x","y","z"})));
+ Ezfield_parser.reset(new ParserWrapper<3>(
+ makeParser(str_Ez_ext_grid_function,{"x","y","z"})));
// Initialize Efield_fp with external function
InitializeExternalFieldsOnGridUsingParser(Efield_fp[lev][0].get(),
@@ -467,8 +467,8 @@ WarpX::InitLevelDataFFT (int lev, Real time)
void
WarpX::InitializeExternalFieldsOnGridUsingParser (
MultiFab *mfx, MultiFab *mfy, MultiFab *mfz,
- ParserWrapper *xfield_parser, ParserWrapper *yfield_parser,
- ParserWrapper *zfield_parser, IntVect x_nodal_flag,
+ ParserWrapper<3> *xfield_parser, ParserWrapper<3> *yfield_parser,
+ ParserWrapper<3> *zfield_parser, IntVect x_nodal_flag,
IntVect y_nodal_flag, IntVect z_nodal_flag,
const int lev)
{
@@ -518,7 +518,7 @@ WarpX::InitializeExternalFieldsOnGridUsingParser (
Real z = k*dx_lev[2] + real_box.lo(2) + fac_z;
#endif
// Initialize the x-component of the field.
- mfxfab(i,j,k) = xfield_parser->getField(x,y,z);
+ mfxfab(i,j,k) = (*xfield_parser)(x,y,z);
},
[=] AMREX_GPU_DEVICE (int i, int j, int k) {
Real fac_x = (1.0 - mfy_type[0]) * dx_lev[0]*0.5;
@@ -534,7 +534,7 @@ WarpX::InitializeExternalFieldsOnGridUsingParser (
Real z = k*dx_lev[2] + real_box.lo(2) + fac_z;
#endif
// Initialize the y-component of the field.
- mfyfab(i,j,k) = yfield_parser->getField(x,y,z);
+ mfyfab(i,j,k) = (*yfield_parser)(x,y,z);
},
[=] AMREX_GPU_DEVICE (int i, int j, int k) {
Real fac_x = (1.0 - mfz_type[0]) * dx_lev[0]*0.5;
@@ -550,13 +550,9 @@ WarpX::InitializeExternalFieldsOnGridUsingParser (
Real z = k*dx_lev[2] + real_box.lo(2) + fac_z;
#endif
// Initialize the z-component of the field.
- mfzfab(i,j,k) = zfield_parser->getField(x,y,z);
- },
- /* To allocate shared memory for the GPU threads. */
- /* But, for now only 4 doubles (x,y,z,t) are allocated. */
- amrex::Gpu::numThreadsPerBlockParallelFor() * sizeof(double) * 4
+ mfzfab(i,j,k) = (*zfield_parser)(x,y,z);
+ }
);
-
}
}