McStasMcXtrace / mccode-antlr

McCode grammar implemented with ANTLR4
1 stars 0 forks source link

`mpirun` without MPI arguments is sometimes problematic #67

Open g5t opened 2 months ago

g5t commented 2 months ago

Using a fresh installation of OpenMPI on an up-to-date Fedora 40 machine gives mpirun version 5.0.2 which is less tolerant than version 4.1.7a1 (from the Nvidia HPC SDK 2024) towards being run without command line options.

It seems that an binary compiled by mpicc which takes no options will work the same under both versions, e.g., mpirun ./binary.out. But if the binary takes optional input, and none is provided to mpirun, then problems can occur -- namely,

mpirun ./compiled_instrument.out --seed=1 ...

raises an error because mpirun does not recognize the option --seed.

If the binary options are separated from the mpirun call, e.g.,

mpirun ./compiled_instrument.out -- --seed=1 ...

then everything works as expected, but inserting the separator does not fit easily into the command-building logic:

https://github.com/McStasMcXtrace/mccode-antlr/blob/20979a3708e5c7dab088e53b9791f9f0929625aa/mccode_antlr/compiler/c.py#L170-L177

An alternative solution may be generally workable: any* mpirun option provided before the name of the binary allows for normal operation. This has only been tested with -n (equivalent to -np for OpenMPI, at least); but may work with other flags.

Interestingly, the explicit setting of -n 0 appears to be the same behavior as not providing -n -- so this could be an appropriate flag to always set for mccode_antlr.compiler.c:run_compiled_instrument