Skip to content

Commit d9b9e0c

Browse files
Merge pull request #1935 from IntelPython/triage-example-warnings
2 parents d6e1042 + ac978f1 commit d9b9e0c

File tree

12 files changed

+183
-170
lines changed

12 files changed

+183
-170
lines changed

.flake8

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -31,6 +31,6 @@ per-file-ignores =
3131
dpctl/utils/_compute_follows_data.pyx: E999, E225, E227
3232
dpctl/utils/_onetrace_context.py: E501, W505
3333
dpctl/tensor/_array_api.py: E501, W505
34-
examples/cython/sycl_buffer/syclbuffer/_buffer_example.pyx: E999, E225, E402
35-
examples/cython/usm_memory/blackscholes/blackscholes.pyx: E999, E225, E226, E402
34+
examples/cython/sycl_buffer/syclbuffer/_syclbuffer.pyx: E999, E225, E402
35+
examples/cython/usm_memory/blackscholes/_blackscholes_usm.pyx: E999, E225, E226, E402
3636
examples/cython/use_dpctl_sycl/use_dpctl_sycl/_cython_api.pyx: E999, E225, E226, E402

.github/workflows/conda-package.yml

Lines changed: 4 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -549,7 +549,7 @@ jobs:
549549
- name: Install example requirements
550550
shell: bash -ex -l {0}
551551
env:
552-
DPCPP_CMPLR: "dpcpp_linux-64>=2024.2"
552+
DPCPP_CMPLR: "dpcpp_linux-64>=2025.0"
553553
run: |
554554
CHANNELS="${{ env.CHANNELS }}"
555555
. $CONDA/etc/profile.d/conda.sh
@@ -569,6 +569,7 @@ jobs:
569569
${{ env.DPCPP_CMPLR }} "${DPCTL_DEPENDS}" \
570570
"sysroot_linux-64>=2.28"
571571
echo "Compiler installed"
572+
conda list -n ${{ env.BUILD_ENV_NAME }}
572573
- name: Install dpctl
573574
shell: bash -l {0}
574575
run: |
@@ -586,14 +587,8 @@ jobs:
586587
for d in $(find . -maxdepth 1 -type d -not -path ".")
587588
do
588589
pushd $d
589-
export MKLROOT=${CONDA_PREFIX}
590-
export TBBROOT=${CONDA_PREFIX}
591590
conda activate --stack build_env
592-
CC=icx CXX=icpx python setup.py build_ext --inplace -G Ninja -- \
593-
-DTBB_LIBRARY_DIR=${TBBROOT}/lib \
594-
-DMKL_LIBRARY_DIR=${MKLROOT}/lib \
595-
-DMKL_INCLUDE_DIR=${MKLROOT}/include \
596-
-DTBB_INCLUDE_DIR=${TBBROOT}/include || exit 1
591+
CC=icx CXX=icpx python setup.py build_ext --inplace -G Ninja || exit 1
597592
conda deactivate
598593
if [ -e tests ]
599594
then
@@ -614,7 +609,7 @@ jobs:
614609
do
615610
pushd $d
616611
conda activate --stack ${{ env.BUILD_ENV_NAME }}
617-
python setup.py build_ext --inplace || exit 1
612+
CC=icx CXX=icpx python setup.py develop -G Ninja || exit 1
618613
conda deactivate
619614
python -m pytest tests || exit 1
620615
popd
Lines changed: 46 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,46 @@
1+
cmake_minimum_required(VERSION 3.22...3.27 FATAL_ERROR)
2+
3+
project(example_cython_syclbuffer VERSION 0.1 LANGUAGES CXX
4+
DESCRIPTION "Example of Cython extension to work on host allocated NumPy array using SYCL buffers and SYCL functions.")
5+
set(DPCTL_CMAKE_MODULES_PATH "${CMAKE_SOURCE_DIR}/../../../cmake")
6+
set(CMAKE_MODULE_PATH ${CMAKE_MODULE_PATH} ${DPCTL_CMAKE_MODULES_PATH})
7+
8+
find_package(IntelSYCL REQUIRED PATHS ${DPCTL_CMAKE_MODULES_PATH} NO_DEFAULT_PATH)
9+
10+
11+
set(CMAKE_MODULE_PATH ${CMAKE_MODULE_PATH} "${CMAKE_SOURCE_DIR}")
12+
set(CMAKE_CXX_STANDARD 17)
13+
set(CMAKE_CXX_STANDARD_REQUIRED True)
14+
15+
# Define CMAKE_INSTALL_xxx: LIBDIR, INCLUDEDIR
16+
include(GNUInstallDirs)
17+
18+
find_package(Python REQUIRED COMPONENTS Development.Module NumPy)
19+
find_package(Dpctl REQUIRED)
20+
21+
# -w is to set working directory (and correctly set __pyx_f[] array of filenames)
22+
set(CYTHON_FLAGS "-t -w \"${CMAKE_SOURCE_DIR}\"")
23+
find_package(Cython REQUIRED)
24+
25+
set(py_module_name _syclbuffer)
26+
27+
set(_cy_source syclbuffer/_syclbuffer.pyx)
28+
add_cython_target(${py_module_name} ${_cy_source} CXX OUTPUT_VAR _generated_cy_src)
29+
Python_add_library(${py_module_name} MODULE WITH_SOABI ${_generated_cy_src})
30+
add_sycl_to_target(TARGET ${py_module_name} SOURCES ${_generated_cy_src})
31+
target_include_directories(${py_module_name} PUBLIC src ${Dpctl_INCLUDE_DIRS})
32+
target_link_libraries(${py_module_name} PRIVATE Python::NumPy)
33+
34+
install(TARGETS ${py_module_name} DESTINATION syclbuffer)
35+
36+
foreach(_src_fn ${_sources})
37+
get_source_file_property(_compile_options ${_src_fn} COMPILE_OPTIONS)
38+
set(_combined_options ${_compile_options} "-O3")
39+
set_source_files_properties(${_src_fn}
40+
PROPERTIES
41+
COMPILE_OPTIONS "${_combined_options}"
42+
)
43+
endforeach()
44+
target_link_options(${py_module_name} PRIVATE -fsycl-device-code-split=per_kernel)
45+
46+
set(ignoreMe "${SKBUILD}")

