User Tools

Site Tools


rise:ejemplos:mpi_hello

This is an old revision of the document!


Table of Contents

Hello World, MPI & SLURM

Esta guía provee un hello world para MPI y como correrlo usando SLURM.

MPI

  • Código fuente de hello world:
hello.cpp
#include <stdio.h>
#include <omp.h>
#include "mpi.h"
 
int main(int argc, char *argv[]) {
 
    MPI_Init(&argc, &argv);
 
    int rank;
    MPI_Comm_rank(MPI_COMM_WORLD, &rank);
 
    char processor_name[MPI_MAX_PROCESSOR_NAME];
    int name_len;
    MPI_Get_processor_name(processor_name, &name_len);
 
    #pragma omp parallel
    {
        int thread_num = omp_get_thread_num();
        printf("Hello from thread %d and process %d on processor %s\n",
               thread_num, rank, processor_name);
    }
 
    MPI_Finalize();
}
  • Makefile para compilar el hello world
Makefile
all: hello-world
 
hello-world: hello-world.cpp
	source $$MODULESHOME/init/bash; module add mpi ; mpic++ hello-world.cpp -o hello-world -fopenmp
 
clean:
	rm -v hello-world

SLURM

rise/ejemplos/mpi_hello.1593565951.txt.gz · Last modified: 2020/07/01 01:12 by fmorac