Skip to content

Commit 252f385

Browse files
Merge move_usm_ndarray into move_tensor_tests
2 parents 5c96686 + 7327502 commit 252f385

54 files changed

Lines changed: 361 additions & 221 deletions

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

.github/workflows/build-sphinx.yml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -26,7 +26,7 @@ jobs:
2626
name: Build and Deploy Docs
2727

2828
runs-on: ubuntu-22.04
29-
timeout-minutes: 60
29+
timeout-minutes: 90
3030

3131
permissions:
3232
# Needed to cancel any previous runs that are not completed for a given workflow

CMakeLists.txt

Lines changed: 8 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -344,14 +344,16 @@ if(DEFINED SKBUILD)
344344
set(_ignore_me ${SKBUILD})
345345
endif()
346346

347-
# TODO: Replace `${CMAKE_BINARY_DIR}` with a dedicated public include root
348-
# for dpctl_ext C-API headers
349-
# Unlike dpctl which exposes C-API from `dpctl/apis/include`,
350-
# dpctl_ext currently relies on generated headers in the build tree.
351-
# `${CMAKE_BINARY_DIR}` is a temporary workaround.
347+
# DpctlExtCAPI: Interface library for dpctl_ext C-API
348+
# Provides access to:
349+
# 1. Public C-API headers from dpctl_ext/apis/include
350+
# 2. Generated Cython headers via per-target header interface libraries
352351

353352
add_library(DpctlExtCAPI INTERFACE)
354-
target_include_directories(DpctlExtCAPI INTERFACE ${CMAKE_BINARY_DIR})
353+
target_include_directories(
354+
DpctlExtCAPI
355+
INTERFACE ${CMAKE_CURRENT_SOURCE_DIR}/dpctl_ext/apis/include
356+
)
355357

356358
add_subdirectory(dpctl_ext)
357359
add_subdirectory(dpnp)

dpctl_ext/CMakeLists.txt

Lines changed: 12 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -159,9 +159,11 @@ function(build_dpctl_ext _trgt _src _dest)
159159
# TODO: create separate folder inside build folder that contains only
160160
# headers related to this target and appropriate folder structure to
161161
# eliminate shadow dependencies
162-
get_filename_component(_generated_src_dir_dir ${_generated_src_dir} DIRECTORY)
162+
# Go up two levels to build root for "dpctl_ext/tensor/_usmarray.h" resolution
163+
get_filename_component(_parent_dir ${_generated_src_dir} DIRECTORY)
164+
get_filename_component(_build_root ${_parent_dir} DIRECTORY)
163165
# TODO: do not set directory if we did not generate header
164-
target_include_directories(${_trgt} INTERFACE ${_generated_src_dir_dir})
166+
target_include_directories(${_trgt} INTERFACE ${_build_root})
165167
set(_rpath_value "$ORIGIN")
166168
if(BUILD_DPCTL_EXT_RELATIVE_PATH)
167169
set(_rpath_value "${_rpath_value}/${BUILD_DPCTL_EXT_RELATIVE_PATH}")
@@ -197,4 +199,12 @@ function(build_dpctl_ext _trgt _src _dest)
197199
target_include_directories(${_trgt_headers} INTERFACE ${_trgt_headers_dir})
198200
endfunction()
199201

