Difference between revisions of "MPI Hello World"

Jump to navigation Jump to search
21 bytes added ,  13:25, 24 September 2022
</nowiki>
 
create a folder and save this file as <codett> hello_mpi.c </codett>
 
You can compile this program with
 
mpicc -g hello_mpi.c -o hello_mpi
 
You now have an executable called <tt> hello_mpi </tt>
 
You can run the command with
 
mpirun ./hello_mpi
 
With no other arguments, mpirun will run all of the tasks on the local machine, usually one for each CPU core. You should see a hello world from each process, on each cpu core.
</nowiki>
 
Put that line in a file called '<tt>localhost' </tt>.
Now run your program with that hostfile, using
mpirun --hostfile localhost ./hello_mpi
 
<nowiki>

Navigation menu