Skip to content

Commit c4d8719

Browse files
Add specialized kernel for sum(axis=0) as extension (#1479)
* Initial commit * Cleanups and fixes * Review comments, bug fixing and tests
1 parent 977b597 commit c4d8719

File tree

7 files changed

+1188
-0
lines changed

7 files changed

+1188
-0
lines changed

dpnp/CMakeLists.txt

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -49,6 +49,7 @@ build_dpnp_cython_ext_with_backend(dparray ${CMAKE_CURRENT_SOURCE_DIR}/dparray.p
4949
add_subdirectory(backend)
5050
add_subdirectory(backend/extensions/lapack)
5151
add_subdirectory(backend/extensions/vm)
52+
add_subdirectory(backend/extensions/sycl_ext)
5253

5354
add_subdirectory(dpnp_algo)
5455
add_subdirectory(dpnp_utils)
Lines changed: 72 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,72 @@
1+
# *****************************************************************************
2+
# Copyright (c) 2016-2023, Intel Corporation
3+
# All rights reserved.
4+
#
5+
# Redistribution and use in source and binary forms, with or without
6+
# modification, are permitted provided that the following conditions are met:
7+
# - Redistributions of source code must retain the above copyright notice,
8+
# this list of conditions and the following disclaimer.
9+
# - Redistributions in binary form must reproduce the above copyright notice,
10+
# this list of conditions and the following disclaimer in the documentation
11+
# and/or other materials provided with the distribution.
12+
#
13+
# THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS"
14+
# AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
15+
# IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
16+
# ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE
17+
# LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR
18+
# CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF
19+
# SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS
20+
# INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN
21+
# CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
22+
# ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF
23+
# THE POSSIBILITY OF SUCH DAMAGE.
24+
# *****************************************************************************
25+
26+
27+
set(python_module_name _sycl_ext_impl)
28+
pybind11_add_module(${python_module_name} MODULE
29+
sum_mean.cpp
30+
)
31+
32+
if (WIN32)
33+
if (${CMAKE_VERSION} VERSION_LESS "3.27")
34+
# this is a work-around for target_link_options inserting option after -link option, cause
35+
# linker to ignore it.
36+
set(CMAKE_CXX_LINK_FLAGS "${CMAKE_CXX_LINK_FLAGS} -fsycl-device-code-split=per_kernel")
37+
endif()
38+
endif()
39+
40+
set_target_properties(${python_module_name} PROPERTIES CMAKE_POSITION_INDEPENDENT_CODE ON)
41+
42+
target_include_directories(${python_module_name} PRIVATE ${CMAKE_CURRENT_SOURCE_DIR}/../../include)
43+
target_include_directories(${python_module_name} PRIVATE ${CMAKE_CURRENT_SOURCE_DIR}/../../src)
44+
45+
target_include_directories(${python_module_name} PUBLIC ${Dpctl_INCLUDE_DIRS})
46+
target_include_directories(${python_module_name} PUBLIC ${Dpctl_TENSOR_INCLUDE_DIR})
47+
48+
if (WIN32)
49+
target_compile_options(${python_module_name} PRIVATE
50+
/clang:-fno-approx-func
51+
/clang:-fno-finite-math-only
52+
)
53+
else()
54+
target_compile_options(${python_module_name} PRIVATE
55+
-fno-approx-func
56+
-fno-finite-math-only
57+
)
58+
endif()
59+
60+
target_link_options(${python_module_name} PUBLIC -fsycl-device-code-split=per_kernel)
61+
if (UNIX)
62+
# this option is support on Linux only
63+
target_link_options(${python_module_name} PUBLIC -fsycl-link-huge-device-code)
64+
endif()
65+
66+
if (DPNP_GENERATE_COVERAGE)
67+
target_link_options(${python_module_name} PRIVATE -fprofile-instr-generate -fcoverage-mapping)
68+
endif()
69+
70+
install(TARGETS ${python_module_name}
71+
DESTINATION "dpnp/backend/extensions/sycl_ext"
72+
)

0 commit comments

Comments
 (0)