在openMPI, c++中发送ImageMagick对象
sending ImageMagick object in openMPI, C++
我的项目遇到了一个严重的问题。我需要将图像数据发送到集群中的另一个节点。我用ImageMagick读取图像,如:
Image testImage;
// read in the file
testImage.read("image.png");
我发送它为:
MPI_Send( &testImage, sizeof(Image), MPI_BYTE, i , 100, MPI_COMM_WORLD);
其他节点应该接收它为:
Image subimage_toModify;
MPI_Recv( &subimage_toModify, sizeof(Image), MPI_BYTE, 0, 100, MPI_COMM_WORLD, &status);
但是我得到一个分割错误:
Signal code: Address not mapped (1)
有谁能帮忙吗?我几乎要沮丧了!
Image
类不是POD类型,因此不能使用MPI_Send
发送
Image testImage;
// read in the file
testImage.read("image.png");
Blob blob;
testImage.write( & blob );
int size = blob.length();
MPI_Send( &size, sizeof( size ), MPI_BYTE, i , 100, MPI_COMM_WORLD);
MPI_Send( blob.data(), blob.length(), MPI_BYTE, i , 100, MPI_COMM_WORLD);
接收:
int size = 0;
MPI_Recv( &size, sizeof( size ), MPI_BYTE, 0, 100, MPI_COMM_WORLD, &status);
std::vector< unsigned char > tempBuffer( size, 0 );
MPI_Recv( &tempBuffer[0], tempBuffer.size(), MPI_BYTE, 0, 100, MPI_COMM_WORLD, &status);
Blob blob( &tempBuffer[0], tempBuffer.size());
相关文章:
- 什么时候调用组成单元对象的析构函数
- 对RValue对象调用的LValue ref限定成员函数
- CMake-按正确顺序将项目与C运行时对象文件链接
- 空基优化子对象的地址
- 将对象数组的引用传递给函数
- 你能重载对象变量名本身返回的内容吗
- C++使用整数的压缩数组初始化对象
- 找不到成员对象:没有名为get_event()的成员,也处理多态性和向量
- 将对象移动到std::shared_ptr
- 代理对象的常量正确性
- 提升 ASIO 无法识别计时器对象
- 将Ref对象作为类成员
- 将包含C样式数组的对象初始化为成员变量(C++)
- 如何返回一个类的两个对象相加的结果
- 使用std::函数映射对象方法
- 是否需要删除包含对象的"pair"?
- 如何在自删除后将对象设置为nullptr
- 迭代时从向量和内存中删除对象
- 构造对象的歧义
- 在openMPI, c++中发送ImageMagick对象