如何使用工具mpich2为Windows 7实现c ++中的并行程序 [英] how implement parallel program in c++ using tool mpich2 for windows 7

查看:95
本文介绍了如何使用工具mpich2为Windows 7实现c ++中的并行程序的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

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

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;
}

推荐答案

您的MPICH2文档肯定会包含一个很好的例子。为什么不看看它。



维基百科的简单搜索也可以帮助你: http://en.wikipedia.org/wiki/Message_Passing_Interface [ ^ ]它们在文章末尾提供了一个非常好的简单示例,您可以将其剪切并粘贴到您的程序中。
Your MPICH2 documentation will certainly contain a nice example. Why not take a look at it.

A simple search in Wikipedia will also get you there:http://en.wikipedia.org/wiki/Message_Passing_Interface[^] They offer a very nice and simple example at the end of the article, which you can cut and paste into your program.


这篇关于如何使用工具mpich2为Windows 7实现c ++中的并行程序的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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