Load the Intel module
If you need to use different version of intel compilers than the default version in HPC, please check the modules and then load the appropriate one. check the Intel modules:
module spider intel
output:
intel/2020b
intel/2021b
intel/2022a
intel/2024a
Load the appropriate module:
module load intel/<version>
To check the version of Intel Compilers, type:
icx --version
output:
Intel(R) oneAPI DPC++/C++ Compiler 2024.2.0 (2024.2.0.20240602)
Compiling a C or C++ Program
Interactive
Request the compute node:
srun --pty bash
Copy the content below in a hello.c file
hello.c:
#include <stdio.h>
int main()
{
printf("Hello World\n");
return 0;
}
Compile the code to create "hello" as an executable
icx -o hello hello.c
Run the Executable
./hello
Your output will be: Hello World
Copy the content in your file (let's say job.slurm).
#!/bin/bash
#SBATCH -o hello.o%j
#SBATCH --time=00:02:00
#SBATCH -N 1
#SBATCH -n 1
#Compiling section
module load intel/2024a
icx -o hello hello.c
#Copying files to scratch
cp -r hello $PFSDIR
#Running job
cd $PFSDIR
./hello
cp -ru * $SLURM_SUBMIT_DIR
Submit the job:
sbatch job.slurm
You will find the output at hello.o<jobid>
To compile the C++ source file "test.cpp" with the Intel C++ compiler, use the command
icpx -o test test.cpp