Question: I have a question about MPI project. The assignment is included into the question. I have trouble implementing the part one. Above is the original,

I have a question about MPI project. The assignment is included into the question. I have trouble implementing the part one.I have a question about MPI project. The assignment is included into

Above is the original, empty code.

the question. I have trouble implementing the part one. Above is the

Above is my implementation which gives me errors.

original, empty code. Above is my implementation which gives me errors. I

I need help parallelizing my code using MPI. I need to send result array after every iteration to each processor.

2{ HNMON = 1 int mpi_vertex_dist(graph_t *graph, int start_vertex, int *result) 3 int num_vertices = graph->num_vertices; 4 fill_n(result, num_vertices, MAX_DIST); 5 6 auto start_time Time:: now(); 7 8 int depth = 0; 9 result[start_vertex] = depth; 10 11 int keep going = true; 12 13 while (keep going) 14 { 15 keep going = false; 17 for (int vertex = 0; vertex v_adj_begin[vertex]; 21 na graph ->v_adj_begin[vertex] + graph->v_adj_length[vertex]; 22 n++) 23 { 24 int neighbor = graph->v_adj_list[n]; 25 26 if (result[neighbor] > depth+1) { 28 result[neighbor] = depth+1; 29 keep going = true; 30 mo 16 OD 0 Nm 27 CO O o } 31 } 32 } 33 } wwwwwwwww depth++; 34 35 36 37 38 39 40 } } //print_result(graph, result, depth); return std::chrono:: duration_cast(Time:: now()-start_time).count(); // Status MPI_Status status; while (keep going) { keep going = false; for (int vertex = 0; vertex v_adj_begin[vertex]; nv_adj_begin[vertex] + graph->v_adj_length[vertex]; n++) int neighbor = graph->v_adj_list[n]; if (result[neighbor] > depth+1) { result[neighbor] = depth+1; keep going = true; } } MPI_Send(&result, num_vertices,MPI_INT,0,0,MPI_COMM_WORLD); if(my_rank == 0) { for(int index = 0; index (Time:: now()-start_time).count(); Part I: Distributed approach In this part, you will have to split the graph vertices. This might seem trivial at first, but since every vertices' neighbor might be assigned to a different process, communication is required. To implement it, you have to split the data structures that represent the graph evenly across the processes. However, you would still need a set of variables or a data Page 4 of 9 Part II: Work efficient approach ASSIGNMENT structure that will be shared across the processes to make sure each of them has relevant and updated information about the already visited nodes and their corresponding depths

Step by Step Solution

There are 3 Steps involved in it

1 Expert Approved Answer
Step: 1 Unlock blur-text-image
Question Has Been Solved by an Expert!

Get step-by-step solutions from verified subject matter experts

Step: 2 Unlock
Step: 3 Unlock

Students Have Also Explored These Related Databases Questions!