examples/cython/sycl_buffer/setup.py

Lines changed: 2 additions & 42 deletions
Original file line numberDiff line numberDiff line change
@@ -14,46 +14,7 @@
1414
# See the License for the specific language governing permissions and
1515
# limitations under the License.
1616

17-
from setuptools import Extension, setup
18-
from setuptools.command.build_ext import build_ext
19-
20-
import dpctl
21-
22-
23-
class custom_build_ext(build_ext):
24-
def build_extensions(self):
25-
self.compiler.set_executable("compiler_so", "icpx -fsycl -fPIC")
26-
self.compiler.set_executable("compiler_cxx", "icpx -fsycl -fPIC")
27-
self.compiler.set_executable(
28-
"linker_so",
29-
"icpx -fsycl -shared -fpic -fsycl-device-code-split=per_kernel",
30-
)
31-
build_ext.build_extensions(self)
32-
33-
34-
ext_modules = [
35-
Extension(
36-
name="syclbuffer._syclbuffer",
37-
sources=[
38-
"syclbuffer/_buffer_example.pyx",
39-
],
40-
depends=[
41-
"src/use_sycl_buffer.hpp",
42-
],
43-
include_dirs=[
44-
".",
45-
"./src",
46-
dpctl.get_include(),
47-
],
48-
extra_compile_args=[
49-
"-Wall",
50-
"-Wextra",
51-
"-fsycl",
52-
],
53-
extra_link_args=["-fPIC"],
54-
language="c++",
55-
)
56-
]
17+
from skbuild import setup
5718

5819
setup(
5920
name="syclbuffer",
@@ -68,6 +29,5 @@ def build_extensions(self):
6829
license="Apache 2.0",
6930
author="Intel Corporation",
7031
url="https://github.com/IntelPython/dpctl",
71-
ext_modules=ext_modules,
72-
cmdclass={"build_ext": custom_build_ext},
32+
packages=["syclbuffer"],
7333
)
Lines changed: 46 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,46 @@
1+
cmake_minimum_required(VERSION 3.22...3.27 FATAL_ERROR)
2+
3+
project(example_cython_use_dpctl_sycl VERSION 0.1 LANGUAGES CXX
4+
DESCRIPTION "Example of Cython extension to use Cython API to SYCL objects.")
5+
set(DPCTL_CMAKE_MODULES_PATH "${CMAKE_SOURCE_DIR}/../../../cmake")
6+
set(CMAKE_MODULE_PATH ${CMAKE_MODULE_PATH} ${DPCTL_CMAKE_MODULES_PATH})
7+
8+
find_package(IntelSYCL REQUIRED PATHS ${DPCTL_CMAKE_MODULES_PATH} NO_DEFAULT_PATH)
9+
10+
11+
set(CMAKE_MODULE_PATH ${CMAKE_MODULE_PATH} "${CMAKE_SOURCE_DIR}")
12+
set(CMAKE_CXX_STANDARD 17)
13+
set(CMAKE_CXX_STANDARD_REQUIRED True)
14+
15+
# Define CMAKE_INSTALL_xxx: LIBDIR, INCLUDEDIR
16+
include(GNUInstallDirs)
17+
18+
find_package(Python REQUIRED COMPONENTS Development.Module NumPy)
19+
find_package(Dpctl REQUIRED)
20+
21+
# -w is to set working directory (and correctly set __pyx_f[] array of filenames)
22+
set(CYTHON_FLAGS "-t -w \"${CMAKE_SOURCE_DIR}\"")
23+
find_package(Cython REQUIRED)
24+
25+
set(py_module_name _cython_api)
26+
27+
set(_cy_source use_dpctl_sycl/_cython_api.pyx)
28+
add_cython_target(${py_module_name} ${_cy_source} CXX OUTPUT_VAR _generated_cy_src)
29+
Python_add_library(${py_module_name} MODULE WITH_SOABI ${_generated_cy_src})
30+
add_sycl_to_target(TARGET ${py_module_name} SOURCES ${_generated_cy_src})
31+
target_include_directories(${py_module_name} PUBLIC include ${Dpctl_INCLUDE_DIRS})
32+
target_link_libraries(${py_module_name} PRIVATE Python::NumPy)
33+
34+
install(TARGETS ${py_module_name} DESTINATION use_dpctl_sycl)
35+
36+
foreach(_src_fn ${_sources})
37+
get_source_file_property(_compile_options ${_src_fn} COMPILE_OPTIONS)
38+
set(_combined_options ${_compile_options} "-O3")
39+
set_source_files_properties(${_src_fn}
40+
PROPERTIES
41+
COMPILE_OPTIONS "${_combined_options}"
42+
)
43+
endforeach()
44+
target_link_options(${py_module_name} PRIVATE -fsycl-device-code-split=per_kernel)
45+
46+
set(ignoreMe "${SKBUILD}")

