Skip to content

Commit f5a868e

Browse files
adarshyogaZzEeKkAa
authored andcommitted
adding conda recipe
1 parent 432d276 commit f5a868e

File tree

12 files changed

+435
-1
lines changed

12 files changed

+435
-1
lines changed
Lines changed: 238 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,238 @@
1+
# SPDX-FileCopyrightText: 2022 - 2023 Intel Corporation
2+
#
3+
# SPDX-License-Identifier: Apache-2.0
4+
5+
name: Conda package
6+
7+
on:
8+
push:
9+
branches:
10+
- main
11+
pull_request:
12+
13+
env:
14+
PACKAGE_NAME: dpbench
15+
MODULE_NAME: dpbench
16+
CHANNELS: '-c dppy/label/dev -c conda-forge -c intel -c nodefaults --override-channels'
17+
VER_JSON_NAME: 'version.json'
18+
VER_SCRIPT1: "import json; f = open('version.json', 'r'); j = json.load(f); f.close(); "
19+
VER_SCRIPT2: "d = j['dpbench'][0]; print('='.join((d[s] for s in ('version', 'build'))))"
20+
21+
jobs:
22+
build:
23+
name: Build ['${{ matrix.os }}', python='${{ matrix.python }}']
24+
25+
strategy:
26+
fail-fast: false
27+
matrix:
28+
python: ['3.9', '3.10']
29+
os: [ubuntu-latest, windows-latest]
30+
31+
runs-on: ${{ matrix.os }}
32+
33+
defaults:
34+
run:
35+
# shell: ${{ matrix.os == 'windows-latest' && 'cmd /C CALL {0}' || 'bash -l {0}' }}
36+
shell: bash -l {0}
37+
38+
continue-on-error: false
39+
40+
steps:
41+
- name: Cancel Previous Runs
42+
uses: styfle/[email protected]
43+
with:
44+
access_token: ${{ github.token }}
45+
46+
- name: Checkout DPBENCH repo
47+
uses: actions/[email protected]
48+
with:
49+
fetch-depth: 0
50+
51+
- name: Setup miniconda
52+
uses: conda-incubator/[email protected]
53+
with:
54+
auto-update-conda: true
55+
python-version: ${{ matrix.python }}
56+
miniconda-version: 'latest'
57+
activate-environment: 'build'
58+
59+
- name: Store conda paths as envs
60+
run: echo "CONDA_BLD=$CONDA_PREFIX/conda-bld/${{ runner.os == 'Linux' && 'linux' || 'win' }}-64/" | tr "\\" '/' >> $GITHUB_ENV
61+
62+
- name: Install conda-build
63+
run: conda install conda-build
64+
65+
- name: Cache conda packages
66+
uses: actions/[email protected]
67+
env:
68+
CACHE_NUMBER: 1 # Increase to reset cache
69+
with:
70+
path: ${{ env.CONDA_PKGS_DIR }}
71+
key:
72+
${{ runner.os }}-conda-${{ env.CACHE_NUMBER }}-python-${{ matrix.python }}-${{hashFiles('**/meta.yaml') }}
73+
restore-keys: |
74+
${{ runner.os }}-conda-${{ env.CACHE_NUMBER }}-python-${{ matrix.python }}-
75+
${{ runner.os }}-conda-${{ env.CACHE_NUMBER }}-
76+
77+
- name: Build conda package
78+
run: conda build --no-test --python ${{ matrix.python }} ${{ env.CHANNELS }} conda-recipe
79+
80+
- name: Upload artifact
81+
uses: actions/[email protected]
82+
with:
83+
name: ${{ env.PACKAGE_NAME }} ${{ runner.os }} Python ${{ matrix.python }}
84+
path: ${{ env.CONDA_BLD }}${{ env.PACKAGE_NAME }}-*.tar.bz2
85+
86+
test:
87+
name: Test ['${{ matrix.os }}', python='${{ matrix.python }}']
88+
89+
needs: build
90+
91+
runs-on: ${{ matrix.os }}
92+
93+
defaults:
94+
run:
95+
# shell: ${{ matrix.os == 'windows-latest' && 'cmd /C CALL {0}' || 'bash -l {0}' }}
96+
shell: bash -l {0}
97+
98+
strategy:
99+
fail-fast: false
100+
matrix:
101+
python: ['3.9', '3.10']
102+
os: [ubuntu-20.04, ubuntu-latest, windows-latest]
103+
experimental: [false]
104+
105+
continue-on-error: ${{ matrix.experimental }}
106+
107+
steps:
108+
- name: Setup miniconda
109+
uses: conda-incubator/[email protected]
110+
with:
111+
auto-update-conda: true
112+
python-version: ${{ matrix.python }}
113+
miniconda-version: 'latest'
114+
activate-environment: 'test'
115+
116+
- name: Store conda paths as envs
117+
shell: bash -l {0}
118+
run: |
119+
echo "CHANNEL_PATH=${{ github.workspace }}/channel/" | tr "\\" "/" >> $GITHUB_ENV
120+
echo "EXTRACTED_PKG_PATH=${{ github.workspace }}/pkg/" | tr "\\" "/" >> $GITHUB_ENV
121+
echo "VER_JSON_PATH=${{ github.workspace }}/version.json" | tr "\\" "/" >> $GITHUB_ENV
122+
echo "PKG_PATH_IN_CHANNEL=${{ github.workspace }}/channel/${{ runner.os == 'Linux' && 'linux' || 'win' }}-64/" | tr "\\" "/" >> $GITHUB_ENV
123+
124+
- name: Download artifact
125+
uses: actions/[email protected]
126+
with:
127+
name: ${{ env.PACKAGE_NAME }} ${{ runner.os }} Python ${{ matrix.python }}
128+
path: ${{ env.PKG_PATH_IN_CHANNEL }}
129+
130+
# We need --force-local because on windows path looks like C:/foo/bar
131+
# and tar interprits semicolons as remote device.
132+
- name: Extract package archive
133+
shell: bash -l {0}
134+
run: |
135+
mkdir -p ${EXTRACTED_PKG_PATH}
136+
tar -xvf ${PKG_PATH_IN_CHANNEL}${PACKAGE_NAME}-*.tar.bz2 -C ${EXTRACTED_PKG_PATH} --force-local
137+
138+
# Needed to be able to run conda index
139+
- name: Install conda-build
140+
run: conda install conda-build
141+
142+
- name: Create conda channel
143+
run: conda index ${{ env.CHANNEL_PATH }}
144+
145+
- name: Test conda channel
146+
run: |
147+
conda search ${{ env.PACKAGE_NAME }} -c ${{ env.CHANNEL_PATH }} --override-channels --info --json > ${{ env.VER_JSON_PATH }}
148+
cat ${{ env.VER_JSON_PATH }}
149+
150+
- name: Collect dependencies
151+
shell: bash -l {0}
152+
run: |
153+
export PACKAGE_VERSION=$(python -c "${{ env.VER_SCRIPT1 }} ${{ env.VER_SCRIPT2 }}")
154+
155+
echo PACKAGE_VERSION=${PACKAGE_VERSION}
156+
echo "PACKAGE_VERSION=$PACKAGE_VERSION" >> $GITHUB_ENV
157+
158+
conda install ${{ env.PACKAGE_NAME }}=${PACKAGE_VERSION} python=${{ matrix.python }} ${{ env.TEST_CHANNELS }} --only-deps --dry-run > lockfile
159+
cat lockfile
160+
env:
161+
TEST_CHANNELS: '-c ${{ env.CHANNEL_PATH }} ${{ env.CHANNELS }}'
162+
163+
- name: Cache conda packages
164+
uses: actions/[email protected]
165+
env:
166+
CACHE_NUMBER: 1 # Increase to reset cache
167+
with:
168+
path: ${{ env.CONDA_PKGS_DIR }}
169+
key:
170+
${{ runner.os }}-conda-${{ env.CACHE_NUMBER }}-python-${{ matrix.python }}-${{hashFiles('lockfile') }}
171+
restore-keys: |
172+
${{ runner.os }}-conda-${{ env.CACHE_NUMBER }}-python-${{ matrix.python }}-
173+
${{ runner.os }}-conda-${{ env.CACHE_NUMBER }}-
174+
175+
- name: Install opencl_rt
176+
run: conda install opencl_rt -c intel --override-channels
177+
178+
- name: Install dpbench
179+
run: conda install ${{ env.PACKAGE_NAME }}=${{ env.PACKAGE_VERSION }} pytest python=${{ matrix.python }} ${{ env.TEST_CHANNELS }}
180+
env:
181+
TEST_CHANNELS: '-c ${{ env.CHANNEL_PATH }} ${{ env.CHANNELS }}'
182+
183+
- name: List installed packages
184+
run: conda list
185+
186+
- name: Smoke test
187+
run: python -c "import dpnp, dpctl, dpbench; dpctl.lsplatform()"
188+
189+
- name: Run benchmakrs
190+
shell: ${{ matrix.os == 'windows-latest' && 'cmd /C CALL {0}' || 'bash -l {0}' }}
191+
run: |
192+
dpbench -i numpy,numba_dpex_p,dpnp,numba_n,sycl run
193+
dpbench report
194+
195+
upload_anaconda:
196+
name: Upload dppy/label/dev ['${{ matrix.os }}', python='${{ matrix.python }}']
197+
198+
needs: [test]
199+
200+
strategy:
201+
matrix:
202+
python: ['3.9', '3.10']
203+
os: [ubuntu-latest, windows-latest]
204+
205+
runs-on: ${{ matrix.os }}
206+
207+
defaults:
208+
run:
209+
# shell: ${{ matrix.os == 'windows-latest' && 'cmd /C CALL {0}' || 'bash -l {0}' }}
210+
shell: bash -l {0}
211+
212+
continue-on-error: false
213+
214+
# if: |
215+
# (github.repository == 'IntelPython/dpbench') &&
216+
# (github.ref == 'refs/heads/main' || (startsWith(github.ref, 'refs/heads/release') == true) || github.event_name == 'push' && contains(github.ref, 'refs/tags/'))
217+
218+
steps:
219+
- name: Download artifact
220+
uses: actions/[email protected]
221+
with:
222+
name: ${{ env.PACKAGE_NAME }} ${{ runner.os }} Python ${{ matrix.python }}
223+
224+
- name: Setup miniconda
225+
uses: conda-incubator/[email protected]
226+
with:
227+
auto-update-conda: true
228+
python-version: ${{ matrix.python }}
229+
miniconda-version: 'latest'
230+
activate-environment: 'upload'
231+
232+
- name: Install anaconda-client
233+
run: conda install anaconda-client
234+
235+
- name: Upload
236+
run: anaconda --token ${{ env.ANACONDA_TOKEN }} upload --user dppy --label dev ${{ env.PACKAGE_NAME }}-*.tar.bz2
237+
env:
238+
ANACONDA_TOKEN: ${{ secrets.ANACONDA_TOKEN }}

CMakeLists.txt

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -10,6 +10,10 @@ project(dpbench
1010
"Benchmark suite to evaluate Intel Data Parallel Extensions for Python"
1111
)
1212

13+
# Help conda build find path from both host and build env.
14+
set(CMAKE_FIND_ROOT_PATH_MODE_INCLUDE BOTH)
15+
set(CMAKE_FIND_ROOT_PATH_MODE_LIBRARY BOTH)
16+
1317
find_package(pybind11 CONFIG REQUIRED)
1418
find_package(IntelDPCPP REQUIRED)
1519
find_package(PythonExtensions REQUIRED)

conda-recipe/bld.bat

Lines changed: 60 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,60 @@
1+
REM SPDX-FileCopyrightText: 2022 - 2023 Intel Corporation
2+
REM
3+
REM SPDX-License-Identifier: Apache-2.0
4+
5+
REM A workaround for activate-dpcpp.bat issue to be addressed in 2021.4
6+
set "LIB=%BUILD_PREFIX%\Library\lib;%BUILD_PREFIX%\compiler\lib;%LIB%"
7+
SET "INCLUDE=%BUILD_PREFIX%\include;%INCLUDE%"
8+
9+
REM Since the 60.0.0 release, setuptools includes a local, vendored copy
10+
REM of distutils (from late copies of CPython) that is enabled by default.
11+
REM It breaks build for Windows, so use distutils from "stdlib" as before.
12+
REM @TODO: remove the setting, once transition to build backend on Windows
13+
REM to cmake is complete.
14+
SET "SETUPTOOLS_USE_DISTUTILS=stdlib"
15+
16+
SET "DPBENCH_SYCL=1"
17+
18+
"%PYTHON%" setup.py clean --all
19+
20+
set "SKBUILD_ARGS=-G Ninja -- -DCMAKE_C_COMPILER:PATH=icx -DCMAKE_CXX_COMPILER:PATH=icx"
21+
set "SKBUILD_ARGS=%SKBUILD_ARGS% -DCMAKE_VERBOSE_MAKEFILE:BOOL=ON"
22+
23+
FOR %%V IN (14.0.0 14 15.0.0 15 16.0.0 16 17.0.0 17) DO @(
24+
REM set DIR_HINT if directory exists
25+
IF EXIST "%BUILD_PREFIX%\Library\lib\clang\%%V\" (
26+
SET "SYCL_INCLUDE_DIR_HINT=%BUILD_PREFIX%\Library\lib\clang\%%V"
27+
)
28+
)
29+
30+
set "PATCHED_CMAKE_VERSION=3.26"
31+
set "PLATFORM_DIR=%PREFIX%\Library\share\cmake-%PATCHED_CMAKE_VERSION%\Modules\Platform"
32+
set "FN=Windows-IntelLLVM.cmake"
33+
34+
rem Save the original file, and copy patched file to
35+
rem fix the issue with IntelLLVM integration with cmake on Windows
36+
if EXIST "%PLATFORM_DIR%" (
37+
dir "%PLATFORM_DIR%\%FN%"
38+
copy /Y "%PLATFORM_DIR%\%FN%" .
39+
if errorlevel 1 exit 1
40+
copy /Y ".github\workflows\Windows-IntelLLVM_%PATCHED_CMAKE_VERSION%.cmake" "%PLATFORM_DIR%\%FN%"
41+
if errorlevel 1 exit 1
42+
)
43+
44+
if NOT "%WHEELS_OUTPUT_FOLDER%"=="" (
45+
rem Install and assemble wheel package from the build bits
46+
"%PYTHON%" setup.py install bdist_wheel %SKBUILD_ARGS%
47+
if errorlevel 1 exit 1
48+
copy dist\dpbench*.whl %WHEELS_OUTPUT_FOLDER%
49+
if errorlevel 1 exit 1
50+
) ELSE (
51+
rem Only install
52+
"%PYTHON%" setup.py install %SKBUILD_ARGS%
53+
if errorlevel 1 exit 1
54+
)
55+
56+
rem copy back
57+
if EXIST "%PLATFORM_DIR%" (
58+
copy /Y "%FN%" "%PLATFORM_DIR%\%FN%"
59+
if errorlevel 1 exit 1
60+
)

