From 4244a8671a742bfe3cfb0a59441a6bbe37954e7e Mon Sep 17 00:00:00 2001 From: hamidrezanorouzi Date: Tue, 4 Oct 2022 20:53:38 +0330 Subject: [PATCH] fixed the problem with cellsSimple on cuda --- src/Interaction/contactSearch/methods/NBS.H | 36 +++++++++++++++- .../contactSearch/wallMappings/cellsSimple.H | 41 +++++++++++++++++-- 2 files changed, 73 insertions(+), 4 deletions(-) diff --git a/src/Interaction/contactSearch/methods/NBS.H b/src/Interaction/contactSearch/methods/NBS.H index 573c0c47..0d5c10bf 100644 --- a/src/Interaction/contactSearch/methods/NBS.H +++ b/src/Interaction/contactSearch/methods/NBS.H @@ -481,7 +481,7 @@ public: } - template + /*template INLINE_FUNCTION_HD int32 addPointsInBoxToList( const teamMemberType& teamMember, @@ -522,6 +522,40 @@ public: return getFull; + }*/ + + template + INLINE_FUNCTION_HD + int32 addPointsInBoxToListModified( + IdType id, + const iBox& triBox, + const PairsContainer& pairs)const + { + int32 getFull = 0; + + auto bExtent = boxExtent(triBox); + int32 numCellBox = bExtent.x()*bExtent.y()*bExtent.z(); + + const auto head = head_; + const auto next = next_; + + for(int32 linIndex=0; linIndex-1) + { + // id is wall id the pair is (particle id, wall id) + if( pairs.insert(static_cast(n), id) < 0 ) + getFull++; + n = next_(n); + } + } + + return getFull; + } }; diff --git a/src/Interaction/contactSearch/wallMappings/cellsSimple.H b/src/Interaction/contactSearch/wallMappings/cellsSimple.H index d0436a80..50a1428d 100644 --- a/src/Interaction/contactSearch/wallMappings/cellsSimple.H +++ b/src/Interaction/contactSearch/wallMappings/cellsSimple.H @@ -257,7 +257,7 @@ public: while (getFull) { - getFull = findPairsElementRange(pairs, particleMap); + getFull = findPairsElementRangeModified(pairs, particleMap); if(getFull) { @@ -280,7 +280,7 @@ public: return true; } - template + /*template int32 findPairsElementRange(PairsContainer& pairs, particleMapType& particleMap) { int32 getFull =0; @@ -296,6 +296,7 @@ public: const typename tpPWContactSearch::member_type & teamMember, int32& valueToUpdate){ int32 i = teamMember.league_rank(); + printf("league size %d , league rank %d , team size %d and team rank %d \n", teamMember.league_size(), i, teamMember.team_size(), teamMember.team_rank()); IdType id = i; const auto triBox = elementBox[i]; @@ -311,9 +312,43 @@ public: ); return getFull; + }*/ + + template + int32 findPairsElementRangeModified(PairsContainer& pairs, particleMapType& particleMap) + { + Kokkos::RangePolicy< + Kokkos::IndexType, + Kokkos::Schedule, + ExecutionSpace> rPolicy(0,numElements_); + + int32 getFull =0; + + const auto pwPairs = pairs; + const auto elementBox = elementBox_; + //printf("we are in modified version \n"); + Kokkos::parallel_reduce( + "cellsSimple::findPairsElementRangeModified", + rPolicy, + LAMBDA_HD( + int32 i, + int32& valueToUpdate){ + + IdType id = i; + const auto triBox = elementBox[i]; + + valueToUpdate += + particleMap.addPointsInBoxToListModified( + id, + triBox, + pwPairs + ); + }, + getFull + ); + return getFull; } - INLINE_FUNCTION_HD void operator()(TagFindCellRange2, int32 i) const {