202+
# Install dpctl_ext C-API headers (similar to dpctl's C-API installation)
203+
install(
204+
DIRECTORY ${CMAKE_CURRENT_SOURCE_DIR}/apis/include/
205+
DESTINATION ${CMAKE_INSTALL_PREFIX}/dpctl_ext/include
206+
FILES_MATCHING
207+
REGEX "\\.h(pp)?$"
208+
)
209+
200210
add_subdirectory(tensor)
Lines changed: 106 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,106 @@
1+
//*****************************************************************************
2+
// Copyright (c) 2026, 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+
// - Neither the name of the copyright holder nor the names of its contributors
13+
// may be used to endorse or promote products derived from this software
14+
// without specific prior written permission.
15+
//
16+
// THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS"
17+
// AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
18+
// IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
19+
// ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE
20+
// LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR
21+
// CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF
22+
// SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS
23+
// INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN
24+
// CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
25+
// ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF
26+
// THE POSSIBILITY OF SUCH DAMAGE.
27+
//*****************************************************************************
28+
//
29+
//===---------------------------------------------------------------------===//
30+
///
31+
/// \file
32+
/// This file provides access to dpctl_ext's C-API, including:
33+
/// - dpctl C-API (from external dpctl package - SYCL interface)
34+
/// - dpctl_ext tensor C-API (usm_ndarray)
35+
//===---------------------------------------------------------------------===//
36+
37+
#pragma once
38+
39+
// Include dpctl C-API headers explicitly from external dpctl package (SYCL
40+
// interface)
41+
// TODO: Once dpctl removes its tensor module and stabilizes dpctl_capi.h,
42+
// we can simplify to just: #include "dpctl_capi.h"
43+
// For now, explicit includes ensure we only get SYCL interface without tensor.
44+
45+
#include "syclinterface/dpctl_sycl_extension_interface.h"
46+
#include "syclinterface/dpctl_sycl_types.h"
47+
48+
#ifdef __cplusplus
49+
#define CYTHON_EXTERN_C extern "C"
50+
#else
51+
#define CYTHON_EXTERN_C
52+
#endif
53+
54+
#include "dpctl/_sycl_context.h"
55+
#include "dpctl/_sycl_context_api.h"
56+
#include "dpctl/_sycl_device.h"
57+
#include "dpctl/_sycl_device_api.h"
58+
#include "dpctl/_sycl_event.h"
59+
#include "dpctl/_sycl_event_api.h"
60+
#include "dpctl/_sycl_queue.h"
61+
#include "dpctl/_sycl_queue_api.h"
62+
#include "dpctl/memory/_memory.h"
63+
#include "dpctl/memory/_memory_api.h"
64+
#include "dpctl/program/_program.h"
65+
#include "dpctl/program/_program_api.h"
66+
67+
// Include the generated Cython C-API headers for usm_ndarray
68+
// These headers are generated during build and placed in the build directory
69+
#include "dpctl_ext/tensor/_usmarray.h"
70+
#include "dpctl_ext/tensor/_usmarray_api.h"
71+
72+
/*
73+
* Function to import dpctl_ext C-API and make it available.
74+
* This imports both:
75+
* - dpctl C-API (from external dpctl package - SYCL interface)
76+
* - dpctl_ext C-API (tensor interface - usm_ndarray)
77+
*
78+
* C functions can use dpctl_ext's C-API functions without linking to
79+
* shared objects defining these symbols, if they call `import_dpctl_ext()`
80+
* prior to using those symbols.
81+
*
82+
* It is declared inline to allow multiple definitions in
83+
* different translation units.
84+
*
85+
* TODO: When dpctl_ext is renamed to dpctl.tensor:
86+
* - Rename this file: dpctl_ext_capi.h → dpctl/tensor/tensor_capi.h
87+
* (Use tensor_capi.h, NOT dpctl_capi.h, to avoid conflict with external
88+
* dpctl)
89+
* - Rename this function: import_dpctl_ext() → import_dpctl_tensor()
90+
* - Include external dpctl_capi.h and simplify imports to use import_dpctl()
91+
*/
92+
static inline void import_dpctl_ext(void)
93+
{
94+
// Import dpctl SYCL interface
95+
// TODO: Once dpctl removes its tensor module and stabilizes dpctl_capi.h,
96+
// we can simplify to just: import_dpctl()
97+
import_dpctl___sycl_device();
98+
import_dpctl___sycl_context();
99+
import_dpctl___sycl_event();
100+
import_dpctl___sycl_queue();
101+
import_dpctl__memory___memory();
102+
import_dpctl__program___program();
103+
// Import dpctl_ext tensor interface
104+
import_dpctl_ext__tensor___usmarray();
105+
return;
106+
}

dpctl_ext/tensor/libtensor/include/kernels/elementwise_functions/angle.hpp

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -32,6 +32,7 @@
3232
/// This file defines kernels for elementwise evaluation of ANGLE(x) function.
3333
//===---------------------------------------------------------------------===//
3434

35+
#pragma once
3536
#include <complex>
3637
#include <cstddef>
3738
#include <cstdint>

dpctl_ext/tensor/libtensor/include/kernels/elementwise_functions/atan2.hpp

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -34,6 +34,7 @@
3434
//===---------------------------------------------------------------------===//
3535

