Skip to content

Commit 549a2ba

Browse files
committed
update use_dpctl_sycl_kernel example
1 parent 77e33bb commit 549a2ba

12 files changed

Lines changed: 53 additions & 40 deletions

File tree

examples/pybind11/onemkl_gemv/README.md

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -7,7 +7,7 @@
77
88
To build on Linux, run:
99
```bash
10-
pip install -e . \
10+
python -m pip install -e . \
1111
-Ccmake.define.CMAKE_C_COMPILER:PATH=icx \
1212
-Ccmake.define.CMAKE_CXX_COMPILER:PATH=icpx \
1313
-Ccmake.define.TBB_LIBRARY_DIR=$CONDA_PREFIX/lib \
@@ -18,7 +18,7 @@ pip install -e . \
1818

1919
To build on Windows, run:
2020
```bash
21-
pip install -e . \
21+
python -m pip install -e . \
2222
-Ccmake.define.CMAKE_C_COMPILER:PATH=icx \
2323
-Ccmake.define.CMAKE_CXX_COMPILER:PATH=icx \
2424
-Ccmake.define.TBB_LIBRARY_DIR=$CONDA_PREFIX/lib \

examples/pybind11/use_dpctl_sycl_kernel/CMakeLists.txt

Lines changed: 6 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -25,13 +25,11 @@ find_package(Python REQUIRED COMPONENTS Development.Module NumPy)
2525
find_package(Dpctl REQUIRED)
2626

2727
set(py_module_name _use_kernel)
28-
set(_sources use_kernel/_example.cpp)
29-
pybind11_add_module(${py_module_name}
30-
MODULE
31-
${_sources}
32-
)
28+
set(_sources src/use_kernel/_example.cpp)
29+
pybind11_add_module(${py_module_name} MODULE ${_sources})
3330
add_sycl_to_target(TARGET ${py_module_name} SOURCES ${_sources})
3431
target_include_directories(${py_module_name} PUBLIC ${Dpctl_INCLUDE_DIRS})
35-
install(TARGETS ${py_module_name}
36-
DESTINATION use_kernel
37-
)
32+
install(TARGETS ${py_module_name} DESTINATION use_kernel)
33+
34+
# explicitly install the SPIR-V resources
35+
install(DIRECTORY src/use_kernel/resource DESTINATION use_kernel)

examples/pybind11/use_dpctl_sycl_kernel/README.md

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -12,7 +12,7 @@ Pybind11 extensions.
1212
To build the extension, run:
1313
```
1414
source /opt/intel/oneapi/compiler/latest/env/vars.sh
15-
CXX=icpx python setup.py build_ext --inplace
15+
CXX=icpx python -m pip install .
1616
python -m pytest tests
1717
python example.py
1818
```

examples/pybind11/use_dpctl_sycl_kernel/example.py

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -16,6 +16,8 @@
1616

1717
# coding: utf-8
1818

19+
import os
20+
1921
import numpy as np
2022
import use_kernel as eg
2123

@@ -27,7 +29,8 @@
2729
q = dpctl.SyclQueue()
2830

2931
# read SPIR-V: a program in Khronos standardized intermediate form
30-
with open("resource/double_it.spv", "br") as fh:
32+
eg_dir = os.path.dirname(os.path.abspath(eg.__file__))
33+
with open(os.path.join(eg_dir, "resource", "double_it.spv"), "br") as fh:
3134
il = fh.read()
3235

3336
# Build the program for the selected device
Lines changed: 39 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,39 @@
1+
# Data Parallel Control (dpctl)
2+
#
3+
# Copyright 2020-2025 Intel Corporation
4+
#
5+
# Licensed under the Apache License, Version 2.0 (the "License");
6+
# you may not use this file except in compliance with the License.
7+
# You may obtain a copy of the License at
8+
#
9+
# http://www.apache.org/licenses/LICENSE-2.0
10+
#
11+
# Unless required by applicable law or agreed to in writing, software
12+
# distributed under the License is distributed on an "AS IS" BASIS,
13+
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
14+
# See the License for the specific language governing permissions and
15+
# limitations under the License.
16+
17+
[build-system]
18+
build-backend = "scikit_build_core.build"
19+
requires = [
20+
"scikit-build-core>=0.8.0",
21+
"dpctl",
22+
"numpy >=1.23"
23+
]
24+
25+
[project]
26+
authors = [{name = "Intel Corporation"}]
27+
dependencies = ["numpy", "dpctl"]
28+
description = "An example of SYCL-powered Python package (with pybind11)"
29+
license = {text = "Apache 2.0"}
30+
name = "use_kernel"
31+
requires-python = ">=3.10"
32+
version = "0.0.1"
33+
34+
[project.urls]
35+
Repository = "https://github.com/IntelPython/dpctl"
36+
37+
[tool.scikit-build]
38+
build-dir = "build/{wheel_tag}"
39+
wheel.packages = ["src/use_kernel"]

examples/pybind11/use_dpctl_sycl_kernel/setup.py

Lines changed: 0 additions & 26 deletions
This file was deleted.

examples/pybind11/use_dpctl_sycl_kernel/use_kernel/__init__.py renamed to examples/pybind11/use_dpctl_sycl_kernel/src/use_kernel/__init__.py

File renamed without changes.

examples/pybind11/use_dpctl_sycl_kernel/use_kernel/_example.cpp renamed to examples/pybind11/use_dpctl_sycl_kernel/src/use_kernel/_example.cpp

File renamed without changes.

examples/pybind11/use_dpctl_sycl_kernel/resource/README.md renamed to examples/pybind11/use_dpctl_sycl_kernel/src/use_kernel/resource/README.md

File renamed without changes.

examples/pybind11/use_dpctl_sycl_kernel/resource/double_it.cl renamed to examples/pybind11/use_dpctl_sycl_kernel/src/use_kernel/resource/double_it.cl

File renamed without changes.

0 commit comments

Comments
 (0)