Answered step by step
Verified Expert Solution
Link Copied!

Question

1 Approved Answer

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.image text in transcribed

Above is the original, empty code.

image text in transcribed

Above is my implementation which gives me errors.

image text in transcribed

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

Step: 1

blur-text-image

Get Instant Access to Expert-Tailored Solutions

See step-by-step solutions with expert insights and AI powered tools for academic success

Step: 2

blur-text-image_2

Step: 3

blur-text-image_3

Ace Your Homework with AI

Get the answers you need in no time with our AI-driven, step-by-step assistance

Get Started

Recommended Textbook for

Fundamentals Of Database Systems

Authors: Ramez Elmasri, Sham Navathe

4th Edition

0321122267, 978-0321122261

Students also viewed these Databases questions

Question

As a tax preparer, which attribute would you most likely filter?

Answered: 1 week ago

Question

6. How would you design your ideal position?

Answered: 1 week ago