Skip to content
Merged
Show file tree
Hide file tree
Changes from 2 commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 4 additions & 0 deletions sycl/source/detail/kernel_bundle_impl.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -97,6 +97,7 @@ class kernel_bundle_impl {
"Not all devices are associated with the context or "
"vector of devices is empty");
MDeviceImages.push_back(DevImage);
MIsInterop = true;
}

// Matches sycl::build and sycl::compile
Expand Down Expand Up @@ -373,6 +374,8 @@ class kernel_bundle_impl {
std::shared_ptr<kernel_impl> KernelImpl = std::make_shared<kernel_impl>(
Kernel, detail::getSyclObjImpl(MContext), DeviceImageImpl, Self);

KernelImpl->setInterop(MIsInterop);

return detail::createSyclObjFromImpl<kernel>(KernelImpl);
}

Expand Down Expand Up @@ -489,6 +492,7 @@ class kernel_bundle_impl {
// This map stores values for specialization constants, that are missing
// from any device image.
SpecConstMapT MSpecConstValues;
bool MIsInterop = false;
};

} // namespace detail
Expand Down
2 changes: 2 additions & 0 deletions sycl/source/detail/kernel_impl.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -30,6 +30,8 @@ kernel_impl::kernel_impl(RT::PiKernel Kernel, ContextImplPtr Context)
// For others, PI will turn this into a NOP.
getPlugin().call<PiApiKind::piKernelSetExecInfo>(
MKernel, PI_USM_INDIRECT_ACCESS, sizeof(pi_bool), &PI_TRUE);

MIsInterop = true;
}

kernel_impl::kernel_impl(RT::PiKernel Kernel, ContextImplPtr ContextImpl,
Expand Down
4 changes: 4 additions & 0 deletions sycl/source/detail/kernel_impl.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -200,13 +200,17 @@ class kernel_impl {

KernelBundleImplPtr get_kernel_bundle() const { return MKernelBundleImpl; }

void setInterop(bool V) { MIsInterop = V; }
bool isInterop() const { return MIsInterop; }

private:
RT::PiKernel MKernel;
const ContextImplPtr MContext;
const ProgramImplPtr MProgramImpl;
bool MCreatedFromSource = true;
const DeviceImageImplPtr MDeviceImageImpl;
const KernelBundleImplPtr MKernelBundleImpl;
bool MIsInterop = false;
};

template <info::kernel param>
Expand Down
18 changes: 12 additions & 6 deletions sycl/source/detail/program_impl.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -244,6 +244,7 @@ void program_impl::compile_with_source(std::string KernelSource,
compile(CompileOptions);
}
MState = program_state::compiled;
MIsInterop = true;
}

void program_impl::build_with_kernel_name(std::string KernelName,
Expand Down Expand Up @@ -275,6 +276,7 @@ void program_impl::build_with_source(std::string KernelSource,
build(BuildOptions);
}
MState = program_state::linked;
MIsInterop = true;
}

void program_impl::link(std::string LinkOptions) {
Expand Down Expand Up @@ -311,17 +313,21 @@ kernel program_impl::get_kernel(std::string KernelName,
std::shared_ptr<program_impl> PtrToSelf,
bool IsCreatedFromSource) const {
throw_if_state_is(program_state::none);
std::shared_ptr<kernel_impl> KImpl;
if (is_host()) {
if (IsCreatedFromSource)
throw invalid_object_error("This instance of program is a host instance",
PI_INVALID_PROGRAM);

return createSyclObjFromImpl<kernel>(
std::make_shared<kernel_impl>(MContext, PtrToSelf));
}
return createSyclObjFromImpl<kernel>(std::make_shared<kernel_impl>(
get_pi_kernel(KernelName), MContext, PtrToSelf,
/*IsCreatedFromSource*/ IsCreatedFromSource));
KImpl = std::make_shared<kernel_impl>(MContext, PtrToSelf);

} else
KImpl = std::make_shared<kernel_impl>(
get_pi_kernel(KernelName), MContext, PtrToSelf,
/*IsCreatedFromSource*/ IsCreatedFromSource);

KImpl->setInterop(MIsInterop);
return createSyclObjFromImpl<kernel>(KImpl);
}

std::vector<std::vector<char>> program_impl::get_binaries() const {
Expand Down
2 changes: 2 additions & 0 deletions sycl/source/detail/program_impl.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -448,6 +448,8 @@ class program_impl {
/// device list and context) and built with build_with_kernel_type with
/// default build options
bool MProgramAndKernelCachingAllowed = false;

bool MIsInterop = false;
};

template <>
Expand Down
3 changes: 2 additions & 1 deletion sycl/source/detail/queue_impl.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -24,6 +24,7 @@
#include <detail/context_impl.hpp>
#include <detail/device_impl.hpp>
#include <detail/event_impl.hpp>
#include <detail/kernel_impl.hpp>
#include <detail/plugin.hpp>
#include <detail/scheduler/scheduler.hpp>
#include <detail/thread_pool.hpp>
Expand Down Expand Up @@ -448,7 +449,7 @@ class queue_impl {
bool KernelUsesAssert = false;
if (IsKernel)
KernelUsesAssert =
Handler.MKernel ? true
Handler.MKernel ? Handler.MKernel->isInterop()
: ProgramManager::getInstance().kernelUsesAssert(
Handler.MOSModuleHandle, Handler.MKernelName);

Expand Down