[SYCL] Limit decorations to init function for annotated_arg/ptr classes #11881
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
annotated_arg/annotated_ptr are special classes and arguments of the __init() member function become kernel arguments. The classes have decorated_global_ptr or other such type applied on the class members to indicate that these must be in global address-space (or other address space as indicated by the applied type). The goal of applying the type on the member was to ensure that class member gets captured as a global address space pointer when set as kernel argument.
However, the type was applied on class constructor arguments as well. This PR restricts the type to only be present on the __init member function argument, otherwise the presence of the type on constructors causes functional errors on certain backends when objects are constructed in the kernel body. The object constructed inside kernel body also gets a global address space cast generated by the compiler when the decorated_global_ptr type is applied on ctor arguments. This is problematic for example when the object is constructed from a pointer to some array defined inside the kernel.