.. _intel: ===== Intel ===== .. contents:: In this section: :local: :depth: 2 Description =========== Intel provides a suite of compilers and libraries optimized for Intel processors, including C/C++ and Fortran compilers, mathematical libraries (MKL), and an MPI implementation. Available Versions ================== * intel/compilers/2017 (default) * intel/mpi/2017 (default) * intel/oneapi/hpc/2025.2 * mkl/2022.2.0 (default) Components ========== - **Intel Compilers**: icc (C), icpc (C++), ifort (Fortran) - **Intel MPI**: Optimized MPI implementation - **Intel MKL**: Math Kernel Library (BLAS, LAPACK, FFT) - **Intel IPP**: Integrated Performance Primitives - **Intel TBB**: Threading Building Blocks Loading Modules =============== .. code-block:: bash # Compilers only module load intel/compilers/2017 # Compilers + MPI module load intel/compilers/2017 module load intel/mpi/2017 # OneAPI module load intel/oneapi/hpc/2025.2 # MKL module load mkl/2022.2.0 Compilation with Intel Compilers ================================ C - .. code-block:: bash :caption: compile_intel_c.sh #!/bin/bash #SBATCH -J compile_intel_c #SBATCH -N 1 #SBATCH -n 1 #SBATCH -t 00:10:00 #SBATCH --mem=2G export INPUT="program.c" export OUTPUT="program" module load intel/compilers/2017 job-nanny icc -O3 -xHost -o program program.c C++ --- .. code-block:: bash :caption: compile_intel_cpp.sh #!/bin/bash #SBATCH -J compile_intel_cpp #SBATCH -N 1 #SBATCH -n 1 #SBATCH -t 00:10:00 #SBATCH --mem=2G export INPUT="program.cpp" export OUTPUT="program" module load intel/compilers/2017 job-nanny icpc -O3 -xHost -std=c++11 -o program program.cpp Fortran ------- .. code-block:: bash :caption: compile_intel_fortran.sh #!/bin/bash #SBATCH -J compile_intel_fortran #SBATCH -N 1 #SBATCH -n 1 #SBATCH -t 00:10:00 #SBATCH --mem=2G export INPUT="program.f90" export OUTPUT="program" module load intel/compilers/2017 job-nanny ifort -O3 -xHost -o program program.f90 Compilation with OpenMP ======================= .. code-block:: bash :caption: compile_intel_omp.sh #!/bin/bash #SBATCH -J compile_intel_omp #SBATCH -N 1 #SBATCH -n 1 #SBATCH -t 00:10:00 #SBATCH --mem=2G export INPUT="program_omp.c" export OUTPUT="program_omp" module load intel/compilers/2017 job-nanny icc -qopenmp -O3 -xHost -o program_omp program_omp.c Compilation with Intel MPI ========================== .. code-block:: bash :caption: compile_intel_mpi.sh #!/bin/bash #SBATCH -J compile_intel_mpi #SBATCH -N 1 #SBATCH -n 1 #SBATCH -t 00:10:00 #SBATCH --mem=2G export INPUT="program_mpi.c" export OUTPUT="program_mpi" module load intel/compilers/2017 module load intel/mpi/2017 job-nanny mpiicc -O3 -xHost -o program_mpi program_mpi.c Execution with Intel MPI ======================== .. code-block:: bash :caption: run_intel_mpi.sh #!/bin/bash #SBATCH -J run_intel_mpi #SBATCH -N 2 #SBATCH --ntasks-per-node=28 #SBATCH -t 24:00:00 #SBATCH --mem-per-cpu=2G export INPUT="program_mpi" export OUTPUT="mpi_output/" module load intel/compilers/2017 module load intel/mpi/2017 job-nanny mpirun -np $SLURM_NTASKS ./program_mpi Using Intel MKL =============== .. code-block:: bash :caption: compile_with_mkl.sh #!/bin/bash #SBATCH -J compile_mkl #SBATCH -N 1 #SBATCH -n 1 #SBATCH -t 00:10:00 #SBATCH --mem=2G export INPUT="dgemm_example.c" export OUTPUT="dgemm_example" module load intel/compilers/2017 module load mkl/2022.2.0 job-nanny icc -O3 -xHost -mkl -o dgemm_example dgemm_example.c .. code-block:: c :caption: dgemm_example.c #include #include #include int main() { int n = 2000; double *A, *B, *C; double alpha = 1.0, beta = 0.0; // Allocate matrices A = (double*)mkl_malloc(n*n*sizeof(double), 64); B = (double*)mkl_malloc(n*n*sizeof(double), 64); C = (double*)mkl_malloc(n*n*sizeof(double), 64); // Initialize for (int i = 0; i < n*n; i++) { A[i] = (double)i; B[i] = (double)(i+1); } // DGEMM: C = alpha*A*B + beta*C cblas_dgemm(CblasRowMajor, CblasNoTrans, CblasNoTrans, n, n, n, alpha, A, n, B, n, beta, C, n); printf("C[0] = %f\n", C[0]); mkl_free(A); mkl_free(B); mkl_free(C); return 0; } OneAPI (Modern Version) ======================= .. code-block:: bash :caption: compile_oneapi.sh #!/bin/bash #SBATCH -J compile_oneapi #SBATCH -N 1 #SBATCH -n 1 #SBATCH -t 00:10:00 #SBATCH --mem=2G export INPUT="program.c" export OUTPUT="program" module load intel/oneapi/hpc/2025.2 # icx compiler (C) and icpx (C++) based on LLVM job-nanny icx -O3 -march=native -o program program.c Intel Optimization Flags ======================== .. list-table:: Intel optimization flags :header-rows: 1 :widths: 25 75 * - Flag - Description * - ``-O0`` - No optimization * - ``-O1`` - Basic optimization * - ``-O2`` - Recommended optimization * - ``-O3`` - Aggressive optimization * - ``-xHost`` - Optimize for current architecture * - ``-xCode`` - Optimize for specific architecture (xAVX, xCORE, etc.) * - ``-ipo`` - Interprocedural optimization * - ``-qopenmp`` - Enable OpenMP * - ``-mkl`` - Link with Intel MKL * - ``-fast`` - Combination of aggressive optimizations Job Array for Testing Different Flags ===================================== .. code-block:: bash :caption: test_intel_flags.sh #!/bin/bash #SBATCH -J test_intel_flags #SBATCH --array=1-6 #SBATCH -N 1 #SBATCH -n 1 #SBATCH -t 00:30:00 #SBATCH --mem=4G FLAGS=("-O0" "-O1" "-O2" "-O3" "-O3 -xHost" "-fast") FLAG=${FLAGS[$SLURM_ARRAY_TASK_ID-1]} export INPUT="benchmark.c" export OUTPUT="benchmark_flag_${SLURM_ARRAY_TASK_ID}/" module load intel/compilers/2017 mkdir -p benchmark_flag_${SLURM_ARRAY_TASK_ID} cd benchmark_flag_${SLURM_ARRAY_TASK_ID} # Compile with specific flag job-nanny icc $FLAG -o benchmark ../benchmark.c # Run and measure time time ./benchmark > performance.txt 2>&1 References ========== - Intel Compilers documentation: https://software.intel.com/content/www/us/en/develop/documentation/cpp-compiler-developer-guide-and-reference/ - Intel MPI: https://software.intel.com/content/www/us/en/develop/documentation/mpi-developer-reference/ - Intel MKL: https://software.intel.com/content/www/us/en/develop/documentation/mkl-developer-reference-c/ .. seealso:: - :ref:`gcc` - GNU compilers - :ref:`openmpi` - Open-source MPI - :ref:`running_simulations` - How to submit jobs