refactoring parallelComputeCandidateMateB

omp-walther
StefanoPetrilli 3 years ago
parent 7cfe198d0f
commit 46047b2202

@ -64,6 +64,7 @@
#include "dataStrStaticQueue.h" #include "dataStrStaticQueue.h"
using namespace std; using namespace std;
#define NUM_THREAD 4
#ifdef __cplusplus #ifdef __cplusplus
extern "C" extern "C"
@ -203,6 +204,13 @@ extern "C"
staticQueue &privateQMsgType, staticQueue &privateQMsgType,
staticQueue &privateQOwner); staticQueue &privateQOwner);
inline void PARALLEL_COMPUTE_CANDIDATE_MATE_B(MilanLongInt NLVer,
MilanLongInt *verLocPtr,
MilanLongInt *verLocInd,
MilanInt myRank,
MilanReal *edgeLocWeight,
MilanLongInt *candidateMate);
void dalgoDistEdgeApproxDomEdgesLinearSearchMesgBndlSmallMateCMP( void dalgoDistEdgeApproxDomEdgesLinearSearchMesgBndlSmallMateCMP(
MilanLongInt NLVer, MilanLongInt NLEdge, MilanLongInt NLVer, MilanLongInt NLEdge,
MilanLongInt *verLocPtr, MilanLongInt *verLocInd, MilanReal *edgeLocWeight, MilanLongInt *verLocPtr, MilanLongInt *verLocInd, MilanReal *edgeLocWeight,

@ -5,6 +5,7 @@
#include "findOwnerOfGhost.cpp" #include "findOwnerOfGhost.cpp"
#include "computeCandidateMate.cpp" #include "computeCandidateMate.cpp"
#include "initialize.cpp" #include "initialize.cpp"
#include "parallelComputeCandidateMateB.cpp"
// *********************************************************************** // ***********************************************************************
// //
@ -258,26 +259,22 @@ void dalgoDistEdgeApproxDomEdgesLinearSearchMesgBndlSmallMateCMP(
///////////////////////////////////////////////////////////////////////////////////////// /////////////////////////////////////////////////////////////////////////////////////////
// Compute the Initial Matching Set: // Compute the Initial Matching Set:
#pragma omp parallel private(k, u, w, v, k1, adj1, adj2, adj11, adj12, heaviestEdgeWt, ghostOwner, privateMyCard, isEmpty) firstprivate(privateU, StartIndex, EndIndex, privateQLocalVtx, privateQGhostVtx, privateQMsgType, privateQOwner) default(shared) num_threads(4)
{
/* /*
* OMP PARALLEL_COMPUTE_CANDIDATE_MATE_B has been splitted from * OMP PARALLEL_COMPUTE_CANDIDATE_MATE_B has been splitted from
* PARALLEL_PROCESS_EXPOSED_VERTEX_B in order to better parallelize * PARALLEL_PROCESS_EXPOSED_VERTEX_B in order to better parallelize
* the two. * the two.
* In particular PARALLEL_COMPUTE_CANDIDATE_MATE_B is now totally parallel. * PARALLEL_COMPUTE_CANDIDATE_MATE_B is now totally parallel.
*/ */
#pragma omp for schedule(static) PARALLEL_COMPUTE_CANDIDATE_MATE_B(NLVer,
for (v = 0; v < NLVer; v++) verLocPtr,
verLocInd,
myRank,
edgeLocWeight,
candidateMate);
#pragma omp parallel private(k, u, w, v, k1, adj1, adj2, adj11, adj12, heaviestEdgeWt, ghostOwner, privateMyCard, isEmpty) firstprivate(privateU, StartIndex, EndIndex, privateQLocalVtx, privateQGhostVtx, privateQMsgType, privateQOwner) default(shared) num_threads(4)
{ {
#ifdef PRINT_DEBUG_INFO_
cout << "\n(" << myRank << ")Processing: " << v + StartIndex << endl;
fflush(stdout);
#endif
// Start: PARALLEL_COMPUTE_CANDIDATE_MATE_B(v)
candidateMate[v] = firstComputeCandidateMate(verLocPtr[v], verLocPtr[v + 1], verLocInd, edgeLocWeight);
// End: PARALLEL_COMPUTE_CANDIDATE_MATE_B(v)
}
/* /*
* PARALLEL_PROCESS_EXPOSED_VERTEX_B * PARALLEL_PROCESS_EXPOSED_VERTEX_B
@ -476,7 +473,7 @@ void dalgoDistEdgeApproxDomEdgesLinearSearchMesgBndlSmallMateCMP(
} }
} }
#pragma omp master #pragma omp single
{ {
tempCounter.clear(); // Do not need this any more tempCounter.clear(); // Do not need this any more
} }

@ -0,0 +1,36 @@
#include "MatchBoxPC.h"
#include <stdio.h>
#include <iostream>
#include <assert.h>
#include <map>
#include <vector>
#include "primitiveDataTypeDefinitions.h"
#include "dataStrStaticQueue.h"
#include "omp.h"
inline void PARALLEL_COMPUTE_CANDIDATE_MATE_B(MilanLongInt NLVer,
MilanLongInt *verLocPtr,
MilanLongInt *verLocInd,
MilanInt myRank,
MilanReal *edgeLocWeight,
MilanLongInt *candidateMate)
{
MilanLongInt v = -1;
#pragma omp parallel private(v) default(shared) num_threads(4)
{
#pragma omp for schedule(static)
for (v = 0; v < NLVer; v++)
{
#ifdef PRINT_DEBUG_INFO_
cout << "\n(" << myRank << ")Processing: " << v + StartIndex << endl;
fflush(stdout);
#endif
// Start: PARALLEL_COMPUTE_CANDIDATE_MATE_B(v)
candidateMate[v] = firstComputeCandidateMate(verLocPtr[v], verLocPtr[v + 1], verLocInd, edgeLocWeight);
// End: PARALLEL_COMPUTE_CANDIDATE_MATE_B(v)
}
}
}
Loading…
Cancel
Save