diff --git a/toolchain/templates/default.mako b/toolchain/templates/default.mako index 2d05d3ab3c..5d9c546e3f 100644 --- a/toolchain/templates/default.mako +++ b/toolchain/templates/default.mako @@ -36,6 +36,13 @@ if engine == 'batch': else ok ":) Selected MPI launcher $MAGENTA$binary$COLOR_RESET. Use$MAGENTA --binary$COLOR_RESET to override." fi + + % if engine == 'interactive': + # On Flux systems, srun is a wrapper that submits a batch job outside an allocation. + if [ "$binary" == "srun" ] && command -v flux > /dev/null; then + ${helpers.require_flux_allocation()} + fi + % endif % endif % for target in targets: diff --git a/toolchain/templates/include/helpers.mako b/toolchain/templates/include/helpers.mako index 58e34a3666..3fd21baa98 100644 --- a/toolchain/templates/include/helpers.mako +++ b/toolchain/templates/include/helpers.mako @@ -45,6 +45,13 @@ END % endif +<%def name="require_flux_allocation()"> + if [ -z "$FLUX_ENCLOSING_ID" ]; then + error ":( Not inside a Flux allocation: each launch would be submitted as its own batch job. Run inside 'flux alloc ...', use '-e batch', or pass --no-mpi.\n" + exit 1 + fi + + <%def name="template_epilogue()"> % if os.name != 'nt': #> diff --git a/toolchain/templates/tuo.mako b/toolchain/templates/tuo.mako index d842151c3e..246f5796c4 100644 --- a/toolchain/templates/tuo.mako +++ b/toolchain/templates/tuo.mako @@ -37,6 +37,10 @@ echo export HSA_XNACK=0 +% if mpi and engine == 'interactive': + ${helpers.require_flux_allocation()} +% endif + % for target in targets: ${helpers.run_prologue(target)}