ecmwf / ecbuild

A CMake-based build system, consisting of a collection of CMake macros and functions that ease the managing of software build systems
https://ecbuild.readthedocs.io
Apache License 2.0
26 stars 25 forks source link

Add capability to launch serial jobs through wrapper #42

Closed climbfuji closed 2 years ago

climbfuji commented 2 years ago

We've come across an unusual system where you can't run an executable that was compiled with an MPI wrapper without srun, even if you want to execute it as a non-MPI (serial, 1 process) application.

For this, it would be nice to be able to launch serial jobs through a wrapper, similar to how MPI jobs are launched. I made the following changes for the latest ecbuild code in this repository:

https://github.com/ecmwf/ecbuild/compare/develop...climbfuji:feature/serexec

I then used

ecbuild -DMPIEXEC_EXECUTABLE="/usr/bin/srun" -DMPIEXEC_NUMPROC_FLAG="-n" -DSEREXEC="/usr/bin/srun" -DSEREXEC_NUMPROC_FLAG="-n" ..
make
ctest

and it worked like a charm.

I am happy to issue a pull request and, if so desired, change the names of the new flags (e.g. one could use -DSEREXEC_EXECUTABLE and -DSEREXEC_NUMPROC_FLAG or something else if SEREXEC sounds bad).

If there is already a solution in place that I haven't seen (I read through the entire file cmake/ecbuild_add_test.cmake), then please let me know.

wdeconinck commented 2 years ago

This is not a ecbuild issue per se. I usually solve it with https://cmake.org/cmake/help/latest/variable/CMAKE_CROSSCOMPILING_EMULATOR.html To do this:

echo 'srun -n 1 "$''@"'   > serial_run
chmod 755 serial_run

Then configure (or reconfigure) with

cmake . -DCMAKE_CROSSCOMPILING_EMULATOR=${PWD}/serial_run -DMPIEXEC_EXECUTABLE="/usr/bin/srun" -DMPIEXEC_NUMPROC_FLAG="-n"

Now ctest should work.

wdeconinck commented 2 years ago

Following simpler approach will also work as of cmake 3.15:

cmake . -DCMAKE_CROSSCOMPILING_EMULATOR=/usr/bin/srun;-n;1 -DMPIEXEC_EXECUTABLE="/usr/bin/srun" -DMPIEXEC_NUMPROC_FLAG="-n"
climbfuji commented 2 years ago

Thanks @wdeconinck, I will try that and report back. I also asked the sysadmins on Gaea if they can change their system settings so that this won't be needed.

climbfuji commented 2 years ago

@wdeconinck Finally got around to test your suggestion, and it works fine. Closing this issue.