MPI并行计算代写

You will be parallelizing and testing a 1-D shallow water simulation code. Provided to you is a C code, shallow_water_1d.c. This is written as a serial code, and you will parallelize it using MPI, and then using OpenMP. You will then compare the scaling performance of all three version (serial, MPI, OMP). Output from the code can be visualized using the MATLAB code also provided, shallow_water_1d_display.m.

What you will turn in will include:
1. Shallow_water_1d_mpi.c (your MPI parallelized code, with commenting)

o The thoroughness of your commenting will be graded!
2. Shallow_water_1d_omp.c (your OMP parallelized code, with commenting)

o The thoroughness of your commenting will be graded!

3. A report (in PDF form) including:
o Explanation for both MPI and OMP codes of why you selected specific segments of code for parallelization

o Analysis of accuracy of each code (both numerical and visual evidence via figures)
o Performance of serial code and also of MPI & OMP codes with 1, 2, 4, 8 processes/threads for

default parameters (NX=41, NT=100, X_LENGTH = 1.0, T_LENGTH = 0.2, G = 9.8)
o Same as above (performance for 1, 2, 4, 8 processes/threads) for each parameter pair below:

NX NT
41 100 401 1000 4001 10000 40001 100000

Note that it is up to you to decide how to comment your modifications to the code for both the MPI and OMP versions; you should include enough commenting to make it clear why you made the changes you did. In your report, you will also be graded for clarity of presentation.

Note that it is up to you to decide what to parallelize, with the intention of achieving optimal performance for very large values of NX and NT.