Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- int checkBit = 1 << ((int)(log(size) / log(2)) - (iteration + 1));
- if (! (rank & checkBit)) {
- // TODO Select main in group
- MPI_Recv(&addSize, 1, MPI_INT, rank ^ checkBit, 1000, MPI_COMM_WORLD, MPI_STATUS_IGNORE);
- MPI_Recv(&(subArray[mySize]), addSize, MPI_INT, rank ^ checkBit, 1000, MPI_COMM_WORLD, MPI_STATUS_IGNORE);
- int partLength = mySize + addSize;
- int less = 0;
- int greater = partLength - 1;
- while (less <= greater) {
- if (subArray[less] >= pivot) {
- int buf = subArray[less];
- subArray[less] = subArray[greater];
- subArray[greater] = buf;
- greater--;
- } else {
- less++;
- }
- }
- sendSize = partLength - less;
- MPI_Send(&sendSize, 1, MPI_INT, rank ^ checkBit, 1000, MPI_COMM_WORLD);
- MPI_Send(&(subArray[less]), sendSize, MPI_INT, rank ^ checkBit, 1000, MPI_COMM_WORLD);
- sendSize = less;
- } else {
- MPI_Send(&mySize, 1, MPI_INT, rank ^ checkBit, 1000, MPI_COMM_WORLD);
- MPI_Send(subArray, mySize, MPI_INT, rank ^ checkBit, 1000, MPI_COMM_WORLD);
- MPI_Recv(&sendSize, 1, MPI_INT, rank ^ checkBit, 1000, MPI_COMM_WORLD, MPI_STATUS_IGNORE);
- MPI_Recv(subArray, sendSize, MPI_INT, rank ^ checkBit, 1000, MPI_COMM_WORLD, MPI_STATUS_IGNORE);
- cout << rank << "/" << size << " (" << localRank << "/" << localSize << ") size = " << mySize << ": ";
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement