static void addOneParticle(ParticlesClass& parClass, MappingDesc cellDescription, DataSpace<DIM3> globalCell) { PMACC_AUTO(simBox, SubGrid<simDim>::getInstance().getSimulationBox()); const DataSpace<DIM3> globalTopLeft = simBox.getGlobalOffset(); const DataSpace<DIM3> localSimulationArea = simBox.getLocalSize(); DataSpace<DIM3> localParCell = globalCell - globalTopLeft; for (int i = 0; i < (int) DIM3; ++i) { //chek if particle is in the simulation area if (localParCell[i] < 0 || localParCell[i] >= localSimulationArea[i]) return; } //calculate supercell DataSpace<DIM3> localSuperCell = (localParCell / MappingDesc::SuperCellSize::getDataSpace()); DataSpace<DIM3> cellInSuperCell = localParCell - (localSuperCell * MappingDesc::SuperCellSize::getDataSpace()); //add garding blocks to supercell localSuperCell = localSuperCell + cellDescription.getGuardingSuperCells(); __cudaKernel(kernelAddOneParticle) (1, 1) (parClass.getDeviceParticlesBox(), localSuperCell, cellInSuperCell); parClass.fillAllGaps(); std::cout << "Wait for add particle" << std::endl; __getTransactionEvent().waitForFinished(); }
static void addOneParticle(ParticlesClass& parClass, MappingDesc cellDescription, DataSpace<simDim> globalCell) { const SubGrid<simDim>& subGrid = Environment<simDim>::get().SubGrid(); const DataSpace<simDim> globalTopLeft = subGrid.getLocalDomain().offset; const DataSpace<simDim> localSimulationArea = subGrid.getLocalDomain().size; DataSpace<simDim> localParCell = globalCell - globalTopLeft; for (int i = 0; i < (int) simDim; ++i) { //chek if particle is in the simulation area if (localParCell[i] < 0 || localParCell[i] >= localSimulationArea[i]) return; } //calculate supercell DataSpace<simDim> localSuperCell = (localParCell / MappingDesc::SuperCellSize::toRT()); DataSpace<simDim> cellInSuperCell = localParCell - (localSuperCell * MappingDesc::SuperCellSize::toRT()); //add garding blocks to supercell localSuperCell = localSuperCell + cellDescription.getGuardingSuperCells(); __cudaKernel(kernelAddOneParticle) (1, 1) (parClass.getDeviceParticlesBox(), localSuperCell, cellInSuperCell); parClass.fillAllGaps(); std::cout << "Wait for add particle" << std::endl; __getTransactionEvent().waitForFinished(); }
void operator()( T_Field field, T_OpFunctor opFunctor, T_ValFunctor valFunctor, uint32_t currentStep, const bool enabled = true ) const { if( !enabled ) return; const SubGrid<simDim>& subGrid = Environment<simDim>::get().SubGrid(); /** offset due to being the n-th GPU */ DataSpace<simDim> totalCellOffset(subGrid.getLocalDomain().offset); const uint32_t numSlides = MovingWindow::getInstance().getSlideCounter( currentStep ); /** Assumption: all GPUs have the same number of cells in * y direction for sliding window */ totalCellOffset.y() += numSlides * subGrid.getLocalDomain().size.y(); /* the first block will start with less offset if started in the GUARD */ if( T_Area & GUARD) totalCellOffset -= m_cellDescription.getSuperCellSize() * m_cellDescription.getGuardingSuperCells(); /* if we run _only_ in the CORE we have to add the BORDER's offset */ else if( T_Area == CORE ) totalCellOffset += m_cellDescription.getSuperCellSize() * m_cellDescription.getBorderSuperCells(); /* start kernel */ __picKernelArea((kernelCellwiseOperation<T_OpFunctor>), m_cellDescription, T_Area) (SuperCellSize::toRT().toDim3()) (field->getDeviceDataBox(), opFunctor, valFunctor, totalCellOffset, currentStep); }