mpi遇到的问题,及解决步骤

在ubuntu12.04 中,遇到的问题

估计是因为安装了open-mpi and mpich2 


 When I compile my program using mpicc, it will be linked to open-mpi not mpich2. To fix this problem, you can use "mpicc.mpich2" to compile your program and then use "mpiexe.mpich2" to execute your code.


测试脚本

# include 
# include 

int main(int argc, char** argv) {
    int myrank, nprocs;

    MPI_Init(&argc, &argv);
    MPI_Comm_size(MPI_COMM_WORLD, &nprocs);
    MPI_Comm_rank(MPI_COMM_WORLD, &myrank);

    printf("Hello from processor %d of %d\n", myrank, nprocs);
   
    MPI_Finalize();
    return 0;
}


 mpicc MPI_Hello.c -o MPI_Hello 

编译成功


mpiexec -n 5 ./MPI_Hello 

运行报错

[[INVALID],INVALID] ORTE_ERROR_LOG: A system-required executable either could not be found or was not executable by this user in file ../../../../../../orte/mca/ess/singleton/ess_singleton_module.c at line 357
[[INVALID],INVALID] ORTE_ERROR_LOG: A system-required executable either could not be found or was not executable by this user in file ../../../../../../orte/mca/ess/singleton/ess_singleton_module.c at line 230


解决步骤

1、dpkg --listfiles mpich2

......

/usr/bin/mpirun.mpich2
/usr/bin/mpiexec.mpich2 

从什么可以看出

2、mpicc.mpich2 MPI_Hello.c -o MPI_Hello

3、mpiexec.mpich2 -n 5 ./MPI_Hello

Hello from processor 0 of 5
Hello from processor 1 of 5
Hello from processor 3 of 5
Hello from processor 2 of 5
Hello from processor 4 of 5

你可能感兴趣的:(mpi遇到的问题,及解决步骤)