Answered step by step
Verified Expert Solution
Link Copied!

Question

1 Approved Answer

Below is an MPI token ring program. Compute so that bandwidth can be calculated using MPI. #include #include #include int main(int argc, char** argv) {

Below is an MPI token ring program. Compute so that bandwidth can be calculated using MPI. image text in transcribed

#include #include #include int main(int argc, char** argv) { // Initialize the MPI environment MPI_Init(NULL); // Find out rank int rank; MPI_Comm_rank (MPI_COMM WORLD, &rank); void ring(int* token, int numtasks, int rank, double time1) if (rank !- 0) MPI Recv(&token, 1, MPI INT, rank-1, 0. MP? COMM WORLD, MPI STATUS IGNORE); double time_end- MPI _Wtime(); double elapsed-time end-time start from printf("Process %d received token %d process %d ", rank, rank-1,elapsed); j else { for(int 1-0; i 250000000; i++) token[i]-1; MPI_Send(token, 1, MPI_INT, (rank 1)%numtasks, 0, MPI _COMMWORLD); if (rank-0) { MPI Recv(token, 1, MPI INT, numtasks-1, 0, MPI COMM WORLD, MPI STATUS IGNORE) double time2-MPI-Wtime(); double elapsed-time end-time start printf("Process 0 received token from process %d in %f seconds. End!", nuntasks-1, elapsed); MPI-Finalize()

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

Step: 3

blur-text-image

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

Database Design For Mere Mortals

Authors: Michael J Hernandez

4th Edition

978-0136788041

More Books

Students also viewed these Databases questions