Skip to content
This repository was archived by the owner on Sep 26, 2025. It is now read-only.

Commit 191bd58

Browse files
kde_skbuild now works as well
1 parent ab9e22b commit 191bd58

File tree

13 files changed

+254
-1
lines changed

13 files changed

+254
-1
lines changed

kde_setuptools/setup.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -20,7 +20,7 @@
2020
name="kde_setuptools",
2121
author="Intel Corporation",
2222
version="0.0.1",
23-
description="An example of data-parallel extensions built with oneAPI",
23+
description="An example of data-parallel Python extensions built with setuptools and oneAPI DPC++",
2424
long_description="""
2525
Example of using oneAPI to build data-parallel extension using setuptools.
2626

kde_setuptools/tests/.gitignore

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,2 @@
1+
__pycache__
2+
*~

kde_skbuild/CMakeLists.txt

Lines changed: 65 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,65 @@
1+
cmake_minimum_required(VERSION 3.22 FATAL_ERROR)
2+
3+
project(oneapi_kde_skbuild LANGUAGES C CXX)
4+
5+
if (NOT DEFINED DPCTL_MODULE_PATH)
6+
if (DEFINED ENV{DPCTL_MODULE_PATH})
7+
set(DPCTL_MODULE_PATH $ENV{DPCTL_MODULE_PATH})
8+
else ()
9+
mesage(FATAL_ERROR "Specify DPCTL_MODULE_PATH, either via cmake or as environment varibale")
10+
endif()
11+
endif()
12+
13+
message(STATUS "${DPCTL_MODULE_PATH}")
14+
set(CMAKE_MODULE_PATH ${CMAKE_MODULE_PATH} ${DPCTL_MODULE_PATH})
15+
find_package(IntelDPCPP REQUIRED)
16+
17+
set(CMAKE_CXX_STANDARD 17)
18+
set(CMAKE_CXX_STANDARD_REQUIRED True)
19+
20+
21+
# Define CMAKE_INSTALL_xxx: LIBDIR, INCLUDEDIR
22+
include(GNUInstallDirs)
23+
24+
# Fetch pybind11
25+
include(FetchContent)
26+
FetchContent_Declare(
27+
pybind11
28+
URL https://github.com/pybind/pybind11/archive/refs/tags/v2.9.2.tar.gz
29+
URL_HASH SHA256=6bd528c4dbe2276635dc787b6b1f2e5316cf6b49ee3e150264e455a0d68d19c1
30+
)
31+
FetchContent_MakeAvailable(pybind11)
32+
33+
find_package(PythonExtensions REQUIRED)
34+
set(CYTHON_FLAGS "-t -w ${CMAKE_SOURCE_DIR}")
35+
find_package(Cython REQUIRED)
36+
find_package(Dpctl REQUIRED)
37+
38+
39+
# Pybind11 extension module
40+
set(py_module_name _pybind11_kde)
41+
pybind11_add_module(${py_module_name}
42+
MODULE
43+
${CMAKE_SOURCE_DIR}/src/pybind11_kde.cpp
44+
)
45+
message(STATUS "Dpctl_INCLUDE_DIR: ${Dpctl_INCLUDE_DIR}")
46+
target_include_directories(${py_module_name}
47+
PUBLIC ${CMAKE_SOURCE_DIR}/src ${Dpctl_INCLUDE_DIR}
48+
)
49+
install(TARGETS ${py_module_name} DESTINATION kde_skbuild)
50+
51+
# Cython extension
52+
53+
54+
set(cy_module_name _cython_kde)
55+
56+
# subdirectory must be known for add_cython_target bails out
57+
add_subdirectory(${CMAKE_SOURCE_DIR}/src)
58+
add_cython_target(${cy_module_name} ${CMAKE_SOURCE_DIR}/src/_cython_kde.pyx CXX PY3 OUTPUT_VAR _generated_src)
59+
add_library(${cy_module_name} MODULE ${_generated_src})
60+
61+
target_include_directories(${cy_module_name} PRIVATE ${NumPy_INCLUDE_DIR} ${Dpctl_INCLUDE_DIR} ${CMAKE_SOURCE_DIR}/src)
62+
python_extension_module(${cy_module_name})
63+
install(TARGETS ${cy_module_name} LIBRARY DESTINATION kde_skbuild)
64+
65+
set(ignoreMe "${SKBUILD}")

kde_skbuild/README.md

Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,9 @@
1+
# Building this extension
2+
3+
Assuming `numpy`, `Cython`, `pybind11`, `pytest`, `scikit-build`, `cmake >=3.21`, and `ninja` are installed
4+
and DCP++ has been activated:
5+
6+
```bash
7+
CC=icx CXX=icpx python setup.py develop -G Ninja -- -DDCPTL_MODULE_PATH=$(python -m dpctl --cmakedir)
8+
pytest -m tests
9+
```
Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,4 @@
1+
from ._cython_kde import kde_eval as cython_kde_eval
2+
from ._pybind11_kde import kde_eval as pybind11_kde_eval
3+
4+
__all__ = ["cyton_kde_eval", "pybind11_kde_eval"]

kde_skbuild/setup.py

Lines changed: 16 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,16 @@
1+
from skbuild import setup
2+
3+
setup(
4+
name="kde_skbuild",
5+
author="Intel Corporation",
6+
version="0.0.1",
7+
description="An example of data-parallel Python extensions built with scikit-build and oneAPI DPC++",
8+
long_description="""
9+
Example of using oneAPI to build data-parallel extension using setuptools.
10+
11+
Part of oneAPI for Scientific Python community virtual poster.
12+
Also see README.md
13+
""",
14+
license="Apache 2.0",
15+
packages=["kde_skbuild",]
16+
)

kde_skbuild/src/_cython_kde.pyx

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1 @@
1+
../../common_ext/cy_kde.pyx

kde_skbuild/src/kde.hpp

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1 @@
1+
../../common_src/kde.hpp

kde_skbuild/src/pybind11_kde.cpp

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1 @@
1+
../../common_ext/py_kde.cpp

0 commit comments

Comments
 (0)