processMatchedVertices rollback to critical regions

omp-walther
StefanoPetrilli 2 years ago
parent 1374f21ba8
commit 71d4cdc319

@ -66,7 +66,7 @@
using namespace std; using namespace std;
#define NUM_THREAD 4 #define NUM_THREAD 4
#define UCHUNK 1000 #define UCHUNK 5
const MilanLongInt REQUEST = 1; const MilanLongInt REQUEST = 1;
const MilanLongInt SUCCESS = 2; const MilanLongInt SUCCESS = 2;
@ -295,7 +295,6 @@ extern "C"
void processMatchedVertices( void processMatchedVertices(
MilanLongInt NLVer, MilanLongInt NLVer,
vector<MilanLongInt> &UChunkBeingProcessed,
staticQueue &U, staticQueue &U,
staticQueue &privateU, staticQueue &privateU,
MilanLongInt StartIndex, MilanLongInt StartIndex,

@ -278,12 +278,8 @@ void dalgoDistEdgeApproxDomEdgesLinearSearchMesgBndlSmallMateCMP(
/////////////////////////// PROCESS MATCHED VERTICES ////////////////////////////// /////////////////////////// PROCESS MATCHED VERTICES //////////////////////////////
/////////////////////////////////////////////////////////////////////////////////// ///////////////////////////////////////////////////////////////////////////////////
vector<MilanLongInt> UChunkBeingProcessed;
UChunkBeingProcessed.reserve(UCHUNK);
//#define PRINT_DEBUG_INFO_
processMatchedVertices(NLVer, processMatchedVertices(NLVer,
UChunkBeingProcessed, //UChunkBeingProcessed,
U, U,
privateU, privateU,
StartIndex, StartIndex,

@ -1,5 +1,7 @@
#include "MatchBoxPC.h" #include "MatchBoxPC.h"
//TODO parallelize this
///Find the owner of a ghost node: ///Find the owner of a ghost node:
MilanInt findOwnerOfGhost(MilanLongInt vtxIndex, MilanLongInt *mVerDistance, MilanInt findOwnerOfGhost(MilanLongInt vtxIndex, MilanLongInt *mVerDistance,
MilanInt myRank, MilanInt numProcs) { MilanInt myRank, MilanInt numProcs) {

@ -4,7 +4,6 @@
void processMatchedVertices( void processMatchedVertices(
MilanLongInt NLVer, MilanLongInt NLVer,
vector<MilanLongInt> &UChunkBeingProcessed,
staticQueue &U, staticQueue &U,
staticQueue &privateU, staticQueue &privateU,
MilanLongInt StartIndex, MilanLongInt StartIndex,
@ -37,7 +36,6 @@ 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;
#ifdef PRINT_DEBUG_INFO_ #ifdef PRINT_DEBUG_INFO_
cout << "\n(" << myRank << "=========================************===============================" << endl; cout << "\n(" << myRank << "=========================************===============================" << endl;
fflush(stdout); fflush(stdout);
@ -93,16 +91,9 @@ void processMatchedVertices(
// for the moment it could generate an error. // for the moment it could generate an error.
if (not isAlreadyMatched(v, StartIndex, EndIndex, GMate, Mate, Ghost2LocalMap)) if (not isAlreadyMatched(v, StartIndex, EndIndex, GMate, Mate, Ghost2LocalMap))
{ {
#pragma omp critical
bool seh = false;
#pragma omp critical(prova)
{ {
seh = candidateMate[v - StartIndex] != u; if (candidateMate[v - StartIndex] == u)
}
if (seh)
continue;
#pragma omp critical(prova)
{ {
// Start: PARALLEL_PROCESS_EXPOSED_VERTEX_B(v) // Start: PARALLEL_PROCESS_EXPOSED_VERTEX_B(v)
w = computeCandidateMate(verLocPtr[v - StartIndex], w = computeCandidateMate(verLocPtr[v - StartIndex],
@ -116,7 +107,6 @@ void processMatchedVertices(
Ghost2LocalMap); Ghost2LocalMap);
candidateMate[v - StartIndex] = w; candidateMate[v - StartIndex] = w;
}
#ifdef PRINT_DEBUG_INFO_ #ifdef PRINT_DEBUG_INFO_
cout << "\n(" << myRank << ")" << v << " Points to: " << w; cout << "\n(" << myRank << ")" << v << " Points to: " << w;
@ -148,15 +138,10 @@ void processMatchedVertices(
privateQMsgType.push_back(REQUEST); privateQMsgType.push_back(REQUEST);
privateQOwner.push_back(ghostOwner); privateQOwner.push_back(ghostOwner);
#pragma omp critical(prova)
{
if (candidateMate[NLVer + Ghost2LocalMap[w]] == v) if (candidateMate[NLVer + Ghost2LocalMap[w]] == v)
{ {
while (!omp_test_lock(&MateLock[v - StartIndex]))
;
Mate[v - StartIndex] = w; // v is a local vertex Mate[v - StartIndex] = w; // v is a local vertex
GMate[Ghost2LocalMap[w]] = v; // w is a ghost vertex GMate[Ghost2LocalMap[w]] = v; // w is a ghost vertex
// Q.push_back(u);
privateU.push_back(v); privateU.push_back(v);
privateU.push_back(w); privateU.push_back(w);
#pragma omp atomic #pragma omp atomic
@ -168,24 +153,14 @@ void processMatchedVertices(
// Decrement the counter: // Decrement the counter:
PROCESS_CROSS_EDGE(Counter, Ghost2LocalMap[w], SPtr); PROCESS_CROSS_EDGE(Counter, Ghost2LocalMap[w], SPtr);
omp_unset_lock(&MateLock[v - StartIndex]);
} // End of if CandidateMate[w] = v } // End of if CandidateMate[w] = v
}
} // End of if a Ghost Vertex } // End of if a Ghost Vertex
else else
{ // w is a local vertex { // w is a local vertex
#pragma omp critical(prova)
{
if (candidateMate[w - StartIndex] == v) if (candidateMate[w - StartIndex] == v)
{ {
while (!omp_test_lock(&MateLock[v - StartIndex]))
;
while (!omp_test_lock(&MateLock[w - StartIndex]))
;
Mate[v - StartIndex] = w; // v is a local vertex Mate[v - StartIndex] = w; // v is a local vertex
Mate[w - StartIndex] = v; // w is a local vertex Mate[w - StartIndex] = v; // w is a local vertex
// Q.push_back(u);
privateU.push_back(v); privateU.push_back(v);
privateU.push_back(w); privateU.push_back(w);
#pragma omp atomic #pragma omp atomic
@ -194,10 +169,7 @@ void processMatchedVertices(
cout << "\n(" << myRank << ")MATCH: (" << v << "," << w << ") "; cout << "\n(" << myRank << ")MATCH: (" << v << "," << w << ") ";
fflush(stdout); fflush(stdout);
#endif #endif
omp_unset_lock(&MateLock[v - StartIndex]);
omp_unset_lock(&MateLock[w - StartIndex]);
} // End of if(CandidateMate(w) = v } // End of if(CandidateMate(w) = v
}
} // End of Else } // End of Else
} // End of if(w >=0) } // End of if(w >=0)
@ -236,20 +208,18 @@ void processMatchedVertices(
} // End of for loop } // End of for loop
} // End of Else: w == -1 } // End of Else: w == -1
// End: PARALLEL_PROCESS_EXPOSED_VERTEX_B(v) // End: PARALLEL_PROCESS_EXPOSED_VERTEX_B(v)
}
} // End of task
} // End of If (candidateMate[v-StartIndex] == u } // End of If (candidateMate[v-StartIndex] == u
} // End of if ( (v >= StartIndex) && (v <= EndIndex) ) //If Local Vertex: } // End of if ( (v >= StartIndex) && (v <= EndIndex) ) //If Local Vertex:
else else
{ // Neighbor is a ghost vertex { // Neighbor is a ghost vertex
while (!omp_test_lock(&MateLock[u - StartIndex])) #pragma omp critical
;
#pragma omp critical(prova)
{ {
if (candidateMate[NLVer + Ghost2LocalMap[v]] == u) if (candidateMate[NLVer + Ghost2LocalMap[v]] == u)
candidateMate[NLVer + Ghost2LocalMap[v]] = -1; candidateMate[NLVer + Ghost2LocalMap[v]] = -1;
}
if (v != Mate[u - StartIndex]) if (v != Mate[u - StartIndex])
{ // u is local { // u is local
@ -275,17 +245,13 @@ void processMatchedVertices(
} // End of If( v != Mate[u] ) } // End of If( v != Mate[u] )
omp_unset_lock(&MateLock[u - StartIndex]); } // End of task
} // End of Else //A Ghost Vertex } // End of Else //A Ghost Vertex
} // End of inner for
} // End of for // TODO privateU.size() < UCHUNK could be commented but it generate errors, why?
if (privateU.size() > UCHUNK || U.empty())
// TODO commenting that part of code might generate errors {
// Ask for the critical section only when there are no more data to
// compute.
if (/*privateU.size() < UCHUNK &&*/ !U.empty())
continue;
#pragma omp critical(U) #pragma omp critical(U)
{ {
while (!privateU.empty()) while (!privateU.empty())
@ -303,9 +269,11 @@ void processMatchedVertices(
QOwner.push_back(privateQOwner.pop_back()); QOwner.push_back(privateQOwner.pop_back());
} }
} }
#endif #endif
} // End of private.size()
} }
} } // End of outer for
} // End of while ( !U.empty() ) } // End of while ( !U.empty() )
queuesTransfer(U, privateU, QLocalVtx, queuesTransfer(U, privateU, QLocalVtx,
QGhostVtx, QGhostVtx,
@ -321,5 +289,5 @@ void processMatchedVertices(
myRank); myRank);
#endif #endif
} } // End of parallel region
} }

Loading…
Cancel
Save