This is an old revision of the document!
$ sudo apt install openmpi-bin libopenmpi-dev
事前に各ノードのCPUの物理コア数とスレッド数を確認してください
$ cat /proc/cpuinfo | grep "physical id"
$ cat /proc/cpuinfo | grep "cpu cores"
$ cat /proc/cpuinfo | grep "processor"
作業は全て管理ノードで行います
次のコードを使って説明します
#include <stdio.h> #include <mpi.h> int main(int argc, char **argv) { int rank, size, len; char name[MPI_MAX_PROCESSOR_NAME]; MPI_Init( &argc, &argv ); MPI_Comm_rank( MPI_COMM_WORLD, &rank ); MPI_Comm_size( MPI_COMM_WORLD, &size ); MPI_Get_processor_name( name, &len ); name[len] = '\0'; printf( "I am %d of %d from %s\n", rank, size, name ); MPI_Barrier( MPI_COMM_WORLD ); MPI_Finalize(); return 0; }
$ mpicc test.c