Guest User

Untitled

a guest
Dec 15th, 2017
90
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 1.99 KB | None | 0 0
  1. MPI_Init(NULL, NULL);
  2. MPI_Comm_rank(MPI_COMM_WORLD, &rank);
  3. MPI_Comm_size(MPI_COMM_WORLD, &size);
  4. int i, j, k, v1, v2, vertices;
  5. struct Graph *g;
  6. int *n;
  7. int rank, size;
  8.  
  9. // Build the Graph from the input file
  10. f = fopen(argv[1], "r");
  11. fscanf(f, "%d", &vertices);
  12. g = createGraph(vertices);
  13. while ((fscanf(f, "%d%d", &v1, &v2)) != EOF) {
  14. addEdge(g, v1, v2);
  15. }
  16.  
  17. fclose(f);
  18.  
  19. n = (int *)malloc(sizeof(int) * vertices);
  20.  
  21. for (i = 0; i < vertices; i++) {
  22. n[i] = i;
  23. }
  24.  
  25. createNeighborSets(g);
  26. printf("create graphn");
  27.  
  28. int sendcount[size];
  29. int offset[size];
  30. int count = 0;
  31. int *localVertices;
  32. int localNum;
  33. MPI_Status status;
  34. MPI_Request request;
  35.  
  36. if (rank == 0) {
  37.  
  38. calculateDistribution(send count, offset);
  39.  
  40. for (int i = 1; i < size; i++) {
  41. MPI_Send(&sendcount[i], 1, MPI_INT, i, 3, MPI_COMM_WORLD);
  42. }
  43. localNum = sendcount[0];
  44. } else {
  45. MPI_Recv(&localNum, 1, MPI_INT, 0, 3, MPI_COMM_WORLD, &status);
  46. }
  47.  
  48. localVertices = (int *)malloc(sizeof(int) * localNum);
  49. MPI_Scatterv(n, sendcount, offset, MPI_INT, localVertices, localNum, MPI_INT, 0, MPI_COMM_WORLD);
  50.  
  51. [MacBook-Pro-7:96512] *** Process received signal ***
  52. [MacBook-Pro-7:96512] Signal: Segmentation fault: 11 (11)
  53. [MacBook-Pro-7:96512] Signal code: (0)
  54. [MacBook-Pro-7:96512] Failing at address: 0x0
  55. [MacBook-Pro-7:96512] [ 0] [MacBook-Pro-7:96513] *** Process received signal ***
  56. [MacBook-Pro-7:96513] Signal: Segmentation fault: 11 (11)
  57. [MacBook-Pro-7:96513] Signal code: (0)
  58. [MacBook-Pro-7:96513] Failing at address: 0x0
  59. [MacBook-Pro-7:96513] [ 0] 0 libsystem_platform.dylib 0x00007fff633b4f5a _sigtramp + 26
  60. [MacBook-Pro-7:96513] [ 1] [MacBook-Pro-7:96510] *** Process received signal ***
  61. [MacBook-Pro-7:96510] Signal: Segmentation fault: 11 (11)
  62. [MacBook-Pro-7:96510] Signal code: (0)
  63. [MacBook-Pro-7:96510] Failing at address: 0x0
  64. [MacBook-Pro-7:96510] [ 0] 0 libsystem_platform.dylib 0x00007fff633b4f5a _sigtramp + 26
  65. [MacBook-Pro-7:96510] [ 1] 0 ??? 0x0000000000000001 0x0 + 1
Add Comment
Please, Sign In to add comment