Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
34 commits
Select commit Hold shift + click to select a range
2503a62
Diagnostic for const qualified DataT with non read-only accessor
mmoadeli Jan 31, 2023
862b688
Merge branch 'sycl' of https://github.com/mmoadeli/llvm into sycl
mmoadeli Jan 31, 2023
1edb94f
Add test for const qualified DataT with non readonly accessor.
mmoadeli Jan 31, 2023
7ba64c6
Assign valid access mode for local accessor, depending on the type of…
mmoadeli Feb 1, 2023
ef0038e
Minor test update.
mmoadeli Feb 1, 2023
36971f8
- Rename AccessMode to AccessModeFromConstness
mmoadeli Feb 2, 2023
29e3036
- Revert test to be without -Xclang -verify.
mmoadeli Feb 2, 2023
92debe8
Refactors implementation of diagnostic to avoid compiler errors due t…
mmoadeli Feb 3, 2023
7eac372
Updates the test to use -Xclang -verify
mmoadeli Feb 3, 2023
dcac706
Fix style-checl
mmoadeli Feb 3, 2023
9d4b313
Merge branch 'intel:sycl' into sycl
mmoadeli Feb 6, 2023
ad92330
Merge branch 'intel:sycl' into sycl
mmoadeli Feb 7, 2023
ce1cbe8
Merge branch 'intel:sycl' into sycl
mmoadeli Feb 20, 2023
dc33cc4
Merge branch 'intel:sycl' into sycl
mmoadeli Feb 22, 2023
44b1f9e
Merge branch 'sycl' of https://github.com/mmoadeli/llvm into sycl
mmoadeli Feb 22, 2023
2803f25
Merge branch 'sycl' of https://github.com/mmoadeli/llvm into sycl
mmoadeli Feb 27, 2023
0b358a5
Merge branch 'sycl' of https://github.com/mmoadeli/llvm into sycl
mmoadeli Feb 28, 2023
b142c5d
Throw exception when using local_accessor in a SYCL kernel function t…
mmoadeli Mar 8, 2023
98ea1ee
Minor size update.
mmoadeli Mar 8, 2023
103f35a
Merge branch 'sycl' of https://github.com/mmoadeli/llvm into sycl
mmoadeli Mar 9, 2023
2d0f1d6
Limit target to spir64
mmoadeli Mar 9, 2023
0310723
Moves test on local accessor diagnostics to llvm-test-suite.
mmoadeli Mar 9, 2023
9ff1db2
Merge branch 'sycl' into local_accessor_misuse
mmoadeli Mar 9, 2023
7fa63a4
Merge branch 'sycl' of https://github.com/mmoadeli/llvm into sycl
mmoadeli Mar 10, 2023
1456887
Merge branch 'sycl' of https://github.com/mmoadeli/llvm into sycl
mmoadeli Mar 11, 2023
805a860
Merge branch 'sycl' into local_accessor_misuse
mmoadeli Mar 11, 2023
2939b5d
Merge branch 'sycl' of https://github.com/mmoadeli/llvm into sycl
mmoadeli Mar 13, 2023
a5c96b0
Merge branch 'sycl' into local_accessor_misuse
mmoadeli Mar 13, 2023
47f59fa
Merge branch 'sycl' of https://github.com/mmoadeli/llvm into sycl
mmoadeli Mar 14, 2023
8d2876b
Merge branch 'sycl' into local_accessor_misuse
mmoadeli Mar 14, 2023
854423b
Replace multiple instances of literal value with consexpr static defi…
mmoadeli Mar 16, 2023
46f380c
Declare throwOnLocalAccessorMisuse as const
mmoadeli Mar 16, 2023
52b4127
Merge branch 'sycl' into local_accessor_misuse
mmoadeli Mar 20, 2023
8aa4d7f
Merge branch 'sycl' into local_accessor_misuse
bader Mar 22, 2023
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
28 changes: 28 additions & 0 deletions sycl/include/sycl/handler.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -354,6 +354,32 @@ class __SYCL_EXPORT handler {
PI_ERROR_INVALID_OPERATION);
}

constexpr static int AccessTargetMask = 0x7ff;
/// According to section 4.7.6.11. of the SYCL specification, a local accessor
/// must not be used in a SYCL kernel function that is invoked via single_task
/// or via the simple form of parallel_for that takes a range parameter.
template <typename KernelName, typename KernelType>
void throwOnLocalAccessorMisuse() const {
using NameT =
typename detail::get_kernel_name_t<KernelName, KernelType>::name;
using KI = sycl::detail::KernelInfo<NameT>;

auto *KernelArgs = &KI::getParamDesc(0);

for (unsigned I = 0; I < KI::getNumParams(); ++I) {
const detail::kernel_param_kind_t &Kind = KernelArgs[I].kind;
const access::target AccTarget =
static_cast<access::target>(KernelArgs[I].info & AccessTargetMask);
if ((Kind == detail::kernel_param_kind_t::kind_accessor) &&
(AccTarget == target::local))
throw sycl::exception(
make_error_code(errc::kernel_argument),
"A local accessor must not be used in a SYCL kernel function "
"that is invoked via single_task or via the simple form of "
"parallel_for that takes a range parameter.");
}
}

/// Extracts and prepares kernel arguments from the lambda using integration
/// header.
void
Expand Down Expand Up @@ -906,6 +932,7 @@ class __SYCL_EXPORT handler {
void parallel_for_lambda_impl(range<Dims> NumWorkItems,
KernelType KernelFunc) {
throwIfActionIsCreated();
throwOnLocalAccessorMisuse<KernelName, KernelType>();
using LambdaArgType = sycl::detail::lambda_arg_type<KernelType, item<Dims>>;

// If 1D kernel argument is an integral type, convert it to sycl::item<1>
Expand Down Expand Up @@ -1387,6 +1414,7 @@ class __SYCL_EXPORT handler {
ext::oneapi::experimental::detail::empty_properties_t>
void single_task_lambda_impl(_KERNELFUNCPARAM(KernelFunc)) {
throwIfActionIsCreated();
throwOnLocalAccessorMisuse<KernelName, KernelType>();
// TODO: Properties may change the kernel function, so in order to avoid
// conflicts they should be included in the name.
using NameT =
Expand Down
5 changes: 3 additions & 2 deletions sycl/source/handler.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -491,7 +491,8 @@ void handler::processArg(void *Ptr, const detail::kernel_param_kind_t &Kind,
case kernel_param_kind_t::kind_accessor: {
// For args kind of accessor Size is information about accessor.
// The first 11 bits of Size encodes the accessor target.
const access::target AccTarget = static_cast<access::target>(Size & 0x7ff);
const access::target AccTarget =
static_cast<access::target>(Size & AccessTargetMask);
switch (AccTarget) {
case access::target::device:
case access::target::constant_buffer: {
Expand Down Expand Up @@ -616,7 +617,7 @@ void handler::extractArgsAndReqsFromLambda(
// For args kind of accessor Size is information about accessor.
// The first 11 bits of Size encodes the accessor target.
const access::target AccTarget =
static_cast<access::target>(Size & 0x7ff);
static_cast<access::target>(Size & AccessTargetMask);
if ((AccTarget == access::target::device ||
AccTarget == access::target::constant_buffer) ||
(AccTarget == access::target::image ||
Expand Down