I've a question regarding openmpi and the standard input file descriptor (fd) and the use of termios. Is actually the standard fd used in ompi programs ?
There's the mpirun -stdin
option for standard input redirection to a certain rank. I assume something is done behind the scene.
For example, the following code snippet fails at tcgetattr
for STDIN_FILENO only with mpirun (but works in sequential).
#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( );
}
In Open MPI, stdin
is read by the mpirun
process.
Then the data read is forwarded to one MPI task (task 0 unless explicitly requested otherwise), and that could involve the orted
daemon(s).
Bottom line, and from the point of view of the MPI task that is forwarded stdin
, file descriptor zero is a pipe
to the local daemon (mpirun
or orted
), and that is why tcgetattr()
and friends fail.
Note all other MPI tasks have file descriptor zero pointing to /dev/null
.
IIRC, SLURM
provides a srun
option (e.g. direct-run) in which stdin
is a pseudo-terminal.