Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #432 from AerialMantis/SYCL-2020/multi-ptr-errata
We have discovered that some of the changes in SYCL 2020 for multi_ptr have introduced breaking changes for SYCL 1.2.1 applications moving to SYCL 2020. At the time of these changes it was thought to be necessary but since then the SYCL working group has adopted a philosophy of deprecating interfaces before removing them outright. This pull request aims to address these changes, such that SYCL 1.2.1 code will still be compatible with SYCL 2020 implementations, avoiding errors in moving from one version to the other and in portability between implementations. 1. Default access::decorated value for multi_ptr The first issue that was identified was that the SYCL 2020 wording introduces the access::decorated template parameter in multi_ptr, however, does not provide a default. This means that any code which declares the multi_ptr without this template argument, as was the case in SYCL 1.2.1 would no longer compiler. For example: multi_ptr<float, access::address_space::global_space> multiPtr; To solve this issue, this PR has the multi_ptr class template default to access::decorated::legacy. It also specifies in the access::decorated enum class that access::decorated::legacy is deprecated. 2. accessor returning a raw pointer The second issue that was identified was that the SYCL 2020 wording changes the return type of accessor::get_pointer from a multi_ptr to a raw pointer. This means that any code which expects the return value of accessor::get_pointer to be a multi_ptr will fail to compile. For example: multi_ptr<float, access::address_space::global_space> multiPtr = acc.get_pointer(); or float f4; f4.load(offset, acc.get_pointer()); To solve this issue, this PR reverts back to accessor::get_pointer returning a multi_ptr with access::decorated::legacy. It also introduces wording for accessor::get_pointer which was previously missing and specifies that it is deprecated. 3. Missing interfaces for multi_ptr with access::decorated::legacy The third issue that was identified was that the SYCL 2020 wording introduces new interfaces for the multi_ptr class; specifically the multi_ptr::get_raw and multi_ptr::get_decorated member functions, but not for the access::decorated::legacy specialization. This means any new code which uses these member functions will not be compatible with old code which uses the access::decorated::legacy specialization of multi_ptr and will therefore have to multi-version for the two specializations. For example: template <typename T, access::address_space AddressSpace, access::decorated IsDecorated> void foo(multi_ptr<T, AddressSpace,IsDecorated> multiPtr) { T *ptr = multiPtr.get_decorated(); // do something with ptr } To solve this issue, this PR adds the multi_ptr::get_raw and multi_ptr::get_decorated member functions to the access::decorated::legacy specialization of multi_ptr as well. 4. async_work_group_copy requiring access::decorated::yes The fourth issue that was identified was that the SYCL 2020 wording changes the nd_item::async_work_group_copy and group::async_work_group_copy member functions such that they now take a multi_ptr with access::decorated::yes explicitly. This means that any code which uses the access::decorated::legacy specialization will not be able to call these functions. For example: multi_ptr<float, access::address_space::global_space> srcPtr = srcAcc.get_pointer(); multi_ptr<float, access::address_space::global_space> destPtr= destAcc.get_pointer(); async_work_group_copy(destPtr, srcPtr, numElements); To solve this issue, this PR re-introduces the original SYCL 1.2.1 overloads of async_work_group_copy which take a multi_ptr with access::decorated::legacy, and specifies them as deprecated. Note, the examples for these are based on the previous changes being applied, however, those issues are all reproducible even if they weren't using other SYCL 2020 interfaces. Edits b84963d: Have local_accessor::get_pointer() also return multi_ptr` for consistency and address comments. Rebased onto gmlueck/SYCL-Docs@gmlueck/gentype-funcs. a101c3b: Removed constraints on the Space and IsDecorated template parameters for builtin functions taking a multi_ptr. 323de84: Maintained builtin functions constraint on mutli_ptr parameters with constant_space and removed const qualifiers on global_ptr parameters to legacy async_work_group_copy overloads. 99c0b3b: Added fixes based on feedback; fix for async_work_group_copy definition, removal of accessor_ptr for get_pointer() and additional get_pointer() declaration for the host_task case.
- Loading branch information