How to use Intel oneapi compilers on the Github actions workflow

Intel has recently changed their business model. Their suite of compilers, debuggers, toolkits, and libraries are given free of cost for personal or academic use. We can also use these compilers on the Github Actions workflow. This post gives details of the steps and a yml file which you can directly use on your Github repository to kick the automatic compilation and testing.

Step 1

Create a file with any name (but with a .yml extention) in the .github/workflows directory in your repository. If you want to use the Github website to create the action’s file, then

  1. click actions
  2. create new workflow
  3. setup a workflow by yourself
  4. Copy paste the following content
name: Intel OneAPI build

on:
  push:
    branches: [main, master]
  pull_request:
    branches: [main, master]
jobs:
  build_intel_champ_fparser:
    runs-on: ubuntu-20.04
    defaults:
      run:
        shell: bash --noprofile --norc {0}
    steps:
    - uses: actions/checkout@v2
    - name: setup repo
      run: |
        wget https://apt.repos.intel.com/intel-gpg-keys/GPG-PUB-KEY-INTEL-SW-PRODUCTS.PUB
        sudo apt-key add GPG-PUB-KEY-INTEL-SW-PRODUCTS.PUB
        rm GPG-PUB-KEY-INTEL-SW-PRODUCTS.PUB
        sudo echo "deb https://apt.repos.intel.com/oneapi all main" | sudo tee /etc/apt/sources.list.d/oneAPI.list
        sudo apt-get update
    - name: install
      run: |
        sudo apt-get install -y intel-oneapi-common-vars
        sudo apt-get install -y intel-oneapi-compiler-fortran
        sudo apt-get install -y intel-oneapi-mkl
        sudo apt-get install -y intel-oneapi-mpi
        sudo apt-get install -y intel-oneapi-mpi-devel

    - name: Compile
      run: |
        source /opt/intel/oneapi/setvars.sh
        printenv >> $GITHUB_ENV
        ifort test.f90 -o test_program
        mpiifort test2.f90 -o mpitest

    - name: "Test the code"
      run: |
        echo "Running the tests using the Intel oneapi fortran compiler"
        cd tests/test01
        mpirun -np 1  $HOME/work/reponame/reponame/mpitest
        ./$HOME/work/reponame/reponame/test_program

Note that entire oneapi-basekit is not needed (and exceeds github’s docker size alloted to each user). Install the components as needed for your project and don’t forget to use “-y” option while installing using apt install

Ravindra Shinde
Ravindra Shinde
Research Scientist

I am a theoretical and computational condensed matter physicist and quantum chemist. I am currently working as a researcher at the University of Twente, the Netherlands. I am also the founder of The Science Dev.



Next
Previous