Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- //preceding code
- int M = 12;
- for (int i = 0; i < L; i++) //START OF PARALLEL CHUNK
- {
- funkystuffresults = dosomefunkystuff();
- for (int j = 0; j < M; j++)
- {
- resultmatrix[i*M + j] = funkystuffresults
- }
- }//END OF PARALLEL CHUNK
- MPI_Comm_size(MPI_COMM_WORLD, &world_size);
- MPI_Comm_rank(MPI_COMM_WORLD, &world_rank);
- int sendcounts[world_size];
- int displs[world_size];
- vector<int> rec_buf(L);
- int rem = L%world_size;
- int counttester = 0;
- for (int i = 0; i < world_size; i++)
- {
- sendcounts[i] = L/world_size;
- if (rem > 0)
- {
- sendcounts[i]++;
- rem--;
- }
- displs[i] = counttester;
- counttester += sendcounts[i];
- }
- vector<int> paralleli(L);
- for (int i = 0; i < L; i++)
- {
- paralleli[i] = i;
- }
- MPI_Scatterv(¶lleli, sendcounts, displs, MPI_INT, &rec_buf, L, MPI_INT, 0, MPI_COMM_WORLD);
- for (int i = 0; i < L; i++) //START OF PARALLEL CHUNK
- {
- //previously mentioned code
- }
Add Comment
Please, Sign In to add comment