Answered step by step
Verified Expert Solution
Link Copied!

Question

1 Approved Answer

At the end result must be printed to a text file by process 0 print each entry of the vector to a seperate line N

At the end result must be printed to a text file by process 0 print each entry of the vector to a seperate line N CI couldnt print to a text fileint main(int argc, char **argv){
int my_rank, comm_sz;
double **A,**x,**y,*local_A,*local_y;
int m,n, local_m;
MPI_Init(&argc, &argv) ;
MPI_Comm_rank (MPI_COMM_WORLD, &my_rank) ;
MPI_Comm_size (MPI_COMM_WORLD, &comm_sz) ;
if (my_rank ==0){
// Master process reads A and x
FILE **fp= fopen ("matrix.mtx","r");
read_matrix_market (fp,A,&m,&n;
x=A[0]; // First row of A is x
fclose (fp);
}
// Broadcast dimensions to all processes
MPI_Bcast (, MPI_INT, , MPI_COMM_WORLD) ;
MPI_Bcast ( &n,1, MPI_INT, , MPI_COMM_WORLD ) ;
// Divide rows of A among processes
local_m =m? comm_sz;
local_A double ** malloc local_m **n** sizeof double
image text in transcribed

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

Pro SQL Server Administration

Authors: Peter Carter

1st Edition

1484207106, 9781484207109

More Books

Students also viewed these Databases questions

Question

describe why abnormal work hours can constitute a health risk;

Answered: 1 week ago

Question

2. Should a disciplinary system be established at Carter Cleaning?

Answered: 1 week ago