3636
#pragma once
37+
#include <cmath>
3738
#include <cstddef>
3839
#include <cstdint>
3940
#include <type_traits>

dpctl_ext/tensor/libtensor/include/kernels/elementwise_functions/bitwise_and.hpp

Lines changed: 0 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -54,7 +54,6 @@ namespace dpctl::tensor::kernels::bitwise_and
5454

5555
using dpctl::tensor::ssize_t;
5656
namespace td_ns = dpctl::tensor::type_dispatch;
57-
namespace tu_ns = dpctl::tensor::type_utils;
5857

5958
template <typename argT1, typename argT2, typename resT>
6059
struct BitwiseAndFunctor
@@ -67,8 +66,6 @@ struct BitwiseAndFunctor
6766

6867
resT operator()(const argT1 &in1, const argT2 &in2) const
6968
{
70-
using tu_ns::convert_impl;
71-
7269
if constexpr (std::is_same_v<resT, bool>) {
7370
return in1 && in2;
7471
}
@@ -296,8 +293,6 @@ struct BitwiseAndInplaceFunctor
296293

297294
void operator()(resT &res, const argT &in) const
298295
{
299-
using tu_ns::convert_impl;
300-
301296
if constexpr (std::is_same_v<resT, bool>) {
302297
res = res && in;
303298
}

dpctl_ext/tensor/libtensor/include/kernels/elementwise_functions/bitwise_invert.hpp

Lines changed: 0 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -47,16 +47,12 @@
4747
#include "kernels/elementwise_functions/common.hpp"
4848

4949
#include "utils/type_dispatch_building.hpp"
50-
#include "utils/type_utils.hpp"
5150

5251
namespace dpctl::tensor::kernels::bitwise_invert
5352
{
5453

5554
using dpctl::tensor::ssize_t;
5655
namespace td_ns = dpctl::tensor::type_dispatch;
57-
namespace tu_ns = dpctl::tensor::type_utils;
58-
59-
using dpctl::tensor::type_utils::vec_cast;
6056

6157
template <typename argT, typename resT>
6258
struct BitwiseInvertFunctor

dpctl_ext/tensor/libtensor/include/kernels/elementwise_functions/bitwise_or.hpp

Lines changed: 0 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -54,7 +54,6 @@ namespace dpctl::tensor::kernels::bitwise_or
5454

5555
using dpctl::tensor::ssize_t;
5656
namespace td_ns = dpctl::tensor::type_dispatch;
57-
namespace tu_ns = dpctl::tensor::type_utils;
5857

5958
template <typename argT1, typename argT2, typename resT>
6059
struct BitwiseOrFunctor
@@ -67,8 +66,6 @@ struct BitwiseOrFunctor
6766

6867
resT operator()(const argT1 &in1, const argT2 &in2) const
6968
{
70-
using tu_ns::convert_impl;
71-
7269
if constexpr (std::is_same_v<resT, bool>) {
7370
return in1 || in2;
7471
}
@@ -296,8 +293,6 @@ struct BitwiseOrInplaceFunctor
296293

297294
void operator()(resT &res, const argT &in) const
298295
{
299-
using tu_ns::convert_impl;
300-
301296
if constexpr (std::is_same_v<resT, bool>) {
302297
res = res || in;
303298
}

dpctl_ext/tensor/libtensor/include/kernels/elementwise_functions/bitwise_xor.hpp

Lines changed: 0 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -54,7 +54,6 @@ namespace dpctl::tensor::kernels::bitwise_xor
5454

5555
using dpctl::tensor::ssize_t;
5656
namespace td_ns = dpctl::tensor::type_dispatch;
57-
namespace tu_ns = dpctl::tensor::type_utils;
5857

5958
template <typename argT1, typename argT2, typename resT>
6059
struct BitwiseXorFunctor
@@ -297,8 +296,6 @@ struct BitwiseXorInplaceFunctor
297296

298297
void operator()(resT &res, const argT &in) const
299298
{
300-
using tu_ns::convert_impl;
301-
302299
if constexpr (std::is_same_v<resT, bool>) {
303300
res = (res != in);
304301
}

0 commit comments

Comments
 (0)