Monday September 21, 2015
This problem challenges you to take an existing program and modify it to write data to a file in parallel using MPI.
The starter code for this problem is a model of a forest fire written in C. The code comes with a Makefile that can generate an executable, which can be run in parallel using MPI. If the executable is run with a -o option, it will generate a text file with tree data from the simulation, e.g. the following command will run with 1 MPI process and generate a file called fire-out.txt:

mpirun -np 1 ./fire -o fire-out.txt

Looking at the resulting file, this works fine for 1 process, but the file is not written with parallel I/O in mind, so running with more than one process will create a race condition, e.g. the file that is produced from running with 2 processes will be somewhat garbled; rows of the forest will be out of order:

mpirun -np 2 ./fire -o fire-out.txt

Your task is to modify the program to use MPI to write to the file in parallel so that the resulting output file has everything in the correct order when run with 2 or more MPI processes. The functions that are likely to be useful to you are MPI_File_open(), MPI_File_write_at(), and MPI_File_close().
Show solution
Challenge Resources:
©1994-2024   |   Shodor   |   Privacy Policy   |   NSDL   |   XSEDE   |   Blue Waters   |   ACM SIGHPC   |   feedback  |   facebook   |   twitter   |   rss   |   youtube   |   XSEDE Code of Conduct   |   Not Logged In. Login