0

我怀疑我没有正确提供文件路径 - 我不是一个 linux 人,所以我不知道真正可能出了什么问题 - 代码:

int main(int argc, char** argv) {
    // ...
    char *filename = argv[3];

    MPI_Init(&argc, &argv);
    const int rank = get_rank();
    if (!rank) printf("%s\n", argv[3]); // /home/users1/stdxx/public_html/grid.txt
    // ...
    MPI_File * fh;
    if (!rank) {
        fprintf(stderr, "%d\n", rank); // I see this : 0
        if (MPI_File_open(MPI_COMM_WORLD, filename, MPI_MODE_RDONLY, 
                                            MPI_INFO_NULL, fh) != MPI_SUCCESS) {
            fprintf(stderr, "Cannot open file %s\n", filename); // never seen
        }
    // rest runs fine if I comment out the MPI_File_open call
    }


int get_rank() {
    int rank = -1;
    MPI_Comm_rank(MPI_COMM_WORLD, &rank);
    return rank;
}

即使我给出无效路径也会挂起
如果我注释掉 if (!rank)它会崩溃:

rank 6 in job 54  linux21_60559   caused collective abort of all ranks
  exit status of rank 6: killed by signal 11 
rank 8 in job 54  linux21_60559   caused collective abort of all ranks
  exit status of rank 8: killed by signal 11 
rank 5 in job 54  linux21_60559   caused collective abort of all ranks
  exit status of rank 5: killed by signal 9 
rank 4 in job 54  linux21_60559   caused collective abort of all ranks
  exit status of rank 4: killed by signal 11 
rank 2 in job 54  linux21_60559   caused collective abort of all ranks
  exit status of rank 2: killed by signal 9 
rank 1 in job 54  linux21_60559   caused collective abort of all ranks
  exit status of rank 1: killed by signal 9 

另一方面,如果我给它一条路径, sftp://stdxxxxx@linux11.di.uoa.gr/home/users1/stdxxxxx/public_html/grid.txt它会以它快乐的方式到达Cannot open file sftp://stdxxxxx@linux11.di.uoa.gr/home/users1/stdxxxxx/public_html/grid.txt

为什么 ?

在 Linux 机器集群中通过 netbeans 远程运行它。命令 :

/usr/local/mpich2/bin/mpiexec -machinefile 机器 -np 9 "${OUTPUT_PATH}" 84 9 /home/users1/stdxxxxx/public_html/grid.txt

"${OUTPUT_PATH}"是可执行文件

mpirun --versionmpiexec --version导致invalid "local" arg: --version

编辑 :

mpicc -v
mpicc for 1.1.1p1
Using built-in specs.
Target: i486-linux-gnu
Configured with: ../src/configure -v --enable-languages=c,c++,fortran,objc,obj-c++,treelang --prefix=/usr --enable-shared --with-system-zlib --libexecdir=/usr/lib --without-included-gettext --enable-threads=posix --enable-nls --with-gxx-include-dir=/usr/include/c++/4.2 --program-suffix=-4.2 --enable-clocale=gnu --enable-libstdcxx-debug --enable-objc-gc --enable-mpfr --enable-targets=all --enable-checking=release --build=i486-linux-gnu --host=i486-linux-gnu --target=i486-linux-gnu
Thread model: posix
gcc version 4.2.4 (Ubuntu 4.2.4-1ubuntu4)
4

1 回答 1

0

最终获胜者是 :

MPI_File * fh = malloc(sizeof * fh);

argghh - C 的简单乐趣

仍然对为什么当我给它 uris 时它不会崩溃感兴趣sftp:(我猜是因为它永远不会到达指针部分) - 以及构造文件名1的正确方法是什么- 所以我还不接受我的答案。

1:从这里

在 filename 参数中指定文件名的格式取决于实现,并且必须由实现记录。

在 MPI 的某些实现中,所有应用程序的所有进程的文件命名空间可能并不相同。例如,“c:\tmp\foo”可能表示不同进程上的不同文件,或者单个文件可能有多个名称,具体取决于进程位置。用户负责确保文件名参数引用单个文件,因为实现可能无法检测到这种类型的命名空间错误。

于 2013-07-08T02:58:40.900 回答