To receive notifications about scheduled maintenance, please subscribe to the mailing-list gitlab-operations@sympa.ethz.ch. You can subscribe to the mailing-list at https://sympa.ethz.ch

Commit 03a14425 authored by chatzidp's avatar chatzidp
Browse files

MPI on slabx

parent 3a1357cd
CC = mpic++
all: example1
example1: example1.c
$(CC) -o example1 example1.c
clean:
rm -f example1
#include <stdio.h>
#include <mpi.h>
int main(int argc, char** argv)
{
int rank, nprocs, len;
char name[MPI_MAX_PROCESSOR_NAME];
MPI_Init(&argc,&argv);
MPI_Comm_size(MPI_COMM_WORLD,&nprocs);
MPI_Comm_rank(MPI_COMM_WORLD,&rank);
MPI_Get_processor_name(name, &len);
printf("Hello, world. I am %d of %d on %s\n", rank, nprocs, name);fflush(stdout);
MPI_Finalize();
return 0;
}
Hello, world. I am 0 of 1 on slab1vrt.ethz.ch
Hello, world. I am 0 of 2 on slab1vrt.ethz.ch
Hello, world. I am 1 of 2 on slab1vrt.ethz.ch
Hello, world. I am 2 of 4 on slab1vrt.ethz.ch
Hello, world. I am 1 of 4 on slab1vrt.ethz.ch
Hello, world. I am 0 of 4 on slab1vrt.ethz.ch
Hello, world. I am 3 of 4 on slab1vrt.ethz.ch
Hello, world. I am 7 of 8 on slab1vrt.ethz.ch
Hello, world. I am 1 of 8 on slab1vrt.ethz.ch
Hello, world. I am 2 of 8 on slab1vrt.ethz.ch
Hello, world. I am 0 of 8 on slab1vrt.ethz.ch
Hello, world. I am 6 of 8 on slab1vrt.ethz.ch
Hello, world. I am 4 of 8 on slab1vrt.ethz.ch
Hello, world. I am 5 of 8 on slab1vrt.ethz.ch
Hello, world. I am 3 of 8 on slab1vrt.ethz.ch
0) Remote access
https://www1.ethz.ch/id/services/list/comp_raum_stud/linux/remote/index_EN
1) Load modules
module load mpi/openmpi-x86_64
2) Compile
mpicc -o example1 example1.c
(or make)
3) Run
mpirun -n 1 ./example1
mpirun -n 2 ./example1
mpirun -n 4 ./example1
mpirun -n 8 ./example1
(or sh ./script)
mpirun -n 1 ./example1 > output01.txt
mpirun -n 2 ./example1 > output02.txt
mpirun -n 4 ./example1 > output04.txt
mpirun -n 8 ./example1 > output08.txt
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment