From 97e2db41d4f2340e3511c4476196757cf49de167 Mon Sep 17 00:00:00 2001 From: Sergey Pokhodenko Date: Tue, 27 Jul 2021 16:12:46 +0300 Subject: [PATCH 1/9] Add conda package workflow --- .github/workflows/conda-package.yml | 115 ++++++++++++++++++++++++++++ 1 file changed, 115 insertions(+) create mode 100644 .github/workflows/conda-package.yml diff --git a/.github/workflows/conda-package.yml b/.github/workflows/conda-package.yml new file mode 100644 index 0000000000..46f5611f8c --- /dev/null +++ b/.github/workflows/conda-package.yml @@ -0,0 +1,115 @@ +name: Conda package + +on: push + +env: + PACKAGE_NAME: dpctl + +jobs: + build: + runs-on: ubuntu-latest + steps: + - uses: actions/checkout@v2 + with: + fetch-depth: 0 + + - name: Set pkgs_dirs + run: | + echo "pkgs_dirs: [~/.conda/pkgs]" >> ~/.condarc + - name: Cache conda packages + uses: actions/cache@v2 + env: + CACHE_NUMBER: 0 # Increase to reset cache + with: + path: ~/.conda/pkgs + key: + ${{ runner.os }}-conda-build-${{ env.CACHE_NUMBER }}-${{hashFiles('**/meta.yaml') }} + + - name: Add conda to system path + run: echo $CONDA/bin >> $GITHUB_PATH + - name: Install conda-build + run: conda install conda-build + - name: Build conda package + run: | + CHANNELS="-c intel -c defaults --override-channels" + VERSIONS="--python 3.8" + TEST="--no-test" + + conda build \ + $TEST \ + $VERSIONS \ + $CHANNELS \ + conda-recipe + - name: Upload artifact + uses: actions/upload-artifact@v2 + with: + name: ${{ env.PACKAGE_NAME }} ${{ runner.os }} + path: /usr/share/miniconda/conda-bld/linux-64/${{ env.PACKAGE_NAME }}-*.tar.bz2 + + test: + needs: build + runs-on: ubuntu-latest + steps: + - name: Download artifact + uses: actions/download-artifact@v2 + with: + name: ${{ env.PACKAGE_NAME }} ${{ runner.os }} + - name: Add conda to system path + run: echo $CONDA/bin >> $GITHUB_PATH + - name: Install conda-build + run: conda install conda-build + - name: Create conda channel + run: | + mkdir -p $GITHUB_WORKSPACE/channel/linux-64 + mv ${PACKAGE_NAME}-*.tar.bz2 $GITHUB_WORKSPACE/channel/linux-64 + conda index $GITHUB_WORKSPACE/channel + # Test channel + conda search $PACKAGE_NAME -c $GITHUB_WORKSPACE/channel --override-channels + - name: Collect dependencies + run: | + CHANNELS="-c $GITHUB_WORKSPACE/channel -c intel -c defaults --override-channels" + conda install $PACKAGE_NAME $CHANNELS --only-deps --dry-run > lockfile + - name: Set pkgs_dirs + run: | + echo "pkgs_dirs: [~/.conda/pkgs]" >> ~/.condarc + - name: Cache conda packages + uses: actions/cache@v2 + env: + CACHE_NUMBER: 0 # Increase to reset cache + with: + path: ~/.conda/pkgs + key: + ${{ runner.os }}-conda-test-${{ env.CACHE_NUMBER }}-${{hashFiles('lockfile') }} + - name: Install ${{ env.PACKAGE_NAME }} + run: | + CHANNELS="-c $GITHUB_WORKSPACE/channel -c intel -c defaults --override-channels" + conda install $PACKAGE_NAME pytest $CHANNELS + # Test installed packages + conda list + - name: Run tests + run: | + # echo "libintelocl.so" | tee /etc/OpenCL/vendors/intel-cpu.icd + export OCL_ICD_FILENAMES=libintelocl.so + python -m pytest --pyargs $PACKAGE_NAME + + upload: + needs: test + if: ${{ github.ref == 'refs/heads/main' }} + runs-on: ubuntu-latest + steps: + - name: Download artifact + uses: actions/download-artifact@v2 + with: + name: ${{ env.PACKAGE_NAME }} ${{ runner.os }} + + - name: Install anaconda-client + run: conda install anaconda-client + - name: Add conda to system path + run: echo $CONDA/bin >> $GITHUB_PATH + + - name: Upload + env: + ANACONDA_TOKEN: ${{ secrets.ANACONDA_TOKEN }} + run: | + conda install anaconda-client + anaconda --token $ANACONDA_TOKEN upload --user dppy --label dev ${PACKAGE_NAME}-*.tar.bz2 From 1e79b1c7b7d409b4c4a36f229667c5fb5ed0e0a7 Mon Sep 17 00:00:00 2001 From: Sergey Pokhodenko Date: Tue, 27 Jul 2021 17:51:23 +0300 Subject: [PATCH 2/9] Use dpcpp compiler package for Linux --- conda-recipe/meta.yaml | 9 ++++----- 1 file changed, 4 insertions(+), 5 deletions(-) diff --git a/conda-recipe/meta.yaml b/conda-recipe/meta.yaml index 846eff4c02..0c30df19d0 100644 --- a/conda-recipe/meta.yaml +++ b/conda-recipe/meta.yaml @@ -1,7 +1,5 @@ -{% set name = "dpctl" %} - package: - name: {{ name|lower }} + name: dpctl version: {{ GIT_DESCRIBE_TAG }} source: @@ -10,12 +8,13 @@ source: build: number: {{ GIT_DESCRIBE_NUMBER }} script_env: - - ONEAPI_ROOT + - ONEAPI_ROOT # [not linux] - WHEELS_OUTPUT_FOLDER requirements: build: - {{ compiler('cxx') }} + - {{ compiler('dpcpp') }} # [linux] host: - setuptools - cython @@ -29,7 +28,7 @@ requirements: run: - python - numpy >=1.17 - - dpcpp_cpp_rt >=2021.2 + - dpcpp_cpp_rt >=2021.2 # [not linux] test: requires: From 4c0ba891b96669a318d447ee522ca5d98483208f Mon Sep 17 00:00:00 2001 From: Sergey Pokhodenko Date: Tue, 27 Jul 2021 18:43:39 +0300 Subject: [PATCH 3/9] Remove ONEAPI_ROOT from build.sh --- conda-recipe/build.sh | 9 --------- 1 file changed, 9 deletions(-) diff --git a/conda-recipe/build.sh b/conda-recipe/build.sh index a3009779bf..c4fedfa5e8 100755 --- a/conda-recipe/build.sh +++ b/conda-recipe/build.sh @@ -1,14 +1,5 @@ #!/bin/bash -# We need dpcpp to compile dpctl_sycl_interface -if [ ! -z "${ONEAPI_ROOT}" ]; then - # Suppress error b/c it could fail on Ubuntu 18.04 - source ${ONEAPI_ROOT}/compiler/latest/env/vars.sh || true -else - echo "DPCPP is needed to build DPCTL. Abort!" - exit 1 -fi - ${PYTHON} setup.py clean --all ${PYTHON} setup.py install From 627822213c314a3cc81f8cbbba532e5820534e56 Mon Sep 17 00:00:00 2001 From: Sergey Pokhodenko Date: Tue, 27 Jul 2021 12:08:19 -0500 Subject: [PATCH 4/9] Pass CONDA_PREFIX as path to SYCL compiler prefix --- conda-recipe/build.sh | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/conda-recipe/build.sh b/conda-recipe/build.sh index c4fedfa5e8..8ffdd56db3 100755 --- a/conda-recipe/build.sh +++ b/conda-recipe/build.sh @@ -1,7 +1,7 @@ #!/bin/bash ${PYTHON} setup.py clean --all -${PYTHON} setup.py install +${PYTHON} setup.py install --sycl-compiler-prefix=$CONDA_PREFIX # Build wheel package if [ "$CONDA_PY" == "36" ]; then From 352216e534757d63e95488f90d284dc6d7065c5f Mon Sep 17 00:00:00 2001 From: Sergey Pokhodenko Date: Tue, 27 Jul 2021 12:12:49 -0500 Subject: [PATCH 5/9] Add dpcpp_cpp_rt in runtime dependency --- conda-recipe/meta.yaml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/conda-recipe/meta.yaml b/conda-recipe/meta.yaml index 0c30df19d0..cfb140e701 100644 --- a/conda-recipe/meta.yaml +++ b/conda-recipe/meta.yaml @@ -28,7 +28,7 @@ requirements: run: - python - numpy >=1.17 - - dpcpp_cpp_rt >=2021.2 # [not linux] + - dpcpp_cpp_rt >=2021.2 test: requires: From 2ae6c7d217b0079268482c61d008c0518b894922 Mon Sep 17 00:00:00 2001 From: Sergey Pokhodenko Date: Wed, 28 Jul 2021 04:56:58 -0500 Subject: [PATCH 6/9] Keep using oneAPI for wheel --- conda-recipe/build.sh | 8 ++++++++ 1 file changed, 8 insertions(+) diff --git a/conda-recipe/build.sh b/conda-recipe/build.sh index c4fedfa5e8..0ae81fa5de 100755 --- a/conda-recipe/build.sh +++ b/conda-recipe/build.sh @@ -10,6 +10,14 @@ else WHEELS_BUILD_ARGS="-p manylinux2014_x86_64" fi if [ -n "${WHEELS_OUTPUT_FOLDER}" ]; then + # We need dpcpp to compile dpctl_sycl_interface + if [ ! -z "${ONEAPI_ROOT}" ]; then + # Suppress error b/c it could fail on Ubuntu 18.04 + source ${ONEAPI_ROOT}/compiler/latest/env/vars.sh || true + else + echo "DPCPP is needed to build DPCTL. Abort!" + exit 1 + fi $PYTHON setup.py bdist_wheel ${WHEELS_BUILD_ARGS} cp dist/dpctl*.whl ${WHEELS_OUTPUT_FOLDER} fi From 4d005f2965325fd1badbf1c36675550c199cb5cb Mon Sep 17 00:00:00 2001 From: Sergey Pokhodenko Date: Tue, 27 Jul 2021 12:08:19 -0500 Subject: [PATCH 7/9] Pass CONDA_PREFIX as path to SYCL compiler prefix --- conda-recipe/build.sh | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/conda-recipe/build.sh b/conda-recipe/build.sh index 0ae81fa5de..a0ca8a7361 100755 --- a/conda-recipe/build.sh +++ b/conda-recipe/build.sh @@ -1,7 +1,7 @@ #!/bin/bash ${PYTHON} setup.py clean --all -${PYTHON} setup.py install +${PYTHON} setup.py install --sycl-compiler-prefix=$CONDA_PREFIX # Build wheel package if [ "$CONDA_PY" == "36" ]; then From 475c09f6a545599b2d9fbf129d3cee591f31a826 Mon Sep 17 00:00:00 2001 From: Sergey Pokhodenko Date: Tue, 27 Jul 2021 12:12:49 -0500 Subject: [PATCH 8/9] Add dpcpp_cpp_rt in runtime dependency --- conda-recipe/meta.yaml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/conda-recipe/meta.yaml b/conda-recipe/meta.yaml index 0c30df19d0..cfb140e701 100644 --- a/conda-recipe/meta.yaml +++ b/conda-recipe/meta.yaml @@ -28,7 +28,7 @@ requirements: run: - python - numpy >=1.17 - - dpcpp_cpp_rt >=2021.2 # [not linux] + - dpcpp_cpp_rt >=2021.2 test: requires: From 7475d34115975b11ddd5513ac46de52ed3e284ed Mon Sep 17 00:00:00 2001 From: Sergey Pokhodenko Date: Wed, 28 Jul 2021 05:43:27 -0500 Subject: [PATCH 9/9] ONEAPI_ROOT in meta.yaml for wheel on Linux --- conda-recipe/meta.yaml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/conda-recipe/meta.yaml b/conda-recipe/meta.yaml index cfb140e701..42437e1af0 100644 --- a/conda-recipe/meta.yaml +++ b/conda-recipe/meta.yaml @@ -8,7 +8,7 @@ source: build: number: {{ GIT_DESCRIBE_NUMBER }} script_env: - - ONEAPI_ROOT # [not linux] + - ONEAPI_ROOT # for wheel on Linux - WHEELS_OUTPUT_FOLDER requirements: