我的想法是,每次每个节点都映射一大块文件并处理它。然后它 munmap 这个块并去下一块。
但是,我总是在集群(Openmpi)上失败,但在我的机器上运行良好(mpich)
映射部分是这样的: PAGE 是一个整数 = 4*1000*1000 // 偏移量必须是一个内存页的数量,即 4kb。ntask 是节点总数 mytask 表示当前节点数,因此缓冲区大小设置为总/节点数(statbuf.st_size/ntask)
char *
mmaping (char *source)
{
int src;
char *sm;
struct stat statbuf;
if ((src = open (source, O_RDONLY)) < 0)
{
perror (" open source ");
exit (EXIT_FAILURE);
}
if (fstat (src, &statbuf) < 0)
{
perror (" fstat source ");
exit (EXIT_FAILURE);
}
sm = mmap (0,(long long)statbuf.st_size/ntask, PROT_READ, MAP_SHARED | MAP_NORESERVE,src, mytask*share*PAGE);
if (MAP_FAILED == sm)
{
perror (" mmap source ");
exit (EXIT_FAILURE);
}
printf("length->%d\n",strlen(sm));
return sm;
}
error msg
[kalkyl3:15871] *** Process received signal ***
[kalkyl3:15871] Signal: Segmentation fault (11)
[kalkyl3:15871] Signal code: Address not mapped (1)
谁能给我一些建议?