Compiling and executing a sequential C program
Let’s compile and execute the program SommeVecVecSEQ.c which computes the sum of the two vectors A and B and the result is put in C.
Definition of the compiling environment:
Supposing that we want to use Cascade partition, we have to connect to one of the login nodes for this partition, for example s92node01 (see Login nodes).
To use the software modules for this partition, we have to execute:
module use /applis/PSMN/debian11/Cascade/modules/all
Now we can see available modules:
module avail
Load a module for GNU compilers (GCC):
module load GCC/10.3.0
We can check the compiler version:
gcc --version
GNU Fortran (GCC) 10.3.0
Copyright (C) 2020 Free Software Foundation, Inc.
Compilation
gcc -o SommeVecVecSEQ.exe SommeVecVecSEQ.c
The binary file (executable) SommeVecVecSEQ.c.exe has been generated.
Note
If you prefer to use the Intel compiler, then you have to load the intel/2021a module (instead of GCC/10.3.0) and launch the compilation with the icc command (instead of gcc)
Interactive execution (on login node):
./SommeVecVecSEQ.exe
The result is displayed on the screen :
Les deux vecteurs :
A = 1 2 3 4 5 6 7 8 9 10
B = 9 8 7 6 5 4 3 2 1 0
Le vecteur somme :
C = 10 10 10 10 10 10 10 10 10 10
Batch execution (by submitting to Cascade partition):
We use a submission script.sh (for sequential program) to submit a job which will run the program on compute nodes.
This submission script configures the environment and then run the binary (with its options, if any) on the compute node.
sbatch script.sh
Submitted batch job 649
The job is waiting that asked ressources become availables and then it will be in Running state:
squeue
JOBID PARTITION NAME USER ST TIME NODES NODELIST(REASON)
649 Cascade SommeVec mylogin R 0:00 1 s92node02
As prescribed in submission script, the standard output is redirected to the file SommeVecVecSEQ.649.s92node02.out and the standard error is redirected to the file SommeVecVecSEQ.649.s92node02.err.
-rw-r--r-- 1 mylogin cbp 0 25 janv. 09:21 SommeVecVecSEQ.649.s92node02.err
-rw-r--r-- 1 mylogin cbp 419 25 janv. 09:21 SommeVecVecSEQ.649.s92node02.out
When the job is finished, we can see the output file as following:
cat SommeVecVecSEQ.649.s92node02.out
Les deux vecteurs :
A = 1 2 3 4 5 6 7 8 9 10
B = 9 8 7 6 5 4 3 2 1 0
Le vecteur somme :
C = 10 10 10 10 10 10 10 10 10 10