f.f, the x-axis, and two vertical lines x=a and x=b.
h. N = 8a = 0b = 2h can be calculated as: h = (b - a) / N = 0.25
P0, P1, P2, P3: size = 4N = 8a = 0b = 2h can be calculated as: h = (b - a) / N = 0.25local_n = N / size = 2;local_a: variable represent the starting point of the local interval for each process. Variable local_a will change as processes finish calculating one trapezoid and moving to another. local_a for P0= 0 = 0 + 0 * 2 * 0.25local_a for P1= 0.5 = 0 + 1 * 2 * 0.25local_a for P2= 1 = 0 + 2 * 2 * 0.25local_a for P2= 1.5 = 0 + 3 * 2 * 0.25trapezoid.c:
1
2
3
4
5
mpicc -o trapezoid trapezoid.c
mpirun --host compute01:2,compute02:2 -np 4 ./trapezoid 0 1 10
mpirun --host compute01:2,compute02:2 -np 4 ./trapezoid 0 1 100
mpirun --host compute01:2,compute02:2 -np 4 ./trapezoid 0 1 1000
mpirun --host compute01:2,compute02:2 -np 4 ./trapezoid 0 1 10000
Ocean/projects/cis250077p/YOUR_PSC_USERNAME intro-mpi using the New Directory button.+ New File, and type in trapezoid.c Edit.Save to save the file.Edit browser tab.Refresh button (next to New File), you will see the updated size of trapezoid.c+ New File, and type in trapezoid.sh Edit.```bash linenums=”1” #!/bin/bash #SBATCH -N 1 #SBATCH -p RM #SBATCH -t 1:00:00 #SBATCH –ntasks-per-node=128
#echo commands to stdout set -x
echo ${PROJECT} cd ${PROJECT}/intro-mpi
module load openmpi/4.1.1-gcc8.3.1
mpicc -o trapezoid trapezoid.c mpirun -np 1 ./trapezoid 0 10 10000000000 mpirun -np 2 ./trapezoid 0 10 10000000000 mpirun -np 4 ./trapezoid 0 10 10000000000 mpirun -np 8 ./trapezoid 0 10 10000000000 mpirun -np 16 ./trapezoid 0 10 10000000000 mpirun -np 32 ./trapezoid 0 10 10000000000 ```
Save to save the file.Edit browser tab.Bridges-2 Shell Access
1
2
3
4
cd ${PROJECT}/intro-mpi
dos2unix trapezoid.sh
sbatch trapezoid.sh
squeue -u $USER
trapezoid.c called trapezoid_static.c and modify trapezoid_static.c to have the following contentstrapezoid_static.c. static workload assignment.
trapezoid_static.c called trapezoid_cyclic.c and modify trapezoid_cyclic.c to have the following contentstrapezoid_cyclic.c: cyclic workload assignment.
trapezoid_dynamic_.c with the following contents:
1
2
- Modify your submission script to compile and run `trapezoid_dynamic.c`:
- What do you observe?
dynamic workload assignment.