split matrix function out
This commit is contained in:
Binary file not shown.
@@ -14,9 +14,6 @@ double B[N][N];
|
|||||||
double AB[N][N];
|
double AB[N][N];
|
||||||
double AB_serial[N][N];
|
double AB_serial[N][N];
|
||||||
|
|
||||||
//timing variables
|
|
||||||
double time1,time2,time3;
|
|
||||||
|
|
||||||
//Function to fill matrices at random
|
//Function to fill matrices at random
|
||||||
void fill_matrices(){
|
void fill_matrices(){
|
||||||
srand(time(NULL));
|
srand(time(NULL));
|
||||||
@@ -64,17 +61,13 @@ void compute_interval(int start,int interval){
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
int main(int argc, char** argv){
|
void multiplyMatrix(int rank, int size){
|
||||||
int interval, remainder, rank, size;
|
//timing variables
|
||||||
MPI_Init(&argc, &argv);
|
double time1,time2,time3;
|
||||||
MPI_Comm_rank(MCW, &rank);
|
|
||||||
MPI_Comm_size(MCW, &size);
|
|
||||||
|
|
||||||
//compute interval size
|
//compute interval size
|
||||||
//rank 0 responsible for remainder
|
//rank 0 responsible for remainder
|
||||||
interval = N/size;
|
int interval = N/size;
|
||||||
remainder = N%size;
|
int remainder = N%size;
|
||||||
|
|
||||||
//Record start time
|
//Record start time
|
||||||
MPI_Barrier(MCW);
|
MPI_Barrier(MCW);
|
||||||
time1 = MPI_Wtime();
|
time1 = MPI_Wtime();
|
||||||
@@ -125,6 +118,18 @@ int main(int argc, char** argv){
|
|||||||
cout << "serial version gives:" << endl;
|
cout << "serial version gives:" << endl;
|
||||||
print_matrix(AB_serial);
|
print_matrix(AB_serial);
|
||||||
}
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
int main(int argc, char** argv){
|
||||||
|
int interval, remainder, rank, size;
|
||||||
|
MPI_Init(&argc, &argv);
|
||||||
|
MPI_Comm_rank(MCW, &rank);
|
||||||
|
MPI_Comm_size(MCW, &size);
|
||||||
|
multiplyMatrix(rank, size);
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
MPI_Finalize();
|
MPI_Finalize();
|
||||||
}
|
}
|
||||||
|
|||||||
Reference in New Issue
Block a user