using System;
using MPI;
namespace MPIHello
{
/// <summary>
/// HelloMpi程序
/// </summary>
class HelloMpiProgram : IProgram
{
#region Implementation of IProgram
/// <summary>
/// 应用程序入口点
/// </summary>
/// <param name="args">入口参数</param>
public void Entrance(string[] args)
{
//初始化MPI运行环境
using (new MPI.Environment(ref args))
{
//获取Communicator
var comm = Communicator.world;
if (0 == comm.Rank)
{
//令0进程发送数据然后接收数据
comm.Send("Rosie", 1, 0);
// receive the final message
var msg = comm.Receive<string>(Communicator.anySource, 0);
//输出收到的信息
Console.WriteLine("Rank " + comm.Rank + " rec

本文是关于C#使用MPI(Message Passing Interface)的初步教程,通过一个简单的'HelloWorld'程序,介绍了MPI的基本用法和C#集成MPI进行并行计算的概念。
最低0.47元/天 解锁文章
795

被折叠的 条评论
为什么被折叠?



