Skip to content

Commit

Permalink
Add versioneer
Browse files Browse the repository at this point in the history
  • Loading branch information
ZzEeKkAa committed Sep 18, 2023
1 parent f56f819 commit f584153
Show file tree
Hide file tree
Showing 33 changed files with 934 additions and 150 deletions.
1 change: 1 addition & 0 deletions .flake8
Original file line number Diff line number Diff line change
Expand Up @@ -8,4 +8,5 @@ exclude =
__pycache__
./dist
./setup.py
./dpbench/_version.py
max-complexity = 10
5 changes: 5 additions & 0 deletions .gitattributes
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
# SPDX-FileCopyrightText: 2022 - 2023 Intel Corporation
#
# SPDX-License-Identifier: Apache-2.0

dpbench/_version.py export-subst
81 changes: 50 additions & 31 deletions .github/workflows/build_and_run.yml
Original file line number Diff line number Diff line change
Expand Up @@ -11,17 +11,18 @@ on:

env:
# sycl is not included. Add it manually if you need
WORKLOADS: python,numpy,dpnp,numba_n,numba_np,numba_npr,numba_dpex_k,numba_dpex_n,numba_dpex_p,numba_mlir_k,numba_mlir_n,numba_mlir_p
# WORKLOADS: python,numpy,dpnp,numba_n,numba_np,numba_npr,numba_dpex_k,numba_dpex_n,numba_dpex_p,numba_mlir_k,numba_mlir_n,numba_mlir_p
WORKLOADS: python,numpy,dpnp,numba_n,numba_np,numba_npr,numba_dpex_k,numba_dpex_n,numba_dpex_p

jobs:
build_linux:
build:
name: Build and run

strategy:
fail-fast: false
matrix:
os: ["ubuntu-latest", "windows-latest"]
python: ["3.9", "3.10"]
python: ["3.9", "3.10", "3.11"]
sycl: ["sycl","no-sycl"]
install: ["pip", "setup.py"]
include:
Expand All @@ -40,6 +41,10 @@ jobs:

runs-on: ${{matrix.os}}

defaults:
run:
shell: ${{ matrix.os == 'windows-latest' && 'cmd /C CALL {0}' || 'bash -l {0}' }}

steps:
- name: Cancel Previous Runs
uses: styfle/[email protected]
Expand All @@ -51,6 +56,14 @@ jobs:
with:
fetch-depth: 0

# intel:numpy for python 3.11 is not upstreamed yet
- name: Patch numpy dependency for Python 3.11
if: matrix.python == '3.11'
shell: bash -l {0}
run: |
find ./environments -type f | xargs sed -i 's/intel::numpy/numpy/'
find ./environments -type f | xargs sed -i '/numba-mlir/d'
- name: Setup miniconda
uses: conda-incubator/setup-miniconda@v2
with:
Expand All @@ -63,25 +76,10 @@ jobs:
run-post: false

- name: Conda info
shell: bash -el {0}
run: |
conda info
conda list
- name: Setup OpenCL CPU device
if: runner.os == 'Windows'
shell: pwsh
run: |
$script_path="$env:CONDA_PREFIX\Scripts\set-intel-ocl-icd-registry.ps1"
&$script_path
echo "OCL_ICD_FILENAMES=$env:CONDA_PREFIX\Library\lib\intelocl64.dll" >> $env:GITHUB_ENV
echo "LIB=$env:CONDA_PREFIX\Library\lib;$env:CONDA_PREFIX\compiler\lib;$env:LIB" >> $env:GITHUB_ENV
echo "INCLUDE=$env:CONDA_PREFIX\include;$env:INCLUDE" >> $env:GITHUB_ENV
# Check the variable assisting OpenCL CPU driver to find TBB DLLs which are not located where it expects them by default
$cl_cfg="$env:CONDA_PREFIX\Library\lib\cl.cfg"
Get-Content -Tail 5 -Path $cl_cfg
- name: Configure Python
if: runner.os == 'Windows'
shell: pwsh
Expand All @@ -107,32 +105,53 @@ jobs:
echo "CXX=${{matrix.cxx}}" >> "$GITHUB_ENV"
echo "DPBENCH_SYCL=1" >> "$GITHUB_ENV"
echo "WORKLOADS=$WORKLOADS,sycl" >> "$GITHUB_ENV"
echo "CMAKE_GENERATOR=Ninja" >> "$GITHUB_ENV"
- name: Configure MSBuild
if: runner.os == 'Windows'
uses: microsoft/[email protected]
with:
vs-version: '14.35'

