User Tools

Site Tools


strutture:cnaf:cnaf_rd:infrastruttura:utilizzo_cluster:job_mpi

Differences

This shows you the differences between two versions of the page.

Link to this comparison view

Next revision
Previous revision
strutture:cnaf:cnaf_rd:infrastruttura:utilizzo_cluster:job_mpi [2013/10/31 08:07] – created caberletti@infn.itstrutture:cnaf:cnaf_rd:infrastruttura:utilizzo_cluster:job_mpi [2013/11/22 14:44] (current) caberletti@infn.it
Line 1: Line 1:
 +====== Job MPI ======
  
 +===== Intel MPI =====
 +
 +Programma di test:
 +<code C>
 +#include "mpi.h"
 +#include <stdio.h>
 +#include <string.h>
 +
 +int
 +main (int argc, char *argv[])
 +{
 +    int i, rank, size, namelen;
 +    char name[MPI_MAX_PROCESSOR_NAME];
 +    MPI_Status stat;
 +
 +    MPI_Init (&argc, &argv);
 +
 +    MPI_Comm_size (MPI_COMM_WORLD, &size);
 +    MPI_Comm_rank (MPI_COMM_WORLD, &rank);
 +    MPI_Get_processor_name (name, &namelen);
 +
 +    if (rank == 0) {
 +
 + printf ("Hello world: rank %d of %d running on %s\n", rank, size, name);
 +
 + for (i = 1; i < size; i++) {
 +     MPI_Recv (&rank, 1, MPI_INT, i, 1, MPI_COMM_WORLD, &stat);
 +     MPI_Recv (&size, 1, MPI_INT, i, 1, MPI_COMM_WORLD, &stat);
 +     MPI_Recv (&namelen, 1, MPI_INT, i, 1, MPI_COMM_WORLD, &stat);
 +     MPI_Recv (name, namelen + 1, MPI_CHAR, i, 1, MPI_COMM_WORLD, &stat);
 +     printf ("Hello world: rank %d of %d running on %s\n", rank, size, name);
 + }
 +
 +    } else {
 +
 + MPI_Send (&rank, 1, MPI_INT, 0, 1, MPI_COMM_WORLD);
 + MPI_Send (&size, 1, MPI_INT, 0, 1, MPI_COMM_WORLD);
 + MPI_Send (&namelen, 1, MPI_INT, 0, 1, MPI_COMM_WORLD);
 + MPI_Send (name, namelen + 1, MPI_CHAR, 0, 1, MPI_COMM_WORLD);
 +
 +    }
 +
 +    MPI_Finalize ();
 +
 +    return (0);
 +}
 +</code>
 +
 +Compilazione:
 +<code>
 +$ module load ips-xe-2013 intel-mpi
 +$ mpiicc -o test test.c
 +</code>
 +
 +==== LSF ====
 +
 +Esempio di job LSF che fa utilizzo di Intel MPI:
 +<code bash>
 +#BSUB -J impi         # Job name
 +#BSUB -o %J.out # Job standard output
 +#BSUB -e %J.err # Job standard error
 +#BSUB -N # Job report
 +#BSUB -B # Send mail
 +#BSUB -q normal # Job queue
 +#BSUB -a intelmpi               # Application
 +#BSUB -m rd-coka-02             # Host selection
 +#BSUB -n 10                     # Number of process
 +#
 +# commands
 +module load ips-xe-2013 intel-mpi
 +mpirun.lsf /home/GUEST/mcaberletti/test_intel_mpi/test
 +</code>
 +
 +Salvare in un file, ad esempio ''impi.job'' e sottometterlo con:
 +<code bash>
 +$ bsub < impi.job
 +</code>
 +
 +
 +==== Slurm ====
 +
 +Con Slurm occorre tenere presente che il comando ''sbatch'' non fa lo spawn di processi,
 +ma riserva solamente le risorse.
 +Per questo occorre indicare il numero di processi
 +Esempio di job:
 +<code bash>
 +#!/bin/bash
 +#SBATCH -J test_impi                                    # Job name
 +#SBATCH -p coka-test                                    # Queue
 +#SBATCH -e %J.err                                       # Stderr
 +#SBATCH -o %J.out                                       # Stdout
 +#SBATCH -n 10                                           # Task number
 +#SBATCH -w rd-coka-[01-02]                              # Host selection
 +#SBATCH -D /home/GUEST/mcaberletti/test_intel_mpi       # Working dir
 +#SBATCH --mail-type=ALL                                 # Send all notification via mail
 +#SBATCH --mail-user=mcaberletti@rd-ui
 +
 +# commands
 +module load ips-xe-2013 intel-mpi
 +srun ./test
 +</code>
 +
 +Salvare in un file, ad esempio ''impi.job'' e sottometterlo con:
 +<code bash>
 +$ sbatch impi.job
 +</code>

Donate Powered by PHP Valid HTML5 Valid CSS Driven by DokuWiki