Skip to content
Merged
Show file tree
Hide file tree
Changes from 3 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
8 changes: 8 additions & 0 deletions sycl/include/sycl/handler.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -528,6 +528,7 @@ class __SYCL_EXPORT handler {
bool IsKernelCreatedFromSource, bool IsESIMD);
#endif

#ifndef __INTEL_PREVIEW_BREAKING_CHANGES
/// \return a string containing name of SYCL kernel.
detail::ABINeutralKernelNameStrT getKernelName();

Expand All @@ -543,6 +544,7 @@ class __SYCL_EXPORT handler {
detail::ABINeutralKernelNameStrT KernelName = getKernelName();
return KernelName == LambdaName;
}
#endif

/// Saves the location of user's code passed in \p CodeLoc for future usage in
/// finalize() method.
Expand Down Expand Up @@ -1897,12 +1899,17 @@ class __SYCL_EXPORT handler {
Kernel);
}

#ifndef __INTEL_PREVIEW_BREAKING_CHANGES
// Implementation for something that had to be removed long ago but now stuck
// until next major release...

/// Defines and invokes a SYCL kernel function.
///
/// \param Kernel is a SYCL kernel that is executed on a SYCL device
/// (except for the host device).
/// \param KernelFunc is a lambda that is used if device, queue is bound to,
/// is a host device.
__SYCL_DEPRECATED("This overload isn't part of SYCL2020 and will be removed.")
template <typename KernelName = detail::auto_name, typename KernelType>
void single_task(kernel Kernel, const KernelType &KernelFunc) {
// Ignore any set kernel bundles and use the one associated with the kernel
Expand Down Expand Up @@ -1931,6 +1938,7 @@ class __SYCL_EXPORT handler {
detail::CheckDeviceCopyable<KernelType>();
#endif
}
#endif // __INTEL_PREVIEW_BREAKING_CHANGES

#ifndef __INTEL_PREVIEW_BREAKING_CHANGES
/// Defines and invokes a SYCL kernel function for the specified range.
Expand Down
8 changes: 5 additions & 3 deletions sycl/source/handler.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -1093,7 +1093,7 @@ void handler::extractArgsAndReqs() {
if (impl->MKernelData.getDeviceKernelInfoPtr() == nullptr) {
impl->MKernelData.setDeviceKernelInfoPtr(
&detail::ProgramManager::getInstance().getOrCreateDeviceKernelInfo(
toKernelNameStrT(getKernelName())));
detail::toKernelNameStrT(MKernel->getName())));
}
#endif
assert(impl->MKernelData.getDeviceKernelInfoPtr() != nullptr);
Expand All @@ -1109,7 +1109,7 @@ void handler::extractArgsAndReqsFromLambda(
if (impl->MKernelData.getDeviceKernelInfoPtr() == nullptr) {
impl->MKernelData.setDeviceKernelInfoPtr(
&detail::ProgramManager::getInstance().getOrCreateDeviceKernelInfo(
toKernelNameStrT(getKernelName())));
detail::toKernelNameStrT(MKernel->getName())));
}
impl->MKernelData.setKernelInfo(LambdaPtr, NumKernelParams, ParamDescGetter,
IsESIMD, true);
Expand Down Expand Up @@ -1158,12 +1158,14 @@ void handler::extractArgsAndReqsFromLambda(
}
#endif // __INTEL_PREVIEW_BREAKING_CHANGES

#ifndef __INTEL_PREVIEW_BREAKING_CHANGES
// Calling methods of kernel_impl requires knowledge of class layout.
// As this is impossible in header, there's a function that calls necessary
// method inside the library and returns the result.
detail::ABINeutralKernelNameStrT handler::getKernelName() {
return MKernel->getName();
}
#endif

