From 3690da41bc477a2a9deb4d6db27005c313d1fcc6 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Franz=20P=C3=B6schel?= Date: Wed, 17 Dec 2025 17:54:20 +0100 Subject: [PATCH 1/2] Dont use remap buffer --- .../plugins/openPMD/restart/LoadSpecies.hpp | 39 ++++++------------- 1 file changed, 12 insertions(+), 27 deletions(-) diff --git a/include/picongpu/plugins/openPMD/restart/LoadSpecies.hpp b/include/picongpu/plugins/openPMD/restart/LoadSpecies.hpp index 9b1feeb2ea..0beba8cb76 100644 --- a/include/picongpu/plugins/openPMD/restart/LoadSpecies.hpp +++ b/include/picongpu/plugins/openPMD/restart/LoadSpecies.hpp @@ -51,12 +51,12 @@ namespace picongpu template struct RedistributeFilteredParticles { - template + template 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]; + dataPtr[particleIndexTarget++] = dataPtr[particleIndexSrc]; } } }; @@ -291,17 +292,13 @@ namespace picongpu manager::Device::get().current(), manager::Device::get().getPlatform(), MemSpace(maxChunkSize).toAlpakaMemVec()); - auto remap = alpaka::allocMappedBuf( - manager::Device::get().current(), - manager::Device::get().getPlatform(), - MemSpace(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,20 +327,7 @@ 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::max(); - } - } - + MemIdxType numParticlesAfterFiltering = 0; meta::ForEach< typename NewParticleDescription::ValueTypeSeq, RedistributeFilteredParticles> @@ -351,18 +335,19 @@ namespace picongpu redistributeFilteredParticles( mappedFrame, filter, - remap, numParticlesCurrentBatch, + numParticlesAfterFiltering, filterRemove); log( "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 + // number cellOffsetToTotalDomain, totalCellIdx_, *threadParams->cellDescription, From 9ede729916e989ff3e30e7543153f5d2c5d8fc60 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Franz=20P=C3=B6schel?= Date: Mon, 5 Jan 2026 15:47:34 +0100 Subject: [PATCH 2/2] Move comments to their own lines --- include/picongpu/plugins/openPMD/restart/LoadSpecies.hpp | 7 ++++--- 1 file changed, 4 insertions(+), 3 deletions(-) diff --git a/include/picongpu/plugins/openPMD/restart/LoadSpecies.hpp b/include/picongpu/plugins/openPMD/restart/LoadSpecies.hpp index 0beba8cb76..99fd100912 100644 --- a/include/picongpu/plugins/openPMD/restart/LoadSpecies.hpp +++ b/include/picongpu/plugins/openPMD/restart/LoadSpecies.hpp @@ -56,7 +56,8 @@ namespace picongpu FrameType& frame, FilterType const& filter, uint64_t const numParticlesCurrentBatch, - MemIdxType& particleIndexTarget, // becomes numParticlesAfterFiltering after this function call + // becomes numParticlesAfterFiltering after this function call + MemIdxType& particleIndexTarget, char const filterRemove) { using Identifier = T_Identifier; @@ -346,8 +347,8 @@ namespace picongpu pmacc::particles::operations::splitIntoListOfFrames( *speciesTmp, mappedFrame, - numParticlesAfterFiltering, // !! not numParticlesCurrentBatch, filtered vs. unfiltered - // number + // @attention not numParticlesCurrentBatch, filtered vs. unfiltered number + numParticlesAfterFiltering, cellOffsetToTotalDomain, totalCellIdx_, *threadParams->cellDescription,