我写了一个简单的 C 程序来尝试 MPI-IO;程序读取一个文本文件,每个进程输出它读取的部分的第一个字符。该程序适用于不同大小(100KB、30MB、500MB、2.5GB),但当我尝试 7.5GB 文件时,出现此错误:
Invalid count, error stack:
MPI_FILE_IREAD_AT(104): Invalid count argument
我尝试了集体方法(MPI_File_read_at_all)和独立方法(MPI_File_read),它们都无法读取7.5GB的文件。这是负责阅读的代码:
MPI_File fh;
MPI_Offset total_number_bytes, number_bytes;
long long nchars;
int errclass, resultlen;
char err_buffer[MPI_MAX_ERROR_STRING];
MPI_File_open(MPI_COMM_WORLD, "bigfastq", MPI_MODE_RDONLY, MPI_INFO_NULL, &fh);
MPI_File_get_size(fh, &total_number_bytes);
number_bytes = total_number_bytes/size;
nchars = number_bytes/sizeof(char);
//char buf[nchars+1];
char *buf = (char*)malloc(sizeof(char)*nchars);
MPI_Offset offset = rank*number_bytes;
int err = MPI_File_read_at_all(fh, offset, buf, nchars, MPI_CHAR, &status);
if(err != MPI_SUCCESS){
MPI_Error_class(err,&errclass);
if (errclass== MPI_ERR_COUNT) {
printf("Invalid count class!!\n");
}
MPI_Error_string(err,err_buffer,&resultlen);
fprintf(stderr,err_buffer);
MPI_File_close(&fh);
MPI_Finalize();
return 0;
}
MPI_File_close(&fh);
printf("rank: %d, buf[%lld]: %c, count: %lld\n", rank, offset, buf[offset], count);
MPI_Finalize();
任何想法为什么在尝试 7.5GB 文件时会出现此错误?
提前致谢!