Skip to content

Commit e110653

Browse files
authored
Merge branch 'master' into dpctl-setting-shape-by-scalar
2 parents 3f5a293 + 6ae16ce commit e110653

33 files changed

+1011
-221
lines changed

.github/workflows/conda-package.yml

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -144,13 +144,13 @@ jobs:
144144
run: conda build --no-test --python ${{ matrix.python }} --numpy 1.24 ${{ env.CHANNELS }} conda-recipe
145145

146146
- name: Upload artifact
147-
uses: actions/upload-artifact@89ef406dd8d7e03cfd12d9e0a4a378f454709029 # v4.3.5
147+
uses: actions/upload-artifact@834a144ee995460fba8ed112a2fc961b36a5ec5a # v4.3.6
148148
with:
149149
name: ${{ env.PACKAGE_NAME }} ${{ runner.os }} Python ${{ matrix.python }}
150150
path: ${{ env.CONDA_BLD }}${{ env.PACKAGE_NAME }}-*.tar.bz2
151151

152152
- name: Upload wheels artifact
153-
uses: actions/upload-artifact@89ef406dd8d7e03cfd12d9e0a4a378f454709029 # v4.3.5
153+
uses: actions/upload-artifact@834a144ee995460fba8ed112a2fc961b36a5ec5a # v4.3.6
154154
with:
155155
name: ${{ env.PACKAGE_NAME }} ${{ runner.os }} Wheels Python ${{ matrix.python }}
156156
path: ${{ env.WHEELS_OUTPUT_FOLDER }}${{ env.PACKAGE_NAME }}-*.whl

.github/workflows/openssf-scorecard.yml

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -60,14 +60,14 @@ jobs:
6060
# Upload the results as artifacts (optional). Commenting out will disable uploads of run results in SARIF
6161
# format to the repository Actions tab.
6262
- name: "Upload artifact"
63-
uses: actions/upload-artifact@89ef406dd8d7e03cfd12d9e0a4a378f454709029 # v4.3.5
63+
uses: actions/upload-artifact@834a144ee995460fba8ed112a2fc961b36a5ec5a # v4.3.6
6464
with:
6565
name: SARIF file
6666
path: results.sarif
6767
retention-days: 14
6868

6969
# Upload the results to GitHub's code scanning dashboard.
7070
- name: "Upload to code-scanning"
71-
uses: github/codeql-action/upload-sarif@afb54ba388a7dca6ecae48f608c4ff05ff4cc77a # v3.25.15
71+
uses: github/codeql-action/upload-sarif@eb055d739abdc2e8de2e5f4ba1a8b246daa779aa # v3.26.0
7272
with:
7373
sarif_file: results.sarif

CMakeLists.txt

Lines changed: 56 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -67,6 +67,62 @@ find_package(Dpctl REQUIRED)
6767
message(STATUS "Dpctl_INCLUDE_DIR=" ${Dpctl_INCLUDE_DIR})
6868
message(STATUS "Dpctl_TENSOR_INCLUDE_DIR=" ${Dpctl_TENSOR_INCLUDE_DIR})
6969

