Refactoring, eliminated useless passed variables

omp-walther
StefanoPetrilli 2 years ago
parent 47c6f4f2f8
commit 1ea1be33ba

@ -73,6 +73,9 @@ const MilanLongInt SUCCESS = 2;
const MilanLongInt FAILURE = 3; const MilanLongInt FAILURE = 3;
const MilanLongInt SIZEINFO = 4; const MilanLongInt SIZEINFO = 4;
const int ComputeTag = 7; // Predefined tag
const int BundleTag = 9; // Predefined tag
// MPI type map // MPI type map
template <typename T> template <typename T>
MPI_Datatype TypeMap(); MPI_Datatype TypeMap();
@ -335,8 +338,6 @@ extern "C"
MilanLongInt *MessageIndexPtr, MilanLongInt *MessageIndexPtr,
MilanInt numProcs, MilanInt numProcs,
MilanInt myRank, MilanInt myRank,
int ComputeTag,
int BundleTag,
MPI_Comm comm, MPI_Comm comm,
vector<MilanLongInt> &QLocalVtx, vector<MilanLongInt> &QLocalVtx,
vector<MilanLongInt> &QGhostVtx, vector<MilanLongInt> &QGhostVtx,
@ -362,19 +363,13 @@ extern "C"
MilanLongInt *verLocPtr, MilanLongInt *verLocPtr,
MilanLongInt k, MilanLongInt k,
MilanLongInt *verLocInd, MilanLongInt *verLocInd,
int error_codeC,
MilanInt numProcs, MilanInt numProcs,
MilanInt myRank, MilanInt myRank,
int ComputeTag,
int BundleTag,
MPI_Comm comm, MPI_Comm comm,
vector<MilanLongInt> &Message, vector<MilanLongInt> &Message,
char *error_message, MilanLongInt numGhostEdges,
int message_length,
vector<MilanLongInt> &ReceiveBuffer,
MilanLongInt u, MilanLongInt u,
MilanLongInt v, MilanLongInt v,
MilanLongInt message_type,
MilanLongInt *SPtr, MilanLongInt *SPtr,
staticQueue &U); staticQueue &U);