conda-recipe/build.sh

Lines changed: 32 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,32 @@
1+
#!/bin/bash
2+
3+
# SPDX-FileCopyrightText: 2022 - 2023 Intel Corporation
4+
#
5+
# SPDX-License-Identifier: Apache-2.0
6+
7+
# Intel LLVM must cooperate with compiler and sysroot from conda
8+
echo "--gcc-toolchain=${BUILD_PREFIX} --sysroot=${BUILD_PREFIX}/${HOST}/sysroot -target ${HOST}" > icpx_for_conda.cfg
9+
export ICPXCFG="$(pwd)/icpx_for_conda.cfg"
10+
export ICXCFG="$(pwd)/icpx_for_conda.cfg"
11+
12+
export CMAKE_GENERATOR="Ninja"
13+
export DPBENCH_SYCL=1
14+
15+
if [ -e "_skbuild" ]; then
16+
${PYTHON} setup.py clean --all
17+
fi
18+
19+
SKBUILD_ARGS="-- -DCMAKE_C_COMPILER:PATH=icx -DCMAKE_CXX_COMPILER:PATH=icpx -DCMAKE_VERBOSE_MAKEFILE:BOOL=ON"
20+
21+
# Build wheel package
22+
if [ "$CONDA_PY" == "36" ]; then
23+
WHEELS_BUILD_ARGS="-p manylinux1_x86_64"
24+
else
25+
WHEELS_BUILD_ARGS="-p manylinux2014_x86_64"
26+
fi
27+
if [ -n "${WHEELS_OUTPUT_FOLDER}" ]; then
28+
$PYTHON setup.py install bdist_wheel ${WHEELS_BUILD_ARGS} ${SKBUILD_ARGS}
29+
cp dist/dpnp*.whl ${WHEELS_OUTPUT_FOLDER}
30+
else
31+
$PYTHON setup.py install ${SKBUILD_ARGS}
32+
fi

0 commit comments

Comments
 (0)