Skip to content

Commit

Permalink
Resolve counting bug during particle writing
Browse files Browse the repository at this point in the history
  • Loading branch information
franzpoeschel committed Jun 13, 2019
1 parent 6ee08f4 commit 3b3dd63
Showing 1 changed file with 5 additions and 6 deletions.
11 changes: 5 additions & 6 deletions include/picongpu/plugins/openPMD/WriteSpecies.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -146,14 +146,13 @@ namespace openPMD
// enforce that the filter interface is fulfilled
particles::filter::IUnary< typename T_SpeciesFilter::Filter >
particleFilter{ params->currentStep };
uint64_cu const totalNumParticles =
uint64_cu const myNumParticles =
pmacc::CountParticles::countOnDevice< CORE + BORDER >(
*speciesTmp,
*( params->cellDescription ),
params->localWindowToDomainOffset,
params->window.localDimensions.size,
particleFilter );
uint64_t myNumParticles = totalNumParticles;
uint64_t allNumParticles[ mpiSize ];
uint64_t globalNumParticles = 0;
uint64_t myParticleOffset = 0;
Expand All @@ -178,10 +177,10 @@ namespace openPMD
}
log< picLog::INPUT_OUTPUT >(
"openPMD: ( end ) count particles: %1% = %2%" ) %
T_SpeciesFilter::getName() % totalNumParticles;
T_SpeciesFilter::getName() % globalNumParticles;


if( totalNumParticles == 0 )
if( globalNumParticles == 0 )
{
log< picLog::INPUT_OUTPUT >(
"openPMD: ( end ) writing species: %1% - no particles "
Expand All @@ -205,7 +204,7 @@ namespace openPMD
ForEach
< typename openPMDFrameType::ValueTypeSeq,
MallocHostMemory< bmpl::_1 > > mallocMem;
mallocMem( hostFrame, totalNumParticles );
mallocMem( hostFrame, myNumParticles );
log< picLog::INPUT_OUTPUT >(
"openPMD: ( end ) malloc host memory: %1%" ) %
T_SpeciesFilter::getName();
Expand Down Expand Up @@ -310,7 +309,7 @@ namespace openPMD
* offset x, y, z) */
std::shared_ptr< uint64_t > particlesMetaInfo{
new uint64_t[ localTableSize ]{
totalNumParticles, gc.getScalarPosition(), 0, 0, 0 },
myNumParticles, gc.getScalarPosition(), 0, 0, 0 },
[]( uint64_t * ptr ) { delete[] ptr; }
};
auto particlesMetaInfoPtr = particlesMetaInfo.get();
Expand Down

0 comments on commit 3b3dd63

Please sign in to comment.