Skip to content

Commit 8079328

Browse files
author
Alexander Batashev
committed
[SYCL] Use public interfaces in function_pointer.hpp
This patch is a part of effort to decouple SYCL Runtime library interface from its actual implementation. The goal is to improve SYCL ABI/API compatibility between different versions of library. Two helper functions were introduced to eliminate calls to _impl classes. This caused 3 tests fail. 2 tests were found to use internal APIs. Missing include clauses were added to workaround those fails. A more robust solution will be provided in separate patches. Signed-off-by: Alexander Batashev <[email protected]>
1 parent 5d1c8a6 commit 8079328

File tree

6 files changed

+40
-5
lines changed

6 files changed

+40
-5
lines changed

sycl/include/CL/sycl/intel/function_pointer.hpp

Lines changed: 7 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -8,7 +8,6 @@
88

99
#pragma once
1010

11-
#include <CL/sycl/detail/program_impl.hpp>
1211
#include <CL/sycl/device.hpp>
1312
#include <CL/sycl/program.hpp>
1413
#include <CL/sycl/stl.hpp>
@@ -17,6 +16,11 @@
1716

1817
__SYCL_INLINE namespace cl {
1918
namespace sycl {
19+
namespace detail {
20+
// Helper functions to avoid calls to implementation detail methods.
21+
pi_device getRawDevice(device &D);
22+
pi_program getRawProgram(program &P);
23+
} // namespace detail
2024
namespace intel {
2125

2226
// This is a preview extension implementation, intended to provide early access
@@ -27,7 +31,7 @@ namespace intel {
2731
// products. If you are interested in using this feature in your software
2832
// product, please let us know!
2933

30-
using device_func_ptr_holder_t = cl::sycl::cl_ulong;
34+
using device_func_ptr_holder_t = cl_ulong;
3135

3236
/// \brief this function performs a cast from device_func_ptr_holder_t type
3337
/// to the provided function pointer type.
@@ -82,9 +86,7 @@ device_func_ptr_holder_t get_device_func_ptr(FuncType F, const char *FuncName,
8286
// FIXME: return value must be checked here, but since we cannot yet check
8387
// if corresponding extension is supported, let's silently ignore it here.
8488
PI_CALL(piextGetDeviceFunctionPointer)(
85-
detail::pi::cast<pi_device>(detail::getSyclObjImpl(D)->getHandleRef()),
86-
detail::pi::cast<pi_program>(detail::getSyclObjImpl(P)->getHandleRef()),
87-
FuncName, &FPtr);
89+
detail::getRawDevice(D), detail::getRawProgram(P), FuncName, &FPtr);
8890

8991
return FPtr;
9092
}

sycl/source/CMakeLists.txt

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -88,6 +88,7 @@ set(SYCL_SOURCES
8888
"event.cpp"
8989
"exception.cpp"
9090
"exception_list.cpp"
91+
"function_pointer.cpp"
9192
"half_type.cpp"
9293
"handler.cpp"
9394
"kernel.cpp"

sycl/source/function_pointer.cpp

Lines changed: 25 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,25 @@
1+
//==----------- function_pointer.cpp --- SYCL Function pointers ------------==//
2+
//
3+
// Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions.
4+
// See https://llvm.org/LICENSE.txt for license information.
5+
// SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception
6+
//
7+
//===----------------------------------------------------------------------===//
8+
9+
#include <CL/sycl/detail/program_impl.hpp>
10+
#include <CL/sycl/intel/function_pointer.hpp>
11+
12+
__SYCL_INLINE namespace cl {
13+
namespace sycl {
14+
namespace detail {
15+
pi_device getRawDevice(device &D) {
16+
return detail::pi::cast<pi_device>(
17+
detail::getSyclObjImpl(D)->getHandleRef());
18+
}
19+
pi_program getRawProgram(program &P) {
20+
return detail::pi::cast<pi_program>(
21+
detail::getSyclObjImpl(P)->getHandleRef());
22+
}
23+
} // namespace detail
24+
} // namespace sycl
25+
}

sycl/test/basic_tests/image_api.cpp

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -7,6 +7,9 @@
77
// RUN: %ACC_RUN_PLACEHOLDER %t1.out
88

99
#include <CL/sycl.hpp>
10+
// FIXME do not use internal methods in tests.
11+
#include <CL/sycl/detail/cg.hpp>
12+
#include <CL/sycl/detail/kernel_impl.hpp>
1013

1114
#include <algorithm>
1215
#include <array>

sycl/test/kernel-and-program/cache.cpp

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -9,6 +9,8 @@
99
//===----------------------------------------------------------------------===//
1010

1111
#include <CL/sycl.hpp>
12+
// FIXME do not use internal methods in tests.
13+
#include <CL/sycl/detail/program_impl.hpp>
1214

1315
namespace RT = cl::sycl::RT;
1416
namespace detail = cl::sycl::detail;

sycl/test/sub_group/common_ocl.cpp

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -16,7 +16,9 @@
1616
#include "helper.hpp"
1717
#include <CL/sycl.hpp>
1818
#include <cstring>
19+
#include <fstream>
1920
#include <iostream>
21+
2022
using namespace cl::sycl;
2123
struct Data {
2224
unsigned int local_id;

0 commit comments

Comments
 (0)