#include #include #include #include void Read_n(int* n_p, int* local_n_p, int my_rank, int comm_sz, MPI_Comm comm); void Check_for_error(int...
Question:
#include
#include
#include
#include
void Read_n(int* n_p, int* local_n_p, int my_rank, int comm_sz,
MPI_Comm comm);
void Check_for_error(int local_ok, char fname[], char message[],
MPI_Comm comm);
void Read_data(double local_vec1[], double local_vec2[], double* scalar_p,
int local_n, int my_rank, int comm_sz, MPI_Comm comm);
void Print_vector(double local_vec[], int local_n, int n, char title[],
int my_rank, MPI_Comm comm);
double Par_dot_product(double local_vec1[], double local_vec2[],
int local_n, MPI_Comm comm);
void Par_vector_scalar_mult(double local_vec[], double scalar,
double local_result[], int local_n);
int main(void) {
int n, local_n;
double *local_vec1, *local_vec2;
double scalar;
double *local_scalar_mult1, *local_scalar_mult2;
double dot_product;
int comm_sz, my_rank;
MPI_Comm comm;
/* Print input data */
/* Print results */
/* Compute and print dot product */
/* Compute scalar multiplication and print out result */
free(local_scalar_mult2);
free(local_scalar_mult1);
free(local_vec2);
free(local_vec1);
MPI_Finalize();
return 0;
}
/*-------------------------------------------------------------------*/
void Check_for_error(
int local_ok /* in */,
char fname[] /* in */,
char message[] /* in */,
MPI_Comm comm /* in */) {
int ok;
MPI_Allreduce(&local_ok, &ok, 1, MPI_INT, MPI_MIN, comm);
if (ok == 0) {
int my_rank;
MPI_Comm_rank(comm, &my_rank);
if (my_rank == 0) {
fprintf(stderr, "Proc %d > In %s, %s ", my_rank, fname,
message);
fflush(stderr);
}
MPI_Finalize();
exit(-1);
}
} /* Check_for_error */
/* Get the input of n: size of the vectors, and then calculate local_n according to comm_sz and n */
/* where local_n is the number of elements each process obtains */
/*-------------------------------------------------------------------*/
void Read_n(int* n_p, int* local_n_p, int my_rank, int comm_sz,
MPI_Comm comm) {
} /* Read_n */
finish this function be sure to add comments