From 28d779ffc83a565f2590a737d95b178606f424b5 Mon Sep 17 00:00:00 2001 From: Adarsh Yoga Date: Wed, 24 Apr 2024 05:18:56 +0000 Subject: [PATCH 01/10] change private arrays to use new dpex api --- dpbench/benchmarks/default/gpairs/gpairs_numba_dpex_k.py | 8 ++++---- dpbench/benchmarks/default/kmeans/kmeans_numba_dpex_k.py | 4 ++-- dpbench/benchmarks/default/knn/knn_numba_dpex_k.py | 2 +- 3 files changed, 7 insertions(+), 7 deletions(-) diff --git a/dpbench/benchmarks/default/gpairs/gpairs_numba_dpex_k.py b/dpbench/benchmarks/default/gpairs/gpairs_numba_dpex_k.py index 52034cef..f5a72b00 100644 --- a/dpbench/benchmarks/default/gpairs/gpairs_numba_dpex_k.py +++ b/dpbench/benchmarks/default/gpairs/gpairs_numba_dpex_k.py @@ -38,9 +38,9 @@ def count_weighted_pairs_3d_intel_no_slm_ker( n_wi = 32 - dsq_mat = dpex.private.array(shape=(32 * 32), dtype=dtype) - w0_vec = dpex.private.array(shape=(32), dtype=dtype) - w1_vec = dpex.private.array(shape=(32), dtype=dtype) + dsq_mat = kapi.PrivateArray(shape=(32 * 32), dtype=dtype) + w0_vec = kapi.PrivateArray(shape=(32), dtype=dtype) + w1_vec = kapi.PrivateArray(shape=(32), dtype=dtype) offset0 = gr0 * n_wi * lws0 + lid0 offset1 = gr1 * n_wi * lws1 + lid1 @@ -80,7 +80,7 @@ def count_weighted_pairs_3d_intel_no_slm_ker( # update slm_hist. Use work-item private buffer of 16 tfloat elements for k in range(0, slm_hist_size, private_hist_size): - private_hist = dpex.private.array(shape=(32), dtype=dtype) + private_hist = kapi.PrivateArray(shape=(32), dtype=dtype) for p in range(private_hist_size): private_hist[p] = 0.0 diff --git a/dpbench/benchmarks/default/kmeans/kmeans_numba_dpex_k.py b/dpbench/benchmarks/default/kmeans/kmeans_numba_dpex_k.py index 6bac670c..c89b6b8d 100644 --- a/dpbench/benchmarks/default/kmeans/kmeans_numba_dpex_k.py +++ b/dpbench/benchmarks/default/kmeans/kmeans_numba_dpex_k.py @@ -56,7 +56,7 @@ def groupByCluster( for i in range(WorkPI): point_id = grid * WorkPI * local_size + i * local_size + lid if point_id < numpoints: - localP = dpex.private.array(dims, dtyp) + localP = kapi.PrivateArray(dims, dtyp) for d in range(dims): localP[d] = arrayP[point_id, d] @@ -179,7 +179,7 @@ def updateLabels( for i in range(WorkPI): point_id = grid * WorkPI * local_size + i * local_size + lid if point_id < numpoints: - localP = dpex.private.array(dims, dtyp) + localP = kapi.PrivateArray(dims, dtyp) for d in range(dims): localP[d] = arrayP[point_id, d] diff --git a/dpbench/benchmarks/default/knn/knn_numba_dpex_k.py b/dpbench/benchmarks/default/knn/knn_numba_dpex_k.py index 8771efa6..4ec82875 100644 --- a/dpbench/benchmarks/default/knn/knn_numba_dpex_k.py +++ b/dpbench/benchmarks/default/knn/knn_numba_dpex_k.py @@ -25,7 +25,7 @@ def _knn_kernel( # noqa: C901: TODO: can we simplify logic? dtype = train.dtype i = item.get_id(0) # here k has to be 5 in order to match with numpy - queue_neighbors = dpex.private.array(shape=(5, 2), dtype=dtype) + queue_neighbors = kapi.PrivateArray(shape=(5, 2), dtype=dtype) for j in range(k): x1 = train[j] From 36e3c36df3973a9515b5ed6686cae55dcdd44a59 Mon Sep 17 00:00:00 2001 From: Adarsh Yoga Date: Wed, 24 Apr 2024 05:19:40 +0000 Subject: [PATCH 02/10] change dpctl.asarray calls in dpcpp framework --- dpbench/infrastructure/frameworks/dpcpp_framework.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/dpbench/infrastructure/frameworks/dpcpp_framework.py b/dpbench/infrastructure/frameworks/dpcpp_framework.py index 21b4c336..7c47fd12 100644 --- a/dpbench/infrastructure/frameworks/dpcpp_framework.py +++ b/dpbench/infrastructure/frameworks/dpcpp_framework.py @@ -59,7 +59,7 @@ def _copy_to_func_impl(ref_array): else: order = "K" return dpt.asarray( - obj=ref_array, + ref_array, dtype=ref_array.dtype, device=self.sycl_device, copy=None, From 45cb63fe9705c1885d166ef9fe1b30fc26a36729 Mon Sep 17 00:00:00 2001 From: Adarsh Yoga Date: Wed, 24 Apr 2024 05:20:50 +0000 Subject: [PATCH 03/10] fix version pinning in yml file --- conda-recipe/meta.yaml | 2 +- dpbench/configs/framework_info/dpcpp.toml | 2 +- environments/conda-linux-sycl.yml | 5 ++--- environments/conda-win-sycl.yml | 2 +- 4 files changed, 5 insertions(+), 6 deletions(-) diff --git a/conda-recipe/meta.yaml b/conda-recipe/meta.yaml index cb2ff422..b1e19f30 100644 --- a/conda-recipe/meta.yaml +++ b/conda-recipe/meta.yaml @@ -17,7 +17,7 @@ build: requirements: build: - {{ compiler('cxx') }} - - {{ compiler('dpcpp') }} ==2024.0.0 # [not osx] + - {{ compiler('dpcpp') }} - sysroot_linux-64 >=2.28 # [linux] host: - python diff --git a/dpbench/configs/framework_info/dpcpp.toml b/dpbench/configs/framework_info/dpcpp.toml index 77ce097d..c1655e91 100644 --- a/dpbench/configs/framework_info/dpcpp.toml +++ b/dpbench/configs/framework_info/dpcpp.toml @@ -10,7 +10,7 @@ postfix = "dpcpp" class = "DpcppFramework" arch = "cpu" sycl_device = "cpu" -dpcpp_version = "IntelLLVM 2024.0.0" +dpcpp_version = "IntelLLVM 2024.1.0" [[framework.postfixes]] impl_postfix = "sycl" diff --git a/environments/conda-linux-sycl.yml b/environments/conda-linux-sycl.yml index e51648a3..d0b4113a 100644 --- a/environments/conda-linux-sycl.yml +++ b/environments/conda-linux-sycl.yml @@ -23,9 +23,8 @@ dependencies: - dpctl - dpnp - numba-dpex - # TODO: fix issues on conda-forge build - - intel::dpcpp_linux-64==2024.0.0 - - intel::dpcpp-cpp-rt==2024.0.0 + - intel::dpcpp_linux-64 + - intel::dpcpp-cpp-rt - cython - cmake - ninja diff --git a/environments/conda-win-sycl.yml b/environments/conda-win-sycl.yml index 89ad4c9b..d3160f22 100644 --- a/environments/conda-win-sycl.yml +++ b/environments/conda-win-sycl.yml @@ -25,7 +25,7 @@ dependencies: - numba-dpex # TODO: switch to conda-forge, but it results in broken OpenCL rt (see below) # - conda-forge::dpcpp_win-64 - - intel::dpcpp_win-64==2024.0.0 + - intel::dpcpp_win-64 # fixing cmake version here, because we need to apply patch for IntelLLVM - cmake==3.26* - cython From 35ee147deb8a7ce7cb5651f5cffb93e2738d280b Mon Sep 17 00:00:00 2001 From: Adarsh Yoga Date: Wed, 24 Apr 2024 05:21:19 +0000 Subject: [PATCH 04/10] fix knn failure on windows due to mismatch in types and precision --- dpbench/benchmarks/default/knn/knn_initialize.py | 4 +++- .../knn/knn_sycl_native_ext/knn_sycl/_knn_kernel.hpp | 12 ++++++------ .../knn/knn_sycl_native_ext/knn_sycl/_knn_sycl.cpp | 2 +- 3 files changed, 10 insertions(+), 8 deletions(-) diff --git a/dpbench/benchmarks/default/knn/knn_initialize.py b/dpbench/benchmarks/default/knn/knn_initialize.py index 720b4348..bcab0280 100644 --- a/dpbench/benchmarks/default/knn/knn_initialize.py +++ b/dpbench/benchmarks/default/knn/knn_initialize.py @@ -24,7 +24,9 @@ def _gen_data_x(ip_size, data_dim, seed, dtype): def _gen_data_y(ip_size, classes_num, seed): default_rng.seed(seed) - data = default_rng.randint(classes_num, size=ip_size) + data = default_rng.randint( + classes_num, size=ip_size, dtype=types_dict["int"] + ) return data def _gen_train_data(train_size, data_dim, classes_num, seed_train, dtype): diff --git a/dpbench/benchmarks/default/knn/knn_sycl_native_ext/knn_sycl/_knn_kernel.hpp b/dpbench/benchmarks/default/knn/knn_sycl_native_ext/knn_sycl/_knn_kernel.hpp index ac1bcbf3..cd9e2623 100644 --- a/dpbench/benchmarks/default/knn/knn_sycl_native_ext/knn_sycl/_knn_kernel.hpp +++ b/dpbench/benchmarks/default/knn/knn_sycl_native_ext/knn_sycl/_knn_kernel.hpp @@ -7,16 +7,16 @@ template class theKernel; -template struct neighbors +template struct neighbors { FpTy dist; - size_t label; + IntTy label; }; template sycl::event knn_impl(sycl::queue q, FpTy *d_train, - size_t *d_train_labels, + IntTy *d_train_labels, FpTy *d_test, size_t k, size_t classes_num, @@ -33,7 +33,7 @@ sycl::event knn_impl(sycl::queue q, // here k has to be 5 in order to match with numpy no. of // neighbors - struct neighbors queue_neighbors[5]; + struct neighbors queue_neighbors[5]; // count distances for (size_t j = 0; j < k; ++j) { @@ -54,7 +54,7 @@ sycl::event knn_impl(sycl::queue q, for (size_t j = 0; j < k; ++j) { // push queue FpTy new_distance = queue_neighbors[j].dist; - FpTy new_neighbor_label = queue_neighbors[j].label; + IntTy new_neighbor_label = queue_neighbors[j].label; size_t index = j; while (index > 0 && new_distance < queue_neighbors[index - 1].dist) @@ -83,7 +83,7 @@ sycl::event knn_impl(sycl::queue q, // push queue FpTy new_distance = queue_neighbors[k - 1].dist; - FpTy new_neighbor_label = queue_neighbors[k - 1].label; + IntTy new_neighbor_label = queue_neighbors[k - 1].label; size_t index = k - 1; while (index > 0 && diff --git a/dpbench/benchmarks/default/knn/knn_sycl_native_ext/knn_sycl/_knn_sycl.cpp b/dpbench/benchmarks/default/knn/knn_sycl_native_ext/knn_sycl/_knn_sycl.cpp index 97938bb0..43f2b1b9 100644 --- a/dpbench/benchmarks/default/knn/knn_sycl_native_ext/knn_sycl/_knn_sycl.cpp +++ b/dpbench/benchmarks/default/knn/knn_sycl_native_ext/knn_sycl/_knn_sycl.cpp @@ -43,7 +43,7 @@ void knn_sync(dpctl::tensor::usm_ndarray x_train, if (typenum == UAR_FLOAT) { sycl::event res_ev = knn_impl( x_train.get_queue(), x_train.get_data(), - y_train.get_data(), x_test.get_data(), k, + y_train.get_data(), x_test.get_data(), k, classes_num, train_size, test_size, predictions.get_data(), votes_to_classes.get_data(), data_dim); From 86056f6550e0cbbd331c98f24fa17183c2f5741e Mon Sep 17 00:00:00 2001 From: Yevhenii Havrylko Date: Tue, 30 Apr 2024 17:40:23 -0400 Subject: [PATCH 05/10] Organize package meta --- conda-recipe/meta.yaml | 41 +++++++++++++++-------------------------- pyproject.toml | 36 +++++++++++++++++++++--------------- 2 files changed, 36 insertions(+), 41 deletions(-) diff --git a/conda-recipe/meta.yaml b/conda-recipe/meta.yaml index b1e19f30..dfde4348 100644 --- a/conda-recipe/meta.yaml +++ b/conda-recipe/meta.yaml @@ -2,6 +2,10 @@ # # SPDX-License-Identifier: Apache-2.0 +{% set pyproject = load_file_data('pyproject.toml') %} +{% set py_deps = pyproject.get('project', {}).get('dependencies', []) %} +{% set py_build_deps = pyproject.get('build-system', {}).get('requires', []) %} + package: name: dpbench version: {{ GIT_DESCRIBE_TAG }} @@ -18,36 +22,21 @@ requirements: build: - {{ compiler('cxx') }} - {{ compiler('dpcpp') }} + # This is required to get compatible headers with the system installed glibc - sysroot_linux-64 >=2.28 # [linux] host: - python - - setuptools - - cmake==3.26* # [win] - - cmake # [not win] - - ninja # [not win] - - scikit-build - - cython - - pybind11 - - versioneer - - intel::numpy - - numba - - dpctl - - dpnp - - numba-dpex + {% for dep in py_build_deps %} + {% if dep.startswith('ninja') %} + - {{ dep.split(';')[0] }} # [not win] + {% else %} + - {{ dep|replace('_','-') }} + {% endif %} + {% endfor %} run: - - python - - tomli - - alembic - - sqlalchemy - - py-cpuinfo - - scipy - - scikit-learn - - pandas - - intel::numpy - - numba - - dpctl - - dpnp - - numba-dpex + {% for dep in py_deps %} + - {{ dep|replace('_','-') }} + {% endfor %} test: requires: diff --git a/pyproject.toml b/pyproject.toml index cfc33785..5c6c1f2c 100644 --- a/pyproject.toml +++ b/pyproject.toml @@ -28,26 +28,25 @@ classifiers = [ license = { text = "Apache-2.0" } requires-python = ">=3.9" dependencies = [ - "tomli", + "tomli>=2.0.0", "alembic>=1.10.0", "sqlalchemy>=2.0.0", - "py-cpuinfo", - "scipy", - "scikit_learn", - "pandas", - "numpy", - "dpctl", - "dpnp", - "numba", - "numba_dpex", + "py-cpuinfo>=9.0.0", + "scipy>=1.13.0", + "scikit_learn>=1.4.0", + "pandas>=2.2.0", + "numpy>=1.24.0", + "dpctl>=0.16.1", + "dpnp>=0.14.0", + "numba>=0.59.0", + "numba_dpex>=0.23.0a0", ] -dynamic =["version"] +dynamic = ["version"] [project.optional-dependencies] numba-mlir = ["numba_mlir"] color-config = ["pygments"] -sycl-build = ["scikit-build>=0.13", "cmake>=3.18", "ninja"] -npbench = ["dace","dask","legate"] +npbench = ["dace", "dask", "legate"] json-to-toml = ["tomli_w"] expected-failure = ["tomlkit"] @@ -62,8 +61,15 @@ dpbench = "dpbench.console.entry:main" # TODO: make it optional for no sycl build. Workaround: `--no-deps`. # https://github.com/scikit-build/scikit-build/issues/981 requires = [ - "setuptools>=42,<64", - "versioneer[toml]", + "setuptools>=63.0.0", + "scikit-build>=0.17.0", # sycl build dep + "ninja>=1.11.1; platform_system!='Windows'", # sycl build dep + "cmake>=3.29.0", # sycl build dep + # We need dpctl for UsmNdArray integration for dpcpp code + "dpctl>=0.16.1", + "pybind11>=2.12.0", + # WARNING: check with doc how to upgrade + "versioneer[toml]==0.29", ] build-backend = "setuptools.build_meta" From 26f0ceb04784232148cb547308129a4cb0003f77 Mon Sep 17 00:00:00 2001 From: Yevhenii Havrylko Date: Tue, 30 Apr 2024 18:01:21 -0400 Subject: [PATCH 06/10] Migrate package build to python-build --- conda-recipe/bld.bat | 45 +++++++++++++++++++++++++++++++----------- conda-recipe/build.sh | 34 ++++++++++++++++++++----------- conda-recipe/meta.yaml | 19 ++++++++++++------ pyproject.toml | 3 +++ 4 files changed, 73 insertions(+), 28 deletions(-) diff --git a/conda-recipe/bld.bat b/conda-recipe/bld.bat index f08875ae..8b4ca425 100644 --- a/conda-recipe/bld.bat +++ b/conda-recipe/bld.bat @@ -17,8 +17,8 @@ set "DPBENCH_SYCL=1" set "CMAKE_GENERATOR=Ninja" set "CC=icx" set "CXX=icx" - -"%PYTHON%" setup.py clean --all +:: Make CMake verbose +set "VERBOSE=1" FOR %%V IN (14.0.0 14 15.0.0 15 16.0.0 16 17.0.0 17) DO @( REM set DIR_HINT if directory exists @@ -41,18 +41,41 @@ if EXIST "%PLATFORM_DIR%" ( if errorlevel 1 exit 1 ) -@REM TODO: switch to pip build. Currently results in broken binary -@REM %PYTHON% -m pip install --no-index --no-deps --no-build-isolation . -v +:: -wnx flags mean: --wheel --no-isolation --skip-dependency-check +%PYTHON% -m build -w -n -x +if %ERRORLEVEL% neq 0 exit 1 + +:: `pip install dist\dpbench*.whl` does not work on windows, +:: so use a loop; there's only one wheel in dist/ anyway +for /f %%f in ('dir /b /S .\dist') do ( + %PYTHON% -m wheel tags --remove --build %GIT_DESCRIBE_NUMBER% %%f + if %ERRORLEVEL% neq 0 exit 1 +) + +:: wheel file was renamed +for /f %%f in ('dir /b /S .\dist') do ( + %PYTHON% -m pip install %%f ^ + --no-build-isolation ^ + --no-deps ^ + --only-binary :all: ^ + --no-index ^ + --prefix %PREFIX% ^ + -vv + if %ERRORLEVEL% neq 0 exit 1 +) + +:: Must be consistent with pyproject.toml project.scritps. Currently pip does +:: not allow to ignore scripts installation, so we have to remove them manually. +:: https://github.com/pypa/pip/issues/3980 +:: We have to let conda-build manage it for use in order to set proper python +:: path. +:: https://docs.conda.io/projects/conda-build/en/stable/resources/define-metadata.html#python-entry-points +rm %PREFIX%\Scripts\dpbench.exe + +:: Copy wheel package if NOT "%WHEELS_OUTPUT_FOLDER%"=="" ( - rem Install and assemble wheel package from the build bits - "%PYTHON%" setup.py install --single-version-externally-managed --record=record.txt bdist_wheel --build-number %GIT_DESCRIBE_NUMBER% - 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 --single-version-externally-managed --record=record.txt - if errorlevel 1 exit 1 ) rem copy back diff --git a/conda-recipe/build.sh b/conda-recipe/build.sh index 544ce140..c06023cb 100644 --- a/conda-recipe/build.sh +++ b/conda-recipe/build.sh @@ -16,18 +16,30 @@ export CMAKE_GENERATOR="Ninja" export CC=icx export CXX=icpx -if [ -e "_skbuild" ]; then - ${PYTHON} setup.py clean --all -fi - # TODO: switch to pip build. Currently results in broken binary on Windows # $PYTHON -m pip install --no-index --no-deps --no-build-isolation . -v -# Build wheel package -if [ -n "${WHEELS_OUTPUT_FOLDER}" ]; then - $PYTHON setup.py install --single-version-externally-managed --record=record.txt bdist_wheel -p manylinux2014_x86_64 --build-number $GIT_DESCRIBE_NUMBER - mkdir -p ${WHEELS_OUTPUT_FOLDER} - cp dist/dpbench*.whl ${WHEELS_OUTPUT_FOLDER} -else - $PYTHON setup.py install --single-version-externally-managed --record=record.txt +# -wnx flags mean: --wheel --no-isolation --skip-dependency-check +${PYTHON} -m build -w -n -x +${PYTHON} -m wheel tags --remove --build "$GIT_DESCRIBE_NUMBER" \ + --platform-tag manylinux2014_x86_64 dist/dpbench*.whl +${PYTHON} -m pip install dist/dpbench*.whl \ + --no-build-isolation \ + --no-deps \ + --only-binary :all: \ + --no-index \ + --prefix ${PREFIX} \ + -vv + +# Must be consistent with pyproject.toml project.scritps. Currently pip does +# not allow to ignore scripts installation, so we have to remove them manually. +# https://github.com/pypa/pip/issues/3980 +# We have to let conda-build manage it for use in order to set proper python +# path. +# https://docs.conda.io/projects/conda-build/en/stable/resources/define-metadata.html#python-entry-points +rm ${PREFIX}/bin/dpbench + +# Copy wheel package +if [[ -v WHEELS_OUTPUT_FOLDER ]]; then + cp dist/dpbench*.whl "${WHEELS_OUTPUT_FOLDER[@]}" fi diff --git a/conda-recipe/meta.yaml b/conda-recipe/meta.yaml index dfde4348..1c8561f3 100644 --- a/conda-recipe/meta.yaml +++ b/conda-recipe/meta.yaml @@ -5,6 +5,7 @@ {% set pyproject = load_file_data('pyproject.toml') %} {% set py_deps = pyproject.get('project', {}).get('dependencies', []) %} {% set py_build_deps = pyproject.get('build-system', {}).get('requires', []) %} +{% set project_scripts = pyproject.get('project', {}).get('scripts', {}) %} package: name: dpbench @@ -17,6 +18,10 @@ build: number: {{ GIT_DESCRIBE_NUMBER }} script_env: - WHEELS_OUTPUT_FOLDER + entry_points: + {% for script, module in project_scripts | dictsort %} + - {{ script ~ " = " ~ module }} + {% endfor %} requirements: build: @@ -26,9 +31,15 @@ requirements: - sysroot_linux-64 >=2.28 # [linux] host: - python + - pip {% for dep in py_build_deps %} {% if dep.startswith('ninja') %} - {{ dep.split(';')[0] }} # [not win] + {% elif dep.startswith('cmake') %} + - cmake=3.26 # [win] + - {{ dep }} # [not win] + {% elif dep.startswith('build>=') %} + - {{ 'python-' ~ dep }} {% else %} - {{ dep|replace('_','-') }} {% endif %} @@ -39,12 +50,8 @@ requirements: {% endfor %} test: - requires: - - dpctl - - dpnp - - numba-dpex - - numba - - numpy + commands: + - dpbench --help about: home: https://github.com/IntelPython/dpbench diff --git a/pyproject.toml b/pyproject.toml index 5c6c1f2c..dded7fec 100644 --- a/pyproject.toml +++ b/pyproject.toml @@ -55,12 +55,15 @@ expected-failure = ["tomlkit"] "Homepage" = "https://https://github.com/IntelPython/dpbench" [project.scripts] +# Keep consistent with conda build scripts dpbench = "dpbench.console.entry:main" [build-system] # TODO: make it optional for no sycl build. Workaround: `--no-deps`. # https://github.com/scikit-build/scikit-build/issues/981 requires = [ + "wheel>=0.43", + "build>=1.1", "setuptools>=63.0.0", "scikit-build>=0.17.0", # sycl build dep "ninja>=1.11.1; platform_system!='Windows'", # sycl build dep From 6542b52919e4a6611975430316f75fd15f933965 Mon Sep 17 00:00:00 2001 From: Yevhenii Havrylko Date: Wed, 1 May 2024 16:10:20 -0400 Subject: [PATCH 07/10] Use conda build over mambabuild --- .github/workflows/build_and_run.yml | 1 - .github/workflows/conda-package.yml | 29 ++++++++++++++--------------- 2 files changed, 14 insertions(+), 16 deletions(-) diff --git a/.github/workflows/build_and_run.yml b/.github/workflows/build_and_run.yml index 959092aa..b2d90013 100644 --- a/.github/workflows/build_and_run.yml +++ b/.github/workflows/build_and_run.yml @@ -77,7 +77,6 @@ jobs: uses: conda-incubator/setup-miniconda@v2 with: python-version: ${{ matrix.python }} - miniforge-variant: Mambaforge miniforge-version: latest activate-environment: "build" channel-priority: "disabled" diff --git a/.github/workflows/conda-package.yml b/.github/workflows/conda-package.yml index e11d8430..15e0960d 100644 --- a/.github/workflows/conda-package.yml +++ b/.github/workflows/conda-package.yml @@ -55,15 +55,13 @@ jobs: fetch-depth: 0 - name: Setup miniconda - uses: conda-incubator/setup-miniconda@v2 + uses: conda-incubator/setup-miniconda@v3 with: - python-version: ${{ matrix.python }} - miniforge-variant: Mambaforge - miniforge-version: latest - activate-environment: "build" + auto-activate-base: true + activate-environment: "" channels: ${{ env.CHANNELS }} channel-priority: "disabled" - run-post: false + miniforge-version: latest - name: Disable defautls run: conda config --remove channels defaults @@ -74,9 +72,8 @@ jobs: echo "CONDA_BLD=$CONDA_PREFIX/conda-bld/${{ runner.os == 'Linux' && 'linux' || 'win' }}-64/" | tr "\\" '/' >> $GITHUB_ENV echo "WHEELS_OUTPUT_FOLDER=$GITHUB_WORKSPACE${{ runner.os == 'Linux' && '/' || '\\' }}" >> $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 + run: conda install conda-build - name: Configure MSBuild if: runner.os == 'Windows' @@ -84,8 +81,12 @@ jobs: with: vs-version: '14.35' + - name: Show conda-rc + shell: bash -el {0} + run: cat ~/.condarc + - name: Build conda package - run: conda mambabuild --no-test --python ${{ matrix.python }} conda-recipe + run: conda build --python ${{ matrix.python }} conda-recipe - name: Upload artifact uses: actions/upload-artifact@v3.1.2 @@ -122,15 +123,13 @@ jobs: steps: - name: Setup miniconda - uses: conda-incubator/setup-miniconda@v2 + uses: conda-incubator/setup-miniconda@v3 with: python-version: ${{ matrix.python }} - miniforge-variant: Mambaforge - miniforge-version: latest activate-environment: "build" channels: ${{ env.CHANNELS }} channel-priority: "disabled" - run-post: false + miniforge-version: latest - name: Disable defautls run: conda config --remove channels defaults @@ -159,7 +158,7 @@ jobs: # Needed to be able to run conda index - name: Install conda-build - run: mamba install conda-build conda-index + run: conda install conda-build conda-index - name: Create conda channel run: python -m conda_index ${{ env.CHANNEL_PATH }} @@ -170,7 +169,7 @@ jobs: cat ${{ env.VER_JSON_PATH }} - name: Install dpbench - run: mamba install ${{ env.PACKAGE_NAME }}=${{ env.PACKAGE_VERSION }} pytest intel::intel-opencl-rt python=${{ matrix.python }} -c ${{ env.CHANNEL_PATH }} + run: conda install ${{ env.PACKAGE_NAME }}=${{ env.PACKAGE_VERSION }} pytest intel::intel-opencl-rt python=${{ matrix.python }} -c ${{ env.CHANNEL_PATH }} - name: Setup OpenCL CPU device if: runner.os == 'Windows' From e1bebacad3169fc4dcf4abe0f50b3b32878cc4e1 Mon Sep 17 00:00:00 2001 From: Yevhenii Havrylko Date: Thu, 2 May 2024 18:19:46 -0400 Subject: [PATCH 08/10] Fix dpbench conda dep on python --- conda-recipe/meta.yaml | 1 + 1 file changed, 1 insertion(+) diff --git a/conda-recipe/meta.yaml b/conda-recipe/meta.yaml index 1c8561f3..055a9c25 100644 --- a/conda-recipe/meta.yaml +++ b/conda-recipe/meta.yaml @@ -45,6 +45,7 @@ requirements: {% endif %} {% endfor %} run: + - python {% for dep in py_deps %} - {{ dep|replace('_','-') }} {% endfor %} From ee1357c7ee9b8ae4fe49ea9fe4b8caf2049816a7 Mon Sep 17 00:00:00 2001 From: Yevhenii Havrylko Date: Fri, 3 May 2024 11:07:37 -0400 Subject: [PATCH 09/10] Use experimental flag with nopybench & npbench --- .github/workflows/conda-package.yml | 4 +-- README.md | 38 +++++++++++++++-------------- dpbench/console/run.py | 9 ++++--- 3 files changed, 28 insertions(+), 23 deletions(-) diff --git a/.github/workflows/conda-package.yml b/.github/workflows/conda-package.yml index 15e0960d..abadd19e 100644 --- a/.github/workflows/conda-package.yml +++ b/.github/workflows/conda-package.yml @@ -196,11 +196,11 @@ jobs: # we want to make sure that configuration files are geting populated - name: Run npbench benchmark run: | - dpbench -i numpy -b azimint_hist run --npbench --precision=${{matrix.precision}} + dpbench -i numpy -b azimint_hist run --experimental-npbench --precision=${{matrix.precision}} - name: Run rodinia benchmark run: | - dpbench run --rodinia --no-dpbench --no-validate -r 1 --precision=${{matrix.precision}} + dpbench run --experimental-rodinia --no-dpbench --no-validate -r 1 --precision=${{matrix.precision}} upload_anaconda: name: Upload dppy/label/dev ['${{ matrix.os }}', python='${{ matrix.python }}'] diff --git a/README.md b/README.md index 7adde796..2bc8489e 100644 --- a/README.md +++ b/README.md @@ -117,9 +117,9 @@ SPDX-License-Identifier: Apache-2.0 4. All available options are available using `dpbench --help` and `dpbench --help`: ``` - usage: dpbench [-h] [-b [BENCHMARKS]] [-i [IMPLEMENTATIONS]] [-a | --all-implementations | --no-all-implementations] [--version] [-r [RUN_ID]] [--last-run | --no-last-run] - [-d [RESULTS_DB]] [--log-level [{critical,fatal,error,warning,info,debug}]] - {run,report,config} ... + usage: dpbench [-h] [-b [BENCHMARKS]] [-i [IMPLEMENTATIONS]] [-a | --all-implementations | --no-all-implementations] [--version] [-r [RUN_ID]] [--last-run | --no-last-run] [-d [RESULTS_DB]] + [--log-level [{critical,fatal,error,warning,info,debug}]] + {run,report,config} ... positional arguments: {run,report,config} @@ -131,12 +131,12 @@ SPDX-License-Identifier: Apache-2.0 -i [IMPLEMENTATIONS], --implementations [IMPLEMENTATIONS] Comma separated list of implementations. Use --all-implementations to load all available implementations. -a, --all-implementations, --no-all-implementations - If set, all available implementations will be loaded. (default: False) + If set, all available implementations will be loaded. --version show program's version number and exit -r [RUN_ID], --run-id [RUN_ID] run_id to perform actions on. Use --last-run to use latest available run, or leave empty to create new one. --last-run, --no-last-run - Sets run_id to the latest run_id from the database. (default: False) + Sets run_id to the latest run_id from the database. -d [RESULTS_DB], --results-db [RESULTS_DB] Path to a database to store results. --log-level [{critical,fatal,error,warning,info,debug}] @@ -144,24 +144,26 @@ SPDX-License-Identifier: Apache-2.0 ``` ``` - usage: dpbench run [-h] [-p [{S,M,L}]] [-s | --validate | --no-validate] [--dpbench | --no-dpbench] [--npbench | --no-npbench] [--polybench | --no-polybench] [-r [REPEAT]] [-t [TIMEOUT]] - [--precision [{single,double}]] [--print-results | --no-print-results] [--save | --no-save] [--sycl-device [SYCL_DEVICE]] - [--skip-expected-failures | --no-skip-expected-failures] + usage: dpbench run [-h] [-p [{S,M16Gb,M,L}]] [-s | --validate | --no-validate] [--dpbench | --no-dpbench] [--experimental-npbench | --no-experimental-npbench] [--experimental-polybench | --no-experimental-polybench] + [--experimental-rodinia | --no-experimental-rodinia] [-r [REPEAT]] [-t [TIMEOUT]] [--precision [{single,double}]] [--print-results | --no-print-results] [--save | --no-save] [--sycl-device [SYCL_DEVICE]] + [--skip-expected-failures | --no-skip-expected-failures] Subcommand to run benchmark executions. options: -h, --help show this help message and exit - -p [{S,M,L}], --preset [{S,M,L}] + -p [{S,M16Gb,M,L}], --preset [{S,M16Gb,M,L}] Preset to use for benchmark execution. -s, --validate, --no-validate - Set if the validation will be run for each benchmark. (default: True) + Set if the validation will be run for each benchmark. --dpbench, --no-dpbench - Set if run dpbench benchmarks. (default: True) - --npbench, --no-npbench - Set if run npbench benchmarks. (default: False) - --polybench, --no-polybench - Set if run polybench benchmarks. (default: False) + Set if run dpbench benchmarks. + --experimental-npbench, --no-experimental-npbench + Set if run npbench benchmarks. + --experimental-polybench, --no-experimental-polybench + Set if run polybench benchmarks. + --experimental-rodinia, --no-experimental-rodinia + Set if run rodinia benchmarks. -r [REPEAT], --repeat [REPEAT] Number of repeats for each benchmark. -t [TIMEOUT], --timeout [TIMEOUT] @@ -169,12 +171,12 @@ SPDX-License-Identifier: Apache-2.0 --precision [{single,double}] Data precision to use for array initialization. --print-results, --no-print-results - Show the result summary or not (default: True) - --save, --no-save Either to save execution into database. (default: True) + Show the result summary or not + --save, --no-save Either to save execution into database. --sycl-device [SYCL_DEVICE] Sycl device to overwrite for framework configurations. --skip-expected-failures, --no-skip-expected-failures - Either to save execution into database. (default: True) + Either to save execution into database. ``` ``` diff --git a/dpbench/console/run.py b/dpbench/console/run.py index 9e44c8b8..da4bee9c 100644 --- a/dpbench/console/run.py +++ b/dpbench/console/run.py @@ -47,19 +47,22 @@ def add_run_arguments(parser: argparse.ArgumentParser): help="Set if run dpbench benchmarks.", ) parser.add_argument( - "--npbench", + "--experimental-npbench", + dest="npbench", action=argparse.BooleanOptionalAction, default=False, help="Set if run npbench benchmarks.", ) parser.add_argument( - "--polybench", + "--experimental-polybench", + dest="polybench", action=argparse.BooleanOptionalAction, default=False, help="Set if run polybench benchmarks.", ) parser.add_argument( - "--rodinia", + "--experimental-rodinia", + dest="rodinia", action=argparse.BooleanOptionalAction, default=False, help="Set if run rodinia benchmarks.", From 583ee26d690f96603bd87d07df18b132ca8818f0 Mon Sep 17 00:00:00 2001 From: Yevhenii Havrylko Date: Fri, 3 May 2024 12:08:40 -0400 Subject: [PATCH 10/10] Add required packages to frameworks --- dpbench/config/reader.py | 13 ++++++++++++- .../infrastructure/frameworks/cupy_framework.py | 4 ++++ .../infrastructure/frameworks/dpnp_framework.py | 4 ++++ dpbench/infrastructure/frameworks/fabric.py | 7 ++++++- dpbench/infrastructure/frameworks/framework.py | 15 +++++++++++++++ .../frameworks/numba_cuda_framework.py | 4 ++++ .../frameworks/numba_dpex_framework.py | 4 ++++ .../infrastructure/frameworks/numba_framework.py | 4 ++++ .../frameworks/numba_mlir_framework.py | 4 ++++ 9 files changed, 57 insertions(+), 2 deletions(-) diff --git a/dpbench/config/reader.py b/dpbench/config/reader.py index 4a37aedc..d89cf91b 100644 --- a/dpbench/config/reader.py +++ b/dpbench/config/reader.py @@ -13,6 +13,8 @@ import tomli +from dpbench.infrastructure.frameworks.fabric import get_framework_class + from .benchmark import Benchmark, BenchmarkImplementation, Presets from .config import Config from .framework import Framework @@ -117,7 +119,7 @@ def read_configs( # noqa: C901: TODO: move modules into config for framework in config.frameworks: config.implementations += framework.postfixes - if implementations is None: + if implementations is None or len(implementations) == 0: implementations = {impl.postfix for impl in config.implementations} if load_implementations: @@ -228,6 +230,15 @@ def read_frameworks( if len(framework.postfixes) == 0: continue + cls = get_framework_class(framework) + unavailable_pkgs = cls.get_missing_required_packages() + if len(unavailable_pkgs) > 0: + logging.warning( + f"Framework {framework.simple_name} unavailable " + + f"due to missing packages {unavailable_pkgs}" + ) + continue + config.frameworks.append(framework) diff --git a/dpbench/infrastructure/frameworks/cupy_framework.py b/dpbench/infrastructure/frameworks/cupy_framework.py index e1c781a9..273995d6 100644 --- a/dpbench/infrastructure/frameworks/cupy_framework.py +++ b/dpbench/infrastructure/frameworks/cupy_framework.py @@ -19,6 +19,10 @@ def __init__(self, fname: str = None, config: cfg.Framework = None): super().__init__(fname, config) + @staticmethod + def required_packages() -> list[str]: + return ["cupy"] + def copy_to_func(self) -> Callable: """Returns the copy-method that should be used for copying the benchmark arguments.""" diff --git a/dpbench/infrastructure/frameworks/dpnp_framework.py b/dpbench/infrastructure/frameworks/dpnp_framework.py index 459e3ff0..5071cb63 100644 --- a/dpbench/infrastructure/frameworks/dpnp_framework.py +++ b/dpbench/infrastructure/frameworks/dpnp_framework.py @@ -35,6 +35,10 @@ def __init__(self, fname: str = None, config: cfg.Framework = None): ) raise sdce + @staticmethod + def required_packages() -> list[str]: + return ["dpnp"] + def device_filter_string(self) -> str: """Returns the sycl device's filter string if the framework has an associated sycl device.""" diff --git a/dpbench/infrastructure/frameworks/fabric.py b/dpbench/infrastructure/frameworks/fabric.py index 0cdc8202..527f3fdb 100644 --- a/dpbench/infrastructure/frameworks/fabric.py +++ b/dpbench/infrastructure/frameworks/fabric.py @@ -39,7 +39,7 @@ def build_framework_map() -> dict[str, Framework]: return result -def build_framework(framework_config: cfg.Framework) -> Framework: +def get_framework_class(framework_config: cfg.Framework) -> Framework: available_classes = [ Framework, DpcppFramework, @@ -61,4 +61,9 @@ def build_framework(framework_config: cfg.Framework) -> Framework: ) constructor = Framework + return constructor + + +def build_framework(framework_config: cfg.Framework) -> Framework: + constructor = get_framework_class(framework_config) return constructor(config=framework_config) diff --git a/dpbench/infrastructure/frameworks/framework.py b/dpbench/infrastructure/frameworks/framework.py index d0bd5887..757e94da 100644 --- a/dpbench/infrastructure/frameworks/framework.py +++ b/dpbench/infrastructure/frameworks/framework.py @@ -5,6 +5,7 @@ # SPDX-License-Identifier: BSD-3-Clause import logging +from importlib.util import find_spec from typing import Any, Callable, Dict, final import pkg_resources @@ -45,6 +46,20 @@ def __init__( self.device_info = cpuinfo.get_cpu_info().get("brand_raw") + @staticmethod + def required_packages() -> list[str]: + return [] + + @classmethod + def get_missing_required_packages(cls) -> None: + unavailable_packages = [] + for pkg in cls.required_packages(): + spec = find_spec(pkg) + if spec is None: + unavailable_packages.append(pkg) + + return unavailable_packages + def device_filter_string(self) -> str: """Returns the sycl device's filter string if the framework has an associated sycl device.""" diff --git a/dpbench/infrastructure/frameworks/numba_cuda_framework.py b/dpbench/infrastructure/frameworks/numba_cuda_framework.py index 5c5940d0..32fb5dfc 100644 --- a/dpbench/infrastructure/frameworks/numba_cuda_framework.py +++ b/dpbench/infrastructure/frameworks/numba_cuda_framework.py @@ -19,6 +19,10 @@ def __init__(self, fname: str = None, config: cfg.Framework = None): super().__init__(fname, config) + @staticmethod + def required_packages() -> list[str]: + return ["cupy"] + def copy_to_func(self) -> Callable: """Returns the copy-method that should be used for copying the benchmark arguments.""" diff --git a/dpbench/infrastructure/frameworks/numba_dpex_framework.py b/dpbench/infrastructure/frameworks/numba_dpex_framework.py index e1cdb5b5..d6868a59 100644 --- a/dpbench/infrastructure/frameworks/numba_dpex_framework.py +++ b/dpbench/infrastructure/frameworks/numba_dpex_framework.py @@ -33,6 +33,10 @@ def __init__(self, fname: str = None, config: cfg.Framework = None): ) raise sdce + @staticmethod + def required_packages() -> list[str]: + return ["numba_dpex"] + def device_filter_string(self) -> str: """Returns the sycl device's filter string if the framework has an associated sycl device.""" diff --git a/dpbench/infrastructure/frameworks/numba_framework.py b/dpbench/infrastructure/frameworks/numba_framework.py index 12180d1d..7eeadb0d 100644 --- a/dpbench/infrastructure/frameworks/numba_framework.py +++ b/dpbench/infrastructure/frameworks/numba_framework.py @@ -27,3 +27,7 @@ def __init__(self, fname: str = None, config: cfg.Framework = None): """ super().__init__(fname, config) + + @staticmethod + def required_packages() -> list[str]: + return ["numba"] diff --git a/dpbench/infrastructure/frameworks/numba_mlir_framework.py b/dpbench/infrastructure/frameworks/numba_mlir_framework.py index c2a87170..8dfd9305 100644 --- a/dpbench/infrastructure/frameworks/numba_mlir_framework.py +++ b/dpbench/infrastructure/frameworks/numba_mlir_framework.py @@ -28,6 +28,10 @@ def __init__(self, fname: str = None, config: cfg.Framework = None): self.device_info = dpctl.SyclDevice(self.sycl_device).name + @staticmethod + def required_packages() -> list[str]: + return ["numba_mlir"] + def copy_to_func(self) -> Callable: """Returns the copy-method that should be used for copying the benchmark arguments to device."""