processMatchedVertices rollback to critical regions

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

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

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

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

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

Loading…
Cancel
Save