-
Notifications
You must be signed in to change notification settings - Fork 223
use span to allocate mesh data by default #6123
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Changes from 3 commits
3ad2a04
3bcdfae
fb2bd48
2e384ba
ff20012
8b926ed
c832012
ff047b1
2a5da56
e79da49
5b84af2
d408dbc
6ad9fb2
30fe6d3
e5370a1
e51ca1a
d0bbf79
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -407,13 +407,27 @@ WarpXOpenPMDPlot::~WarpXOpenPMDPlot () | |
} | ||
} | ||
|
||
/* | ||
* If I/O is through ADIOS: | ||
* isBTD=true => PerformPut | ||
* this way we do not flush out every buffer in a snapshot, | ||
* (BTD uses few data ranks so this is costly for ADIOS collective functions) | ||
* Instead we aggregate a few buffers before calling ForceFlush(isBTD) to write out. | ||
* Note that SPAN is used to allocate CPU data in ADIOS. | ||
* The advantage is when SPAN is successful, PerformPut takes no action. | ||
* | ||
* isBTD=false => PDW | ||
*/ | ||
guj marked this conversation as resolved.
Outdated
Show resolved
Hide resolved
|
||
void WarpXOpenPMDPlot::flushCurrent (bool isBTD) const | ||
{ | ||
WARPX_PROFILE("WarpXOpenPMDPlot::flushCurrent"); | ||
|
||
openPMD::Iteration currIteration = GetIteration(m_CurrentStep, isBTD); | ||
|
||
currIteration.seriesFlush(); | ||
openPMD::Iteration currIteration = GetIteration(m_CurrentStep, isBTD); | ||
if (isBTD) { | ||
WARPX_PROFILE("WarpXOpenPMDPlot::flushCurrent-PP()"); | ||
guj marked this conversation as resolved.
Outdated
Show resolved
Hide resolved
|
||
currIteration.seriesFlush( "adios2.engine.preferred_flush_target = \"buffer\"" ); | ||
guj marked this conversation as resolved.
Outdated
Show resolved
Hide resolved
|
||
} else { | ||
WARPX_PROFILE("WarpXOpenPMDPlot::flushCurrent()"); | ||
currIteration.seriesFlush(); | ||
} | ||
} | ||
|
||
std::string | ||
|
@@ -463,6 +477,7 @@ void WarpXOpenPMDPlot::SetStep (int ts, const std::string& dirPrefix, int file_m | |
|
||
void WarpXOpenPMDPlot::CloseStep (bool isBTD, bool isLastBTDFlush) | ||
{ | ||
WARPX_PROFILE("WarpXOpenPMDPlot::CloseStep()"); | ||
// default close is true | ||
bool callClose = true; | ||
// close BTD file only when isLastBTDFlush is true | ||
|
@@ -666,19 +681,37 @@ for (const auto & particle_diag : particle_diags) { | |
pc->getCharge(), pc->getMass(), | ||
isBTD, isLastBTDFlush); | ||
} | ||
} | ||
|
||
/* | ||
* Flush a few BTD buffers in a snapshot | ||
* controlled by FlushFormatOpenPMD::m_NumAggBTDBufferToFlush (default to 5) | ||
* can be adjusted in the input file: <diag>.buffer_flush_limit_btd | ||
*/ | ||
guj marked this conversation as resolved.
Outdated
Show resolved
Hide resolved
|
||
void | ||
WarpXOpenPMDPlot::ForceFlush(bool isBTD) | ||
{ | ||
if (!isBTD) | ||
ax3l marked this conversation as resolved.
Outdated
Show resolved
Hide resolved
|
||
return; | ||
|
||
auto hasOption = m_OpenPMDoptions.find("FlattenSteps"); | ||
const bool flattenSteps = isBTD && (m_Series->backend() == "ADIOS2") && (hasOption != std::string::npos); | ||
const bool result = (m_Series->backend() == "ADIOS2") && (hasOption != std::string::npos); | ||
guj marked this conversation as resolved.
Outdated
Show resolved
Hide resolved
guj marked this conversation as resolved.
Outdated
Show resolved
Hide resolved
|
||
|
||
if (flattenSteps) | ||
if (result) | ||
{ | ||
// forcing new step so data from each btd batch in | ||
// preferred_flush_target="buffer" can be flushed out | ||
openPMD::Iteration currIteration = GetIteration(m_CurrentStep, isBTD); | ||
currIteration.seriesFlush(R"(adios2.engine.preferred_flush_target = "new_step")"); | ||
WARPX_PROFILE("WarpXOpenPMDPlot::FlattenSteps()"); | ||
guj marked this conversation as resolved.
Outdated
Show resolved
Hide resolved
|
||
openPMD::Iteration currIteration = GetIteration(m_CurrentStep, isBTD); | ||
currIteration.seriesFlush(R"(adios2.engine.preferred_flush_target = "new_step")"); | ||
guj marked this conversation as resolved.
Show resolved
Hide resolved
|
||
} | ||
else | ||
{ | ||
WARPX_PROFILE("WarpXOpenPMDPlot::PDW()"); | ||
guj marked this conversation as resolved.
Outdated
Show resolved
Hide resolved
|
||
openPMD::Iteration currIteration = GetIteration(m_CurrentStep, isBTD); | ||
currIteration.seriesFlush(R"(adios2.engine.preferred_flush_target = "disk")"); | ||
guj marked this conversation as resolved.
Show resolved
Hide resolved
|
||
} | ||
} | ||
|
||
|
||
void | ||
WarpXOpenPMDPlot::DumpToFile (ParticleContainer* pc, | ||
const std::string& name, | ||
|
@@ -1509,12 +1542,22 @@ WarpXOpenPMDPlot::WriteOpenPMDFieldsAll ( //const std::string& filename, | |
// GPU pointers to the I/O library | ||
#ifdef AMREX_USE_GPU | ||
if (fab.arena()->isManaged() || fab.arena()->isDevice()) { | ||
amrex::BaseFab<amrex::Real> foo(local_box, 1, amrex::The_Pinned_Arena()); | ||
std::shared_ptr<amrex::Real> data_pinned(foo.release()); | ||
amrex::Gpu::dtoh_memcpy_async(data_pinned.get(), fab.dataPtr(icomp), local_box.numPts()*sizeof(amrex::Real)); | ||
// intentionally delayed until before we .flush(): amrex::Gpu::streamSynchronize(); | ||
mesh_comp.storeChunk(data_pinned, chunk_offset, chunk_size); | ||
} else | ||
{ | ||
WARPX_PROFILE("WarpXOpenPMDPlot::WriteOpenPMDFields::D2H_Span()"); | ||
auto dynamicMemoryView = mesh_comp.storeChunk<amrex::Real>( | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Oh no, when we have an un-equal number of blocks over all MPI ranks, this will not work because There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. To double check: is There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more.
Only one rank is writing when using BTD. Other ranks have no data. |
||
chunk_offset, chunk_size, | ||
[&local_box](size_t size) { | ||
(void) size; | ||
amrex::Print()<<" span failed \n"; | ||
guj marked this conversation as resolved.
Outdated
Show resolved
Hide resolved
|
||
amrex::BaseFab<amrex::Real> foo(local_box, 1, amrex::The_Pinned_Arena()); | ||
std::shared_ptr<amrex::Real> data_pinned(foo.release()); | ||
return data_pinned; | ||
}); | ||
guj marked this conversation as resolved.
Outdated
Show resolved
Hide resolved
|
||
|
||
auto span = dynamicMemoryView.currentBuffer(); | ||
amrex::Gpu::dtoh_memcpy_async(span.data(), fab.dataPtr(icomp), local_box.numPts()*sizeof(amrex::Real)); | ||
} | ||
} else | ||
#endif | ||
{ | ||
amrex::Real const *local_data = fab.dataPtr(icomp); | ||
ax3l marked this conversation as resolved.
Outdated
Show resolved
Hide resolved
|
||
|
Uh oh!
There was an error while loading. Please reload this page.