From da02df178b595d2a0bac861c9b1e00a781f6fcc5 Mon Sep 17 00:00:00 2001 From: Oleksandr Pavlyk Date: Wed, 21 Feb 2024 09:06:14 -0600 Subject: [PATCH 1/6] Update copyright year range --- common_ext/cy_kde.pyx | 2 +- common_ext/py_kde.cpp | 2 +- common_src/kde.hpp | 2 +- common_src/main.cpp | 59 ----------------------- kde_setuptools/kde_setuptools/__init__.py | 2 +- kde_setuptools/setup.py | 2 +- kde_setuptools/tests/test_cy_kde.py | 2 +- kde_setuptools/tests/test_py_kde.py | 2 +- 8 files changed, 7 insertions(+), 66 deletions(-) delete mode 100644 common_src/main.cpp diff --git a/common_ext/cy_kde.pyx b/common_ext/cy_kde.pyx index 078424e..3dca3ee 100644 --- a/common_ext/cy_kde.pyx +++ b/common_ext/cy_kde.pyx @@ -1,4 +1,4 @@ -# Copyright 2022 Intel Corporation +# Copyright 2022-2024 Intel Corporation # # Licensed under the Apache License, Version 2.0 (the "License"); # you may not use this file except in compliance with the License. diff --git a/common_ext/py_kde.cpp b/common_ext/py_kde.cpp index 293e310..dc00629 100644 --- a/common_ext/py_kde.cpp +++ b/common_ext/py_kde.cpp @@ -1,4 +1,4 @@ -// Copyright 2022 Intel Corporation +// Copyright 2022-2024 Intel Corporation // // Licensed under the Apache License, Version 2.0 (the "License"); // you may not use this file except in compliance with the License. diff --git a/common_src/kde.hpp b/common_src/kde.hpp index d2d3a51..67ec3ae 100644 --- a/common_src/kde.hpp +++ b/common_src/kde.hpp @@ -1,4 +1,4 @@ -// Copyright 2022 Intel Corporation +// Copyright 2022-2024 Intel Corporation // // Licensed under the Apache License, Version 2.0 (the "License"); // you may not use this file except in compliance with the License. diff --git a/common_src/main.cpp b/common_src/main.cpp deleted file mode 100644 index 1fc674e..0000000 --- a/common_src/main.cpp +++ /dev/null @@ -1,59 +0,0 @@ -// Copyright 2022 Intel Corporation -// -// Licensed under the Apache License, Version 2.0 (the "License"); -// you may not use this file except in compliance with the License. -// You may obtain a copy of the License at -// -// http://www.apache.org/licenses/LICENSE-2.0 -// -// Unless required by applicable law or agreed to in writing, software -// distributed under the License is distributed on an "AS IS" BASIS, -// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -// See the License for the specific language governing permissions and -// limitations under the License. - -// This is auxiliary file used to test kde.hpp - -#include -#include -#include "kde.hpp" - -int main(void) { - sycl::queue q; - - using T = double; - - size_t n = 4; - size_t n_data = 16253; - - T *x = new T[n]; - T *f = new T[n]; - T *x_data = new T[n_data]; - - for(size_t i=0; i < n; ++i) { - x[i] = T(i+2)/T(n+4); - } - - std::random_device r; - std::default_random_engine e(r()); - std::uniform_real_distribution uniform_d(T(0), T(1)); - - for(size_t i=0; i < n_data; ++i) { - x_data[i] = uniform_d(e); - } - - example::kernel_density_estimate( - q, - static_cast(1), - const_cast(x), - f, n, - const_cast(x_data), - n_data, 0.2 - ); - - for(size_t i=0; i < n; ++i) { - std::cout << "f(" << x[i] << ")=" << f[i] << std::endl; - } - - return 0; -} diff --git a/kde_setuptools/kde_setuptools/__init__.py b/kde_setuptools/kde_setuptools/__init__.py index 2c15bf1..7c2abba 100644 --- a/kde_setuptools/kde_setuptools/__init__.py +++ b/kde_setuptools/kde_setuptools/__init__.py @@ -1,4 +1,4 @@ -# Copyright 2022 Intel Corporation +# Copyright 2022-2024 Intel Corporation # # Licensed under the Apache License, Version 2.0 (the "License"); # you may not use this file except in compliance with the License. diff --git a/kde_setuptools/setup.py b/kde_setuptools/setup.py index 8546824..ece3824 100644 --- a/kde_setuptools/setup.py +++ b/kde_setuptools/setup.py @@ -1,4 +1,4 @@ -# Copyright 2022 Intel Corporation +# Copyright 2022-2024 Intel Corporation # # Licensed under the Apache License, Version 2.0 (the "License"); # you may not use this file except in compliance with the License. diff --git a/kde_setuptools/tests/test_cy_kde.py b/kde_setuptools/tests/test_cy_kde.py index 4427393..775fcf5 100644 --- a/kde_setuptools/tests/test_cy_kde.py +++ b/kde_setuptools/tests/test_cy_kde.py @@ -1,4 +1,4 @@ -# Copyright 2022 Intel Corporation +# Copyright 2022-2024 Intel Corporation # # Licensed under the Apache License, Version 2.0 (the "License"); # you may not use this file except in compliance with the License. diff --git a/kde_setuptools/tests/test_py_kde.py b/kde_setuptools/tests/test_py_kde.py index f8b8c51..c7966e3 100644 --- a/kde_setuptools/tests/test_py_kde.py +++ b/kde_setuptools/tests/test_py_kde.py @@ -1,4 +1,4 @@ -# Copyright 2022 Intel Corporation +# Copyright 2022-2024 Intel Corporation # # Licensed under the Apache License, Version 2.0 (the "License"); # you may not use this file except in compliance with the License. From 538296a1b63cec5e5a24c91a3932c7b53a3d9f3d Mon Sep 17 00:00:00 2001 From: Oleksandr Pavlyk Date: Wed, 21 Feb 2024 09:08:38 -0600 Subject: [PATCH 2/6] Updated README --- kde_skbuild/README.md | 9 ++++----- 1 file changed, 4 insertions(+), 5 deletions(-) diff --git a/kde_skbuild/README.md b/kde_skbuild/README.md index bfd0d4c..05533e8 100644 --- a/kde_skbuild/README.md +++ b/kde_skbuild/README.md @@ -1,18 +1,17 @@ # Building this extension -Assuming `numpy`, `Cython`, `pybind11`, `pytest`, `scikit-build`, `cmake >=3.21`, and `ninja` are installed -and DCP++ has been activated: +Assuming `numpy`, `Cython`, `pybind11`, `pytest`, `scikit-build`, `cmake >=3.21`, `dpctl`, and `ninja` are +installed and DCP++ has been activated: ```bash -CC=icx CXX=icpx python setup.py develop -G Ninja -- -DDPCTL_MODULE_PATH=$(python -m dpctl --cmakedir) +CC=icx CXX=icpx python setup.py develop -G Ninja pytest -m tests ``` Scikit-build enables building Python native extensions using CMake. This package leverage integration DPC++ with CMake [dpcpp-cmake-integration] as well as integration of `dpctl` with CMake. -**Note**: Building this package requires the using latest development version of `dpctl`. -This can be installed using conda package manager using +The latest version of `dpctl` can be installed using conda package manager using ```bash conda install -c dppy/label/dev dpctl From e2f8943866985e6034e001ce39cdad694cb160df Mon Sep 17 00:00:00 2001 From: Oleksandr Pavlyk Date: Wed, 21 Feb 2024 09:41:22 -0600 Subject: [PATCH 3/6] Set default permissions --- .github/workflows/ci.yaml | 49 +++++++++++++++++++++++++++++++++++---- 1 file changed, 44 insertions(+), 5 deletions(-) diff --git a/.github/workflows/ci.yaml b/.github/workflows/ci.yaml index 27b0fb1..4e188b7 100644 --- a/.github/workflows/ci.yaml +++ b/.github/workflows/ci.yaml @@ -4,14 +4,16 @@ on: push: branches: [main] +permissions: read-all + jobs: - setup_develop: + build_and_test_kde_setuptools: name: Build packages with DPC++ runs-on: Ubuntu-latest steps: - name: Cancel Previous Runs - uses: styfle/cancel-workflow-action@0.11.0 + uses: styfle/cancel-workflow-action@0.12.1 with: access_token: ${{ github.token }} @@ -32,7 +34,7 @@ jobs: run: echo $CONDA/bin >> $GITHUB_PATH - name: Checkout repo - uses: actions/checkout@v2 + uses: actions/checkout@v4.1.1 with: fetch-depth: 0 @@ -51,13 +53,50 @@ jobs: python -m pytest tests popd + + build_and_test_kde_skbuild: + name: Build packages with DPC++ + runs-on: Ubuntu-latest + + steps: + - name: Cancel Previous Runs + uses: styfle/cancel-workflow-action@0.12.1 + with: + access_token: ${{ github.token }} + + - name: Add Intel repository + run: | + wget https://apt.repos.intel.com/intel-gpg-keys/GPG-PUB-KEY-INTEL-SW-PRODUCTS-2023.PUB + sudo apt-key add GPG-PUB-KEY-INTEL-SW-PRODUCTS-2023.PUB + rm GPG-PUB-KEY-INTEL-SW-PRODUCTS-2023.PUB + sudo add-apt-repository "deb https://apt.repos.intel.com/oneapi all main" + sudo apt-get update + + - name: Install Intel OneAPI + run: | + sudo apt-get install intel-oneapi-compiler-dpcpp-cpp + sudo apt-get install intel-oneapi-tbb + + - name: Add conda to system path + run: echo $CONDA/bin >> $GITHUB_PATH + + - name: Checkout repo + uses: actions/checkout@v4.1.1 + with: + fetch-depth: 0 + + - name: Install dependencies + run: | + conda install python=3.10 dpctl -c dppy/label/dev -c intel -c conda-forge --override-channels + pip install --no-cache-dir cython scikit-build pybind11 pytest cmake ninja + conda list + - name: Build kde_skbuild run: | source /opt/intel/oneapi/setvars.sh export OCL_ICD_FILENAMES=libintelocl.so pushd kde_skbuild CC=icx CXX=icpx python setup.py develop -G Ninja \ - -- -DCMAKE_VERBOSE_MAKEFILE=ON \ - -DDPCTL_MODULE_PATH=$(python -m dpctl --cmakedir) + -- -DCMAKE_VERBOSE_MAKEFILE=ON python -m pytest tests popd From 3cd8dc6b8c711127f4d00efb81475247b0450220 Mon Sep 17 00:00:00 2001 From: Oleksandr Pavlyk Date: Wed, 21 Feb 2024 09:41:54 -0600 Subject: [PATCH 4/6] Add dependabot --- .github/dependabot.yml | 6 ++++++ 1 file changed, 6 insertions(+) create mode 100644 .github/dependabot.yml diff --git a/.github/dependabot.yml b/.github/dependabot.yml new file mode 100644 index 0000000..5ace460 --- /dev/null +++ b/.github/dependabot.yml @@ -0,0 +1,6 @@ +version: 2 +updates: + - package-ecosystem: "github-actions" + directory: "/" + schedule: + interval: "weekly" From 73217a76a1f6adcb94ff64164453b236cc9c9b7b Mon Sep 17 00:00:00 2001 From: Oleksandr Pavlyk Date: Wed, 21 Feb 2024 09:44:37 -0600 Subject: [PATCH 5/6] Remove kludge to allow cmake to find Dpctl package --- kde_skbuild/CMakeLists.txt | 10 ---------- 1 file changed, 10 deletions(-) diff --git a/kde_skbuild/CMakeLists.txt b/kde_skbuild/CMakeLists.txt index 0be5e81..7f61900 100644 --- a/kde_skbuild/CMakeLists.txt +++ b/kde_skbuild/CMakeLists.txt @@ -2,21 +2,11 @@ cmake_minimum_required(VERSION 3.22...3.27 FATAL_ERROR) project(oneapi_kde_skbuild VERSION 0.1 LANGUAGES C CXX DESCRIPTION "Example of DPC++-based Python extension") -if (NOT DEFINED DPCTL_MODULE_PATH) - if (DEFINED ENV{DPCTL_MODULE_PATH}) - set(DPCTL_MODULE_PATH $ENV{DPCTL_MODULE_PATH}) - else () - message(FATAL_ERROR "Specify DPCTL_MODULE_PATH, either via cmake or as environment varibale") - endif() -endif() - -set(CMAKE_MODULE_PATH ${CMAKE_MODULE_PATH} ${DPCTL_MODULE_PATH}) find_package(IntelSYCL REQUIRED) set(CMAKE_CXX_STANDARD 17) set(CMAKE_CXX_STANDARD_REQUIRED True) - # Define CMAKE_INSTALL_xxx: LIBDIR, INCLUDEDIR include(GNUInstallDirs) From 02a24bf61900e8bd0057eab044d6797aa5ffed7f Mon Sep 17 00:00:00 2001 From: Oleksandr Pavlyk Date: Wed, 21 Feb 2024 09:50:43 -0600 Subject: [PATCH 6/6] Use conda create instead of conda install --- .github/workflows/ci.yaml | 18 +++++++++++++----- 1 file changed, 13 insertions(+), 5 deletions(-) diff --git a/.github/workflows/ci.yaml b/.github/workflows/ci.yaml index 4e188b7..96c65af 100644 --- a/.github/workflows/ci.yaml +++ b/.github/workflows/ci.yaml @@ -8,7 +8,7 @@ permissions: read-all jobs: build_and_test_kde_setuptools: - name: Build packages with DPC++ + name: Build kde_setuptools with DPC++ runs-on: Ubuntu-latest steps: @@ -40,8 +40,10 @@ jobs: - name: Install dependencies run: | - conda install python=3.10 dpctl -c dppy/label/dev -c intel -c conda-forge --override-channels - pip install --no-cache-dir cython scikit-build pybind11 pytest cmake ninja + source $CONDA/etc/profile.d/conda.sh + conda create -n build_kde_setuptools python=3.10 dpctl -c dppy/label/dev -c intel -c conda-forge --override-channels + conda activate build_kde_setuptools + pip install --no-cache-dir cython pybind11 pytest cmake ninja conda list - name: Build kde_setuptools @@ -49,13 +51,15 @@ jobs: source /opt/intel/oneapi/setvars.sh export OCL_ICD_FILENAMES=libintelocl.so pushd kde_setuptools + source $CONDA/etc/profile.d/conda.sh + conda activate build_kde_setuptools python setup.py develop python -m pytest tests popd build_and_test_kde_skbuild: - name: Build packages with DPC++ + name: Build kde_skbuild with DPC++ runs-on: Ubuntu-latest steps: @@ -87,7 +91,9 @@ jobs: - name: Install dependencies run: | - conda install python=3.10 dpctl -c dppy/label/dev -c intel -c conda-forge --override-channels + source $CONDA/etc/profile.d/conda.sh + conda create -n build_kde_skbuild python=3.10 dpctl -c dppy/label/dev -c intel -c conda-forge --override-channels + conda activate build_kde_skbuild pip install --no-cache-dir cython scikit-build pybind11 pytest cmake ninja conda list @@ -96,6 +102,8 @@ jobs: source /opt/intel/oneapi/setvars.sh export OCL_ICD_FILENAMES=libintelocl.so pushd kde_skbuild + source $CONDA/etc/profile.d/conda.sh + conda activate build_kde_skbuild CC=icx CXX=icpx python setup.py develop -G Ninja \ -- -DCMAKE_VERBOSE_MAKEFILE=ON python -m pytest tests