- name: Populate conda environment paths
if: runner.os == 'Windows'
shell: pwsh
run: |
echo "LIB=$env:CONDA_PREFIX\Library\lib;$env:CONDA_PREFIX\compiler\lib;$env:LIB" >> $env:GITHUB_ENV
echo "INCLUDE=$env:CONDA_PREFIX\include;$env:INCLUDE" >> $env:GITHUB_ENV
- name: Build dpbench
if: matrix.install == 'pip'
shell: bash -el {0}
run: |
pip install \
--no-index --no-deps --no-build-isolation -e . -v
run: pip install --no-index --no-deps --no-build-isolation -e . -v

- name: Build dpbench
if: matrix.install == 'setup.py'
shell: bash -el {0}
run: |
python setup.py develop
run: python setup.py develop

- name: Run benchmarks
- name: Configure dpbench
shell: bash -el {0}
run: |
export NUMBA_MLIR_GPU_RUNTIME=sycl
# Turn off numba-dpex autofall back
export NUMBA_DPEX_FALLBACK_ON_CPU=0
# Make sure numba-dpex is using native atomics in github CI
export NUMBA_DPEX_ACTIVATE_ATOMICS_FP_NATIVE=1
dpbench -i ${WORKLOADS} run -r2 --no-print-results || exit 1
# - name: Setup OpenCL CPU device
# if: runner.os == 'Windows'
# shell: pwsh
# run: |
# $script_path="$env:CONDA_PREFIX\Scripts\set-intel-ocl-icd-registry.ps1"
# &$script_path
# echo "OCL_ICD_FILENAMES=$env:CONDA_PREFIX\Library\lib\intelocl64.dll" >> $env:GITHUB_ENV
# echo "LIB=$env:CONDA_PREFIX\Library\lib;$env:CONDA_PREFIX\compiler\lib;$env:LIB" >> $env:GITHUB_ENV
# echo "INCLUDE=$env:CONDA_PREFIX\include;$env:INCLUDE" >> $env:GITHUB_ENV
# # Check the variable assisting OpenCL CPU driver to find TBB DLLs which are not located where it expects them by default
# $cl_cfg="$env:CONDA_PREFIX\Library\lib\cl.cfg"
# Get-Content -Tail 5 -Path $cl_cfg

- name: Run benchmarks
shell: bash -el {0}
run: dpbench -i ${WORKLOADS} run -r2 --no-print-results || exit 1

- name: Generate report
shell: bash -el {0}
run: |
dpbench -i ${WORKLOADS} report || exit 1
run: dpbench -i ${WORKLOADS} report || exit 1
13 changes: 10 additions & 3 deletions .github/workflows/conda-package.yml
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,7 @@ env:
PACKAGE_NAME: dpbench
MODULE_NAME: dpbench
# There is a separate action that removes defaults.
CHANNELS: 'dppy/label/dev,conda-forge,intel'
CHANNELS: 'dppy/label/dev,conda-forge,intel,nodefaults'
VER_JSON_NAME: 'version.json'
VER_SCRIPT1: "import json; f = open('version.json', 'r'); j = json.load(f); f.close(); "
VER_SCRIPT2: "d = j['dpbench'][0]; print('='.join((d[s] for s in ('version', 'build'))))"
Expand All @@ -26,14 +26,14 @@ jobs:
strategy:
fail-fast: false
matrix:
python: ['3.9', '3.10']
python: ['3.9', '3.10', '3.11']
os: [ubuntu-latest, windows-latest]

runs-on: ${{ matrix.os }}

defaults:
run:
shell: bash -l {0}
shell: ${{ matrix.os == 'windows-latest' && 'cmd /C CALL {0}' || 'bash -l {0}' }}

continue-on-error: false

Expand Down Expand Up @@ -63,12 +63,19 @@ jobs:
run: conda config --remove channels defaults

- name: Store conda paths as envs
shell: bash -l {0}
run: echo "CONDA_BLD=$CONDA_PREFIX/conda-bld/${{ runner.os == 'Linux' && 'linux' || 'win' }}-64/" | tr "\\" '/' >> $GITHUB_ENV

