Reorganize MatchBox (prepare for S OpenMP)

PolySmooth
sfilippone 7 months ago
parent cfbec1f6ea
commit 02a83575a2

@ -72,7 +72,8 @@ void dMatchBoxPC(MilanLongInt NLVer, MilanLongInt NLEdge,
double tmr = MPI_Wtime(); double tmr = MPI_Wtime();
#endif #endif
#if defined(OPENMP) #if 1
// defined(OPENMP)
//fprintf(stderr,"Warning: using buggy OpenMP matching!\n"); //fprintf(stderr,"Warning: using buggy OpenMP matching!\n");
dalgoDistEdgeApproxDomEdgesLinearSearchMesgBndlSmallMateCMP(NLVer, NLEdge, dalgoDistEdgeApproxDomEdgesLinearSearchMesgBndlSmallMateCMP(NLVer, NLEdge,
verLocPtr, verLocInd, edgeLocWeight, verLocPtr, verLocInd, edgeLocWeight,

@ -178,7 +178,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 /* These functions are only used in the experimental OMP implementation, if that
is disabled there is no reason to actually compile or reference them. */ is disabled there is no reason to actually compile or reference them. */
@ -186,7 +185,7 @@ is disabled there is no reason to actually compile or reference them. */
MilanInt findOwnerOfGhost(MilanLongInt vtxIndex, MilanLongInt *mVerDistance, MilanInt findOwnerOfGhost(MilanLongInt vtxIndex, MilanLongInt *mVerDistance,
MilanInt myRank, MilanInt numProcs); MilanInt myRank, MilanInt numProcs);
MilanLongInt firstComputeCandidateMate(MilanLongInt adj1, MilanLongInt firstComputeCandidateMateD(MilanLongInt adj1,
MilanLongInt adj2, MilanLongInt adj2,
MilanLongInt *verLocInd, MilanLongInt *verLocInd,
MilanReal *edgeLocWeight); MilanReal *edgeLocWeight);
@ -209,7 +208,7 @@ is disabled there is no reason to actually compile or reference them. */
MilanLongInt *Mate, MilanLongInt *Mate,
map<MilanLongInt, MilanLongInt> &Ghost2LocalMap); map<MilanLongInt, MilanLongInt> &Ghost2LocalMap);
MilanLongInt computeCandidateMate(MilanLongInt adj1, MilanLongInt computeCandidateMateD(MilanLongInt adj1,
MilanLongInt adj2, MilanLongInt adj2,
MilanReal *edgeLocWeight, MilanReal *edgeLocWeight,
MilanLongInt k, MilanLongInt k,
@ -260,7 +259,7 @@ is disabled there is no reason to actually compile or reference them. */
MilanLongInt NumMessagesBundled, MilanLongInt NumMessagesBundled,
MilanReal *msgPercent); MilanReal *msgPercent);
void PARALLEL_COMPUTE_CANDIDATE_MATE_B(MilanLongInt NLVer, void PARALLEL_COMPUTE_CANDIDATE_MATE_BD(MilanLongInt NLVer,
MilanLongInt *verLocPtr, MilanLongInt *verLocPtr,
MilanLongInt *verLocInd, MilanLongInt *verLocInd,
MilanInt myRank, MilanInt myRank,
@ -300,7 +299,7 @@ is disabled there is no reason to actually compile or reference them. */
void PROCESS_CROSS_EDGE(MilanLongInt *edge, void PROCESS_CROSS_EDGE(MilanLongInt *edge,
MilanLongInt *SPtr); MilanLongInt *SPtr);
void processMatchedVertices( void processMatchedVerticesD(
MilanLongInt NLVer, MilanLongInt NLVer,
vector<MilanLongInt> &UChunkBeingProcessed, vector<MilanLongInt> &UChunkBeingProcessed,
vector<MilanLongInt> &U, vector<MilanLongInt> &U,
@ -332,7 +331,7 @@ is disabled there is no reason to actually compile or reference them. */
vector<MilanLongInt> &privateQMsgType, vector<MilanLongInt> &privateQMsgType,
vector<MilanInt> &privateQOwner); vector<MilanInt> &privateQOwner);
void processMatchedVerticesAndSendMessages( void processMatchedVerticesAndSendMessagesD(
MilanLongInt NLVer, MilanLongInt NLVer,
vector<MilanLongInt> &UChunkBeingProcessed, vector<MilanLongInt> &UChunkBeingProcessed,
vector<MilanLongInt> &U, vector<MilanLongInt> &U,
@ -387,7 +386,7 @@ is disabled there is no reason to actually compile or reference them. */
vector<MPI_Request> &SRequest, vector<MPI_Request> &SRequest,
vector<MPI_Status> &SStatus); vector<MPI_Status> &SStatus);
void processMessages( void processMessagesD(
MilanLongInt NLVer, MilanLongInt NLVer,
MilanLongInt *Mate, MilanLongInt *Mate,
MilanLongInt *candidateMate, MilanLongInt *candidateMate,
@ -428,14 +427,8 @@ 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,4 @@
#include "MatchBoxPC.h" #include "MatchBoxPC.h"
#ifdef OPENMP
// *********************************************************************** // ***********************************************************************
// //
// MatchboxP: A C++ library for approximate weighted matching // MatchboxP: A C++ library for approximate weighted matching
@ -244,7 +243,7 @@ void dalgoDistEdgeApproxDomEdgesLinearSearchMesgBndlSmallMateCMP(
* PARALLEL_COMPUTE_CANDIDATE_MATE_B is now totally parallel. * PARALLEL_COMPUTE_CANDIDATE_MATE_B is now totally parallel.
*/ */
PARALLEL_COMPUTE_CANDIDATE_MATE_B(NLVer, PARALLEL_COMPUTE_CANDIDATE_MATE_BD(NLVer,
verLocPtr, verLocPtr,
verLocInd, verLocInd,
myRank, myRank,
@ -321,7 +320,7 @@ void dalgoDistEdgeApproxDomEdgesLinearSearchMesgBndlSmallMateCMP(
vector<MilanLongInt> UChunkBeingProcessed; vector<MilanLongInt> UChunkBeingProcessed;
UChunkBeingProcessed.reserve(UCHUNK); UChunkBeingProcessed.reserve(UCHUNK);
processMatchedVertices(NLVer, processMatchedVerticesD(NLVer,
UChunkBeingProcessed, UChunkBeingProcessed,
U, U,
privateU, privateU,
@ -430,7 +429,7 @@ void dalgoDistEdgeApproxDomEdgesLinearSearchMesgBndlSmallMateCMP(
/////////////////////////// PROCESS MATCHED VERTICES ////////////////////////////// /////////////////////////// PROCESS MATCHED VERTICES //////////////////////////////
/////////////////////////////////////////////////////////////////////////////////// ///////////////////////////////////////////////////////////////////////////////////
processMatchedVerticesAndSendMessages(NLVer, processMatchedVerticesAndSendMessagesD(NLVer,
UChunkBeingProcessed, UChunkBeingProcessed,
U, U,
privateU, privateU,
@ -491,7 +490,7 @@ void dalgoDistEdgeApproxDomEdgesLinearSearchMesgBndlSmallMateCMP(
/////////////////////////// PROCESS MESSAGES ////////////////////////////////////// /////////////////////////// PROCESS MESSAGES //////////////////////////////////////
/////////////////////////////////////////////////////////////////////////////////// ///////////////////////////////////////////////////////////////////////////////////
processMessages(NLVer, processMessagesD(NLVer,
Mate, Mate,
candidateMate, candidateMate,
Ghost2LocalMap, Ghost2LocalMap,
@ -559,4 +558,3 @@ void dalgoDistEdgeApproxDomEdgesLinearSearchMesgBndlSmallMateCMP(
#endif #endif
#endif #endif
#endif

@ -1,5 +1,4 @@
#include "MatchBoxPC.h" #include "MatchBoxPC.h"
#ifdef OPENMP
// TODO comment // TODO comment
void clean(MilanLongInt NLVer, void clean(MilanLongInt NLVer,
@ -89,4 +88,3 @@ void clean(MilanLongInt NLVer,
} }
} }
} }
#endif

@ -1,5 +1,4 @@
#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,7 +8,7 @@
* @param edgeLocWeight * @param edgeLocWeight
* @return * @return
*/ */
MilanLongInt firstComputeCandidateMate(MilanLongInt adj1, MilanLongInt firstComputeCandidateMateD(MilanLongInt adj1,
MilanLongInt adj2, MilanLongInt adj2,
MilanLongInt *verLocInd, MilanLongInt *verLocInd,
MilanReal *edgeLocWeight) MilanReal *edgeLocWeight)
@ -42,7 +41,7 @@ MilanLongInt firstComputeCandidateMate(MilanLongInt adj1,
* @param Ghost2LocalMap * @param Ghost2LocalMap
* @return * @return
*/ */
MilanLongInt computeCandidateMate(MilanLongInt adj1, MilanLongInt computeCandidateMateD(MilanLongInt adj1,
MilanLongInt adj2, MilanLongInt adj2,
MilanReal *edgeLocWeight, MilanReal *edgeLocWeight,
MilanLongInt k, MilanLongInt k,
@ -71,4 +70,3 @@ MilanLongInt computeCandidateMate(MilanLongInt adj1,
return w; return w;
} }
#endif

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

@ -1,5 +1,4 @@
#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 +26,3 @@ MilanInt findOwnerOfGhost(MilanLongInt vtxIndex, MilanLongInt *mVerDistance,
return Current; return Current;
} // End of findOwnerOfGhost() } // End of findOwnerOfGhost()
#endif

@ -1,5 +1,4 @@
#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,
@ -302,4 +301,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,4 @@
#include "MatchBoxPC.h" #include "MatchBoxPC.h"
#ifdef OPENMP
/** /**
* //TODO documentation * //TODO documentation
* @param k * @param k
@ -44,4 +43,3 @@ bool isAlreadyMatched(MilanLongInt node,
return val >= 0; // Already matched return val >= 0; // Already matched
} }
#endif

@ -1,6 +1,5 @@
#include "MatchBoxPC.h" #include "MatchBoxPC.h"
#ifdef OPENMP void PARALLEL_COMPUTE_CANDIDATE_MATE_BD(MilanLongInt NLVer,
void PARALLEL_COMPUTE_CANDIDATE_MATE_B(MilanLongInt NLVer,
MilanLongInt *verLocPtr, MilanLongInt *verLocPtr,
MilanLongInt *verLocInd, MilanLongInt *verLocInd,
MilanInt myRank, MilanInt myRank,
@ -20,9 +19,9 @@ void PARALLEL_COMPUTE_CANDIDATE_MATE_B(MilanLongInt NLVer,
fflush(stdout); fflush(stdout);
#endif #endif
// Start: PARALLEL_COMPUTE_CANDIDATE_MATE_B(v) // Start: PARALLEL_COMPUTE_CANDIDATE_MATE_B(v)
candidateMate[v] = firstComputeCandidateMate(verLocPtr[v], verLocPtr[v + 1], verLocInd, edgeLocWeight); candidateMate[v] = firstComputeCandidateMateD(verLocPtr[v], verLocPtr[v + 1],
verLocInd, edgeLocWeight);
// End: PARALLEL_COMPUTE_CANDIDATE_MATE_B(v) // End: PARALLEL_COMPUTE_CANDIDATE_MATE_B(v)
} }
} }
} }
#endif

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

@ -1,5 +1,4 @@
#include "MatchBoxPC.h" #include "MatchBoxPC.h"
#ifdef OPENMP
void PARALLEL_PROCESS_EXPOSED_VERTEX_B(MilanLongInt NLVer, void PARALLEL_PROCESS_EXPOSED_VERTEX_B(MilanLongInt NLVer,
MilanLongInt *candidateMate, MilanLongInt *candidateMate,
MilanLongInt *verLocInd, MilanLongInt *verLocInd,
@ -66,7 +65,7 @@ void PARALLEL_PROCESS_EXPOSED_VERTEX_B(MilanLongInt NLVer,
#pragma omp critical(Matching) #pragma omp critical(Matching)
{ {
if (isAlreadyMatched(verLocInd[k], StartIndex, EndIndex, GMate, Mate, Ghost2LocalMap)) { if (isAlreadyMatched(verLocInd[k], StartIndex, EndIndex, GMate, Mate, Ghost2LocalMap)) {
w = computeCandidateMate(verLocPtr[v], verLocPtr[v + 1], edgeLocWeight, 0, w = computeCandidateMateD(verLocPtr[v], verLocPtr[v + 1], edgeLocWeight, 0,
verLocInd, StartIndex, EndIndex, verLocInd, StartIndex, EndIndex,
GMate, Mate, Ghost2LocalMap); GMate, Mate, Ghost2LocalMap);
candidateMate[v] = w; candidateMate[v] = w;
@ -181,4 +180,3 @@ void PARALLEL_PROCESS_EXPOSED_VERTEX_B(MilanLongInt NLVer,
} // End of parallel region } // End of parallel region
} }
#endif

@ -1,6 +1,5 @@
#include "MatchBoxPC.h" #include "MatchBoxPC.h"
#ifdef OPENMP void processMatchedVerticesD(
void processMatchedVertices(
MilanLongInt NLVer, MilanLongInt NLVer,
vector<MilanLongInt> &UChunkBeingProcessed, vector<MilanLongInt> &UChunkBeingProcessed,
vector<MilanLongInt> &U, vector<MilanLongInt> &U,
@ -98,7 +97,7 @@ void processMatchedVertices(
if (candidateMate[v - StartIndex] == u) { if (candidateMate[v - StartIndex] == u) {
// Start: PARALLEL_PROCESS_EXPOSED_VERTEX_B(v) // Start: PARALLEL_PROCESS_EXPOSED_VERTEX_B(v)
w = computeCandidateMate(verLocPtr[v - StartIndex], w = computeCandidateMateD(verLocPtr[v - StartIndex],
verLocPtr[v - StartIndex + 1], verLocPtr[v - StartIndex + 1],
edgeLocWeight, 0, edgeLocWeight, 0,
verLocInd, StartIndex, EndIndex, verLocInd, StartIndex, EndIndex,
@ -290,4 +289,3 @@ void processMatchedVertices(
#endif #endif
} // End of parallel region } // End of parallel region
} }
#endif

@ -1,7 +1,6 @@
#include "MatchBoxPC.h" #include "MatchBoxPC.h"
#ifdef OPENMP
//#define DEBUG_HANG_ //#define DEBUG_HANG_
void processMatchedVerticesAndSendMessages( void processMatchedVerticesAndSendMessagesD(
MilanLongInt NLVer, MilanLongInt NLVer,
vector<MilanLongInt> &UChunkBeingProcessed, vector<MilanLongInt> &UChunkBeingProcessed,
vector<MilanLongInt> &U, vector<MilanLongInt> &U,
@ -103,7 +102,7 @@ void processMatchedVerticesAndSendMessages(
if (candidateMate[v - StartIndex] == u) { if (candidateMate[v - StartIndex] == u) {
// Start: PARALLEL_PROCESS_EXPOSED_VERTEX_B(v) // Start: PARALLEL_PROCESS_EXPOSED_VERTEX_B(v)
w = computeCandidateMate(verLocPtr[v - StartIndex], w = computeCandidateMateD(verLocPtr[v - StartIndex],
verLocPtr[v - StartIndex + 1], verLocPtr[v - StartIndex + 1],
edgeLocWeight, 0, edgeLocWeight, 0,
verLocInd, StartIndex, EndIndex, verLocInd, StartIndex, EndIndex,
@ -293,4 +292,3 @@ void processMatchedVerticesAndSendMessages(
cout << myRank<<" Done sending messages"<<endl; cout << myRank<<" Done sending messages"<<endl;
#endif #endif
} }
#endif

@ -1,8 +1,7 @@
#include "MatchBoxPC.h" #include "MatchBoxPC.h"
#ifdef OPENMP
//#define DEBUG_HANG_ //#define DEBUG_HANG_
void processMessages( void processMessagesD(
MilanLongInt NLVer, MilanLongInt NLVer,
MilanLongInt *Mate, MilanLongInt *Mate,
MilanLongInt *candidateMate, MilanLongInt *candidateMate,
@ -212,7 +211,7 @@ void processMessages(
// Process only if not already matched ( v is local) // Process only if not already matched ( v is local)
if (candidateMate[v - StartIndex] == u) { if (candidateMate[v - StartIndex] == u) {
// Start: PARALLEL_PROCESS_EXPOSED_VERTEX_B(v) // Start: PARALLEL_PROCESS_EXPOSED_VERTEX_B(v)
w = computeCandidateMate(verLocPtr[v - StartIndex], verLocPtr[v - StartIndex + 1], edgeLocWeight, k, w = computeCandidateMateD(verLocPtr[v - StartIndex], verLocPtr[v - StartIndex + 1], edgeLocWeight, k,
verLocInd, StartIndex, EndIndex, GMate, Mate, Ghost2LocalMap); verLocInd, StartIndex, EndIndex, GMate, Mate, Ghost2LocalMap);
candidateMate[v - StartIndex] = w; candidateMate[v - StartIndex] = w;
#ifdef PRINT_DEBUG_INFO_ #ifdef PRINT_DEBUG_INFO_
@ -314,4 +313,3 @@ void processMessages(
return; return;
} }
#endif

@ -1,5 +1,4 @@
#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,
@ -31,4 +30,3 @@ void queuesTransfer(vector<MilanLongInt> &U,
privateQOwner.clear(); privateQOwner.clear();
} }
#endif

@ -1,5 +1,4 @@
#include "MatchBoxPC.h" #include "MatchBoxPC.h"
#ifdef OPENMP
void sendBundledMessages(MilanLongInt *numGhostEdges, void sendBundledMessages(MilanLongInt *numGhostEdges,
MilanInt *BufferSize, MilanInt *BufferSize,
MilanLongInt *Buffer, MilanLongInt *Buffer,
@ -207,4 +206,3 @@ void sendBundledMessages(MilanLongInt *numGhostEdges,
} }
} }
} }
#endif

Loading…
Cancel
Save