Guest User

Untitled

a guest
Aug 15th, 2018
77
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 1.02 KB | None | 0 0
  1. //preceding code
  2.  
  3. int M = 12;
  4. for (int i = 0; i < L; i++) //START OF PARALLEL CHUNK
  5. {
  6. funkystuffresults = dosomefunkystuff();
  7.  
  8. for (int j = 0; j < M; j++)
  9. {
  10. resultmatrix[i*M + j] = funkystuffresults
  11. }
  12. }//END OF PARALLEL CHUNK
  13.  
  14. MPI_Comm_size(MPI_COMM_WORLD, &world_size);
  15. MPI_Comm_rank(MPI_COMM_WORLD, &world_rank);
  16. int sendcounts[world_size];
  17. int displs[world_size];
  18. vector<int> rec_buf(L);
  19. int rem = L%world_size;
  20. int counttester = 0;
  21. for (int i = 0; i < world_size; i++)
  22. {
  23. sendcounts[i] = L/world_size;
  24. if (rem > 0)
  25. {
  26. sendcounts[i]++;
  27. rem--;
  28. }
  29. displs[i] = counttester;
  30. counttester += sendcounts[i];
  31. }
  32. vector<int> paralleli(L);
  33. for (int i = 0; i < L; i++)
  34. {
  35. paralleli[i] = i;
  36. }
  37. MPI_Scatterv(&paralleli, sendcounts, displs, MPI_INT, &rec_buf, L, MPI_INT, 0, MPI_COMM_WORLD);
  38. for (int i = 0; i < L; i++) //START OF PARALLEL CHUNK
  39. {
  40. //previously mentioned code
  41. }
Add Comment
Please, Sign In to add comment