Cbb/Baobab/examples: Difference between revisions
Jump to navigation
Jump to search
No edit summary |
No edit summary |
||
Line 36: | Line 36: | ||
module add openmpi-x86_64 | module add openmpi-x86_64 | ||
</PRE> | </PRE> | ||
I generally recommend you add this to your .bashrc file. | I generally recommend you add this to your .bashrc file before you get started. | ||
Second: Compile your program | Second: Compile your program |
Revision as of 13:57, 6 November 2014
Hello example mpi program: Save this as hello.c
/****************************************************************************** * * FILE: mpi_hello.c * * DESCRIPTION: * * MPI tutorial example code: Simple hello world program * * AUTHOR: Blaise Barney * * LAST REVISED: 03/05/10 * ******************************************************************************/ #include "mpi.h" #include <stdio.h> #include <stdlib.h> #define MASTER 0 int main (int argc, char *argv[]) { int numtasks, taskid, len; char hostname[MPI_MAX_PROCESSOR_NAME]; MPI_Init(&argc, &argv); MPI_Comm_size(MPI_COMM_WORLD, &numtasks); MPI_Comm_rank(MPI_COMM_WORLD,&taskid); MPI_Get_processor_name(hostname, &len); printf ("Hello from task %d on %s!\n", taskid, hostname); if (taskid == MASTER) printf("MASTER: Number of MPI tasks is: %d\n",numtasks); MPI_Finalize(); }
How to compile:
First: Setup your environment to use mpi
module add openmpi-x86_64
I generally recommend you add this to your .bashrc file before you get started.
Second: Compile your program
mpicc -o hello hello.c
Third: Edit your submit script to match how you want to run your parallel program.
vi sub_script
Forth: Submit your script into the queue
qsub sub_script