CentOS 8 install MPICH

1.  download MPICH rpm
$ su -
$ dnf install mpi*
2. setup PATH variable about MPI bin PATH in /etc/bashrc or ~/.basrhc and source it
$ export PATH = /usr/lib64/mpich/bin    # for bashrc
3. test mpicc or mpif
test  C code saved as hellompi.c :

#include <mpi.h>
#include <stdio.h>

int main(int argc,char** argv)
{
    int id, nums, nlength;
    char node_name[MPI_MAX_PROCESSOR_NAME];


    MPI_Init(&argc,&argv);
    MPI_Comm_rank(MPI_COMM_WORLD,&id);
    MPI_Comm_size(MPI_COMM_WORLD,&nums);
    MPI_Get_processor_name(node_name,&nlength);


    printf("Hello, MPI! thread %d of %d on %s\n",
            id, nums, node_name);
    MPI_Finalize();

    return 0;
}




4. compile by mpicc
$ mpicc -O2 -o hellompi hellompi.c

5. test hellompi
$ mpirun -np 8 hellompi

這個網誌中的熱門文章

取消Excel與word網際網路與網路路徑超連結自動格式

Installing VMware workstation pro on Ubuntu 22.X (Jammy Jellyfish)