70+
option(DPNP_TARGET_CUDA
71+
"Build DPNP to target CUDA devices"
72+
OFF
73+
)
74+
option(DPNP_USE_ONEMKL_INTERFACES
75+
"Build DPNP with oneMKL Interfaces"
76+
OFF
77+
)
78+
set(_dpnp_sycl_targets)
79+
set(_use_onemkl_interfaces_cuda OFF)
80+
if ("x${DPNP_SYCL_TARGETS}" STREQUAL "x")
81+
if(DPNP_TARGET_CUDA)
82+
set(_dpnp_sycl_targets "nvptx64-nvidia-cuda,spir64-unknown-unknown")
83+
set(_use_onemkl_interfaces_cuda ON)
84+
else()
85+
if(DEFINED ENV{DPNP_TARGET_CUDA})
86+
set(_dpnp_sycl_targets "nvptx64-nvidia-cuda,spir64-unknown-unknown")
87+
set(_use_onemkl_interfaces_cuda ON)
88+
endif()
89+
endif()
90+
else()
91+
set(_dpnp_sycl_targets ${DPNP_SYCL_TARGETS})
92+
endif()
93+
94+
if(_dpnp_sycl_targets)
95+
message(STATUS "Compiling for -fsycl-targets=${_dpnp_sycl_targets}")
96+
endif()
97+
98+
set(_use_onemkl_interfaces OFF)
99+
if(DPNP_USE_ONEMKL_INTERFACES)
100+
set(_use_onemkl_interfaces ON)
101+
else()
102+
if(DEFINED ENV{DPNP_USE_ONEMKL_INTERFACES})
103+
set(_use_onemkl_interfaces ON)
104+
endif()
105+
endif()
106+
107+
if(_use_onemkl_interfaces)
108+
set(BUILD_FUNCTIONAL_TESTS False)
109+
set(BUILD_EXAMPLES False)
110+
if(_use_onemkl_interfaces_cuda)
111+
# set(ENABLE_CUBLAS_BACKEND True)
112+
set(ENABLE_CUSOLVER_BACKEND True)
113+
set(ENABLE_CUFFT_BACKEND True)
114+
# set(ENABLE_CURAND_BACKEND True)
115+
set(ENABLE_MKLGPU_BACKEND False)
116+
set(ENABLE_MKLCPU_BACKEND False)
117+
endif()
118+
FetchContent_Declare(
119+
onemkl_interfaces_library
120+
GIT_REPOSITORY https://github.com/oneapi-src/oneMKL.git
121+
GIT_TAG f2d2dcb4213a435bb60fbb88320c5f24892423ce
122+
)
123+
FetchContent_MakeAvailable(onemkl_interfaces_library)
124+
endif()
125+
70126
if(WIN32)
71127
string(CONCAT WARNING_FLAGS
72128
"-Wall "

dpnp/backend/extensions/fft/CMakeLists.txt

Lines changed: 20 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -34,6 +34,20 @@ set(_module_src
3434
pybind11_add_module(${python_module_name} MODULE ${_module_src})
3535
add_sycl_to_target(TARGET ${python_module_name} SOURCES ${_module_src})
3636

37+
if(_dpnp_sycl_targets)
38+
# make fat binary
39+
target_compile_options(
40+
${python_module_name}
41+
PRIVATE
42+
-fsycl-targets=${_dpnp_sycl_targets}
43+
)
44+
target_link_options(
45+
${python_module_name}
46+
PRIVATE
47+
-fsycl-targets=${_dpnp_sycl_targets}
48+
)
49+
endif()
50+
3751
if (WIN32)
3852
if (${CMAKE_VERSION} VERSION_LESS "3.27")
3953
# this is a work-around for target_link_options inserting option after -link option, cause
@@ -68,7 +82,12 @@ if (DPNP_GENERATE_COVERAGE)
6882
target_link_options(${python_module_name} PRIVATE -fprofile-instr-generate -fcoverage-mapping)
6983
endif()
7084

71-
target_link_libraries(${python_module_name} PUBLIC MKL::MKL_SYCL::DFT)
85+
if(_use_onemkl_interfaces)
86+
target_link_libraries(${python_module_name} PUBLIC onemkl)
87+
target_compile_options(${python_module_name} PRIVATE -DUSE_ONEMKL_INTERFACES)
88+
else()
89+
target_link_libraries(${python_module_name} PUBLIC MKL::MKL_SYCL::DFT)
90+
endif()
7291

7392
install(TARGETS ${python_module_name}
7493
DESTINATION "dpnp/backend/extensions/fft"

dpnp/backend/extensions/fft/common.hpp

Lines changed: 22 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -187,26 +187,32 @@ class DescriptorWrapper
187187
// config_param::PLACEMENT
188188
bool get_in_place()
189189
{
190-
// TODO: replace when MKLD-10506 is implemented
191-
// mkl_dft::config_value placement;
190+
#if defined(USE_ONEMKL_INTERFACES)
191+
mkl_dft::config_value placement;
192+
descr_.get_value(mkl_dft::config_param::PLACEMENT, &placement);
193+
return (placement == mkl_dft::config_value::INPLACE);
194+
#else
195+
// TODO: remove branch when MKLD-10506 is implemented
192196
DFTI_CONFIG_VALUE placement;
193-
194197
descr_.get_value(mkl_dft::config_param::PLACEMENT, &placement);
195-
// TODO: replace when MKLD-10506 is implemented
196-
// return (placement == mkl_dft::config_value::INPLACE);
197198
return (placement == DFTI_CONFIG_VALUE::DFTI_INPLACE);
199+
#endif // USE_ONEMKL_INTERFACES
198200
}
199201

200202
void set_in_place(const bool &in_place_request)
201203
{
202-
// TODO: replace when MKLD-10506 is implemented
203-
// descr_.set_value(mkl_dft::config_param::PLACEMENT, (in_place_request)
204-
// ? mkl_dft::config_value::INPLACE :
205-
// mkl_dft::config_value::NOT_INPLACE);
204+
#if defined(USE_ONEMKL_INTERFACES)
205+
descr_.set_value(mkl_dft::config_param::PLACEMENT,
206+
(in_place_request)
207+
? mkl_dft::config_value::INPLACE
208+
: mkl_dft::config_value::NOT_INPLACE);
209+
#else
210+
// TODO: remove branch when MKLD-10506 is implemented
206211
descr_.set_value(mkl_dft::config_param::PLACEMENT,
207212
(in_place_request)
208213
? DFTI_CONFIG_VALUE::DFTI_INPLACE
209214
: DFTI_CONFIG_VALUE::DFTI_NOT_INPLACE);
215+
#endif // USE_ONEMKL_INTERFACES
210216
}
211217

212218
// config_param::PRECISION
@@ -221,14 +227,16 @@ class DescriptorWrapper
221227
// config_param::COMMIT_STATUS
222228
bool is_committed()
223229
{
224-
// TODO: replace when MKLD-10506 is implemented
225-
// mkl_dft::config_value committed;
230+
#if defined(USE_ONEMKL_INTERFACES)
231+
mkl_dft::config_value committed;
232+
descr_.get_value(mkl_dft::config_param::COMMIT_STATUS, &committed);
233+
return (committed == mkl_dft::config_value::COMMITTED);
234+
#else
235+
// TODO: remove branch when MKLD-10506 is implemented
226236
DFTI_CONFIG_VALUE committed;
227-
228237
descr_.get_value(mkl_dft::config_param::COMMIT_STATUS, &committed);
229-
// TODO: replace when MKLD-10506 is implemented
230-
// return (committed == mkl_dft::config_value::COMMITTED);
231238
return (committed == DFTI_CONFIG_VALUE::DFTI_COMMITTED);
239+
#endif // USE_ONEMKL_INTERFACES
232240
}
233241

234242
private:

dpnp/backend/extensions/fft/out_of_place.cpp

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -23,7 +23,7 @@
2323
// THE POSSIBILITY OF SUCH DAMAGE.
2424
//*****************************************************************************
2525

26-
#include <oneapi/mkl/dfti.hpp>
26+
#include <oneapi/mkl.hpp>
2727
#include <sycl/sycl.hpp>
2828

2929
#include <dpctl4pybind11.hpp>

dpnp/backend/extensions/lapack/CMakeLists.txt

Lines changed: 20 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -51,6 +51,20 @@ set(_module_src
5151
pybind11_add_module(${python_module_name} MODULE ${_module_src})
5252
add_sycl_to_target(TARGET ${python_module_name} SOURCES ${_module_src})
5353

54+
if(_dpnp_sycl_targets)
55+
# make fat binary
56+
target_compile_options(
57+
${python_module_name}
58+
PRIVATE
59+
-fsycl-targets=${_dpnp_sycl_targets}
60+
)
61+
target_link_options(
62+
${python_module_name}
63+
PRIVATE
64+
-fsycl-targets=${_dpnp_sycl_targets}
65+
)
66+
endif()
67+
5468
if (WIN32)
5569
if (${CMAKE_VERSION} VERSION_LESS "3.27")
5670
# this is a work-around for target_link_options inserting option after -link option, cause
@@ -85,7 +99,12 @@ if (DPNP_GENERATE_COVERAGE)
8599
target_link_options(${python_module_name} PRIVATE -fprofile-instr-generate -fcoverage-mapping)
86100
endif()
87101

88-
target_link_libraries(${python_module_name} PUBLIC MKL::MKL_SYCL::LAPACK)
102+
if(_use_onemkl_interfaces)
103+
target_link_libraries(${python_module_name} PUBLIC onemkl)
104+
target_compile_options(${python_module_name} PRIVATE -DUSE_ONEMKL_INTERFACES)
105+
else()
106+
target_link_libraries(${python_module_name} PUBLIC MKL::MKL_SYCL::LAPACK)
107+
endif()
89108

90109
install(TARGETS ${python_module_name}
91110
DESTINATION "dpnp/backend/extensions/lapack"

dpnp/backend/extensions/lapack/gesv.cpp

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -56,6 +56,11 @@ static sycl::event gesv_impl(sycl::queue &exec_q,
5656
char *in_b,
5757
const std::vector<sycl::event> &depends)
5858
{
59+
#if defined(USE_ONEMKL_INTERFACES)
60+
// Temporary flag for build only
61+
// FIXME: Need to implement by using lapack::getrf and lapack::getrs
62+
std::logic_error("Not Implemented");
63+
#else
5964
type_utils::validate_type_for_device<T>(exec_q);
6065

6166
T *a = reinterpret_cast<T *>(in_a);
@@ -129,6 +134,7 @@ static sycl::event gesv_impl(sycl::queue &exec_q,
129134
});
130135

131136
return ht_ev;
137+
#endif // USE_ONEMKL_INTERFACES
132138
}
133139

134140
std::pair<sycl::event, sycl::event>

dpnp/backend/extensions/ufunc/CMakeLists.txt

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -27,6 +27,7 @@ set(_elementwise_sources
2727
${CMAKE_CURRENT_SOURCE_DIR}/elementwise_functions/common.cpp
2828
${CMAKE_CURRENT_SOURCE_DIR}/elementwise_functions/degrees.cpp
2929
${CMAKE_CURRENT_SOURCE_DIR}/elementwise_functions/fabs.cpp
30+
${CMAKE_CURRENT_SOURCE_DIR}/elementwise_functions/fix.cpp
3031
${CMAKE_CURRENT_SOURCE_DIR}/elementwise_functions/float_power.cpp
3132
${CMAKE_CURRENT_SOURCE_DIR}/elementwise_functions/fmax.cpp
3233
${CMAKE_CURRENT_SOURCE_DIR}/elementwise_functions/fmin.cpp

dpnp/backend/extensions/ufunc/elementwise_functions/common.cpp

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -27,6 +27,7 @@
2727

2828
#include "degrees.hpp"
2929
#include "fabs.hpp"
30+
#include "fix.hpp"
3031
#include "float_power.hpp"
3132
#include "fmax.hpp"
3233
#include "fmin.hpp"
@@ -45,6 +46,7 @@ void init_elementwise_functions(py::module_ m)
4546
{
4647
init_degrees(m);
4748
init_fabs(m);
49+
init_fix(m);
4850
init_float_power(m);
4951
init_fmax(m);
5052
init_fmin(m);

0 commit comments

Comments
 (0)