Exercise: J1D-Collectives-Nonblocking
This exercise is similar to exercise J1D-PtP-Blocking and basic descriptions are not reiterated. In this exercise we add a convergence criterion to terminate the Jacobi algorithm before completing the maximum number of iterations. The criterion is based on the maximum component of the residual (\( r_{max} \)), and all processes muss be aware of it ("global consensus") to be able to smoothly end the calculations by breaking the loop. For this reason, we need a collective communication to make \( r_{max} \) of all chunks known to all processes. Also, we prefer not to block the loop while receiving the (\( r_{max} \)), for this reason we use nonblocking collective communication to allow the Jacobi loop continue while the global communication takes place. Once the \( r_{max} \) of the previous iteration is received and if the criterion is fulfilled, the loop is broken.
- In the directory J1D-Collectives-Nonblocking, there are f and c subdirectories for Fortran and C, respectively. If you have loaded the modules as described in exercise Hello, compilers and MPI wrappers are ready for use. The compilation process is facilitated using a Makefile.
- There are 7 FIXME markers, all related to the transfer of \( r_{max} \). In the code, it corresponds to variables gmax and gmax_global.
- The reference file at ref/domain-10000000.pgm is generated for nstep=\( 10^7 \) and n=1001 (for Fortran n=1000). You can use the cmp command to compare your domain with the reference file.