【发布时间】:2019-03-27 11:33:32
【问题描述】:
我正在尝试使用带有共享文件指针的 MPI-I/O(OpenMPI 实现)将几个长分布式数组写入单个文件。我收到以下错误消息
lseek:无效参数
写入失败
我准备了一个简化的代码 sn-p 来重现这个问题。
long long globalUpperBnd = 2200000000;// more than size of int
long long average = globalUpperBnd/commSize;
long long length = (commRank == commSize-1) ? globalUpperBnd-(average*commRank) : average;
char *buf = new char[length];
... // fill the buffer
MPI_File file;
MPI_File_open(comm, "test.bin", MPI_MODE_CREATE|MPI_MODE_WRONLY, MPI_INFO_NULL, &file);
MPI_File_set_view(file, 0, MPI_BYTE, MPI_BYTE, "native", MPI_INFO_NULL);
MPI_File_write_ordered(file, buf, length, MPI_BYTE, MPI_STATUS_IGNORE);
// here I got an error message
MPI_File_write_ordered(file, buf, length, MPI_BYTE, MPI_STATUS_IGNORE);
MPI_File_close(&file);
delete []buf;
看起来MPI_Offset 只是int 并且MPI_File_write_ordered 的第二次调用导致MPI_Offset 溢出,偏移量变为负数。
相当有趣的是,通过将globalUpperBnd 乘以2 并只调用一次MPI_File_write_ordered 可以成功地写入相同数量的数据。所以看起来MPI_File_write_ordered 以某种方式避免了偏移溢出。
我使用 64 位 OpenMPI 库。
这种情况有什么解决办法吗?
【问题讨论】:
-
你能上传一个minimal reproducible example吗?注意
length应该是int,如果它可能溢出,您应该使用派生数据类型。另外,您正在运行哪个 Open MPI 版本?
标签: file mpi distributed mpi-io parallel-io