Version 2 (modified by 10 years ago) ( diff ) | ,
---|
MPI C
Hello World
/* hello_mpi.c: display a message on the screen */ #include <stdio.h> #include <mpi.h> int main (int argc, char *argv[]) { int myid,numproc; /* Initialize */ MPI_Init(&argc,&argv); /* get myid and # of processors */ MPI_Comm_size(MPI_COMM_WORLD,&numproc); MPI_Comm_rank(MPI_COMM_WORLD,&myid); printf("hello from %d\n", myid); /* wait until all processors come here */ MPI_Barrier (MPI_COMM_WORLD); if ( myid == 0 ) { /* only id = 0 do this */ printf("%d processors said hello!\n",numproc); } MPI_Finalize(); }
Compile
mpicc hello_mpi.c
Example of Jobscript
#!/bin/bash #SBATCH --job-name=HelloC_MPI #SBATCH --qos=normal #SBATCH --time=0-00:10:00 #SBATCH --nodes=4 #SBATCH --ntasks-per-node=1 ########## THE JOB ITSELF ########### echo Start Job pwd cat $SLURM_JOB_NODELIST echo Number of tasks: $SLURM_NTASKS mpirun ./a.out echo End job
Attachments (1)
- HelloC_MPI_Flow.png (55.9 KB ) - added by 10 years ago.
Download all attachments as: .zip
Note:
See TracWiki
for help on using the wiki.