Skip to content

Commit

Permalink
[SYCL] Remove program_impl (#14368)
Browse files Browse the repository at this point in the history
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.
  • Loading branch information
sergey-semenov authored Jul 5, 2024
1 parent 577c349 commit 4ae7cad
Show file tree
Hide file tree
Showing 11 changed files with 12 additions and 987 deletions.
1 change: 0 additions & 1 deletion sycl/source/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -223,7 +223,6 @@ set(SYCL_COMMON_SOURCES
"detail/memory_manager.cpp"
"detail/pipes.cpp"
"detail/platform_impl.cpp"
"detail/program_impl.cpp"
"detail/program_manager/program_manager.cpp"
"detail/queue_impl.cpp"
"detail/online_compiler/online_compiler.cpp"
Expand Down
1 change: 0 additions & 1 deletion sycl/source/backend/level_zero.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,6 @@

#include <detail/platform_impl.hpp>
#include <detail/plugin.hpp>
#include <detail/program_impl.hpp>
#include <detail/queue_impl.hpp>
#include <sycl/backend.hpp>
#include <sycl/sycl.hpp>
Expand Down
1 change: 0 additions & 1 deletion sycl/source/backend/opencl.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,6 @@
#include <detail/kernel_impl.hpp>
#include <detail/platform_impl.hpp>
#include <detail/plugin.hpp>
#include <detail/program_impl.hpp>
#include <detail/queue_impl.hpp>
#include <sycl/sycl.hpp>

Expand Down
41 changes: 11 additions & 30 deletions sycl/source/detail/kernel_impl.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,6 @@
#include <detail/context_impl.hpp>
#include <detail/kernel_bundle_impl.hpp>
#include <detail/kernel_impl.hpp>
#include <detail/program_impl.hpp>

#include <memory>

Expand All @@ -18,34 +17,14 @@ inline namespace _V1 {
namespace detail {

kernel_impl::kernel_impl(sycl::detail::pi::PiKernel Kernel,
ContextImplPtr Context,
KernelBundleImplPtr KernelBundleImpl,
const KernelArgMask *ArgMask)
: kernel_impl(Kernel, Context,
std::make_shared<program_impl>(Context, Kernel),
/*IsCreatedFromSource*/ true, KernelBundleImpl, ArgMask) {
// Enable USM indirect access for interoperability kernels.
// Some PI Plugins (like OpenCL) require this call to enable USM
// For others, PI will turn this into a NOP.
if (Context->getPlatformImpl()->supports_usm())
getPlugin()->call<PiApiKind::piKernelSetExecInfo>(
MKernel, PI_USM_INDIRECT_ACCESS, sizeof(pi_bool), &PI_TRUE);

// This constructor is only called in the interoperability kernel constructor.
MIsInterop = true;
}

kernel_impl::kernel_impl(sycl::detail::pi::PiKernel Kernel,
ContextImplPtr ContextImpl, ProgramImplPtr ProgramImpl,
bool IsCreatedFromSource,
ContextImplPtr ContextImpl,
KernelBundleImplPtr KernelBundleImpl,
const KernelArgMask *ArgMask)
: MKernel(Kernel), MContext(ContextImpl),
MProgram(ProgramImpl->getHandleRef()),
MCreatedFromSource(IsCreatedFromSource),
MKernelBundleImpl(std::move(KernelBundleImpl)),
MKernelArgMaskPtr{ArgMask} {

MProgram(ProgramManager::getInstance().getPiProgramFromPiKernel(
Kernel, ContextImpl)),
MCreatedFromSource(true), MKernelBundleImpl(std::move(KernelBundleImpl)),
MIsInterop(true), MKernelArgMaskPtr{ArgMask} {
sycl::detail::pi::PiContext Context = nullptr;
// Using the plugin from the passed ContextImpl
getPlugin()->call<PiApiKind::piKernelGetInfo>(
Expand All @@ -55,7 +34,12 @@ kernel_impl::kernel_impl(sycl::detail::pi::PiKernel Kernel,
"Input context must be the same as the context of cl_kernel",
PI_ERROR_INVALID_CONTEXT);

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

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

kernel_impl::kernel_impl(ContextImplPtr Context, ProgramImplPtr ProgramImpl)
: MContext(Context), MProgram(ProgramImpl->getHandleRef()) {}

kernel_impl::~kernel_impl() {
try {
// TODO catch an exception and put it to list of asynchronous exceptions
Expand Down
29 changes: 1 addition & 28 deletions sycl/source/detail/kernel_impl.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -26,20 +26,17 @@ namespace sycl {
inline namespace _V1 {
namespace detail {
// Forward declaration
class program_impl;
class kernel_bundle_impl;

using ContextImplPtr = std::shared_ptr<context_impl>;
using ProgramImplPtr = std::shared_ptr<program_impl>;
using KernelBundleImplPtr = std::shared_ptr<kernel_bundle_impl>;
using sycl::detail::pi::PiProgram;
class kernel_impl {
public:
/// Constructs a SYCL kernel instance from a PiKernel
///
/// This constructor is used for plug-in interoperability. It always marks
/// kernel as being created from source and creates a new program_impl
/// instance.
/// kernel as being created from source.
///
/// \param Kernel is a valid PiKernel instance
/// \param Context is a valid SYCL context
Expand All @@ -48,24 +45,6 @@ class kernel_impl {
KernelBundleImplPtr KernelBundleImpl,
const KernelArgMask *ArgMask = nullptr);

/// Constructs a SYCL kernel instance from a SYCL program and a PiKernel
///
/// This constructor creates a new instance from PiKernel and saves
/// the provided SYCL program. If context of PiKernel differs from
/// context of the SYCL program, an invalid_parameter_error exception is
/// thrown.
///
/// \param Kernel is a valid PiKernel instance
/// \param ContextImpl is a valid SYCL context
/// \param ProgramImpl is a valid instance of program_impl
/// \param IsCreatedFromSource is a flag that indicates whether program
/// is created from source code
/// \param KernelBundleImpl is a valid instance of kernel_bundle_impl
kernel_impl(sycl::detail::pi::PiKernel Kernel, ContextImplPtr ContextImpl,
ProgramImplPtr ProgramImpl, bool IsCreatedFromSource,
KernelBundleImplPtr KernelBundleImpl,
const KernelArgMask *ArgMask);

/// Constructs a SYCL kernel_impl instance from a SYCL device_image,
/// kernel_bundle and / PiKernel.
///
Expand All @@ -78,12 +57,6 @@ class kernel_impl {
const KernelArgMask *ArgMask, PiProgram ProgramPI,
std::mutex *CacheMutex);

/// Constructs a SYCL kernel for host device
///
/// \param Context is a valid SYCL context
/// \param ProgramImpl is a valid instance of program_impl
kernel_impl(ContextImplPtr Context, ProgramImplPtr ProgramImpl);

// This section means the object is non-movable and non-copyable
// There is no need of move and copy constructors in kernel_impl.
// If they need to be added, piKernelRetain method for MKernel
Expand Down
Loading

0 comments on commit 4ae7cad

Please sign in to comment.