void handler::verifyUsedKernelBundleInternal(detail::string_view KernelName) {
detail::kernel_bundle_impl *UsedKernelBundleImplPtr =
Expand Down Expand Up @@ -2239,7 +2241,7 @@ sycl::detail::CGType handler::getType() const { return impl->MCGType; }

void handler::setDeviceKernelInfo(kernel &&Kernel) {
MKernel = detail::getSyclObjImpl(std::move(Kernel));
MKernelName = getKernelName();
MKernelName = MKernel->getName();
setDeviceKernelInfoPtr(&MKernel->getDeviceKernelInfo());
setType(detail::CGType::Kernel);

Expand Down
6 changes: 4 additions & 2 deletions sycl/test-e2e/Basic/kernel_info.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -18,6 +18,8 @@
using namespace sycl;
namespace syclex = sycl::ext::oneapi;

class SingleTask;

auto checkExceptionIsThrown = [](auto &getInfoFunc,
const std::string &refErrMsg,
std::error_code refErrc) {
Expand All @@ -40,13 +42,13 @@ int main() {
queue q;
auto ctx = q.get_context();
buffer<int, 1> buf(range<1>(1));
auto kernelID = sycl::get_kernel_id<class SingleTask>();
auto kernelID = sycl::get_kernel_id<SingleTask>();
auto kb = get_kernel_bundle<bundle_state::executable>(ctx, {kernelID});
kernel krn = kb.get_kernel(kernelID);

q.submit([&](handler &cgh) {
auto acc = buf.get_access<access::mode::read_write>(cgh);
cgh.single_task<class SingleTask>(krn, [=]() { acc[0] = acc[0] + 1; });
cgh.single_task<SingleTask>([=]() { acc[0] = acc[0] + 1; });
});

const std::string krnName = krn.get_info<info::kernel::function_name>();
Expand Down
6 changes: 4 additions & 2 deletions sycl/test-e2e/Basic/kernel_info_attr.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -25,17 +25,19 @@
using namespace sycl;
namespace syclex = sycl::ext::oneapi;

class SingleTask;

int main() {
queue q;
auto ctx = q.get_context();
buffer<int, 1> buf(range<1>(1));
auto KernelID = sycl::get_kernel_id<class SingleTask>();
auto KernelID = sycl::get_kernel_id<SingleTask>();
auto KB = get_kernel_bundle<bundle_state::executable>(ctx, {KernelID});
kernel krn = KB.get_kernel(KernelID);

q.submit([&](handler &cgh) {
auto acc = buf.get_access<access::mode::read_write>(cgh);
cgh.single_task<class SingleTask>(krn, [=]() { acc[0] = acc[0] + 1; });
cgh.single_task<SingleTask>([=]() { acc[0] = acc[0] + 1; });
});

const std::string krnAttr = krn.get_info<info::kernel::attributes>();
Expand Down
6 changes: 3 additions & 3 deletions sycl/test-e2e/DeviceCodeSplit/split-per-kernel.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -26,7 +26,7 @@ int main() {

Q.submit([&](sycl::handler &Cgh) {
auto Acc = Buf.get_access<sycl::access::mode::read_write>(Cgh);
Cgh.single_task<Kern1>(Krn, [=]() { Acc[0] = 1; });
Cgh.single_task<Kern1>([=]() { Acc[0] = 1; });
});
}
assert(Data == 1);
Expand All @@ -45,7 +45,7 @@ int main() {

Q.submit([&](sycl::handler &Cgh) {
auto Acc = Buf.get_access<sycl::access::mode::read_write>(Cgh);
Cgh.single_task<Kern2>(Krn, [=]() { Acc[0] = 2; });
Cgh.single_task<Kern2>([=]() { Acc[0] = 2; });
});
}
assert(Data == 2);
Expand All @@ -64,7 +64,7 @@ int main() {

Q.submit([&](sycl::handler &Cgh) {
auto Acc = Buf.get_access<sycl::access::mode::read_write>(Cgh);
Cgh.single_task<Kern3>(Krn, [=]() { Acc[0] = 3; });
Cgh.single_task<Kern3>([=]() { Acc[0] = 3; });
});
}
assert(Data == 3);
Expand Down
4 changes: 2 additions & 2 deletions sycl/test-e2e/DeviceCodeSplit/split-per-source-main.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -31,7 +31,7 @@ int main() {
sycl::buffer<int, 1> Buf(&Data, sycl::range<1>(1));
Q.submit([&](sycl::handler &Cgh) {
auto Acc = Buf.get_access<sycl::access::mode::read_write>(Cgh);
Cgh.single_task<File1Kern1>(Krn1, [=]() { Acc[0] = 1; });
Cgh.single_task<File1Kern1>([=]() { Acc[0] = 1; });
});
}
assert(Data == 1);
Expand All @@ -40,7 +40,7 @@ int main() {
sycl::buffer<int, 1> Buf(&Data, sycl::range<1>(1));
Q.submit([&](sycl::handler &Cgh) {
auto Acc = Buf.get_access<sycl::access::mode::read_write>(Cgh);
Cgh.single_task<File1Kern2>(Krn2, [=]() { Acc[0] = 2; });
Cgh.single_task<File1Kern2>([=]() { Acc[0] = 2; });
});
}
assert(Data == 2);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -7,18 +7,20 @@
#include <sycl/detail/core.hpp>
#include <vector>

class mykernel;

int main() {
sycl::queue q;
sycl::context ctxt = q.get_context();
sycl::kernel_id k_id = sycl::get_kernel_id<class mykernel>();
sycl::kernel_id k_id = sycl::get_kernel_id<mykernel>();
auto bundle =
sycl::get_kernel_bundle<sycl::bundle_state::executable>(ctxt, {k_id});
assert(!bundle.empty());
sycl::kernel krn = bundle.get_kernel(k_id);
sycl::buffer<int> buf(sycl::range<1>(1));
q.submit([&](sycl::handler &cgh) {
sycl::accessor acc(buf, cgh);
cgh.single_task<class mykernel>(krn, [=]() { acc[0] = 42; });
cgh.single_task<mykernel>([=]() { acc[0] = 42; });
});
const auto img = *(bundle.begin());
const auto bytes = img.ext_oneapi_get_backend_content();
Expand Down
6 changes: 4 additions & 2 deletions sycl/test-e2e/DeviceImageBackendContent/basic_test.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -5,18 +5,20 @@
#include <sycl/kernel_bundle.hpp>
#include <type_traits>

class mykernel;

int main() {
sycl::queue q;
sycl::context ctxt = q.get_context();
sycl::buffer<int> buf(sycl::range<1>(1));
sycl::kernel_id k_id = sycl::get_kernel_id<class mykernel>();
sycl::kernel_id k_id = sycl::get_kernel_id<mykernel>();
auto bundle =
sycl::get_kernel_bundle<sycl::bundle_state::executable>(ctxt, {k_id});
assert(!bundle.empty());
sycl::kernel krn = bundle.get_kernel(k_id);
q.submit([&](sycl::handler &cgh) {
sycl::accessor acc(buf, cgh);
cgh.single_task<class mykernel>(krn, [=]() { acc[0] = 42; });
cgh.single_task<mykernel>([=]() { acc[0] = 42; });
});
sycl::backend backend;
std::vector<std::byte> bytes;
Expand Down
4 changes: 2 additions & 2 deletions sycl/test-e2e/NewOffloadDriver/split-per-source-main.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -31,7 +31,7 @@ int main() {
sycl::buffer<int, 1> Buf(&Data, sycl::range<1>(1));
Q.submit([&](sycl::handler &Cgh) {
auto Acc = Buf.get_access<sycl::access::mode::read_write>(Cgh);
Cgh.single_task<File1Kern1>(Krn1, [=]() { Acc[0] = 1; });
Cgh.single_task<File1Kern1>([=]() { Acc[0] = 1; });
});
}
assert(Data == 1);
Expand All @@ -40,7 +40,7 @@ int main() {
sycl::buffer<int, 1> Buf(&Data, sycl::range<1>(1));
Q.submit([&](sycl::handler &Cgh) {
auto Acc = Buf.get_access<sycl::access::mode::read_write>(Cgh);
Cgh.single_task<File1Kern2>(Krn2, [=]() { Acc[0] = 2; });
Cgh.single_task<File1Kern2>([=]() { Acc[0] = 2; });
});
}
assert(Data == 2);
Expand Down
Loading