读书人

Message Passing Interface有人用过没

发布时间: 2013-08-01 15:23:18 作者: rapoo

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 不会

读书人网 >C++

热点推荐