Executing Calculations¶
This section explains how to run calculations on the supercomputing system. It is assumed that Logging In to the System has already been completed.
MASAMUNE-II employs a job management mechanism using the PBS Professional job scheduler.
Users write the calculations they wish to perform in a job script and submit it to a queue corresponding to the required computing resources. Jobs submitted by each user are allocated computing resources and executed according to the execution priority determined by the job scheduler.
The execution priority of a job is determined based on the amount of reserved computing resources and past resource usage of each user, in order to ensure that jobs are executed as fairly and efficiently as possible among users.
For details, please refer to Job execution order.
Overview¶
To run a calculation, the following steps are usually performed:
Compile the calculation program source code
Create a job script to run the program
Submit the job using the
qsubcommand
Note
Many materials science calculation applications are pre-installed on MASAMUNE-II, so you can use them without compiling code yourself. You can check job script examples on each application’s page in Applications.
Job Script¶
Jobs are written in shell script format as follows:
#!/bin/sh
#PBS -l select=1:ncpus=1:mem=4gb
#PBS -q queue_name
#PBS -N job_name
(Specify program to execute, etc. below)
The lines starting with “#PBS” in lines 2–4 of the script reserve computing resources, specify the queue, and set the job name.
For details, please refer to Job submit command(qsub command) and related pages.
Procedure for Running a Sample Program¶
Here, we explain the procedure for compiling a C language Hello World program and running it as a job.
Creating and Compiling the Source Code¶
First, create a file named hello.c with the following content:
#include <stdio.h>
int main(void) {
printf("Hello world!\n");
return 0;
}
Next, compile the program using a compiler to generate the executable file hello.
Here we will use the GNU compiler (gcc).
$ gcc hello.c -o hello
Note
In addition to the GNU compiler, MASAMUNE-II has the Intel compiler, NVIDIA HPC compiler, and CUDA toolkit installed. For how to use them, please refer to Compilers and Libraries.
Creating the Job Script¶
Next, create a job script to submit the compiled program to the queue.
Create a file named hello.sh with the following content.
This script submits a job named “hello” to the queue CP_001 and executes the hello program created above.
#!/bin/sh
#PBS -l select=1:ncpus=1:mem=4gb
#PBS -q CP_001
#PBS -N hello
# Move to the directory where the job was submitted
cd ${PBS_O_WORKDIR}
# Redirect standard output to result.out and standard error to result.err
./hello > result.out 2> result.err
For details on the script format, please refer to Format of an execution script and related pages.
Submitting the Job¶
Once the script is created, submit the job using the qsub command as follows:
When the job submission is successful, the Job ID (in this case, 123456.cmspbs1) is displayed.
$ qsub hello.sh
123456.cmspbs1
You can check the status of the job using the statj command.
$ statj
sdb:
Req'd Req'd Elap
Job ID Username Queue Jobname SessID NDS TSK Memory Time S Time
--------------- -------- -------- ---------- ------ --- --- ------ ----- - -----
123456.cmspbs1 sc-user CP_001 hello -- 1 1 4gb 24:00 Q --
The meaning of each item is as follows:
Item |
Meaning |
|---|---|
Job ID |
ID assigned to the job |
Username |
User name |
Queue |
Name of the queue to which the job was submitted |
Jobname |
Job name |
SessID |
Session ID |
NDS |
Number of allocated nodes |
TSK |
Number of CPU cores |
Req’d Memory |
Maximum available memory limit |
Req’d Time |
Maximum execution time limit |
S |
Job status |
Elap Time |
Elapsed time since the job started running |
When the job finishes, the following files will be saved in the current directory:
result.out
result.err
hello.o123456
hello.e123456
Files named hello.o123456 and hello.e123456 record the contents of standard output and standard error, respectively.
In this example, these files should be empty because they are redirected to result.out and result.err respectively.
Attention
When running a program that outputs large amounts of calculation results to standard output or standard error, be sure to redirect the output to a file.
Unredirected output is stored in the PBS temporary file storage area, which may cause storage space exhaustion and adversely affect other users’ job executions.
Therefore, if this precaution is not observed, the job may be forcibly terminated.
Let’s check the output results. If you can see the output like below, the program has run successfully.:
$ cat result.out
Hello world!
If the output is incorrect or if no output is produced, please check whether an error message is output to the standard error output.
$ cat result.err
This concludes the explanation of how to execute calculations on MASAMUNE-II. For more detailed instructions, please refer to the following references: