merge with PolySmooth

l1aggregation
Cirdans-Home 3 months ago
parent 5b17e1bbf1
commit b4c60ae409

@ -42,7 +42,6 @@
#include <stdlib.h> #include <stdlib.h>
#if !defined(SERIAL_MPI) #if !defined(SERIAL_MPI)
#include <mpi.h> #include <mpi.h>
#endif
#include "MatchBoxPC.h" #include "MatchBoxPC.h"
#ifdef __cplusplus #ifdef __cplusplus
@ -72,9 +71,8 @@ void dMatchBoxPC(MilanLongInt NLVer, MilanLongInt NLEdge,
double tmr = MPI_Wtime(); double tmr = MPI_Wtime();
#endif #endif
// Rimosso per tornare al vecchio matching #define OMP #define OMP
#ifdef OPENMP #ifdef OMP
//fprintf(stderr,"Warning: using buggy OpenMP matching!\n");
dalgoDistEdgeApproxDomEdgesLinearSearchMesgBndlSmallMateCMP(NLVer, NLEdge, dalgoDistEdgeApproxDomEdgesLinearSearchMesgBndlSmallMateCMP(NLVer, NLEdge,
verLocPtr, verLocInd, edgeLocWeight, verLocPtr, verLocInd, edgeLocWeight,
verDistance, Mate, verDistance, Mate,
@ -128,3 +126,4 @@ void sMatchBoxPC(MilanLongInt NLVer, MilanLongInt NLEdge,
#ifdef __cplusplus #ifdef __cplusplus
} }
#endif #endif
#endif

@ -59,11 +59,7 @@
#include <assert.h> #include <assert.h>
#include <map> #include <map>
#include <vector> #include <vector>
#ifdef OPENMP
// OpenMP is included and used if and only if the OpenMP version of the matching
// is required
#include "omp.h" #include "omp.h"
#endif
#include "primitiveDataTypeDefinitions.h" #include "primitiveDataTypeDefinitions.h"
#include "dataStrStaticQueue.h" #include "dataStrStaticQueue.h"
@ -82,6 +78,8 @@ const int BundleTag = 9; // Predefined tag
static vector<MilanLongInt> DEFAULT_VECTOR; static vector<MilanLongInt> DEFAULT_VECTOR;
#if !defined(SERIAL_MPI)
// MPI type map // MPI type map
template <typename T> template <typename T>
MPI_Datatype TypeMap(); MPI_Datatype TypeMap();
@ -93,6 +91,7 @@ template <>
inline MPI_Datatype TypeMap<double>() { return MPI_DOUBLE; } inline MPI_Datatype TypeMap<double>() { return MPI_DOUBLE; }
template <> template <>
inline MPI_Datatype TypeMap<float>() { return MPI_FLOAT; } inline MPI_Datatype TypeMap<float>() { return MPI_FLOAT; }
#endif
#ifdef __cplusplus #ifdef __cplusplus
extern "C" extern "C"
@ -178,10 +177,6 @@ extern "C"
#define MilanRealMin MINUS_INFINITY #define MilanRealMin MINUS_INFINITY
#endif #endif
#ifdef OPENMP
/* These functions are only used in the experimental OMP implementation, if that
is disabled there is no reason to actually compile or reference them. */
// Function of find the owner of a ghost vertex using binary search: // Function of find the owner of a ghost vertex using binary search:
MilanInt findOwnerOfGhost(MilanLongInt vtxIndex, MilanLongInt *mVerDistance, MilanInt findOwnerOfGhost(MilanLongInt vtxIndex, MilanLongInt *mVerDistance,
MilanInt myRank, MilanInt numProcs); MilanInt myRank, MilanInt numProcs);
@ -428,14 +423,6 @@ is disabled there is no reason to actually compile or reference them. */
MilanLongInt *msgIndSent, MilanLongInt *msgActualSent, MilanReal *msgPercent, MilanLongInt *msgIndSent, MilanLongInt *msgActualSent, MilanReal *msgPercent,
MilanReal *ph0_time, MilanReal *ph1_time, MilanReal *ph2_time, MilanReal *ph0_time, MilanReal *ph1_time, MilanReal *ph2_time,
MilanLongInt *ph1_card, MilanLongInt *ph2_card); MilanLongInt *ph1_card, MilanLongInt *ph2_card);
#endif
#ifndef OPENMP
//Function of find the owner of a ghost vertex using binary search:
inline MilanInt findOwnerOfGhost(MilanLongInt vtxIndex, MilanLongInt *mVerDistance,
MilanInt myRank, MilanInt numProcs);
#endif
void dalgoDistEdgeApproxDomEdgesLinearSearchMesgBndlSmallMateC( void dalgoDistEdgeApproxDomEdgesLinearSearchMesgBndlSmallMateC(
MilanLongInt NLVer, MilanLongInt NLEdge, MilanLongInt NLVer, MilanLongInt NLEdge,

@ -1,5 +1,5 @@
#include "MatchBoxPC.h" #include "MatchBoxPC.h"
#ifdef OPENMP
// *********************************************************************** // ***********************************************************************
// //
// MatchboxP: A C++ library for approximate weighted matching // MatchboxP: A C++ library for approximate weighted matching
@ -126,10 +126,8 @@ void dalgoDistEdgeApproxDomEdgesLinearSearchMesgBndlSmallMateCMP(
fflush(stdout); fflush(stdout);
#endif #endif
// The starting vertex owned by the current rank MilanLongInt StartIndex = verDistance[myRank]; // The starting vertex owned by the current rank
MilanLongInt StartIndex = verDistance[myRank]; MilanLongInt EndIndex = verDistance[myRank + 1] - 1; // The ending vertex owned by the current rank
// The ending vertex owned by the current rank
MilanLongInt EndIndex = verDistance[myRank + 1] - 1;
MPI_Status computeStatus; MPI_Status computeStatus;
@ -147,8 +145,7 @@ void dalgoDistEdgeApproxDomEdgesLinearSearchMesgBndlSmallMateCMP(
// only one message will be sent in the initialization phase - // only one message will be sent in the initialization phase -
// one of: REQUEST/FAILURE/SUCCESS // one of: REQUEST/FAILURE/SUCCESS
vector<MilanLongInt> QLocalVtx, QGhostVtx, QMsgType; vector<MilanLongInt> QLocalVtx, QGhostVtx, QMsgType;
// Changed by Fabio to be an integer, addresses needs to be integers! vector<MilanInt> QOwner; // Changed by Fabio to be an integer, addresses needs to be integers!
vector<MilanInt> QOwner;
MilanLongInt *PCounter = new MilanLongInt[numProcs]; MilanLongInt *PCounter = new MilanLongInt[numProcs];
for (int i = 0; i < numProcs; i++) for (int i = 0; i < numProcs; i++)
@ -156,8 +153,7 @@ void dalgoDistEdgeApproxDomEdgesLinearSearchMesgBndlSmallMateCMP(
MilanLongInt NumMessagesBundled = 0; MilanLongInt NumMessagesBundled = 0;
// TODO when the last computational section will be refactored this could be eliminated // TODO when the last computational section will be refactored this could be eliminated
// Changed by Fabio to be an integer, addresses needs to be integers! MilanInt ghostOwner = 0; // Changed by Fabio to be an integer, addresses needs to be integers!
MilanInt ghostOwner = 0;
MilanLongInt *candidateMate = nullptr; MilanLongInt *candidateMate = nullptr;
#ifdef PRINT_DEBUG_INFO_ #ifdef PRINT_DEBUG_INFO_
cout << "\n(" << myRank << ")NV: " << NLVer << " Edges: " << NLEdge; cout << "\n(" << myRank << ")NV: " << NLVer << " Edges: " << NLEdge;
@ -172,12 +168,9 @@ void dalgoDistEdgeApproxDomEdgesLinearSearchMesgBndlSmallMateCMP(
MilanLongInt myCard = 0; MilanLongInt myCard = 0;
// Build the Ghost Vertex Set: Vg // Build the Ghost Vertex Set: Vg
// Map each ghost vertex to a local vertex map<MilanLongInt, MilanLongInt> Ghost2LocalMap; // Map each ghost vertex to a local vertex
map<MilanLongInt, MilanLongInt> Ghost2LocalMap; vector<MilanLongInt> Counter; // Store the edge count for each ghost vertex
// Store the edge count for each ghost vertex MilanLongInt numGhostVertices = 0, numGhostEdges = 0; // Number of Ghost vertices
vector<MilanLongInt> Counter;
// Number of Ghost vertices
MilanLongInt numGhostVertices = 0, numGhostEdges = 0;
#ifdef PRINT_DEBUG_INFO_ #ifdef PRINT_DEBUG_INFO_
cout << "\n(" << myRank << ")About to compute Ghost Vertices..."; cout << "\n(" << myRank << ")About to compute Ghost Vertices...";
@ -229,7 +222,7 @@ void dalgoDistEdgeApproxDomEdgesLinearSearchMesgBndlSmallMateCMP(
cout << myRank << " Finished initialization" << endl; cout << myRank << " Finished initialization" << endl;
fflush(stdout); fflush(stdout);
#endif #endif
startTime = MPI_Wtime(); startTime = MPI_Wtime();
///////////////////////////////////////////////////////////////////////////////////////// /////////////////////////////////////////////////////////////////////////////////////////
@ -398,7 +391,7 @@ void dalgoDistEdgeApproxDomEdgesLinearSearchMesgBndlSmallMateCMP(
cout << myRank << " Finished sendBundles" << endl; cout << myRank << " Finished sendBundles" << endl;
fflush(stdout); fflush(stdout);
#endif #endif
*ph1_card = myCard; // Cardinality at the end of Phase-1 *ph1_card = myCard; // Cardinality at the end of Phase-1
startTime = MPI_Wtime(); startTime = MPI_Wtime();
///////////////////////////////////////////////////////////////////////////////////////// /////////////////////////////////////////////////////////////////////////////////////////
@ -429,7 +422,7 @@ void dalgoDistEdgeApproxDomEdgesLinearSearchMesgBndlSmallMateCMP(
/////////////////////////////////////////////////////////////////////////////////// ///////////////////////////////////////////////////////////////////////////////////
/////////////////////////// PROCESS MATCHED VERTICES ////////////////////////////// /////////////////////////// PROCESS MATCHED VERTICES //////////////////////////////
/////////////////////////////////////////////////////////////////////////////////// ///////////////////////////////////////////////////////////////////////////////////
processMatchedVerticesAndSendMessages(NLVer, processMatchedVerticesAndSendMessages(NLVer,
UChunkBeingProcessed, UChunkBeingProcessed,
U, U,
@ -463,7 +456,7 @@ void dalgoDistEdgeApproxDomEdgesLinearSearchMesgBndlSmallMateCMP(
comm, comm,
&msgActual, &msgActual,
Message); Message);
///////////////////////// END OF PROCESS MATCHED VERTICES ///////////////////////// ///////////////////////// END OF PROCESS MATCHED VERTICES /////////////////////////
//// BREAK IF NO MESSAGES EXPECTED ///////// //// BREAK IF NO MESSAGES EXPECTED /////////
@ -559,4 +552,3 @@ void dalgoDistEdgeApproxDomEdgesLinearSearchMesgBndlSmallMateCMP(
#endif #endif
#endif #endif
#endif

@ -1,6 +1,7 @@
#include "MatchBoxPC.h" #include "MatchBoxPC.h"
#ifdef OPENMP
// TODO comment // TODO comment
#if !defined(SERIAL_MPI)
void clean(MilanLongInt NLVer, void clean(MilanLongInt NLVer,
MilanInt myRank, MilanInt myRank,

@ -1,5 +1,5 @@
#include "MatchBoxPC.h" #include "MatchBoxPC.h"
#ifdef OPENMP
/** /**
* Execute the research fr the Candidate Mate without controlling if the vertices are already matched. * Execute the research fr the Candidate Mate without controlling if the vertices are already matched.
* Returns the vertices with the highest weight * Returns the vertices with the highest weight
@ -9,6 +9,8 @@
* @param edgeLocWeight * @param edgeLocWeight
* @return * @return
*/ */
#if !defined(SERIAL_MPI)
MilanLongInt firstComputeCandidateMate(MilanLongInt adj1, MilanLongInt firstComputeCandidateMate(MilanLongInt adj1,
MilanLongInt adj2, MilanLongInt adj2,
MilanLongInt *verLocInd, MilanLongInt *verLocInd,
@ -60,7 +62,7 @@ MilanLongInt computeCandidateMate(MilanLongInt adj1,
for (k = adj1; k < adj2; k++) { for (k = adj1; k < adj2; k++) {
if (isAlreadyMatched(verLocInd[k], StartIndex, EndIndex, GMate, Mate, Ghost2LocalMap)) if (isAlreadyMatched(verLocInd[k], StartIndex, EndIndex, GMate, Mate, Ghost2LocalMap))
continue; continue;
if ((edgeLocWeight[k] > heaviestEdgeWt) || if ((edgeLocWeight[k] > heaviestEdgeWt) ||
((edgeLocWeight[k] == heaviestEdgeWt) && (w < verLocInd[k]))) { ((edgeLocWeight[k] == heaviestEdgeWt) && (w < verLocInd[k]))) {
heaviestEdgeWt = edgeLocWeight[k]; heaviestEdgeWt = edgeLocWeight[k];
@ -68,7 +70,7 @@ MilanLongInt computeCandidateMate(MilanLongInt adj1,
} }
} // End of for loop } // End of for loop
// End: PARALLEL_COMPUTE_CANDIDATE_MATE_B(v) // End: PARALLEL_COMPUTE_CANDIDATE_MATE_B(v)
return w; return w;
} }
#endif #endif

@ -1,5 +1,5 @@
#include "MatchBoxPC.h" #include "MatchBoxPC.h"
#ifdef OPENMP
void extractUChunk( void extractUChunk(
vector<MilanLongInt> &UChunkBeingProcessed, vector<MilanLongInt> &UChunkBeingProcessed,
vector<MilanLongInt> &U, vector<MilanLongInt> &U,
@ -28,5 +28,4 @@ void extractUChunk(
} }
} // End of critical U // End of critical U } // End of critical U // End of critical U
} }
#endif

@ -1,5 +1,5 @@
#include "MatchBoxPC.h" #include "MatchBoxPC.h"
#ifdef OPENMP
/// 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)
@ -27,4 +27,3 @@ MilanInt findOwnerOfGhost(MilanLongInt vtxIndex, MilanLongInt *mVerDistance,
return Current; return Current;
} // End of findOwnerOfGhost() } // End of findOwnerOfGhost()
#endif

@ -1,5 +1,5 @@
#include "MatchBoxPC.h" #include "MatchBoxPC.h"
#ifdef OPENMP
void initialize(MilanLongInt NLVer, MilanLongInt NLEdge, void initialize(MilanLongInt NLVer, MilanLongInt NLEdge,
MilanLongInt StartIndex, MilanLongInt EndIndex, MilanLongInt StartIndex, MilanLongInt EndIndex,
MilanLongInt *numGhostEdges, MilanLongInt *numGhostEdges,
@ -291,7 +291,7 @@ void initialize(MilanLongInt NLVer, MilanLongInt NLEdge,
//new (&U) staticQueue(NLVer + (*numGhostVertices)); //new (&U) staticQueue(NLVer + (*numGhostVertices));
U.reserve(NLVer + (*numGhostVertices)); U.reserve(NLVer + (*numGhostVertices));
// Initialize the private vectors // Initialize the private vectors
privateQLocalVtx.reserve(*numGhostVertices); privateQLocalVtx.reserve(*numGhostVertices);
privateQGhostVtx.reserve(*numGhostVertices); privateQGhostVtx.reserve(*numGhostVertices);
privateQMsgType.reserve(*numGhostVertices); privateQMsgType.reserve(*numGhostVertices);
@ -302,4 +302,3 @@ void initialize(MilanLongInt NLVer, MilanLongInt NLEdge,
} // End of single region } // End of single region
} // End of parallel region } // End of parallel region
} }
#endif

@ -1,5 +1,5 @@
#include "MatchBoxPC.h" #include "MatchBoxPC.h"
#ifdef OPENMP
/** /**
* //TODO documentation * //TODO documentation
* @param k * @param k
@ -32,7 +32,7 @@ bool isAlreadyMatched(MilanLongInt node,
*/ */
MilanLongInt val; MilanLongInt val;
if ((node < StartIndex) || (node > EndIndex)) // if ghost vertex if ((node < StartIndex) || (node > EndIndex)) // if ghost vertex
{ {
#pragma omp atomic read #pragma omp atomic read
val = GMate[Ghost2LocalMap[node]]; val = GMate[Ghost2LocalMap[node]];
return val >= 0; // Already matched return val >= 0; // Already matched
@ -43,5 +43,4 @@ bool isAlreadyMatched(MilanLongInt node,
val = Mate[node - StartIndex]; val = Mate[node - StartIndex];
return val >= 0; // Already matched return val >= 0; // Already matched
} }
#endif

@ -1,5 +1,6 @@
#include "MatchBoxPC.h" #include "MatchBoxPC.h"
#ifdef OPENMP #if !defined(SERIAL_MPI)
void PARALLEL_COMPUTE_CANDIDATE_MATE_B(MilanLongInt NLVer, void PARALLEL_COMPUTE_CANDIDATE_MATE_B(MilanLongInt NLVer,
MilanLongInt *verLocPtr, MilanLongInt *verLocPtr,
MilanLongInt *verLocInd, MilanLongInt *verLocInd,

@ -1,5 +1,5 @@
#include "MatchBoxPC.h" #include "MatchBoxPC.h"
#ifdef OPENMP
void PROCESS_CROSS_EDGE(MilanLongInt *edge, void PROCESS_CROSS_EDGE(MilanLongInt *edge,
MilanLongInt *S) MilanLongInt *S)
{ {
@ -21,5 +21,4 @@ void PROCESS_CROSS_EDGE(MilanLongInt *edge,
#endif #endif
// End: PARALLEL_PROCESS_CROSS_EDGE_B // End: PARALLEL_PROCESS_CROSS_EDGE_B
} }
#endif

@ -1,5 +1,6 @@
#include "MatchBoxPC.h" #include "MatchBoxPC.h"
#ifdef OPENMP #if !defined(SERIAL_MPI)
void PARALLEL_PROCESS_EXPOSED_VERTEX_B(MilanLongInt NLVer, void PARALLEL_PROCESS_EXPOSED_VERTEX_B(MilanLongInt NLVer,
MilanLongInt *candidateMate, MilanLongInt *candidateMate,
MilanLongInt *verLocInd, MilanLongInt *verLocInd,
@ -29,7 +30,7 @@ void PARALLEL_PROCESS_EXPOSED_VERTEX_B(MilanLongInt NLVer,
vector<MilanLongInt> &privateQGhostVtx, vector<MilanLongInt> &privateQGhostVtx,
vector<MilanLongInt> &privateQMsgType, vector<MilanLongInt> &privateQMsgType,
vector<MilanInt> &privateQOwner) vector<MilanInt> &privateQOwner)
{ {
MilanLongInt v = -1, k = -1, w = -1, adj11 = 0, adj12 = 0, k1 = 0; MilanLongInt v = -1, k = -1, w = -1, adj11 = 0, adj12 = 0, k1 = 0;
MilanInt ghostOwner = 0, option, igw; MilanInt ghostOwner = 0, option, igw;
@ -79,7 +80,7 @@ void PARALLEL_PROCESS_EXPOSED_VERTEX_B(MilanLongInt NLVer,
Ghost2LocalMap); Ghost2LocalMap);
candidateMate[v] = w; candidateMate[v] = w;
} }
if (w >= 0) { if (w >= 0) {
(*myCard)++; (*myCard)++;
if ((w < StartIndex) || (w > EndIndex)) { // w is a ghost vertex if ((w < StartIndex) || (w > EndIndex)) { // w is a ghost vertex
@ -88,63 +89,60 @@ void PARALLEL_PROCESS_EXPOSED_VERTEX_B(MilanLongInt NLVer,
option = 1; option = 1;
Mate[v] = w; Mate[v] = w;
GMate[Ghost2LocalMap[w]] = v + StartIndex; // w is a Ghost GMate[Ghost2LocalMap[w]] = v + StartIndex; // w is a Ghost
} // 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 { // w is a local vertex else { // w is a local vertex
if (candidateMate[w - StartIndex] == (v + StartIndex)) { if (candidateMate[w - StartIndex] == (v + StartIndex)) {
option = 3; option = 3;
Mate[v] = w; // v is local Mate[v] = w; // v is local
Mate[w - StartIndex] = v + StartIndex; // w is local Mate[w - StartIndex] = v + StartIndex; // w is local
#ifdef PRINT_DEBUG_INFO_ #ifdef PRINT_DEBUG_INFO_
cout << "\n(" << myRank << ")MATCH: (" << v + StartIndex << "," << w << ") "; cout << "\n(" << myRank << ")MATCH: (" << v + StartIndex << "," << w << ") ";
fflush(stdout); fflush(stdout);
#endif #endif
} // End of if ( candidateMate[w-StartIndex] == (v+StartIndex) ) } // End of if ( candidateMate[w-StartIndex] == (v+StartIndex) )
} // End of Else } // End of Else
} // End of second if } // End of second if
} // End critical processExposed } // End critical processExposed
} // End of if(w >=0) } // End of if(w >=0)
else { else {
#pragma omp critical(adjuse) // This piece of code is executed a really small amount of times
{ adj11 = verLocPtr[v];
// This piece of code is executed a really small number of times adj12 = verLocPtr[v + 1];
adj11 = verLocPtr[v]; for (k1 = adj11; k1 < adj12; k1++) {
adj12 = verLocPtr[v + 1]; w = verLocInd[k1];
for (k1 = adj11; k1 < adj12; k1++) { if ((w < StartIndex) || (w > EndIndex)) { // A ghost
w = verLocInd[k1];
if ((w < StartIndex) || (w > EndIndex)) { // A ghost
#ifdef PRINT_DEBUG_INFO_ #ifdef PRINT_DEBUG_INFO_
cout << "\n(" << myRank << ")Sending a failure message: "; cout << "\n(" << myRank << ")Sending a failure message: ";
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)++; (*msgInd)++;
(*NumMessagesBundled)++; (*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]++; PCounter[ghostOwner]++;
privateQLocalVtx.push_back(v + StartIndex); privateQLocalVtx.push_back(v + StartIndex);
privateQGhostVtx.push_back(w); privateQGhostVtx.push_back(w);
privateQMsgType.push_back(FAILURE); privateQMsgType.push_back(FAILURE);
privateQOwner.push_back(ghostOwner); privateQOwner.push_back(ghostOwner);
} // End of if(GHOST) } // End of if(GHOST)
} // End of for loop } // End of for loop
}
} }
// End: PARALLEL_PROCESS_EXPOSED_VERTEX_B(v) // End: PARALLEL_PROCESS_EXPOSED_VERTEX_B(v)
switch (option) switch (option)
{ {
case -1: case -1:

@ -1,5 +1,6 @@
#include "MatchBoxPC.h" #include "MatchBoxPC.h"
#ifdef OPENMP
#if !defined(SERIAL_MPI)
void processMatchedVertices( void processMatchedVertices(
MilanLongInt NLVer, MilanLongInt NLVer,
vector<MilanLongInt> &UChunkBeingProcessed, vector<MilanLongInt> &UChunkBeingProcessed,
@ -58,29 +59,29 @@ void processMatchedVertices(
{ {
while (!U.empty()) { while (!U.empty()) {
extractUChunk(UChunkBeingProcessed, U, privateU); extractUChunk(UChunkBeingProcessed, U, privateU);
for (MilanLongInt u : UChunkBeingProcessed) { for (MilanLongInt u : UChunkBeingProcessed) {
#ifdef PRINT_DEBUG_INFO_ #ifdef PRINT_DEBUG_INFO_
cout << "\n(" << myRank << ")u: " << u; cout << "\n(" << myRank << ")u: " << u;
fflush(stdout); fflush(stdout);
#endif #endif
if ((u >= StartIndex) && (u <= EndIndex)) { // Process Only the Local Vertices if ((u >= StartIndex) && (u <= EndIndex)) { // Process Only the Local Vertices
#ifdef COUNT_LOCAL_VERTEX #ifdef COUNT_LOCAL_VERTEX
localVertices++; localVertices++;
#endif #endif
// Get the Adjacency list for u // Get the Adjacency list for u
adj1 = verLocPtr[u - StartIndex]; // Pointer adj1 = verLocPtr[u - StartIndex]; // Pointer
adj2 = verLocPtr[u - StartIndex + 1]; adj2 = verLocPtr[u - StartIndex + 1];
for (k = adj1; k < adj2; k++) { for (k = adj1; k < adj2; k++) {
option = -1; option = -1;
v = verLocInd[k]; v = verLocInd[k];
if ((v >= StartIndex) && (v <= EndIndex)) { // If Local Vertex: if ((v >= StartIndex) && (v <= EndIndex)) { // If Local Vertex:
#ifdef PRINT_DEBUG_INFO_ #ifdef PRINT_DEBUG_INFO_
cout << "\n(" << myRank << ")v: " << v << " c(v)= " << candidateMate[v - StartIndex] << " Mate[v]: " << Mate[v]; cout << "\n(" << myRank << ")v: " << v << " c(v)= " << candidateMate[v - StartIndex] << " Mate[v]: " << Mate[v];
fflush(stdout); fflush(stdout);
@ -102,27 +103,27 @@ void processMatchedVertices(
GMate, GMate,
Mate, Mate,
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;
fflush(stdout); fflush(stdout);
#endif #endif
// If found a dominating edge: // If found a dominating edge:
if (w >= 0) { if (w >= 0) {
if ((w < StartIndex) || (w > EndIndex)) { // A ghost if ((w < StartIndex) || (w > EndIndex)) { // A ghost
#ifdef PRINT_DEBUG_INFO_ #ifdef PRINT_DEBUG_INFO_
cout << "\n(" << myRank << ")Sending a request message:"; cout << "\n(" << myRank << ")Sending a request message:";
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
option = 2; option = 2;
if (candidateMate[NLVer + Ghost2LocalMap[w]] == v) { if (candidateMate[NLVer + Ghost2LocalMap[w]] == v) {
option = 1; option = 1;
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
} // 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 { // w is a local vertex else { // w is a local vertex
@ -130,7 +131,7 @@ void processMatchedVertices(
option = 3; option = 3;
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
#ifdef PRINT_DEBUG_INFO_ #ifdef PRINT_DEBUG_INFO_
cout << "\n(" << myRank << ")MATCH: (" << v << "," << w << ") "; cout << "\n(" << myRank << ")MATCH: (" << v << "," << w << ") ";
fflush(stdout); fflush(stdout);
@ -146,7 +147,7 @@ void processMatchedVertices(
} // mateval < 0 } // mateval < 0
} // End of if ( (v >= StartIndex) && (v <= EndIndex) ) //If Local Vertex: } // End of if ( (v >= StartIndex) && (v <= EndIndex) ) //If Local Vertex:
else { // Neighbor is a ghost vertex else { // Neighbor is a ghost vertex
#pragma omp critical #pragma omp critical
{ {
if (candidateMate[NLVer + Ghost2LocalMap[v]] == u) if (candidateMate[NLVer + Ghost2LocalMap[v]] == u)
@ -155,7 +156,7 @@ void processMatchedVertices(
option = 5; // u is local option = 5; // u is local
} // End of critical } // End of critical
} // End of Else //A Ghost Vertex } // End of Else //A Ghost Vertex
switch (option) switch (option)
{ {
case -1: case -1:
@ -165,7 +166,7 @@ void processMatchedVertices(
// Found a dominating edge, it is a ghost and candidateMate[NLVer + Ghost2LocalMap[w]] == v // Found a dominating edge, it is a ghost and candidateMate[NLVer + Ghost2LocalMap[w]] == v
privateU.push_back(v); privateU.push_back(v);
privateU.push_back(w); privateU.push_back(w);
(*myCard)++; (*myCard)++;
#ifdef PRINT_DEBUG_INFO_ #ifdef PRINT_DEBUG_INFO_
cout << "\n(" << myRank << ")MATCH: (" << v << "," << w << ") "; cout << "\n(" << myRank << ")MATCH: (" << v << "," << w << ") ";
@ -174,7 +175,7 @@ void processMatchedVertices(
// Decrement the counter: // Decrement the counter:
PROCESS_CROSS_EDGE(&Counter[Ghost2LocalMap[w]], SPtr); PROCESS_CROSS_EDGE(&Counter[Ghost2LocalMap[w]], SPtr);
case 2: case 2:
// Found a dominating edge, it is a ghost // Found a dominating edge, it is a ghost
ghostOwner = findOwnerOfGhost(w, verDistance, myRank, numProcs); ghostOwner = findOwnerOfGhost(w, verDistance, myRank, numProcs);
// assert(ghostOwner != -1); // assert(ghostOwner != -1);
@ -182,7 +183,7 @@ void processMatchedVertices(
PCounter[ghostOwner]++; PCounter[ghostOwner]++;
(*NumMessagesBundled)++; (*NumMessagesBundled)++;
(*msgInd)++; (*msgInd)++;
privateQLocalVtx.push_back(v); privateQLocalVtx.push_back(v);
privateQGhostVtx.push_back(w); privateQGhostVtx.push_back(w);
privateQMsgType.push_back(REQUEST); privateQMsgType.push_back(REQUEST);
@ -191,7 +192,7 @@ void processMatchedVertices(
case 3: case 3:
privateU.push_back(v); privateU.push_back(v);
privateU.push_back(w); privateU.push_back(w);
(*myCard)++; (*myCard)++;
break; break;
case 4: case 4:
@ -201,94 +202,94 @@ void processMatchedVertices(
for (k1 = adj11; k1 < adj12; k1++) { for (k1 = adj11; k1 < adj12; k1++) {
w = verLocInd[k1]; w = verLocInd[k1];
if ((w < StartIndex) || (w > EndIndex)) { // A ghost if ((w < StartIndex) || (w > EndIndex)) { // A ghost
#ifdef PRINT_DEBUG_INFO_ #ifdef PRINT_DEBUG_INFO_
cout << "\n(" << myRank << ")Sending a failure message: "; cout << "\n(" << myRank << ")Sending a failure message: ";
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
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]++; PCounter[ghostOwner]++;
(*NumMessagesBundled)++; (*NumMessagesBundled)++;
(*msgInd)++; (*msgInd)++;
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);
} // End of if(GHOST) } // End of if(GHOST)
} // End of for loop } // End of for loop
break; break;
case 5: case 5:
default: default:
#ifdef PRINT_DEBUG_INFO_ #ifdef PRINT_DEBUG_INFO_
cout << "\n(" << myRank << ")Sending a success message: "; cout << "\n(" << myRank << ")Sending a success message: ";
cout << "\n(" << myRank << ")Ghost is " << v << " Owner is: " << findOwnerOfGhost(v, verDistance, myRank, numProcs) << "\n"; cout << "\n(" << myRank << ")Ghost is " << v << " Owner is: " << findOwnerOfGhost(v, verDistance, myRank, numProcs) << "\n";
fflush(stdout); fflush(stdout);
#endif #endif
ghostOwner = findOwnerOfGhost(v, verDistance, myRank, numProcs); ghostOwner = findOwnerOfGhost(v, verDistance, myRank, numProcs);
// assert(ghostOwner != -1); // assert(ghostOwner != -1);
// assert(ghostOwner != myRank); // assert(ghostOwner != myRank);
(*NumMessagesBundled)++; (*NumMessagesBundled)++;
PCounter[ghostOwner]++; PCounter[ghostOwner]++;
(*msgInd)++; (*msgInd)++;
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);
break; break;
} // End of switch } // End of switch
} // End of inner for } // End of inner for
} }
} // End of outer for } // End of outer for
queuesTransfer(U, privateU, QLocalVtx, queuesTransfer(U, privateU, QLocalVtx,
QGhostVtx, QGhostVtx,
QMsgType, QOwner, privateQLocalVtx, QMsgType, QOwner, privateQLocalVtx,
privateQGhostVtx, privateQGhostVtx,
privateQMsgType, privateQMsgType,
privateQOwner); privateQOwner);
#pragma omp critical(U) #pragma omp critical(U)
{ {
U.insert(U.end(), privateU.begin(), privateU.end()); U.insert(U.end(), privateU.begin(), privateU.end());
} }
privateU.clear(); privateU.clear();
#pragma omp critical(sendMessageTransfer) #pragma omp critical(sendMessageTransfer)
{ {
QLocalVtx.insert(QLocalVtx.end(), privateQLocalVtx.begin(), privateQLocalVtx.end()); QLocalVtx.insert(QLocalVtx.end(), privateQLocalVtx.begin(), privateQLocalVtx.end());
QGhostVtx.insert(QGhostVtx.end(), privateQGhostVtx.begin(), privateQGhostVtx.end()); QGhostVtx.insert(QGhostVtx.end(), privateQGhostVtx.begin(), privateQGhostVtx.end());
QMsgType.insert(QMsgType.end(), privateQMsgType.begin(), privateQMsgType.end()); QMsgType.insert(QMsgType.end(), privateQMsgType.begin(), privateQMsgType.end());
QOwner.insert(QOwner.end(), privateQOwner.begin(), privateQOwner.end()); QOwner.insert(QOwner.end(), privateQOwner.begin(), privateQOwner.end());
} }
privateQLocalVtx.clear(); privateQLocalVtx.clear();
privateQGhostVtx.clear(); privateQGhostVtx.clear();
privateQMsgType.clear(); privateQMsgType.clear();
privateQOwner.clear(); privateQOwner.clear();
} // End of while ( !U.empty() ) } // End of while ( !U.empty() )
#ifdef COUNT_LOCAL_VERTEX #ifdef COUNT_LOCAL_VERTEX
printf("Count local vertexes: %ld for thread %d of processor %d\n", printf("Count local vertexes: %ld for thread %d of processor %d\n",
localVertices, localVertices,
omp_get_thread_num(), omp_get_thread_num(),
myRank); myRank);
#endif #endif
} // End of parallel region } // End of parallel region
} }

@ -1,6 +1,6 @@
#include "MatchBoxPC.h" #include "MatchBoxPC.h"
#ifdef OPENMP
//#define DEBUG_HANG_ //#define DEBUG_HANG_
#if !defined(SERIAL_MPI)
void processMatchedVerticesAndSendMessages( void processMatchedVerticesAndSendMessages(
MilanLongInt NLVer, MilanLongInt NLVer,
vector<MilanLongInt> &UChunkBeingProcessed, vector<MilanLongInt> &UChunkBeingProcessed,
@ -64,29 +64,29 @@ void processMatchedVerticesAndSendMessages(
{ {
while (!U.empty()) { while (!U.empty()) {
extractUChunk(UChunkBeingProcessed, U, privateU); extractUChunk(UChunkBeingProcessed, U, privateU);
for (MilanLongInt u : UChunkBeingProcessed) { for (MilanLongInt u : UChunkBeingProcessed) {
#ifdef PRINT_DEBUG_INFO_ #ifdef PRINT_DEBUG_INFO_
cout << "\n(" << myRank << ")u: " << u; cout << "\n(" << myRank << ")u: " << u;
fflush(stdout); fflush(stdout);
#endif #endif
if ((u >= StartIndex) && (u <= EndIndex)) { // Process Only the Local Vertices if ((u >= StartIndex) && (u <= EndIndex)) { // Process Only the Local Vertices
#ifdef COUNT_LOCAL_VERTEX #ifdef COUNT_LOCAL_VERTEX
localVertices++; localVertices++;
#endif #endif
// Get the Adjacency list for u // Get the Adjacency list for u
adj1 = verLocPtr[u - StartIndex]; // Pointer adj1 = verLocPtr[u - StartIndex]; // Pointer
adj2 = verLocPtr[u - StartIndex + 1]; adj2 = verLocPtr[u - StartIndex + 1];
for (k = adj1; k < adj2; k++) { for (k = adj1; k < adj2; k++) {
option = -1; option = -1;
v = verLocInd[k]; v = verLocInd[k];
if ((v >= StartIndex) && (v <= EndIndex)) { // If Local Vertex: if ((v >= StartIndex) && (v <= EndIndex)) { // If Local Vertex:
#ifdef PRINT_DEBUG_INFO_ #ifdef PRINT_DEBUG_INFO_
cout << "\n(" << myRank << ")v: " << v << " c(v)= " << candidateMate[v - StartIndex] << " Mate[v]: " << Mate[v]; cout << "\n(" << myRank << ")v: " << v << " c(v)= " << candidateMate[v - StartIndex] << " Mate[v]: " << Mate[v];
fflush(stdout); fflush(stdout);
@ -108,28 +108,28 @@ void processMatchedVerticesAndSendMessages(
GMate, GMate,
Mate, Mate,
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;
fflush(stdout); fflush(stdout);
#endif #endif
// If found a dominating edge: // If found a dominating edge:
if (w >= 0) { if (w >= 0) {
if ((w < StartIndex) || (w > EndIndex)) { // A ghost if ((w < StartIndex) || (w > EndIndex)) { // A ghost
#ifdef PRINT_DEBUG_INFO_ #ifdef PRINT_DEBUG_INFO_
cout << "\n(" << myRank << ")Sending a request message:"; cout << "\n(" << myRank << ")Sending a request message:";
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
option = 2; option = 2;
if (candidateMate[NLVer + Ghost2LocalMap[w]] == v) { if (candidateMate[NLVer + Ghost2LocalMap[w]] == v) {
option = 1; option = 1;
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
} // 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 { // w is a local vertex else { // w is a local vertex
@ -137,7 +137,7 @@ void processMatchedVerticesAndSendMessages(
option = 3; option = 3;
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
#ifdef PRINT_DEBUG_INFO_ #ifdef PRINT_DEBUG_INFO_
cout << "\n(" << myRank << ")MATCH: (" << v << "," << w << ") "; cout << "\n(" << myRank << ")MATCH: (" << v << "," << w << ") ";
fflush(stdout); fflush(stdout);
@ -153,7 +153,7 @@ void processMatchedVerticesAndSendMessages(
} // mateval < 0 } // mateval < 0
} // End of if ( (v >= StartIndex) && (v <= EndIndex) ) //If Local Vertex: } // End of if ( (v >= StartIndex) && (v <= EndIndex) ) //If Local Vertex:
else { // Neighbor is a ghost vertex else { // Neighbor is a ghost vertex
#pragma omp critical #pragma omp critical
{ {
if (candidateMate[NLVer + Ghost2LocalMap[v]] == u) if (candidateMate[NLVer + Ghost2LocalMap[v]] == u)
@ -162,7 +162,7 @@ void processMatchedVerticesAndSendMessages(
option = 5; // u is local option = 5; // u is local
} // End of critical } // End of critical
} // End of Else //A Ghost Vertex } // End of Else //A Ghost Vertex
switch (option) switch (option)
{ {
case -1: case -1:
@ -180,20 +180,20 @@ void processMatchedVerticesAndSendMessages(
// Decrement the counter: // Decrement the counter:
PROCESS_CROSS_EDGE(&Counter[Ghost2LocalMap[w]], SPtr); PROCESS_CROSS_EDGE(&Counter[Ghost2LocalMap[w]], SPtr);
case 2: case 2:
// Found a dominating edge, it is a ghost // Found a dominating edge, it is a ghost
ghostOwner = findOwnerOfGhost(w, verDistance, myRank, numProcs); ghostOwner = findOwnerOfGhost(w, verDistance, myRank, numProcs);
// Build the Message Packet: // Build the Message Packet:
// Message[0] = v; // LOCAL // Message[0] = v; // LOCAL
// Message[1] = w; // GHOST // Message[1] = w; // GHOST
// Message[2] = REQUEST; // TYPE // Message[2] = REQUEST; // TYPE
// Send a Request (Asynchronous) // Send a Request (Asynchronous)
// MPI_Bsend(&Message[0], 3, TypeMap<MilanLongInt>(), ghostOwner, ComputeTag, comm); // MPI_Bsend(&Message[0], 3, TypeMap<MilanLongInt>(), ghostOwner, ComputeTag, comm);
(*msgActual)++; (*msgActual)++;
(*msgInd)++; (*msgInd)++;
privateQLocalVtx.push_back(v); privateQLocalVtx.push_back(v);
privateQGhostVtx.push_back(w); privateQGhostVtx.push_back(w);
privateQMsgType.push_back(REQUEST); privateQMsgType.push_back(REQUEST);
@ -211,94 +211,94 @@ void processMatchedVerticesAndSendMessages(
for (k1 = adj11; k1 < adj12; k1++) { for (k1 = adj11; k1 < adj12; k1++) {
w = verLocInd[k1]; w = verLocInd[k1];
if ((w < StartIndex) || (w > EndIndex)) { // A ghost if ((w < StartIndex) || (w > EndIndex)) { // A ghost
#ifdef PRINT_DEBUG_INFO_ #ifdef PRINT_DEBUG_INFO_
cout << "\n(" << myRank << ")Sending a failure message: "; cout << "\n(" << myRank << ")Sending a failure message: ";
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
ghostOwner = findOwnerOfGhost(w, verDistance, myRank, numProcs); ghostOwner = findOwnerOfGhost(w, verDistance, myRank, numProcs);
// Build the Message Packet: // Build the Message Packet:
// Message[0] = v; // LOCAL // Message[0] = v; // LOCAL
// Message[1] = w; // GHOST // Message[1] = w; // GHOST
// Message[2] = FAILURE; // TYPE // Message[2] = FAILURE; // TYPE
// Send a Request (Asynchronous) // Send a Request (Asynchronous)
// MPI_Bsend(&Message[0], 3, TypeMap<MilanLongInt>(), ghostOwner, ComputeTag, comm); // MPI_Bsend(&Message[0], 3, TypeMap<MilanLongInt>(), ghostOwner, ComputeTag, comm);
(*msgActual)++; (*msgActual)++;
(*msgInd)++; (*msgInd)++;
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);
} // End of if(GHOST) } // End of if(GHOST)
} // End of for loop } // End of for loop
break; break;
case 5: case 5:
default: default:
#ifdef PRINT_DEBUG_INFO_ #ifdef PRINT_DEBUG_INFO_
cout << "\n(" << myRank << ")Sending a success message: "; cout << "\n(" << myRank << ")Sending a success message: ";
cout << "\n(" << myRank << ")Ghost is " << v << " Owner is: " << findOwnerOfGhost(v, verDistance, myRank, numProcs) << "\n"; cout << "\n(" << myRank << ")Ghost is " << v << " Owner is: " << findOwnerOfGhost(v, verDistance, myRank, numProcs) << "\n";
fflush(stdout); fflush(stdout);
#endif #endif
ghostOwner = findOwnerOfGhost(v, verDistance, myRank, numProcs); ghostOwner = findOwnerOfGhost(v, verDistance, myRank, numProcs);
// Build the Message Packet: // Build the Message Packet:
// Message[0] = u; // LOCAL // Message[0] = u; // LOCAL
// Message[1] = v; // GHOST // Message[1] = v; // GHOST
// Message[2] = SUCCESS; // TYPE // Message[2] = SUCCESS; // TYPE
// Send a Request (Asynchronous) // Send a Request (Asynchronous)
// MPI_Bsend(&Message[0], 3, TypeMap<MilanLongInt>(), ghostOwner, ComputeTag, comm); // MPI_Bsend(&Message[0], 3, TypeMap<MilanLongInt>(), ghostOwner, ComputeTag, comm);
(*msgActual)++; (*msgActual)++;
(*msgInd)++; (*msgInd)++;
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);
break; break;
} // End of switch } // End of switch
} // End of inner for } // End of inner for
} }
} // End of outer for } // End of outer for
queuesTransfer(U, privateU, QLocalVtx, queuesTransfer(U, privateU, QLocalVtx,
QGhostVtx, QGhostVtx,
QMsgType, QOwner, privateQLocalVtx, QMsgType, QOwner, privateQLocalVtx,
privateQGhostVtx, privateQGhostVtx,
privateQMsgType, privateQMsgType,
privateQOwner); privateQOwner);
} // End of while ( !U.empty() ) } // End of while ( !U.empty() )
#ifdef COUNT_LOCAL_VERTEX #ifdef COUNT_LOCAL_VERTEX
printf("Count local vertexes: %ld for thread %d of processor %d\n", printf("Count local vertexes: %ld for thread %d of processor %d\n",
localVertices, localVertices,
omp_get_thread_num(), omp_get_thread_num(),
myRank); myRank);
#endif #endif
} // End of parallel region } // End of parallel region
// Send the messages // Send the messages
#ifdef DEBUG_HANG_ #ifdef DEBUG_HANG_
cout << myRank<<" Sending: "<<QOwner.size()-initialSize<<" messages" <<endl; cout << myRank<<" Sending: "<<QOwner.size()-initialSize<<" messages" <<endl;
#endif #endif
for (int i = initialSize; i < QOwner.size(); i++) { for (int i = initialSize; i < QOwner.size(); i++) {
Message[0] = QLocalVtx[i]; Message[0] = QLocalVtx[i];
Message[1] = QGhostVtx[i]; Message[1] = QGhostVtx[i];
Message[2] = QMsgType[i]; Message[2] = QMsgType[i];
ghostOwner = QOwner[i]; ghostOwner = QOwner[i];
//MPI_Bsend(&Message[0], 3, TypeMap<MilanLongInt>(), ghostOwner, ComputeTag, comm); //MPI_Bsend(&Message[0], 3, TypeMap<MilanLongInt>(), ghostOwner, ComputeTag, comm);
//cout << myRank<<" Sending to "<<ghostOwner<<endl; //cout << myRank<<" Sending to "<<ghostOwner<<endl;
MPI_Bsend(&Message[0], 3, TypeMap<MilanLongInt>(), ghostOwner, ComputeTag, comm); MPI_Bsend(&Message[0], 3, TypeMap<MilanLongInt>(), ghostOwner, ComputeTag, comm);

@ -1,6 +1,6 @@
#include "MatchBoxPC.h" #include "MatchBoxPC.h"
#ifdef OPENMP
//#define DEBUG_HANG_ //#define DEBUG_HANG_
#if !defined(SERIAL_MPI)
void processMessages( void processMessages(
MilanLongInt NLVer, MilanLongInt NLVer,
@ -139,12 +139,12 @@ void processMessages(
if (!ReceiveBuffer.empty()) if (!ReceiveBuffer.empty())
ReceiveBuffer.clear(); // Empty it out first ReceiveBuffer.clear(); // Empty it out first
ReceiveBuffer.resize(bundleSize, -1); // Initialize ReceiveBuffer.resize(bundleSize, -1); // Initialize
ReceiveBuffer[0] = Message[0]; // u ReceiveBuffer[0] = Message[0]; // u
ReceiveBuffer[1] = Message[1]; // v ReceiveBuffer[1] = Message[1]; // v
ReceiveBuffer[2] = Message[2]; // message_type ReceiveBuffer[2] = Message[2]; // message_type
} }
#ifdef DEBUG_GHOST_ #ifdef DEBUG_GHOST_
if ((v < StartIndex) || (v > EndIndex)) { if ((v < StartIndex) || (v > EndIndex)) {
cout << "\n(" << myRank << ") From ReceiveBuffer: This should not happen: u= " << u << " v= " << v << " Type= " << message_type << " StartIndex " << StartIndex << " EndIndex " << EndIndex << endl; cout << "\n(" << myRank << ") From ReceiveBuffer: This should not happen: u= " << u << " v= " << v << " Type= " << message_type << " StartIndex " << StartIndex << " EndIndex " << EndIndex << endl;
@ -161,7 +161,7 @@ void processMessages(
u = ReceiveBuffer[bundleCounter - 3]; // GHOST u = ReceiveBuffer[bundleCounter - 3]; // GHOST
v = ReceiveBuffer[bundleCounter - 2]; // LOCAL v = ReceiveBuffer[bundleCounter - 2]; // LOCAL
message_type = ReceiveBuffer[bundleCounter - 1]; // TYPE message_type = ReceiveBuffer[bundleCounter - 1]; // TYPE
// CASE I: REQUEST // CASE I: REQUEST
if (message_type == REQUEST) { if (message_type == REQUEST) {
#ifdef PRINT_DEBUG_INFO_ #ifdef PRINT_DEBUG_INFO_
@ -189,7 +189,7 @@ void processMessages(
cout << "\n(" << myRank << ")MATCH: (" << v << "," << u << ") " << endl; cout << "\n(" << myRank << ")MATCH: (" << v << "," << u << ") " << endl;
fflush(stdout); fflush(stdout);
#endif #endif
PROCESS_CROSS_EDGE(&Counter[Ghost2LocalMap[u]], S); PROCESS_CROSS_EDGE(&Counter[Ghost2LocalMap[u]], S);
} // End of if ( candidateMate[v-StartIndex] == u )e } // End of if ( candidateMate[v-StartIndex] == u )e
} // End of if ( Mate[v] == -1 ) } // End of if ( Mate[v] == -1 )
@ -250,7 +250,7 @@ void processMessages(
cout << "\n(" << myRank << ")MATCH: (" << v << "," << w << ") " << endl; cout << "\n(" << myRank << ")MATCH: (" << v << "," << w << ") " << endl;
fflush(stdout); fflush(stdout);
#endif #endif
PROCESS_CROSS_EDGE(&Counter[Ghost2LocalMap[w]], S); PROCESS_CROSS_EDGE(&Counter[Ghost2LocalMap[w]], S);
} // End of if CandidateMate[w] = v } // End of if CandidateMate[w] = v
} // End of if a Ghost Vertex } // End of if a Ghost Vertex
@ -311,7 +311,7 @@ void processMessages(
} // End of else: CASE III } // End of else: CASE III
} // End of else: CASE I } // End of else: CASE I
} }
return; return;
} }
#endif #endif

@ -1,5 +1,5 @@
#include "MatchBoxPC.h" #include "MatchBoxPC.h"
#ifdef OPENMP
void queuesTransfer(vector<MilanLongInt> &U, void queuesTransfer(vector<MilanLongInt> &U,
vector<MilanLongInt> &privateU, vector<MilanLongInt> &privateU,
vector<MilanLongInt> &QLocalVtx, vector<MilanLongInt> &QLocalVtx,
@ -17,6 +17,8 @@ void queuesTransfer(vector<MilanLongInt> &U,
U.insert(U.end(), privateU.begin(), privateU.end()); U.insert(U.end(), privateU.begin(), privateU.end());
} }
privateU.clear();
#pragma omp critical(sendMessageTransfer) #pragma omp critical(sendMessageTransfer)
{ {
@ -26,11 +28,9 @@ void queuesTransfer(vector<MilanLongInt> &U,
QOwner.insert(QOwner.end(), privateQOwner.begin(), privateQOwner.end()); QOwner.insert(QOwner.end(), privateQOwner.begin(), privateQOwner.end());
} }
privateU.clear();
privateQLocalVtx.clear(); privateQLocalVtx.clear();
privateQGhostVtx.clear(); privateQGhostVtx.clear();
privateQMsgType.clear(); privateQMsgType.clear();
privateQOwner.clear(); privateQOwner.clear();
} }
#endif

@ -1,5 +1,5 @@
#include "MatchBoxPC.h" #include "MatchBoxPC.h"
#ifdef OPENMP #if !defined(SERIAL_MPI)
void sendBundledMessages(MilanLongInt *numGhostEdges, void sendBundledMessages(MilanLongInt *numGhostEdges,
MilanInt *BufferSize, MilanInt *BufferSize,
MilanLongInt *Buffer, MilanLongInt *Buffer,
@ -62,7 +62,7 @@ void sendBundledMessages(MilanLongInt *numGhostEdges,
for (i = 0; i < numProcs; i++) for (i = 0; i < numProcs; i++)
PCumulative[i + 1] = PCumulative[i] + PCounter[i]; PCumulative[i + 1] = PCumulative[i] + PCounter[i];
} }
#pragma omp task depend(inout \ #pragma omp task depend(inout \
: PCounter) : PCounter)
{ {
@ -84,7 +84,7 @@ void sendBundledMessages(MilanLongInt *numGhostEdges,
PCounter[QOwner[i]]++; PCounter[QOwner[i]]++;
} }
} }
// Send the Bundled Messages: Use ISend // Send the Bundled Messages: Use ISend
#pragma omp task depend(out \ #pragma omp task depend(out \
: SRequest, SStatus) : SRequest, SStatus)
@ -101,7 +101,7 @@ void sendBundledMessages(MilanLongInt *numGhostEdges,
exit(1); exit(1);
} }
} }
// Send the Messages // Send the Messages
#pragma omp task depend(inout \ #pragma omp task depend(inout \
: SRequest, PSizeInfoMessages, PCumulative) depend(out \ : SRequest, PSizeInfoMessages, PCumulative) depend(out \

Loading…
Cancel
Save