examples/cython/use_dpctl_sycl/setup.py

Lines changed: 13 additions & 33 deletions
Original file line numberDiff line numberDiff line change
@@ -14,40 +14,20 @@
1414
# See the License for the specific language governing permissions and
1515
# limitations under the License.
1616

17-
import Cython.Build
18-
import setuptools
19-
from setuptools.command.build_ext import build_ext as build_ext_base
17+
from skbuild import setup
2018

21-
import dpctl
22-
23-
24-
class custom_build_ext(build_ext_base):
25-
def build_extensions(self):
26-
self.compiler.set_executable("compiler_so", "icx -fsycl -fPIC")
27-
self.compiler.set_executable("compiler_cxx", "icpx -fsycl -fPIC")
28-
self.compiler.set_executable(
29-
"linker_so",
30-
"icpx -fsycl -shared -fpic -fsycl-device-code-split=per_kernel",
31-
)
32-
super().build_extensions()
33-
34-
35-
ext = setuptools.Extension(
36-
"use_dpctl_sycl._cython_api",
37-
["./use_dpctl_sycl/_cython_api.pyx"],
38-
include_dirs=[dpctl.get_include(), "./use_dpctl_sycl"],
39-
language="c++",
40-
)
41-
42-
(cythonized_ext,) = Cython.Build.cythonize(
43-
[
44-
ext,
45-
]
46-
)
47-
48-
setuptools.setup(
19+
setup(
4920
name="use_dpctl_sycl",
5021
version="0.0.0",
51-
ext_modules=[cythonized_ext],
52-
cmdclass={"build_ext": custom_build_ext},
22+
description="An example of Cython extension calling SYCL Cython API",
23+
long_description="""
24+
Example of using SYCL to work on host allocated NumPy array using
25+
SYCL buffers and SYCL functions.
26+
27+
See README.md for more details.
28+
""",
29+
license="Apache 2.0",
30+
author="Intel Corporation",
31+
url="https://github.com/IntelPython/dpctl",
32+
packages=["use_dpctl_sycl"],
5333
)
Lines changed: 56 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,56 @@
1+
cmake_minimum_required(VERSION 3.22...3.27 FATAL_ERROR)
2+
3+
project(example_cython_blackscholes_usm VERSION 0.1 LANGUAGES CXX
4+
DESCRIPTION "Example of Cython extension calling SYCL routines")
5+
set(DPCTL_CMAKE_MODULES_PATH "${CMAKE_SOURCE_DIR}/../../../cmake")
6+
set(CMAKE_MODULE_PATH ${CMAKE_MODULE_PATH} ${DPCTL_CMAKE_MODULES_PATH})
7+
8+
find_package(IntelSYCL REQUIRED PATHS ${DPCTL_CMAKE_MODULES_PATH} NO_DEFAULT_PATH)
9+
10+
11+
set(CMAKE_MODULE_PATH ${CMAKE_MODULE_PATH} "${CMAKE_SOURCE_DIR}")
12+
set(CMAKE_CXX_STANDARD 17)
13+
set(CMAKE_CXX_STANDARD_REQUIRED True)
14+
15+
# Define CMAKE_INSTALL_xxx: LIBDIR, INCLUDEDIR
16+
include(GNUInstallDirs)
17+
18+
find_package(Python REQUIRED COMPONENTS Development.Module NumPy)
19+
find_package(Dpctl REQUIRED)
20+
21+
# -t is to only Cythonize sources with timestamps newer than existing CXX files (if present)
22+
# -w is to set working directory (and correctly set __pyx_f[] array of filenames)
23+
set(CYTHON_FLAGS "-t -w \"${CMAKE_SOURCE_DIR}\"")
24+
find_package(Cython REQUIRED)
25+
26+
find_package(TBB REQUIRED)
27+
28+
set(MKL_ARCH "intel64")
29+
set(MKL_LINK "dynamic")
30+
set(MKL_THREADING "tbb_thread")
31+
set(MKL_INTERFACE "ilp64")
32+
find_package(MKL REQUIRED)
33+
34+
set(py_module_name _blackscholes_usm)
35+
36+
set(_cy_source blackscholes/_blackscholes_usm.pyx)
37+
add_cython_target(${py_module_name} ${_cy_source} CXX OUTPUT_VAR _generated_cy_src)
38+
Python_add_library(${py_module_name} MODULE WITH_SOABI ${_generated_cy_src})
39+
add_sycl_to_target(TARGET ${py_module_name} SOURCES ${_generated_cy_src})
40+
target_compile_definitions(${py_module_name} PRIVATE -DMKL_ILP64)
41+
target_include_directories(${py_module_name} PUBLIC src ${Dpctl_INCLUDE_DIRS})
42+
target_link_libraries(${py_module_name} PRIVATE MKL::MKL_SYCL Python::NumPy)
43+
44+
install(TARGETS ${py_module_name} DESTINATION blackscholes)
45+
46+
foreach(_src_fn ${_sources})
47+
get_source_file_property(_compile_options ${_src_fn} COMPILE_OPTIONS)
48+
set(_combined_options ${_compile_options} "-O3")
49+
set_source_files_properties(${_src_fn}
50+
PROPERTIES
51+
COMPILE_OPTIONS "${_combined_options}"
52+
)
53+
endforeach()
54+
target_link_options(${py_module_name} PRIVATE -fsycl-device-code-split=per_kernel)
55+
56+
set(ignoreMe "${SKBUILD}")

examples/cython/usm_memory/setup.py

Lines changed: 2 additions & 61 deletions
Original file line numberDiff line numberDiff line change
@@ -14,65 +14,7 @@
1414
# See the License for the specific language governing permissions and
1515
# limitations under the License.
1616

17-
import os.path
18-
import sysconfig
19-
20-
import numpy as np
21-
from setuptools import Extension, setup
22-
from setuptools.command.build_ext import build_ext
23-
24-
import dpctl
25-
26-
27-
class custom_build_ext(build_ext):
28-
def build_extensions(self):
29-
self.compiler.set_executable("compiler_so", "icpx -fsycl -fPIC")
30-
self.compiler.set_executable("compiler_cxx", "icpx -fsycl -fPIC")
31-
self.compiler.set_executable(
32-
"linker_so",
33-
"icpx -fsycl -shared -fpic -fsycl-device-code-split=per_kernel",
34-
)
35-
build_ext.build_extensions(self)
36-
37-
38-
ext_modules = [
39-
Extension(
40-
name="blackscholes._blackscholes_usm",
41-
sources=[
42-
"blackscholes/blackscholes.pyx",
43-
],
44-
depends=[
45-
"src/sycl_black_scholes.hpp",
46-
],
47-
include_dirs=[
48-
"./src",
49-
np.get_include(),
50-
dpctl.get_include(),
51-
os.path.join(sysconfig.get_paths()["include"], ".."),
52-
],
53-
library_dirs=[
54-
os.path.join(sysconfig.get_paths()["stdlib"], ".."),
55-
],
56-
libraries=["sycl"]
57-
+ [
58-
"mkl_sycl",
59-
"mkl_intel_ilp64",
60-
"mkl_tbb_thread",
61-
"mkl_core",
62-
"tbb",
63-
],
64-
runtime_library_dirs=[],
65-
extra_compile_args=[
66-
"-Wall",
67-
"-Wextra",
68-
"-fsycl",
69-
"-fno-fast-math",
70-
],
71-
extra_link_args=["-fPIC"],
72-
language="c++",
73-
)
74-
]
75-
17+
from skbuild import setup
7618

7719
setup(
7820
name="blackscholes_usm",
@@ -86,6 +28,5 @@ def build_extensions(self):
8628
license="Apache 2.0",
8729
author="Intel Corporation",
8830
url="https://github.com/IntelPython/dpctl",
89-
ext_modules=ext_modules,
90-
cmdclass={"build_ext": custom_build_ext},
31+
packages=["blackscholes"],
9132
)

0 commit comments

Comments
 (0)