2014-10-28 177 views
0

我也跟着下面的教程上的代码块MPI_Comm_size总是在代码块返回1

执行MPI

Tutorial for installing MPI on Code blocks

如果我执行简单的MPI代码的教程来了,我总能得到1 MPI_Comm_size。 如何从下面的代码获取更多线程?

#include <iostream> 
#include "mpi.h" 
#include <string> 

using namespace std; 

int main(int argc, char *argv[]) 
{ 

    int my_rank;  /* rank of process */ 
    int noProcesses; /* number of processes */ 
    int nameSize;  /* length of name */ 

    char computerName[MPI_MAX_PROCESSOR_NAME]; 

    MPI_Init(&argc, &argv); /*START MPI */ 

    /*Determines the size of the group associated with a communicator */ 
    MPI_Comm_size(MPI_COMM_WORLD, &noProcesses); 

    /*Determines the rank of the calling process in the communicator*/ 
    MPI_Comm_rank(MPI_COMM_WORLD, &my_rank); 

    /*Gets the name of the processor*/ 
    MPI_Get_processor_name(computerName, &nameSize); 

    printf("Hello from process %d of %d processor on %s\n", my_rank, noProcesses, computerName); 

    MPI_Finalize(); /* EXIT MPI */ 

    return 0; 
} 

我已经试过在相应位置的cmd提示符mpiexec -n 2 file.exe

但我得到一个错误信息Can't find ~~ __gxx_personality_v0 ~~~ DLL libstdc++-6.dll ~~~.


我通过重命名等mpiexec.exe文件解决。在我的情况下,它是在C:\ Program Files \ Microsoft MPI \ Bin。

+0

请将您的解决方案转换为答案。之后你甚至可以接受。 – niklasfi 2014-10-29 07:00:31

回答

0

该问题是由系统路径中的另一个mpiexec.exe引起的。因此我在前面写了特定的完整路径,例如:“C:\ Program Files \ MPICH2 \ bin \ mpiexec.exe”。

之后,将“C:\ Program Files \ Microsoft MPI \ Bin”中的另一个mpiexec.exe文件重命名为“C:\ Program Files \ Microsoft MPI_temp \ Bin”。

但是,在重命名“smpd version mismatch”之后,会出现另一个错误。所以我通过smpd -version检查了它的版本。它是“1.0.3”。所以我只需通过“smpd.exe -install”命令重新安装smpd。