MCPcopy Create free account
hub / github.com/SeisSol/SeisSol / deriveRequiredScratchpadMemoryForWp

Method deriveRequiredScratchpadMemoryForWp

src/Initializer/MemoryManager.cpp:662–723  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

660
661#ifdef ACL_DEVICE
662void seissol::initializer::MemoryManager::deriveRequiredScratchpadMemoryForWp(LTSTree& ltsTree, LTS& lts) {
663 constexpr size_t totalDerivativesSize = yateto::computeFamilySize<tensor::dQ>();
664 constexpr size_t nodalDisplacementsSize = tensor::averageNormalDisplacement::size();
665
666 for (auto& layer : ltsTree.leaves(Ghost)) {
667
668 CellLocalInformation *cellInformation = layer.var(lts.cellInformation);
669 std::unordered_set<real *> registry{};
670 real *(*faceNeighbors)[4] = layer.var(lts.faceNeighborsDevice);
671
672 std::size_t derivativesCounter{0};
673 std::size_t integratedDofsCounter{0};
674 std::size_t nodalDisplacementsCounter{0};
675 std::size_t analyticCounter = 0;
676
677 for (unsigned cell = 0; cell < layer.getNumberOfCells(); ++cell) {
678 bool needsScratchMemForDerivatives = (cellInformation[cell].ltsSetup >> 9) % 2 == 0;
679 if (needsScratchMemForDerivatives) {
680 ++derivativesCounter;
681 }
682 ++integratedDofsCounter;
683
684 // include data provided by ghost layers
685 for (unsigned face = 0; face < 4; ++face) {
686 real *neighborBuffer = faceNeighbors[cell][face];
687
688 // check whether a neighbour element idofs has not been counted twice
689 if ((registry.find(neighborBuffer) == registry.end())) {
690
691 // maybe, because of BCs, a pointer can be a nullptr, i.e. skip it
692 if (neighborBuffer != nullptr) {
693 if (cellInformation[cell].faceTypes[face] != FaceType::Outflow &&
694 cellInformation[cell].faceTypes[face] != FaceType::DynamicRupture) {
695
696 bool isNeighbProvidesDerivatives = ((cellInformation[cell].ltsSetup >> face) % 2) == 1;
697 if (isNeighbProvidesDerivatives) {
698 ++integratedDofsCounter;
699 }
700 registry.insert(neighborBuffer);
701 }
702 }
703 }
704
705 if (cellInformation[cell].faceTypes[face] == FaceType::FreeSurfaceGravity) {
706 ++nodalDisplacementsCounter;
707 }
708
709 if (cellInformation[cell].faceTypes[face] == FaceType::Analytical) {
710 ++analyticCounter;
711 }
712 }
713 }
714 layer.setScratchpadSize(lts.integratedDofsScratch,
715 integratedDofsCounter * tensor::I::size() * sizeof(real));
716 layer.setScratchpadSize(lts.derivativesScratch,
717 derivativesCounter * totalDerivativesSize * sizeof(real));
718 layer.setScratchpadSize(lts.nodalAvgDisplacements,
719 nodalDisplacementsCounter * nodalDisplacementsSize * sizeof(real));

Callers

nothing calls this directly

Calls 6

sizeFunction · 0.85
leavesMethod · 0.80
setScratchpadSizeMethod · 0.80
varMethod · 0.45
getNumberOfCellsMethod · 0.45
endMethod · 0.45

Tested by

no test coverage detected