Skip to content
Snippets Groups Projects

feat: add single core job example

Merged Rasmus Ringdahl requested to merge dev into main
4 files
+ 90
82
Compare changes
  • Side-by-side
  • Inline
Files
4
+ 34
0
# Single core jobs
A single core job is a job with only a single thread. This type of job is used when it is hard or impossible to make use of multiple cores/threads. A simple example could be a data parser that reads a file and transforms it into a more suitable format.
## How to run
To run the example do the following steps:
1. Log in to Lundgren
2. Change directory to the example code
3. Run `sbatch single_core_job.sh`
4. Check queue status by running `squeue`
5. When the job is completed check the file _single_core_job.log_
## Detailed description of the example
The batch script is the main file for the job allocation and preparation. Inside the python script a few environmental variables are fetched and printed out.
### The batch script
The batch script, _single_core_job.sh_, contains three sections. The first section contains input arguments to the Slurm scheduler. The second section loads Python into environment so it is accessible and lastly the a job step is performed.
The input arguments are defined with a comment beginning with SBATCH followed by the argument key and value. For easier readablility the -- method is used.
- __job-name:__ The name of the job is set to _demo_single_core_
- __time:__ The requeted time is set to 1 minute, _00:01:00_
- __ntasks:__ The number of tasks to be performed in this job is set to _1_.
- __cpus-per-task:__ The requested number of cores per task is set to _1_
- __mem:__ The requested memory is set to _50 MB_
- __output:__ The standard output should be sent to the file _single_core_job.log_
Python needs to be loaded into the environment in order to be accessible this is done in the next step with the __module__ command.
The job step with the single task is allocated and performed with the __srun__ command.
#### The python script
The python script represents the taskt to be done. In this case the task is to print out some environment variables that are set by Slurm.
The environment variable __JOB_ID__ can be used to create temporary files and folders. In this example it creates a file named <JOB_ID>.txt and writes the job name into it.
\ No newline at end of file
Loading