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

    branches: [main, master]
    branches: [main, master]
    runs-on: ubuntu-20.04
        shell: bash --noprofile --norc {0}
    - uses: actions/checkout@v2
    - name: setup repo
      run: |
        sudo apt-key add GPG-PUB-KEY-INTEL-SW-PRODUCTS.PUB
        sudo echo "deb 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/
        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

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.