Changes between Initial Version and Version 1 of cypress/Programming/Cexamples/Mpi


Ignore:
Timestamp:
05/14/15 14:27:18 (10 years ago)
Author:
cmaggio
Comment:

migrated content from ccs wiki and edited for cypress

Legend:

Unmodified
Added
Removed
Modified
  • cypress/Programming/Cexamples/Mpi

    v1 v1  
     1= MPI C =
     2== Hello World ==
     3{{{#!C
     4/*
     5  hello_mpi.c: display a message on the screen
     6 */
     7#include <stdio.h>
     8#include <mpi.h>
     9 
     10int main (int argc, char *argv[]) {
     11  int myid,numproc;
     12 
     13  /* Initialize */
     14  MPI_Init(&argc,&argv);
     15 
     16  /* get myid and # of processors */
     17  MPI_Comm_size(MPI_COMM_WORLD,&numproc);
     18  MPI_Comm_rank(MPI_COMM_WORLD,&myid);
     19 
     20  printf("hello from %d\n", myid);
     21 
     22  /* wait until all processors come here */
     23  MPI_Barrier (MPI_COMM_WORLD);
     24 
     25  if ( myid == 0 ) {
     26    /* only id = 0 do this */
     27    printf("%d processors said hello!\n",numproc);
     28  }
     29 
     30  MPI_Finalize();
     31}
     32}}}
     33
     34=== Compile ===
     35{{{mpicc hello_mpi.c}}}
     36
     37== Example of Jobscript ==
     38{{{#!sh
     39#!/bin/bash
     40#SBATCH --job-name=HelloC_MPI
     41#SBATCH --qos=normal
     42#SBATCH --time=0-00:10:00
     43#SBATCH --nodes=4
     44#SBATCH --ntasks-per-node=1
     45 
     46########## THE JOB ITSELF ###########
     47 
     48echo Start Job
     49pwd
     50cat $SLURM_JOB_NODELIST
     51echo Number of tasks: $SLURM_NTASKS
     52 
     53mpirun ./a.out
     54 
     55echo End job
     56}}}