parallelQueues working

omp-walther
StefanoPetrilli 2 years ago
parent 5ca78fb871
commit 561cadee0f

@ -66,7 +66,7 @@
using namespace std; using namespace std;
#define NUM_THREAD 4 #define NUM_THREAD 4
#define UCHUNK 1000 #define UCHUNK 100000
const MilanLongInt REQUEST = 1; const MilanLongInt REQUEST = 1;
const MilanLongInt SUCCESS = 2; const MilanLongInt SUCCESS = 2;

@ -71,8 +71,6 @@
Statistics: ph1_card, ph2_card : Size: |P| number of processes in the comm-world (number of matched edges in Phase 1 and Phase 2) Statistics: ph1_card, ph2_card : Size: |P| number of processes in the comm-world (number of matched edges in Phase 1 and Phase 2)
*/ */
#define UCHUNK 1000
#ifdef SERIAL_MPI #ifdef SERIAL_MPI
#else #else
@ -282,6 +280,7 @@ void dalgoDistEdgeApproxDomEdgesLinearSearchMesgBndlSmallMateCMP(
vector<MilanLongInt> UChunkBeingProcessed; vector<MilanLongInt> UChunkBeingProcessed;
UChunkBeingProcessed.reserve(UCHUNK); UChunkBeingProcessed.reserve(UCHUNK);
processMatchedVertices(NLVer, processMatchedVertices(NLVer,
UChunkBeingProcessed, UChunkBeingProcessed,
U, U,
@ -329,8 +328,6 @@ void dalgoDistEdgeApproxDomEdgesLinearSearchMesgBndlSmallMateCMP(
&MessageIndex, &MessageIndex,
numProcs, numProcs,
myRank, myRank,
//ComputeTag,
//BundleTag,
comm, comm,
QLocalVtx, QLocalVtx,
QGhostVtx, QGhostVtx,

@ -1,6 +1,6 @@
#include "MatchBoxPC.h" #include "MatchBoxPC.h"
//#define privateQueues //#define error
void processMatchedVertices( void processMatchedVertices(
MilanLongInt NLVer, MilanLongInt NLVer,
@ -38,8 +38,13 @@ void processMatchedVertices(
MilanLongInt adj1, adj2, adj11, adj12, k, k1, v = -1, w = -1, ghostOwner; MilanLongInt adj1, adj2, adj11, adj12, k, k1, v = -1, w = -1, ghostOwner;
MilanLongInt myCard = *myCardPtr, msgInd = *msgIndPtr, NumMessagesBundled = *NumMessagesBundledPtr, S = *SPtr, privateMyCard = 0; MilanLongInt myCard = *myCardPtr, msgInd = *msgIndPtr, NumMessagesBundled = *NumMessagesBundledPtr, S = *SPtr, privateMyCard = 0;
// TODO check if private queues arrive empty // TODO check that the queues arrives empty
#pragma omp parallel private(k, w, v, k1, adj1, adj2, adj11, adj12, ghostOwner) firstprivate(privateMyCard, privateU, StartIndex, EndIndex, privateQLocalVtx, privateQGhostVtx, privateQMsgType, privateQOwner) default(shared) num_threads(4) assert(privateQGhostVtx.empty());
assert(privateQLocalVtx.empty());
assert(privateQMsgType.empty());
assert(privateQOwner.empty());
#pragma omp parallel private(k, w, v, k1, adj1, adj2, adj11, adj12, ghostOwner) firstprivate(privateMyCard, privateU, StartIndex, EndIndex, privateQLocalVtx, privateQGhostVtx, privateQMsgType, privateQOwner) default(shared) num_threads(NUM_THREAD)
{ {
#ifdef PRINT_DEBUG_INFO_ #ifdef PRINT_DEBUG_INFO_
@ -140,25 +145,18 @@ void processMatchedVertices(
cout << "\n(" << myRank << ")Ghost is " << w << " Owner is: " << findOwnerOfGhost(w, verDistance, myRank, numProcs); cout << "\n(" << myRank << ")Ghost is " << w << " Owner is: " << findOwnerOfGhost(w, verDistance, myRank, numProcs);
#endif #endif
msgInd++;
NumMessagesBundled++;
ghostOwner = findOwnerOfGhost(w, verDistance, myRank, numProcs); ghostOwner = findOwnerOfGhost(w, verDistance, myRank, numProcs);
assert(ghostOwner != -1); assert(ghostOwner != -1);
assert(ghostOwner != myRank); assert(ghostOwner != myRank);
PCounter[ghostOwner]++;
#ifdef privateQueues
privateQLocalVtx.push_back(v); privateQLocalVtx.push_back(v);
privateQGhostVtx.push_back(w); privateQGhostVtx.push_back(w);
privateQMsgType.push_back(REQUEST); privateQMsgType.push_back(REQUEST);
privateQOwner.push_back(ghostOwner); privateQOwner.push_back(ghostOwner);
#endif
#ifndef privateQueues
QLocalVtx.push_back(v);
QGhostVtx.push_back(w);
QMsgType.push_back(REQUEST);
QOwner.push_back(ghostOwner);
#endif
PCounter[ghostOwner]++;
NumMessagesBundled++;
msgInd++;
if (candidateMate[NLVer + Ghost2LocalMap[w]] == v) if (candidateMate[NLVer + Ghost2LocalMap[w]] == v)
{ {
Mate[v - StartIndex] = w; // v is a local vertex Mate[v - StartIndex] = w; // v is a local vertex
@ -214,28 +212,18 @@ void processMatchedVertices(
cout << "\n(" << myRank << ")Ghost is " << w << " Owner is: " << findOwnerOfGhost(w, verDistance, myRank, numProcs); cout << "\n(" << myRank << ")Ghost is " << w << " Owner is: " << findOwnerOfGhost(w, verDistance, myRank, numProcs);
fflush(stdout); fflush(stdout);
#endif #endif
msgInd++;
// ghostOwner = inputSubGraph.findOwner(w); NumMessagesBundled++;
ghostOwner = findOwnerOfGhost(w, verDistance, myRank, numProcs); ghostOwner = findOwnerOfGhost(w, verDistance, myRank, numProcs);
assert(ghostOwner != -1); assert(ghostOwner != -1);
assert(ghostOwner != myRank); assert(ghostOwner != myRank);
PCounter[ghostOwner]++;
#ifdef privateQueues
privateQLocalVtx.push_back(v); privateQLocalVtx.push_back(v);
privateQGhostVtx.push_back(w); privateQGhostVtx.push_back(w);
privateQMsgType.push_back(FAILURE); privateQMsgType.push_back(FAILURE);
privateQOwner.push_back(ghostOwner); privateQOwner.push_back(ghostOwner);
#endif
#ifndef privateQueues
QLocalVtx.push_back(v);
QGhostVtx.push_back(w);
QMsgType.push_back(FAILURE);
QOwner.push_back(ghostOwner);
#endif
PCounter[ghostOwner]++;
NumMessagesBundled++;
msgInd++;
} // End of if(GHOST) } // End of if(GHOST)
} // End of for loop } // End of for loop
} // End of Else: w == -1 } // End of Else: w == -1
@ -270,26 +258,18 @@ void processMatchedVertices(
fflush(stdout); fflush(stdout);
#endif #endif
msgInd++;
NumMessagesBundled++;
ghostOwner = findOwnerOfGhost(v, verDistance, myRank, numProcs); ghostOwner = findOwnerOfGhost(v, verDistance, myRank, numProcs);
assert(ghostOwner != -1); assert(ghostOwner != -1);
assert(ghostOwner != myRank); assert(ghostOwner != myRank);
PCounter[ghostOwner]++;
#ifdef privateQueues
privateQLocalVtx.push_back(u); privateQLocalVtx.push_back(u);
privateQGhostVtx.push_back(v); privateQGhostVtx.push_back(v);
privateQMsgType.push_back(SUCCESS); privateQMsgType.push_back(SUCCESS);
privateQOwner.push_back(ghostOwner); privateQOwner.push_back(ghostOwner);
#endif
#ifndef privateQueues
QLocalVtx.push_back(u);
QGhostVtx.push_back(v);
QMsgType.push_back(SUCCESS);
QOwner.push_back(ghostOwner);
#endif
PCounter[ghostOwner]++;
NumMessagesBundled++;
msgInd++;
} // End of If( v != Mate[u] ) } // End of If( v != Mate[u] )
// omp_unset_lock(&MateLock[u - StartIndex]); // omp_unset_lock(&MateLock[u - StartIndex]);
@ -306,14 +286,15 @@ void processMatchedVertices(
if (privateU.size() < UCHUNK && !U.empty()) if (privateU.size() < UCHUNK && !U.empty())
continue; continue;
#ifdef privateQueues printf("Executed \n");
#ifdef error
#pragma omp critical(U) #pragma omp critical(U)
{ {
while (!privateU.empty()) while (!privateU.empty())
U.push_back(privateU.pop_back()); U.push_back(privateU.pop_back());
} }
#endif #endif
#ifndef privateQueues #ifndef error
queuesTransfer(U, privateU, QLocalVtx, queuesTransfer(U, privateU, QLocalVtx,
QGhostVtx, QGhostVtx,
QMsgType, QOwner, privateQLocalVtx, QMsgType, QOwner, privateQLocalVtx,
@ -322,7 +303,7 @@ void processMatchedVertices(
privateQOwner); privateQOwner);
#endif #endif
} }
} // End of while ( /*!Q.empty()*/ !U.empty() ) } // End of while ( !U.empty() )
queuesTransfer(U, privateU, QLocalVtx, queuesTransfer(U, privateU, QLocalVtx,
QGhostVtx, QGhostVtx,

@ -12,6 +12,7 @@ void queuesTransfer(staticQueue &U,
staticQueue &privateQOwner) staticQueue &privateQOwner)
{ {
#pragma omp critical(U) #pragma omp critical(U)
{ {
while (!privateU.empty()) while (!privateU.empty())

Loading…
Cancel
Save