简单的MPI_GATHER测试带有memcpy错误
Simple MPI_Gather test with memcpy error
我正在学习MPI,并尝试创建某些功能的示例。我已经工作了几个工作,但是我与MPI_Gather有问题。我进行了更复杂的拟合测试,但是将其修剪为最简单的代码。但是,我仍然会遇到以下错误:
root@master:/home/sgeadmin# mpirun ./expfitTest5
Assertion failed in file src/mpid/ch3/src/ch3u_request.c at line 584: FALSE
memcpy argument memory ranges overlap, dst_=0x1187e30 src_=0x1187e40 len_=400
internal ABORT - process 0
我正在通过AWS EC2运行一个主实例和两个节点实例。我已经安装了所有适当的库,因为我得到了其他MPI示例。我的程序是:
int main()
{
int world_size, world_rank;
int nFits = 100;
double arrCount[100];
double *rBuf = NULL;
MPI_Init(NULL,NULL);
MPI_Comm_size(MPI_COMM_WORLD, &world_size);
MPI_Comm_rank(MPI_COMM_WORLD, &world_rank);
assert(world_size!=1);
int nElements = nFits/(world_size-1);
if(world_rank>0){
for(int k = 0; k < nElements; k++)
{
arrCount[k] = k;
}}
MPI_Barrier(MPI_COMM_WORLD);
if(world_rank==0)
{
rBuf = (double*) malloc( nFits*sizeof(double));
}
MPI_Gather(arrCount, nElements, MPI_DOUBLE, rBuf, nElements, MPI_DOUBLE, 0, MPI_COMM_WORLD);
if(world_rank==0){
for(int i = 0; i < nFits; i++)
{
cout<<rBuf[i]<<"n";
}}
MPI_Finalize();
exit(0);
}
在malloc或mpi_gather中我不了解一些东西吗?我将代码与其他样本进行了比较,找不到任何区别。
收集操作中的root
进程确实参与了操作。IE。它将数据发送到其自己的接收缓冲区。这也意味着您必须在接收缓冲区中分配内存。
现在,您可以使用MPI_Gatherv
并在0的根上指定recvcounts[0]
/sendcount
以密切关注您的示例。但是通常,您希望以同等参与操作的方式编写MPI应用程序,即int nElements = nFits/world_size
。
相关文章:
- 警告处理为错误这里有什么问题
- 使用 memcpy() 复制到 std::chrono::milliseconds 会给出错误 -Werror=clas
- 尝试通过memcpy复制大尺寸浮点向量时的分割错误
- 由于指针算法错误,代码在 memcpy 中崩溃
- C++ - 程序接收信号SIGSEGV,分段错误.In msvcrt!memcpy () (C:\Windows\S
- 简单的MPI_GATHER测试带有memcpy错误
- memcpy()给了我seg错误
- 使用 memcpy 将动态数组的内容复制到另一个动态数组上会产生运行时错误
- memcpy错误,长度不正确
- memcpy局部静态变量时出现分段错误
- memcpy(),更改预定义变量值时的分割错误
- 错误/usr/include/string.h:652:42:错误:生成caffe时未在此作用域中声明“memcpy”
- 带有structs和memcpy的C++分段错误
- 使用 C++ 复制而不是 memcpy 的分段错误
- Eclipse Nios2 返回错误:memcpy 的参数无效
- 使用memcpy时出现内存错误
- memcpy-qt和编译错误
- memcpy.Asm未发现错误
- std::copy的分段错误,memcpy 工作
- memcpy问题;复制错误的块和多次