首页 诗词 字典 板报 句子 名言 友答 励志 学校 网站地图
当前位置: 首页 > 教程频道 > 开发语言 > C++ >

Message Passing Interface有人用过没有

2013-08-01 
Message Passing Interface有人用过没我有几个问题。1.从这儿下的源码,不知道怎么使用和编译http://www.ope

Message Passing Interface有人用过没
我有几个问题。
1.从这儿下的源码,不知道怎么使用和编译http://www.open-mpi.org/
2.使用boost库中的MPI


// boostMPI_test.cpp : 定义控制台应用程序的入口点。
//

#include "stdafx.h"
#include <boost/interprocess/shared_memory_object.hpp>
#include <boost/interprocess/mapped_region.hpp>
#include <iostream>

using namespace boost::interprocess;

int _tmain(int argc, _TCHAR* argv[])
{
try
{
shared_memory_object sharedmem1(create_only,
"Hello",
read_write);
sharedmem1.truncate(256);

mapped_region mmap(sharedmem1 , read_write , 256);

char * str = static_cast<char*>(mmap.get_address());

assert(str);

strcpy_s( str , -1 , "Hello world!\n");

system("pause");
}
catch (interprocess_exception & e)
{
std::cout<<e.what()<<std::endl;
shared_memory_object::remove("Hello");
}
return 0;
}



运行之后,发现有异常。异常是捕获到的interprocess_exception.
拒绝访问。这个是什么情况。
[解决办法]
编译了解过 MPICH2,
open mpi 没用过, 是不是要用 cmake?

boost 不会

热点排行