From 63b7602d3abd1adb2bbd41eacd80d994b2ea2ea9 Mon Sep 17 00:00:00 2001 From: StefanoPetrilli Date: Wed, 6 Jul 2022 13:12:31 -0500 Subject: [PATCH] refactoring queueTransfer --- amgprec/impl/aggregator/MatchBoxPC.h | 11 ++++++ .../impl/aggregator/processExposedVertex.cpp | 23 ++++------- amgprec/impl/aggregator/queueTransfer.cpp | 38 +++++++++++++++++++ 3 files changed, 56 insertions(+), 16 deletions(-) create mode 100644 amgprec/impl/aggregator/queueTransfer.cpp diff --git a/amgprec/impl/aggregator/MatchBoxPC.h b/amgprec/impl/aggregator/MatchBoxPC.h index 122a1380..96630f9c 100644 --- a/amgprec/impl/aggregator/MatchBoxPC.h +++ b/amgprec/impl/aggregator/MatchBoxPC.h @@ -241,6 +241,17 @@ extern "C" staticQueue &privateQMsgType, staticQueue &privateQOwner); + inline void queuesTransfer(staticQueue &U, + staticQueue &privateU, + vector &QLocalVtx, + vector &QGhostVtx, + vector &QMsgType, + vector &QOwner, + staticQueue &privateQLocalVtx, + staticQueue &privateQGhostVtx, + staticQueue &privateQMsgType, + staticQueue &privateQOwner); + void dalgoDistEdgeApproxDomEdgesLinearSearchMesgBndlSmallMateCMP( MilanLongInt NLVer, MilanLongInt NLEdge, MilanLongInt *verLocPtr, MilanLongInt *verLocInd, MilanReal *edgeLocWeight, diff --git a/amgprec/impl/aggregator/processExposedVertex.cpp b/amgprec/impl/aggregator/processExposedVertex.cpp index a76d3df8..148951a5 100644 --- a/amgprec/impl/aggregator/processExposedVertex.cpp +++ b/amgprec/impl/aggregator/processExposedVertex.cpp @@ -7,6 +7,7 @@ #include "primitiveDataTypeDefinitions.h" #include "dataStrStaticQueue.h" #include "omp.h" +#include "queueTransfer.cpp" /* * PARALLEL_PROCESS_EXPOSED_VERTEX_B @@ -227,11 +228,12 @@ inline void PARALLEL_PROCESS_EXPOSED_VERTEX_B(MilanLongInt NLVer, // End: PARALLEL_PROCESS_EXPOSED_VERTEX_B(v) } // End of for ( v=0; v < NLVer; v++ ) -#pragma omp critical(U) - { - while (!privateU.empty()) - U.push_back(privateU.pop_front()); - } + queuesTransfer(U, privateU, QLocalVtx, + QGhostVtx, + QMsgType, QOwner, privateQLocalVtx, + privateQGhostVtx, + privateQMsgType, + privateQOwner); #pragma omp master { @@ -241,16 +243,5 @@ inline void PARALLEL_PROCESS_EXPOSED_VERTEX_B(MilanLongInt NLVer, *SPtr = S; } -#pragma omp critical(privateMsg) - { - while (!privateQLocalVtx.empty()) - { - QLocalVtx.push_back(privateQLocalVtx.pop_front()); - QGhostVtx.push_back(privateQGhostVtx.pop_front()); - QMsgType.push_back(privateQMsgType.pop_front()); - QOwner.push_back(privateQOwner.pop_front()); - } - } - } // End of parallel region } \ No newline at end of file diff --git a/amgprec/impl/aggregator/queueTransfer.cpp b/amgprec/impl/aggregator/queueTransfer.cpp new file mode 100644 index 00000000..55b0983a --- /dev/null +++ b/amgprec/impl/aggregator/queueTransfer.cpp @@ -0,0 +1,38 @@ +#include "MatchBoxPC.h" +#include +#include +#include +#include +#include "primitiveDataTypeDefinitions.h" +#include "dataStrStaticQueue.h" +#include "omp.h" + +inline void queuesTransfer(staticQueue &U, + staticQueue &privateU, + vector &QLocalVtx, + vector &QGhostVtx, + vector &QMsgType, + vector &QOwner, + staticQueue &privateQLocalVtx, + staticQueue &privateQGhostVtx, + staticQueue &privateQMsgType, + staticQueue &privateQOwner) +{ + +#pragma omp critical(U) + { + while (!privateU.empty()) + U.push_back(privateU.pop_front()); + } + +#pragma omp critical(privateMsg) + { + while (!privateQLocalVtx.empty()) + { + QLocalVtx.push_back(privateQLocalVtx.pop_front()); + QGhostVtx.push_back(privateQGhostVtx.pop_front()); + QMsgType.push_back(privateQMsgType.pop_front()); + QOwner.push_back(privateQOwner.pop_front()); + } + } +} \ No newline at end of file