@ -125,26 +125,16 @@ void dalgoDistEdgeApproxDomEdgesLinearSearchMesgBndlSmallMateCMP(
MilanLongInt EndIndex = verDistance[myRank + 1] - 1; // The ending vertex owned by the current rank MilanLongInt EndIndex = verDistance[myRank + 1] - 1; // The ending vertex owned by the current rank
MPI_Status computeStatus; MPI_Status computeStatus;
const int ComputeTag = 7; // Predefined tag
const int BundleTag = 9; // Predefined tag //TODO refactor this
//TODO refactor this
int error_codeC;
error_codeC = MPI_Comm_set_errhandler(MPI_COMM_WORLD, MPI_ERRORS_RETURN);
char error_message[MPI_MAX_ERROR_STRING];
int message_length;
// MilanLongInt NLVer=0, NLEdge=0, StartIndex=0, EndIndex=0;
MilanLongInt msgActual = 0, msgInd = 0; MilanLongInt msgActual = 0, msgInd = 0;
MilanReal heaviestEdgeWt = 0.0f; // Assumes positive weight MilanReal heaviestEdgeWt = 0.0f; // Assumes positive weight
MilanReal startTime, finishTime; MilanReal startTime, finishTime;
// MilanReal Precision = MPI_Wtick(); //Get the precision of the MPI Timer
startTime = MPI_Wtime(); startTime = MPI_Wtime();
// Data structures for sending and receiving messages: // Data structures for sending and receiving messages:
vector<MilanLongInt> Message; // [ u, v, message_type ] vector<MilanLongInt> Message; // [ u, v, message_type ]
Message.resize(3, -1); Message.resize(3, -1);
MilanLongInt message_type = 0; //TODO refactor this, it could be constants
// Data structures for Message Bundling: // Data structures for Message Bundling:
// Although up to two messages can be sent along any cross edge, // Although up to two messages can be sent along any cross edge,
// only one message will be sent in the initialization phase - // only one message will be sent in the initialization phase -
@ -204,7 +194,6 @@ void dalgoDistEdgeApproxDomEdgesLinearSearchMesgBndlSmallMateCMP(
MilanLongInt *Buffer; MilanLongInt *Buffer;
// Declare the locks // Declare the locks
// TODO destroy the locks
omp_lock_t MateLock[NLVer]; omp_lock_t MateLock[NLVer];
initialize(NLVer, NLEdge, StartIndex, initialize(NLVer, NLEdge, StartIndex,
@ -341,8 +330,8 @@ void dalgoDistEdgeApproxDomEdgesLinearSearchMesgBndlSmallMateCMP(
&MessageIndex, &MessageIndex,
numProcs, numProcs,
myRank, myRank,
ComputeTag, //ComputeTag,
BundleTag, //BundleTag,
comm, comm,
QLocalVtx, QLocalVtx,
QGhostVtx, QGhostVtx,
@ -376,21 +365,7 @@ void dalgoDistEdgeApproxDomEdgesLinearSearchMesgBndlSmallMateCMP(
fflush(stdout); fflush(stdout);
fflush(stdout); fflush(stdout);
#endif #endif
// Buffer to receive bundled messages
// Maximum messages that can be received from any processor is
// twice the edge cut: REQUEST; REQUEST+(FAILURE/SUCCESS)
vector<MilanLongInt> ReceiveBuffer;
MilanLongInt bundleSize = 0, bundleCounter = 0;
try
{
ReceiveBuffer.reserve(numGhostEdges * 2 * 3); // Three integers per cross edge
}
catch (length_error)
{
cout << "Error in function algoDistEdgeApproxDominatingEdgesMessageBundling: \n";
cout << "Not enough memory to allocate the internal variables \n";
exit(1);
}
while (true) while (true)
{ {
#ifdef DEBUG_HANG_ #ifdef DEBUG_HANG_
@ -615,19 +590,13 @@ void dalgoDistEdgeApproxDomEdgesLinearSearchMesgBndlSmallMateCMP(
verLocPtr, verLocPtr,
k, k,
verLocInd, verLocInd,
error_codeC,
numProcs, numProcs,
myRank, myRank,
ComputeTag,
BundleTag,
comm, comm,
Message, Message,
error_message, numGhostEdges,
message_length,
ReceiveBuffer,
u, u,
v, v,
message_type,
&S, &S,
U); U);

@ -1,7 +1,5 @@
#include "MatchBoxPC.h" #include "MatchBoxPC.h"
//TODO there are many useless parameter passed to this function
void processMessages( void processMessages(
MilanLongInt NLVer, MilanLongInt NLVer,
MilanLongInt *Mate, MilanLongInt *Mate,
@ -19,19 +17,13 @@ void processMessages(
MilanLongInt *verLocPtr, MilanLongInt *verLocPtr,
MilanLongInt k, MilanLongInt k,
MilanLongInt *verLocInd, MilanLongInt *verLocInd,
int error_codeC,
MilanInt numProcs, MilanInt numProcs,
MilanInt myRank, MilanInt myRank,
int ComputeTag,
int BundleTag,
MPI_Comm comm, MPI_Comm comm,
vector<MilanLongInt> &Message, vector<MilanLongInt> &Message,
char *error_message, MilanLongInt numGhostEdges,
int message_length,
vector<MilanLongInt> &ReceiveBuffer,
MilanLongInt u, MilanLongInt u,
MilanLongInt v, MilanLongInt v,
MilanLongInt message_type,
MilanLongInt *SPtr, MilanLongInt *SPtr,
staticQueue &U) staticQueue &U)
{ {
@ -42,6 +34,25 @@ void processMessages(
MilanLongInt S = *SPtr; // TODO refactor this MilanLongInt S = *SPtr; // TODO refactor this
MilanLongInt adj11, adj12, k1; MilanLongInt adj11, adj12, k1;
MilanLongInt ghostOwner; MilanLongInt ghostOwner;
int error_codeC;
error_codeC = MPI_Comm_set_errhandler(MPI_COMM_WORLD, MPI_ERRORS_RETURN);
char error_message[MPI_MAX_ERROR_STRING];
int message_length;
MilanLongInt message_type = 0;
// Buffer to receive bundled messages
// Maximum messages that can be received from any processor is
// twice the edge cut: REQUEST; REQUEST+(FAILURE/SUCCESS)
vector<MilanLongInt> ReceiveBuffer;
try
{
ReceiveBuffer.reserve(numGhostEdges * 2 * 3); // Three integers per cross edge
}
catch (length_error)
{
cout << "Error in function algoDistEdgeApproxDominatingEdgesMessageBundling: \n";
cout << "Not enough memory to allocate the internal variables \n";
exit(1);
}
#ifdef PRINT_DEBUG_INFO_ #ifdef PRINT_DEBUG_INFO_
cout cout

@ -12,8 +12,6 @@ void sendBundledMessages(MilanLongInt *numGhostEdgesPtr,
MilanLongInt *MessageIndexPtr, MilanLongInt *MessageIndexPtr,
MilanInt numProcs, MilanInt numProcs,
MilanInt myRank, MilanInt myRank,
int ComputeTag,
int BundleTag,
MPI_Comm comm, MPI_Comm comm,
vector<MilanLongInt> &QLocalVtx, vector<MilanLongInt> &QLocalVtx,
vector<MilanLongInt> &QGhostVtx, vector<MilanLongInt> &QGhostVtx,
@ -24,7 +22,6 @@ void sendBundledMessages(MilanLongInt *numGhostEdgesPtr,
{ {
MilanLongInt myIndex = 0, msgActual = *msgActualPtr, MessageIndex = *MessageIndexPtr, numGhostEdges = *numGhostEdgesPtr, numMessagesToSend; MilanLongInt myIndex = 0, msgActual = *msgActualPtr, MessageIndex = *MessageIndexPtr, numGhostEdges = *numGhostEdgesPtr, numMessagesToSend;
const MilanLongInt SIZEINFO = 4;
MilanInt i = 0, OneMessageSize = 0, BufferSize = *BufferSizePtr; MilanInt i = 0, OneMessageSize = 0, BufferSize = *BufferSizePtr;
#ifdef DEBUG_HANG_ #ifdef DEBUG_HANG_

Loading…
Cancel
Save