# boa is an extention to conda so we can use mamba resolver in conda build
- name: Install conda-build
run: mamba install boa

- name: Configure MSBuild
if: runner.os == 'Windows'
uses: microsoft/[email protected]
with:
vs-version: '14.35'

- name: Build conda package
run: conda mambabuild --no-test --python ${{ matrix.python }} conda-recipe

Expand Down
26 changes: 22 additions & 4 deletions CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@
#
# SPDX-License-Identifier: Apache-2.0

cmake_minimum_required(VERSION 3.22 FATAL_ERROR)
cmake_minimum_required(VERSION 3.22..3.27 FATAL_ERROR)

project(dpbench
LANGUAGES CXX
Expand All @@ -14,10 +14,28 @@ project(dpbench
set(CMAKE_FIND_ROOT_PATH_MODE_INCLUDE BOTH)
set(CMAKE_FIND_ROOT_PATH_MODE_LIBRARY BOTH)

find_package(Python 3.9 REQUIRED
COMPONENTS Interpreter Development.Module)

if(NOT DEFINED DPCTL_LIBRARY_PATH)
execute_process(
COMMAND ${Python3_EXECUTABLE} -c "import dpctl,os; print(os.path.dirname(dpctl.__file__));"
OUTPUT_VARIABLE DPCTL_LIBRARY_PATH
RESULT_VARIABLE RET
OUTPUT_STRIP_TRAILING_WHITESPACE
)

if(RET EQUAL "1")
message(FATAL_ERROR "Module \'dpctl\' not found.")
endif()
endif()

cmake_path(APPEND DPCTL_MODULE_PATH ${DPCTL_LIBRARY_PATH} resources cmake)
list(APPEND CMAKE_MODULE_PATH ${DPCTL_MODULE_PATH})

find_package(pybind11 CONFIG REQUIRED)
find_package(IntelDPCPP REQUIRED)
find_package(PythonExtensions REQUIRED)
find_package(Python3 COMPONENTS NumPy Development)
find_package(IntelSYCL REQUIRED)
find_package(Dpctl REQUIRED)

set(CMAKE_CXX_STANDARD 17)
set(CMAKE_CXX_STANDARD_REQUIRED True)
Expand Down
7 changes: 4 additions & 3 deletions conda-recipe/bld.bat
Original file line number Diff line number Diff line change
Expand Up @@ -15,9 +15,10 @@ SET "SETUPTOOLS_USE_DISTUTILS=stdlib"

SET "DPBENCH_SYCL=1"

"%PYTHON%" setup.py clean --all
@REM "%PYTHON%" setup.py clean --all

set "SKBUILD_ARGS=-G Ninja -- -DCMAKE_C_COMPILER:PATH=icx -DCMAKE_CXX_COMPILER:PATH=icx"
@REM set "SKBUILD_ARGS=%SKBUILD_ARGS% -DMSVC_TOOLSET_VERSION=141"
set "SKBUILD_ARGS=%SKBUILD_ARGS% -DCMAKE_VERBOSE_MAKEFILE:BOOL=ON"

FOR %%V IN (14.0.0 14 15.0.0 15 16.0.0 16 17.0.0 17) DO @(
Expand All @@ -43,13 +44,13 @@ if EXIST "%PLATFORM_DIR%" (

if NOT "%WHEELS_OUTPUT_FOLDER%"=="" (
rem Install and assemble wheel package from the build bits
"%PYTHON%" setup.py install bdist_wheel %SKBUILD_ARGS%
"%PYTHON%" setup.py install bdist_wheel --single-version-externally-managed --record=record.txt %SKBUILD_ARGS%
if errorlevel 1 exit 1
copy dist\dpbench*.whl %WHEELS_OUTPUT_FOLDER%
if errorlevel 1 exit 1
) ELSE (
rem Only install
"%PYTHON%" setup.py install %SKBUILD_ARGS%
"%PYTHON%" setup.py install --single-version-externally-managed --record=record.txt %SKBUILD_ARGS%
if errorlevel 1 exit 1
)

Expand Down
36 changes: 21 additions & 15 deletions conda-recipe/build.sh
Original file line number Diff line number Diff line change
@@ -1,32 +1,38 @@
#!/bin/bash
#!/bin/bash -x

# SPDX-FileCopyrightText: 2022 - 2023 Intel Corporation
#
# SPDX-License-Identifier: Apache-2.0

# Intel LLVM must cooperate with compiler and sysroot from conda
export LD_LIBRARY_PATH="$LD_LIBRARY_PATH:${BUILD_PREFIX}/lib"

echo "--gcc-toolchain=${BUILD_PREFIX} --sysroot=${BUILD_PREFIX}/${HOST}/sysroot -target ${HOST}" > icpx_for_conda.cfg
export ICPXCFG="$(pwd)/icpx_for_conda.cfg"
export ICXCFG="$(pwd)/icpx_for_conda.cfg"

export CMAKE_GENERATOR="Ninja"
export DPBENCH_SYCL=1
export CMAKE_GENERATOR="Ninja"
export CC=icx
export CXX=icpx

if [ -e "_skbuild" ]; then
${PYTHON} setup.py clean --all
fi

SKBUILD_ARGS="-- -DCMAKE_C_COMPILER:PATH=icx -DCMAKE_CXX_COMPILER:PATH=icpx -DCMAKE_VERBOSE_MAKEFILE:BOOL=ON"
# declare -a ARGS=(install --single-version-externally-managed --record=record.txt)

# Build wheel package
if [ "$CONDA_PY" == "36" ]; then
WHEELS_BUILD_ARGS="-p manylinux1_x86_64"
else
WHEELS_BUILD_ARGS="-p manylinux2014_x86_64"
fi
if [ -n "${WHEELS_OUTPUT_FOLDER}" ]; then
$PYTHON setup.py install bdist_wheel ${WHEELS_BUILD_ARGS} ${SKBUILD_ARGS}
cp dist/dpnp*.whl ${WHEELS_OUTPUT_FOLDER}
else
$PYTHON setup.py install ${SKBUILD_ARGS}
fi
# if [[ -v WHEELS_OUTPUT_FOLDER ]]; then
# ARGS+=(bdist_wheel -p manylinux2014_x86_64)
# fi

# ARGS+=(-G Ninja -- -DCMAKE_C_COMPILER:PATH=icx -DCMAKE_CXX_COMPILER:PATH=icpx -DCMAKE_VERBOSE_MAKEFILE:BOOL=ON)

# echo "${ARGS[*]}"

# $PYTHON setup.py ${ARGS[@]}
$PYTHON -m pip install --no-index --no-deps --no-build-isolation . -v

# if [[ -v WHEELS_OUTPUT_FOLDER ]]; then
# cp dist/numba_dpex*.whl "${WHEELS_OUTPUT_FOLDER[@]}"
# fi
38 changes: 20 additions & 18 deletions conda-recipe/meta.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -4,32 +4,33 @@

package:
name: dpbench
version: 0.1
version: {{ GIT_DESCRIBE_TAG }}

source:
path: ..

build:
number: {{ GIT_DESCRIBE_NUMBER }}
script_env:
- WHEELS_OUTPUT_FOLDER

requirements:
build:
- {{ compiler('cxx') }}
- {{ compiler('dpcpp') }} >=2023.1 # [not osx]
# - conda-forge::dpcpp_win-64 # [windows]
- sysroot_linux-64 >=2.28 # [linux]
host:
- pip
- python
- setuptools
- cmake
- ninja
- wheel
- cmake==3.26* # [win]
- cmake # [not win]
- ninja # [not win]
- scikit-build
- cython
- pybind11
# runtime requirements, cause conda tries to install after build
# - tomli
# - alembic
# - sqlalchemy
# - py-cpuinfo
# - scipy
# - scikit-learn
# - pandas
- versioneer
- intel::numpy
- numba
- dpctl
Expand All @@ -40,11 +41,12 @@ requirements:
- tomli
- alembic
- sqlalchemy
# - py-cpuinfo
# - versioneer
- py-cpuinfo
- scipy
- scikit-learn
- pandas
- numpy
- intel::numpy
- numba
- dpctl
- dpnp
Expand All @@ -60,10 +62,10 @@ test:
- numba-dpex
- numba
- numpy
imports:
- dpbench
commands:
- python -c "import dpbench"
# imports:
# - dpbench
# commands:
# - python -c "import dpbench"

about:
home: https://github.com/IntelPython/dpbench
Expand Down
Loading

0 comments on commit f584153

Please sign in to comment.