The Slurm Workload Manager (Slurm) also provides an interactive scheduling mode. This mode is useful for running programs that require user interaction, or for tasks such as compiling software using backend multi-core processors. The following example demonstrates how to use interactive scheduling to compile LAMMPS on the HPC system,
Request computing resources, for example,
salloc --ntasks=8 --partition=cpu-2g --time=0-0:10
The command above requests 8 CPU cores from the cpu-2g partition for a duration of 0 days, 0 hours, and 10 minutes. After running the command, you will see a message similar to the following,
salloc: Granted job allocation 4946
This indicates that you have successfully obtained computing resources and your job ID is 4946. If there is no response for an extended period, it means the system currently lacks sufficient resources to fulfill your request. In that case, press Ctrl + C to cancel the request.
Next, you can start the interactive session. In this example, the user has already placed the LAMMPS source code in the directory ~/usr/local/src/lammps/, and will compile it using the GNU C/C++ compiler. The command to execute is as follows,
module load gcc mpi
cd ~/usr/local/src/lammps/src/STBUS
srun -n 1 make -j8
cd ~/usr/local/src/lammps/src/
srun -n 1 make serial -j8
srun -n 1 make mpi -j8
上述指令有 srun -n 1 均是使用後段的計算核心來處理工作,例如「srun -n 1 make mpi -j8」就是要呼叫後端的計算核心來執行「
make mpi -j8」這個指令。之所以寫「-n 1」是因為編譯器不需要「srun」的多執行緒,而是用「make」指令的「-j8」參數來指定 8 核心。
The command includes srun -n 1, which means the task is executed using one of the allocated compute cores. For example, the command,
srun -n 1 make mpi -j8
runs the make mpi -j8 command on a backend compute core. The reason for specifying -n 1 is that the compiler itself does not require multiple parallel tasks through srun. Instead, parallel compilation is handled by the -j8 option in the make command, which uses 8 CPU cores during the build process.
After the compilation is complete, use the command,
exit
to leave the interactive session and return to your original login environment.