optimization processMatchedVerticesAndSendMessages.cpp

omp-walther
StefanoPetrilli 2 years ago
parent 1ab166b38b
commit 066c1a5e62

@ -351,10 +351,6 @@ extern "C"
vector<MilanLongInt> &QGhostVtx, vector<MilanLongInt> &QGhostVtx,
vector<MilanLongInt> &QMsgType, vector<MilanLongInt> &QMsgType,
vector<MilanInt> &QOwner, vector<MilanInt> &QOwner,
staticQueue &privateQLocalVtx,
staticQueue &privateQGhostVtx,
staticQueue &privateQMsgType,
staticQueue &privateQOwner,
MPI_Comm comm, MPI_Comm comm,
MilanLongInt *msgActual, MilanLongInt *msgActual,
vector<MilanLongInt> &Message); vector<MilanLongInt> &Message);

@ -395,10 +395,6 @@ void dalgoDistEdgeApproxDomEdgesLinearSearchMesgBndlSmallMateCMP(
QGhostVtx, QGhostVtx,
QMsgType, QMsgType,
QOwner, QOwner,
privateQLocalVtx,
privateQGhostVtx,
privateQMsgType,
privateQOwner,
comm, comm,
&msgActual, &msgActual,
Message); Message);

@ -27,20 +27,22 @@ void processMatchedVerticesAndSendMessages(
vector<MilanLongInt> &QGhostVtx, vector<MilanLongInt> &QGhostVtx,
vector<MilanLongInt> &QMsgType, vector<MilanLongInt> &QMsgType,
vector<MilanInt> &QOwner, vector<MilanInt> &QOwner,
staticQueue &privateQLocalVtx,
staticQueue &privateQGhostVtx,
staticQueue &privateQMsgType,
staticQueue &privateQOwner,
MPI_Comm comm, MPI_Comm comm,
MilanLongInt *msgActual, MilanLongInt *msgActual,
vector<MilanLongInt> &Message) vector<MilanLongInt> &Message)
{ {
MilanLongInt initialSize = QLocalVtx.size();
MilanLongInt adj1, adj2, adj11, adj12, k, k1, v = -1, w = -1, ghostOwner; MilanLongInt adj1, adj2, adj11, adj12, k, k1, v = -1, w = -1, ghostOwner;
int option; int option;
MilanLongInt mateVal; MilanLongInt mateVal;
vector<MilanLongInt> privatemessagesToSend, messagesToSend; // TODO reserve!!!
vector<MilanLongInt> privateQLocalVtx, privateQGhostVtx, privateQMsgType, privateQOwner;
privateQLocalVtx.reserve(100000);
privateQGhostVtx.reserve(100000);
privateQMsgType.reserve(100000);
privateQOwner.reserve(100000);
#ifdef PRINT_DEBUG_INFO_ #ifdef PRINT_DEBUG_INFO_
cout << "\n(" << myRank << "=========================************===============================" << endl; cout << "\n(" << myRank << "=========================************===============================" << endl;
@ -51,7 +53,7 @@ void processMatchedVerticesAndSendMessages(
#ifdef COUNT_LOCAL_VERTEX #ifdef COUNT_LOCAL_VERTEX
MilanLongInt localVertices = 0; MilanLongInt localVertices = 0;
#endif #endif
#pragma omp parallel private(k, w, v, k1, adj1, adj2, adj11, adj12, ghostOwner, option, privatemessagesToSend) \ #pragma omp parallel private(k, w, v, k1, adj1, adj2, adj11, adj12, ghostOwner, option) \
firstprivate(Message, privateU, StartIndex, EndIndex, privateQLocalVtx, privateQGhostVtx, privateQMsgType, privateQOwner, UChunkBeingProcessed) default(shared) \ firstprivate(Message, privateU, StartIndex, EndIndex, privateQLocalVtx, privateQGhostVtx, privateQMsgType, privateQOwner, UChunkBeingProcessed) default(shared) \
num_threads(NUM_THREAD) \ num_threads(NUM_THREAD) \
reduction(+ \ reduction(+ \
@ -195,21 +197,12 @@ void processMatchedVerticesAndSendMessages(
// 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 != myRank);
// 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)
// printf("Send case 2: (%ld, %ld, %ld)\n", Message[0], Message[1], Message[2]);
// fflush(stdout);
privatemessagesToSend.push_back(v);
privatemessagesToSend.push_back(w);
privatemessagesToSend.push_back(REQUEST);
privatemessagesToSend.push_back(ghostOwner);
// MPI_Bsend(&Message[0], 3, TypeMap<MilanLongInt>(), ghostOwner, ComputeTag, comm); // MPI_Bsend(&Message[0], 3, TypeMap<MilanLongInt>(), ghostOwner, ComputeTag, comm);
(*msgActual)++; (*msgActual)++;
@ -242,21 +235,12 @@ void processMatchedVerticesAndSendMessages(
#endif #endif
ghostOwner = findOwnerOfGhost(w, verDistance, myRank, numProcs); ghostOwner = findOwnerOfGhost(w, verDistance, myRank, numProcs);
// assert(ghostOwner != -1);
// assert(ghostOwner != myRank);
// 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)
// printf("Send case 4: (%ld, %ld, %ld)\n", Message[0], Message[1], Message[2]);
// fflush(stdout);
privatemessagesToSend.push_back(v);
privatemessagesToSend.push_back(w);
privatemessagesToSend.push_back(FAILURE);
privatemessagesToSend.push_back(ghostOwner);
// MPI_Bsend(&Message[0], 3, TypeMap<MilanLongInt>(), ghostOwner, ComputeTag, comm); // MPI_Bsend(&Message[0], 3, TypeMap<MilanLongInt>(), ghostOwner, ComputeTag, comm);
(*msgActual)++; (*msgActual)++;
@ -280,21 +264,12 @@ void processMatchedVerticesAndSendMessages(
#endif #endif
ghostOwner = findOwnerOfGhost(v, verDistance, myRank, numProcs); ghostOwner = findOwnerOfGhost(v, verDistance, myRank, numProcs);
// assert(ghostOwner != -1);
// assert(ghostOwner != myRank);
// 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)
// printf("Send case 5: (%ld, %ld, %ld)\n", Message[0], Message[1], Message[2]);
// fflush(stdout);)
privatemessagesToSend.push_back(u);
privatemessagesToSend.push_back(v);
privatemessagesToSend.push_back(SUCCESS);
privatemessagesToSend.push_back(ghostOwner);
// MPI_Bsend(&Message[0], 3, TypeMap<MilanLongInt>(), ghostOwner, ComputeTag, comm); // MPI_Bsend(&Message[0], 3, TypeMap<MilanLongInt>(), ghostOwner, ComputeTag, comm);
(*msgActual)++; (*msgActual)++;
@ -311,19 +286,25 @@ void processMatchedVerticesAndSendMessages(
} }
} // End of outer for } // End of outer for
#pragma omp critical(U)
{
while (!privateU.empty())
U.push_back(privateU.pop_back());
}
#pragma omp critical(sendMessageTransfer) #pragma omp critical(sendMessageTransfer)
{ {
messagesToSend.insert(messagesToSend.end(), privatemessagesToSend.begin(), privatemessagesToSend.end());
privatemessagesToSend.clear(); QLocalVtx.insert(QLocalVtx.end(), privateQLocalVtx.begin(), privateQLocalVtx.end());
} QGhostVtx.insert(QGhostVtx.end(), privateQGhostVtx.begin(), privateQGhostVtx.end());
QMsgType.insert(QMsgType.end(), privateQMsgType.begin(), privateQMsgType.end());
QOwner.insert(QOwner.end(), privateQOwner.begin(), privateQOwner.end());
queuesTransfer(U, privateU, QLocalVtx, privateQLocalVtx.clear();
QGhostVtx, privateQGhostVtx.clear();
QMsgType, QOwner, privateQLocalVtx, privateQMsgType.clear();
privateQGhostVtx, privateQOwner.clear();
privateQMsgType, }
privateQOwner);
} // End of while ( !U.empty() ) } // End of while ( !U.empty() )
@ -336,12 +317,15 @@ void processMatchedVerticesAndSendMessages(
#endif #endif
} // End of parallel region } // End of parallel region
for (int i = 0; i < messagesToSend.size(); i += 4) //Send the messages
for (int i = initialSize; i < QOwner.size(); i++)
{ {
Message[0] = messagesToSend[i];
Message[1] = messagesToSend[i + 1]; Message[0] = QLocalVtx[i];
Message[2] = messagesToSend[i + 2]; Message[1] = QGhostVtx[i];
ghostOwner = messagesToSend[i + 3]; Message[2] = QMsgType[i];
ghostOwner = QOwner[i];
MPI_Bsend(&Message[0], 3, TypeMap<MilanLongInt>(), ghostOwner, ComputeTag, comm); MPI_Bsend(&Message[0], 3, TypeMap<MilanLongInt>(), ghostOwner, ComputeTag, comm);
} }
} }

Loading…
Cancel
Save