|
1 | | -//===----------- dpctl_ext_capi.h - Headers for dpctl_ext C-API -*-C++-*-===// |
| 1 | +//***************************************************************************** |
| 2 | +// Copyright (c) 2026, Intel Corporation |
| 3 | +// All rights reserved. |
2 | 4 | // |
3 | | -// Data Parallel Extension for NumPy (dpnp) |
| 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. |
4 | 15 | // |
5 | | -// Copyright 2026 Intel Corporation |
| 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 | +//***************************************************************************** |
6 | 28 | // |
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 | | -//===----------------------------------------------------------------------===// |
| 29 | +//===---------------------------------------------------------------------===// |
20 | 30 | /// |
21 | 31 | /// \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 | | -//===----------------------------------------------------------------------===// |
| 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 | +//===---------------------------------------------------------------------===// |
31 | 36 |
|
32 | 37 | #pragma once |
33 | 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 | + |
34 | 67 | // Include the generated Cython C-API headers for usm_ndarray |
35 | 68 | // These headers are generated during build and placed in the build directory |
36 | 69 | #include <dpctl_ext/tensor/_usmarray.h> |
37 | 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 | +} |
0 commit comments