Mpi在Windows中的用法 [英] Mpi usage in Windows

查看:438
本文介绍了Mpi在Windows中的用法的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我安装mpi到windows,我可以使用它的库。问题是在我写的时候在窗口

I installed mpi into windows and I can use its libraries. The problem is that in windows when I write

mpiexec -n 4 proj.exe 

到命令提示符,它不会进行正确的操作。 4个不同的进程分别使用整个代码文件。它们的行为不像只在MPI_Init和MPI_Finalize行中工作的并行进程。如何解决这个问题?

into command prompt it does not make the proper operations. 4 different processes uses the whole code file separately. They don't behave like parallel processes that are working only in the MPI_Init and MPI_Finalize rows. How can I fix this problem? Is it impossible to work MPI in Windows.

Ps:我使用的是Dev c ++

P.s : I am using Dev c++

推荐答案

MPI由​​你说的正确运行 - 而你的假设是不正确的。在每个MPI实现(我已经使用),整个程序从开始到结束在每个过程。 MPI_Init和MPI_Finalize函数用于为每个进程设置和拆除MPI结构,但是不指定并行执行的开始和结束

MPI is running correctly by what you said -- instead your assumptions are incorrect. In every MPI implementation (that I have used anyway), the entire program is run from beginning to end on every process. The MPI_Init and MPI_Finalize functions are required to setup and tear-down MPI structures for each process, but they do not specify the beginning and end of parallel execution. The beginning of the parallel section is first instruction in main, and the end is the final return.

一个好的模板程序,它看起来像你想要的将是(也在 http://stackoverflow.com/questions/2156714/ how-to-speed-up-this-problem-by-mpi ):

A good "template" program for what it seems like you want would be (also answered in http://stackoverflow.com/questions/2156714/how-to-speed-up-this-problem-by-mpi):

int main(int argc, char *argv[]) {
    MPI_Init(&argc, &argv);  
    MPI_Comm_size(MPI_COMM_WORLD,&numprocs);  
    MPI_Comm_rank(MPI_COMM_WORLD,&myid);

    if (myid == 0) { // Do the serial part on a single MPI thread
        printf("Performing serial computation on cpu %d\n", myid);
        PreParallelWork();
    }

    ParallelWork();  // Every MPI thread will run the parallel work

    if (myid == 0) { // Do the final serial part on a single MPI thread
        printf("Performing the final serial computation on cpu %d\n", myid);
        PostParallelWork();
    }

    MPI_Finalize();  
    return 0;  
}  

这篇关于Mpi在Windows中的用法的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