Skip to content

Commit 4ae7cad

Browse files
[SYCL] Remove program_impl (#14368)
The class was originally an implementation of the SYCL 1.2.1 program class, and then used internally for the kernel bundle implementation. It shouldn't be needed anymore.
1 parent 577c349 commit 4ae7cad

File tree

11 files changed

+12
-987
lines changed

11 files changed

+12
-987
lines changed

sycl/source/CMakeLists.txt

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -223,7 +223,6 @@ set(SYCL_COMMON_SOURCES
223223
"detail/memory_manager.cpp"
224224
"detail/pipes.cpp"
225225
"detail/platform_impl.cpp"
226-
"detail/program_impl.cpp"
227226
"detail/program_manager/program_manager.cpp"
228227
"detail/queue_impl.cpp"
229228
"detail/online_compiler/online_compiler.cpp"

sycl/source/backend/level_zero.cpp

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -8,7 +8,6 @@
88

99
#include <detail/platform_impl.hpp>
1010
#include <detail/plugin.hpp>
11-
#include <detail/program_impl.hpp>
1211
#include <detail/queue_impl.hpp>
1312
#include <sycl/backend.hpp>
1413
#include <sycl/sycl.hpp>

sycl/source/backend/opencl.cpp

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -9,7 +9,6 @@
99
#include <detail/kernel_impl.hpp>
1010
#include <detail/platform_impl.hpp>
1111
#include <detail/plugin.hpp>
12-
#include <detail/program_impl.hpp>
1312
#include <detail/queue_impl.hpp>
1413
#include <sycl/sycl.hpp>
1514

sycl/source/detail/kernel_impl.cpp

Lines changed: 11 additions & 30 deletions
Original file line numberDiff line numberDiff line change
@@ -9,7 +9,6 @@
99
#include <detail/context_impl.hpp>
1010
#include <detail/kernel_bundle_impl.hpp>
1111
#include <detail/kernel_impl.hpp>
12-
#include <detail/program_impl.hpp>
1312

1413
#include <memory>
1514

@@ -18,34 +17,14 @@ inline namespace _V1 {
1817
namespace detail {
1918

2019
kernel_impl::kernel_impl(sycl::detail::pi::PiKernel Kernel,
21-
ContextImplPtr Context,
22-
KernelBundleImplPtr KernelBundleImpl,
23-
const KernelArgMask *ArgMask)
24-
: kernel_impl(Kernel, Context,
25-
std::make_shared<program_impl>(Context, Kernel),
26-
/*IsCreatedFromSource*/ true, KernelBundleImpl, ArgMask) {
27-
// Enable USM indirect access for interoperability kernels.
28-
// Some PI Plugins (like OpenCL) require this call to enable USM
29-
// For others, PI will turn this into a NOP.
30-
if (Context->getPlatformImpl()->supports_usm())
31-
getPlugin()->call<PiApiKind::piKernelSetExecInfo>(
32-
MKernel, PI_USM_INDIRECT_ACCESS, sizeof(pi_bool), &PI_TRUE);
33-
34-
// This constructor is only called in the interoperability kernel constructor.
35-
MIsInterop = true;
36-
}
37-
38-
kernel_impl::kernel_impl(sycl::detail::pi::PiKernel Kernel,
39-
ContextImplPtr ContextImpl, ProgramImplPtr ProgramImpl,
40-
bool IsCreatedFromSource,
20+
ContextImplPtr ContextImpl,
4121
KernelBundleImplPtr KernelBundleImpl,
4222
const KernelArgMask *ArgMask)
4323
: MKernel(Kernel), MContext(ContextImpl),
44-
MProgram(ProgramImpl->getHandleRef()),
45-
MCreatedFromSource(IsCreatedFromSource),
46-
MKernelBundleImpl(std::move(KernelBundleImpl)),
47-
MKernelArgMaskPtr{ArgMask} {
48-
24+
MProgram(ProgramManager::getInstance().getPiProgramFromPiKernel(
25+
Kernel, ContextImpl)),
26+
MCreatedFromSource(true), MKernelBundleImpl(std::move(KernelBundleImpl)),
27+
MIsInterop(true), MKernelArgMaskPtr{ArgMask} {
4928
sycl::detail::pi::PiContext Context = nullptr;
5029
// Using the plugin from the passed ContextImpl
5130
getPlugin()->call<PiApiKind::piKernelGetInfo>(
@@ -55,7 +34,12 @@ kernel_impl::kernel_impl(sycl::detail::pi::PiKernel Kernel,
5534
"Input context must be the same as the context of cl_kernel",
5635
PI_ERROR_INVALID_CONTEXT);
5736

58-
MIsInterop = ProgramImpl->isInterop();
37+
// Enable USM indirect access for interoperability kernels.
38+
// Some PI Plugins (like OpenCL) require this call to enable USM
39+
// For others, PI will turn this into a NOP.
40+
if (ContextImpl->getPlatformImpl()->supports_usm())
41+
getPlugin()->call<PiApiKind::piKernelSetExecInfo>(
42+
MKernel, PI_USM_INDIRECT_ACCESS, sizeof(pi_bool), &PI_TRUE);
5943
}
6044

6145
kernel_impl::kernel_impl(sycl::detail::pi::PiKernel Kernel,
@@ -71,9 +55,6 @@ kernel_impl::kernel_impl(sycl::detail::pi::PiKernel Kernel,
7155
MIsInterop = MKernelBundleImpl->isInterop();
7256
}
7357

74-
kernel_impl::kernel_impl(ContextImplPtr Context, ProgramImplPtr ProgramImpl)
75-
: MContext(Context), MProgram(ProgramImpl->getHandleRef()) {}
76-
7758
kernel_impl::~kernel_impl() {
7859
try {
7960
// TODO catch an exception and put it to list of asynchronous exceptions

sycl/source/detail/kernel_impl.hpp

Lines changed: 1 addition & 28 deletions
Original file line numberDiff line numberDiff line change
@@ -26,20 +26,17 @@ namespace sycl {
2626
inline namespace _V1 {
2727
namespace detail {
2828
// Forward declaration
29-
class program_impl;
3029
class kernel_bundle_impl;
3130

3231
using ContextImplPtr = std::shared_ptr<context_impl>;
33-
using ProgramImplPtr = std::shared_ptr<program_impl>;
3432
using KernelBundleImplPtr = std::shared_ptr<kernel_bundle_impl>;
3533
using sycl::detail::pi::PiProgram;
3634
class kernel_impl {
3735
public:
3836
/// Constructs a SYCL kernel instance from a PiKernel
3937
///
4038
/// This constructor is used for plug-in interoperability. It always marks
41-
/// kernel as being created from source and creates a new program_impl
42-
/// instance.
39+
/// kernel as being created from source.
4340
///
4441
/// \param Kernel is a valid PiKernel instance
4542
/// \param Context is a valid SYCL context
@@ -48,24 +45,6 @@ class kernel_impl {
4845
KernelBundleImplPtr KernelBundleImpl,
4946
const KernelArgMask *ArgMask = nullptr);
5047

51-
/// Constructs a SYCL kernel instance from a SYCL program and a PiKernel
52-
///
53-
/// This constructor creates a new instance from PiKernel and saves
54-
/// the provided SYCL program. If context of PiKernel differs from
55-
/// context of the SYCL program, an invalid_parameter_error exception is
56-
/// thrown.
57-
///
58-
/// \param Kernel is a valid PiKernel instance
59-
/// \param ContextImpl is a valid SYCL context
60-
/// \param ProgramImpl is a valid instance of program_impl
61-
/// \param IsCreatedFromSource is a flag that indicates whether program
62-
/// is created from source code
63-
/// \param KernelBundleImpl is a valid instance of kernel_bundle_impl
64-
kernel_impl(sycl::detail::pi::PiKernel Kernel, ContextImplPtr ContextImpl,
65-
ProgramImplPtr ProgramImpl, bool IsCreatedFromSource,
66-
KernelBundleImplPtr KernelBundleImpl,
67-
const KernelArgMask *ArgMask);
68-
6948
/// Constructs a SYCL kernel_impl instance from a SYCL device_image,
7049
/// kernel_bundle and / PiKernel.
7150
///
@@ -78,12 +57,6 @@ class kernel_impl {
7857
const KernelArgMask *ArgMask, PiProgram ProgramPI,
7958
std::mutex *CacheMutex);
8059

81-
/// Constructs a SYCL kernel for host device
82-
///
83-
/// \param Context is a valid SYCL context
84-
/// \param ProgramImpl is a valid instance of program_impl
85-
kernel_impl(ContextImplPtr Context, ProgramImplPtr ProgramImpl);
86-
8760
// This section means the object is non-movable and non-copyable
8861
// There is no need of move and copy constructors in kernel_impl.
8962
// If they need to be added, piKernelRetain method for MKernel

0 commit comments

Comments
 (0)