Skip to content

Commit

Permalink
Remove reliance on managed memory in HDF5 mesh IO (#4047)
Browse files Browse the repository at this point in the history
The proposed changes:
- [x] fix a bug or incorrect behavior in AMReX
- [ ] add new capabilities to AMReX
- [ ] changes answers in the test suite to more than roundoff level
- [ ] are likely to significantly affect the results of downstream AMReX
users
- [ ] include documentation in the code and/or rst files, if appropriate
  • Loading branch information
atmyers committed Jul 24, 2024
1 parent 3cb7f15 commit d9dec56
Showing 1 changed file with 14 additions and 2 deletions.
16 changes: 14 additions & 2 deletions Src/Extern/HDF5/AMReX_PlotFileUtilHDF5.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -696,12 +696,24 @@ void WriteMultiLevelPlotfileHDF5SingleDset (const std::string& plotfilename,
for(MFIter mfi(*data); mfi.isValid(); ++mfi) {
const FArrayBox &fab = (*data)[mfi];
writeDataItems = fab.box().numPts() * (*data).nComp();
Real const* fabdata = fab.dataPtr();
#ifdef AMREX_USE_GPU
std::unique_ptr<FArrayBox> hostfab;
if (fab.arena()->isManaged() || fab.arena()->isDevice()) {
hostfab = std::make_unique<FArrayBox>(fab.box(), fab.nComp(),
The_Pinned_Arena());
Gpu::dtoh_memcpy_async(hostfab->dataPtr(), fab.dataPtr(),
fab.size()*sizeof(Real));
Gpu::streamSynchronize();
fabdata = hostfab->dataPtr();
}
#endif
if(doConvert) {
RealDescriptor::convertFromNativeFormat(static_cast<void *> (a_buffer.dataPtr()+writeDataSize),
writeDataItems, fab.dataPtr(), *whichRD);
writeDataItems, fabdata, *whichRD);
} else { // ---- copy from the fab
memcpy(static_cast<void *> (a_buffer.dataPtr()+writeDataSize),
fab.dataPtr(), writeDataItems * whichRDBytes);
fabdata, writeDataItems * whichRDBytes);
}
writeDataSize += writeDataItems;
}
Expand Down

0 comments on commit d9dec56

Please sign in to comment.