-
Notifications
You must be signed in to change notification settings - Fork 226
openPMD plugin: optimized restart from partial domain #5582
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 1 commit
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 |
|---|---|---|
|
|
@@ -51,12 +51,12 @@ namespace picongpu | |
| template<typename T_Identifier> | ||
| struct RedistributeFilteredParticles | ||
| { | ||
| template<typename FrameType, typename FilterType, typename RemapType> | ||
| template<typename FrameType, typename FilterType> | ||
| HINLINE void operator()( | ||
| FrameType& frame, | ||
| FilterType const& filter, | ||
| RemapType const& remap, | ||
| uint64_t const numParticlesCurrentBatch, | ||
| MemIdxType& particleIndexTarget, // becomes numParticlesAfterFiltering after this function call | ||
| char const filterRemove) | ||
| { | ||
| using Identifier = T_Identifier; | ||
|
|
@@ -65,13 +65,14 @@ namespace picongpu | |
|
|
||
| ValueType* dataPtr = frame.getIdentifier(Identifier()).getPointer(); | ||
|
|
||
| for(size_t particleIndex = 0; particleIndex < numParticlesCurrentBatch; ++particleIndex) | ||
| particleIndexTarget = 0; | ||
| for(MemIdxType particleIndexSrc = 0; particleIndexSrc < numParticlesCurrentBatch; ++particleIndexSrc) | ||
| { | ||
| if(filter[particleIndex] == filterRemove) | ||
| if(filter[particleIndexSrc] == filterRemove) | ||
| { | ||
| continue; | ||
| } | ||
| dataPtr[remap[particleIndex]] = dataPtr[particleIndex]; | ||
|
Member
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. This looks like magic to me and a find the new version much clearer.
Contributor
Author
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. The major change is that the previous version (unnecessarily) precomputed the target indices. Could have been made a bit clearer by: auto previouslyComputedNewIndex = remap[particleIndex];
dataPtr[previouslyComputedNewIndex] = dataPtr[particleIndex]; |
||
| dataPtr[particleIndexTarget++] = dataPtr[particleIndexSrc]; | ||
| } | ||
| } | ||
| }; | ||
|
|
@@ -291,17 +292,13 @@ namespace picongpu | |
| manager::Device<HostDevice>::get().current(), | ||
| manager::Device<ComputeDevice>::get().getPlatform(), | ||
| MemSpace<DIM1>(maxChunkSize).toAlpakaMemVec()); | ||
| auto remap = alpaka::allocMappedBuf<MemIdxType, MemIdxType>( | ||
| manager::Device<HostDevice>::get().current(), | ||
| manager::Device<ComputeDevice>::get().getPlatform(), | ||
| MemSpace<DIM1>(maxChunkSize).toAlpakaMemVec()); | ||
|
|
||
| loadMatchesGeneric( | ||
| partialMatches, | ||
| threadParams, | ||
| totalNumParticles, | ||
| maxChunkSize, /* forEachPatch = */ | ||
| [this, threadParams, &filter, &remap, &patchTotalOffset, &patchExtent, &patchUpperCorner]( | ||
| [this, threadParams, &filter, &patchTotalOffset, &patchExtent, &patchUpperCorner]( | ||
| uint64_t loadRound, | ||
| uint64_t numParticlesCurrentBatch, | ||
| FrameType& mappedFrame, | ||
|
|
@@ -330,39 +327,27 @@ namespace picongpu | |
| alpaka::getPtrNative(filter)); | ||
| eventSystem::getTransactionEvent().waitForFinished(); | ||
|
|
||
| // For simplicity, do the remapping on the CPU again | ||
| MemIdxType remapCurrent = 0; | ||
| for(size_t particleIndex = 0; particleIndex < numParticlesCurrentBatch; ++particleIndex) | ||
| { | ||
| if(filter[particleIndex] == filterKeep) | ||
| { | ||
| remap[particleIndex] = remapCurrent++; | ||
| } | ||
| else | ||
| { | ||
| remap[particleIndex] = std::numeric_limits<MemIdxType>::max(); | ||
| } | ||
| } | ||
|
|
||
| MemIdxType numParticlesAfterFiltering = 0; | ||
| meta::ForEach< | ||
| typename NewParticleDescription::ValueTypeSeq, | ||
| RedistributeFilteredParticles<boost::mpl::_1>> | ||
| redistributeFilteredParticles; | ||
| redistributeFilteredParticles( | ||
| mappedFrame, | ||
| filter, | ||
| remap, | ||
| numParticlesCurrentBatch, | ||
| numParticlesAfterFiltering, | ||
| filterRemove); | ||
|
|
||
| log<picLog::INPUT_OUTPUT>( | ||
| "openPMD: Keeping %1% of the current batch's %2% particles after filtering.") | ||
| % remapCurrent % numParticlesCurrentBatch; | ||
| % numParticlesAfterFiltering % numParticlesCurrentBatch; | ||
|
|
||
| pmacc::particles::operations::splitIntoListOfFrames( | ||
| *speciesTmp, | ||
| mappedFrame, | ||
| remapCurrent, // !! not numParticlesCurrentBatch, filtered vs. unfiltered number | ||
| numParticlesAfterFiltering, // !! not numParticlesCurrentBatch, filtered vs. unfiltered | ||
|
franzpoeschel marked this conversation as resolved.
Outdated
|
||
| // number | ||
| cellOffsetToTotalDomain, | ||
| totalCellIdx_, | ||
| *threadParams->cellDescription, | ||
|
|
||
Uh oh!
There was an error while loading. Please reload this page.