我有一个关于openmpi和标准输入文件描述符(fd)以及termios的使用的问题。实际上,标准fd在ompi程序中使用吗?
有一个mpirun -stdin选项,用于标准输入重定向到某个级别。我想是在幕后做了些什么。
例如,下面的代码片段仅在mpirun中在tcgetattr STDIN_FILENO中失败(但按顺序工作)。
#include <iostream>
#include <mpi.h>
#include <termios.h>
#include <unistd.h>
#include <stdio.h>
#include <assert.h>
using namespace std;
int main(int argc, char* argv[]) {
MPI_Status status;
MPI_Init(&argc, &argv);
int in = dup( STDIN_FILENO );
struct termios org_opts, new_opts;
res = tcgetattr( in, &org_opts);
assert(res==0);
MPI_Finalize( );
} 发布于 2018-05-08 00:05:41
在Open中,stdin由mpirun进程读取。
然后将读取的数据转发给一个MPI任务(任务0,除非另有明确请求),这可能涉及orted守护进程。
总之,从转发stdin的MPI任务的角度来看,文件描述符零是本地守护进程(mpirun或orted)的pipe,这就是tcgetattr()和朋友失败的原因。
注意,所有其他MPI任务都有指向/dev/null的文件描述符为零。
SLURM提供了一个srun选项(例如直接运行),其中stdin是伪终端.
https://stackoverflow.com/questions/50220368
复制相似问题