Skip to content

Commit 3ba741a

Browse files
Add public C-API header for dpctl_ext
1 parent 9a7fae9 commit 3ba741a

4 files changed

Lines changed: 60 additions & 10 deletions

File tree

CMakeLists.txt

Lines changed: 12 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -344,14 +344,20 @@ 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 from the build directory
351+
#
352+
# This follows the same pattern as dpctl's DpctlCAPI interface library
352353

353354
add_library(DpctlExtCAPI INTERFACE)
354-
target_include_directories(DpctlExtCAPI INTERFACE ${CMAKE_BINARY_DIR})
355+
target_include_directories(
356+
DpctlExtCAPI
357+
INTERFACE
358+
${CMAKE_CURRENT_SOURCE_DIR}/dpctl_ext/apis/include
359+
${CMAKE_BINARY_DIR} # For generated Cython headers
360+
)
355361

356362
add_subdirectory(dpctl_ext)
357363
add_subdirectory(dpnp)

dpctl_ext/CMakeLists.txt

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -197,4 +197,12 @@ function(build_dpctl_ext _trgt _src _dest)
197197
target_include_directories(${_trgt_headers} INTERFACE ${_trgt_headers_dir})
198198
endfunction()
199199

200+
# Install dpctl_ext C-API headers (similar to dpctl's C-API installation)
201+
install(
202+
DIRECTORY ${CMAKE_CURRENT_SOURCE_DIR}/apis/include/
203+
DESTINATION ${CMAKE_INSTALL_PREFIX}/dpctl_ext/include
204+
FILES_MATCHING
205+
REGEX "\\.h(pp)?$"
206+
)
207+
200208
add_subdirectory(tensor)
Lines changed: 37 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,37 @@
1+
//===----------- dpctl_ext_capi.h - Headers for dpctl_ext C-API -*-C++-*-===//
2+
//
3+
// Data Parallel Extension for NumPy (dpnp)
4+
//
5+
// Copyright 2026 Intel Corporation
6+
//
7+
// Licensed under the Apache License, Version 2.0 (the "License");
8+
// you may not use this file except in compliance with the License.
9+
// You may obtain a copy of the License at
10+
//
11+
// http://www.apache.org/licenses/LICENSE-2.0
12+
//
13+
// Unless required by applicable law or agreed to in writing, software
14+
// distributed under the License is distributed on an "AS IS" BASIS,
15+
// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
16+
// See the License for the specific language governing permissions and
17+
// limitations under the License.
18+
//
19+
//===----------------------------------------------------------------------===//
20+
///
21+
/// \file
22+
/// This file provides access to dpctl_ext's C-API, primarily for accessing
23+
/// usm_ndarray types generated by Cython.
24+
///
25+
/// The generated Cython headers are located in the build directory at:
26+
/// ${CMAKE_BINARY_DIR}/dpctl_ext/tensor/
27+
///
28+
/// This header serves as the public API entry point and should be included
29+
/// instead of directly including the generated headers.
30+
//===----------------------------------------------------------------------===//
31+
32+
#pragma once
33+
34+
// Include the generated Cython C-API headers for usm_ndarray
35+
// These headers are generated during build and placed in the build directory
36+
#include <dpctl_ext/tensor/_usmarray.h>
37+
#include <dpctl_ext/tensor/_usmarray_api.h>

dpnp/backend/include/dpnp4pybind11.hpp

Lines changed: 3 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -63,10 +63,9 @@
6363

6464
// clang-format on
6565

66-
// TODO: Keep these includes once `dpctl.tensor` is removed from dpctl,
67-
// but replace the hardcoded relative path with a proper include pathы
68-
#include <dpctl_ext/tensor/_usmarray.h>
69-
#include <dpctl_ext/tensor/_usmarray_api.h>
66+
// Include dpctl_ext C-API (provides access to usm_ndarray types)
67+
// This uses the public API header from dpctl_ext/apis/include
68+
#include "dpctl_ext_capi.h"
7069

7170
/*
7271
* Function to import dpctl and make C-API functions available.

0 commit comments

Comments
 (0)