diff --git a/.github/workflows/python-package.yml b/.github/workflows/python-package.yml new file mode 100644 index 0000000000..3396f630d7 --- /dev/null +++ b/.github/workflows/python-package.yml @@ -0,0 +1,59 @@ +name: Python package + +on: + pull_request: + push: + branches: [master] + +env: + LINUX_BASEKIT_URL: https://registrationcenter-download.intel.com/akdlm/irc_nas/17769/l_BaseKit_p_2021.2.0.2883_offline.sh + LINUX_DPCPP_COMPONENTS_WEB: intel.oneapi.lin.dpcpp-cpp-compiler + +jobs: + build: + runs-on: ubuntu-latest + strategy: + matrix: + python-version: [3.7, 3.8, 3.9] + + env: + ONEAPI_ROOT: /opt/intel/oneapi + + steps: + - uses: actions/checkout@v2 + with: + fetch-depth: 0 + + - name: Set up Python ${{ matrix.python-version }} + uses: actions/setup-python@v2 + with: + python-version: ${{ matrix.python-version }} + - name: Install dependencies + run: | + python -m pip install --upgrade pip + if [ -f requirements.txt ]; then pip install -r requirements.txt; fi + + - name: Cache oneAPI + id: cache-oneapi + uses: actions/cache@v2 + with: + path: | + /opt/intel/oneapi/compiler + /opt/intel/oneapi/tbb + key: build-${{ env.LINUX_BASEKIT_URL }}-${{ env.LINUX_DPCPP_COMPONENTS_WEB }}-compiler-tbb-${{ hashFiles('**/scripts/cache_exclude_linux.sh') }} + - name: Install oneAPI + if: steps.cache-oneapi.outputs.cache-hit != 'true' + run: scripts/install_linux.sh $LINUX_BASEKIT_URL $LINUX_DPCPP_COMPONENTS_WEB + - name: Exclude unused files from oneAPI cache + if: steps.cache-oneapi.outputs.cache-hit != 'true' + run: scripts/cache_exclude_linux.sh + + - name: Install in Development Mode + run: | + source $ONEAPI_ROOT/compiler/latest/env/vars.sh + python setup.py develop + - name: Test with pytest + run: | + source $ONEAPI_ROOT/compiler/latest/env/vars.sh + source $ONEAPI_ROOT/tbb/latest/env/vars.sh + pytest diff --git a/requirements.txt b/requirements.txt new file mode 100644 index 0000000000..6412c66048 --- /dev/null +++ b/requirements.txt @@ -0,0 +1,4 @@ +Cython +numpy +pytest +pytest-cov \ No newline at end of file diff --git a/scripts/build_backend.py b/scripts/build_backend.py index 7d1c2483d0..454226ee1c 100644 --- a/scripts/build_backend.py +++ b/scripts/build_backend.py @@ -85,7 +85,7 @@ "-DDPCPP_INSTALL_DIR=" + DPCPP_ROOT, "-DCMAKE_C_COMPILER:PATH=" + os.path.join(DPCPP_ROOT, "bin", "clang"), "-DCMAKE_CXX_COMPILER:PATH=" + os.path.join(DPCPP_ROOT, "bin", "dpcpp"), - "-DDPCTL_ENABLE_LO_PROGRAM_CREATION=ON", + # "-DDPCTL_ENABLE_LO_PROGRAM_CREATION=ON", backends, ] subprocess.check_call(cmake_args, stderr=subprocess.STDOUT, shell=False) diff --git a/scripts/cache_exclude_linux.sh b/scripts/cache_exclude_linux.sh new file mode 100755 index 0000000000..e9365ab80d --- /dev/null +++ b/scripts/cache_exclude_linux.sh @@ -0,0 +1,13 @@ +#!/bin/bash + +# SPDX-FileCopyrightText: 2020 Intel Corporation +# +# SPDX-License-Identifier: MIT + +#shellcheck disable=SC2010 +LATEST_VERSION=$(ls -1 /opt/intel/oneapi/compiler/ | grep -v latest | sort | tail -1) + +sudo rm -rf /opt/intel/oneapi/compiler/"$LATEST_VERSION"/linux/compiler/lib/ia32_lin +sudo rm -rf /opt/intel/oneapi/compiler/"$LATEST_VERSION"/linux/bin/ia32 +sudo rm -rf /opt/intel/oneapi/compiler/"$LATEST_VERSION"/linux/lib/emu +sudo rm -rf /opt/intel/oneapi/compiler/"$LATEST_VERSION"/linux/lib/oclfpga diff --git a/scripts/install_linux.sh b/scripts/install_linux.sh new file mode 100755 index 0000000000..4428dd95e8 --- /dev/null +++ b/scripts/install_linux.sh @@ -0,0 +1,23 @@ +#!/bin/bash + +# SPDX-FileCopyrightText: 2020 Intel Corporation +# +# SPDX-License-Identifier: MIT + +URL=$1 +COMPONENTS=$2 + +curl --output webimage.sh --url "$URL" --retry 5 --retry-delay 5 +chmod +x webimage.sh +./webimage.sh -x -f webimage_extracted --log extract.log +rm -rf webimage.sh +WEBIMAGE_NAME=$(ls -1 webimage_extracted/) +if [ -z "$COMPONENTS" ]; then + sudo webimage_extracted/"$WEBIMAGE_NAME"/bootstrapper -s --action install --eula=accept --continue-with-optional-error=yes --log-dir=. + installer_exit_code=$? +else + sudo webimage_extracted/"$WEBIMAGE_NAME"/bootstrapper -s --action install --components="$COMPONENTS" --eula=accept --continue-with-optional-error=yes --log-dir=. + installer_exit_code=$? +fi +rm -rf webimage_extracted +exit $installer_exit_code