-
Notifications
You must be signed in to change notification settings - Fork 113
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Specify access mode in __result_and_scratch_storage
methods
#1909
base: main
Are you sure you want to change the base?
Specify access mode in __result_and_scratch_storage
methods
#1909
Conversation
…add template parameter sycl::access_mode into __usm_or_buffer_accessor Signed-off-by: Sergey Kopienko <sergey.kopienko@intel.com>
…add template parameter sycl::access_mode into __result_and_scratch_storage::__get_result_acc Signed-off-by: Sergey Kopienko <sergey.kopienko@intel.com>
…add template parameter sycl::access_mode into __result_and_scratch_storage::__get_scratch_acc Signed-off-by: Sergey Kopienko <sergey.kopienko@intel.com>
Signed-off-by: Sergey Kopienko <sergey.kopienko@intel.com>
Signed-off-by: Sergey Kopienko <sergey.kopienko@intel.com>
@@ -319,6 +319,8 @@ struct __parallel_scan_submitter<_CustomName, __internal::__optional_kernel_name | |||
// 1. Local scan on each workgroup | |||
auto __submit_event = __exec.queue().submit([&](sycl::handler& __cgh) { | |||
oneapi::dpl::__ranges::__require_access(__cgh, __rng1, __rng2); //get an access to data under SYCL buffer | |||
// TODO what is correct access mode here for __get_scratch_acc call? |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
@danhoeflinger do you know the correct template param state here and in other TODO's ?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
i think this can be write
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Please instigate these yourself as well but i tried to assess each, mostly looks good with structure. we will need to confirm with some testing of course.
@@ -478,12 +478,11 @@ using __repacked_tuple_t = typename __repacked_tuple<T>::type; | |||
template <typename _ContainerOrIterable> | |||
using __value_t = typename __internal::__memobj_traits<_ContainerOrIterable>::value_type; | |||
|
|||
template <typename _T> | |||
template <typename _T, sycl::access_mode _AccessMode = sycl::access_mode::read_write> |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I don't think we gain anything from this default template argument. All the usages specify explicitly at this level.
static auto __get_access_mode_tag() | ||
{ | ||
if constexpr (_AccessMode == sycl::access::mode::read) | ||
return sycl::read; | ||
|
||
else if constexpr (_AccessMode == sycl::access::mode::write) | ||
return sycl::write; | ||
|
||
else if constexpr (_AccessMode == sycl::access::mode::read_write) | ||
return sycl::read_write; | ||
|
||
else | ||
static_assert(false, "Unknown _AccessMode state"); | ||
} |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Should this be a general utility function outside of this structure (with a template arg)? It's useful in the structure but it seems to have general applicability. I'm a little surprised this utility doesn't exist in the specification itself actually.
Also the function itself should be able to be constexpr
.
@@ -453,8 +454,8 @@ struct __parallel_reduce_then_scan_scan_submitter< | |||
__dpl_sycl::__local_accessor<_InitValueType> __sub_group_partials(__num_sub_groups_local + 1, __cgh); | |||
__cgh.depends_on(__prior_event); | |||
oneapi::dpl::__ranges::__require_access(__cgh, __in_rng, __out_rng); | |||
auto __temp_acc = __scratch_container.__get_scratch_acc(__cgh); | |||
auto __res_acc = __scratch_container.__get_result_acc(__cgh); | |||
auto __temp_acc = __scratch_container.__get_scratch_acc<sycl::access_mode::read_write>(__cgh); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I think this can be just read access.
_InitValueType* __temp_ptr = | ||
_TmpStorageAcc::__get_usm_or_buffer_accessor_ptr<sycl::access_mode::write>(__temp_acc); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I don't think we need an access mode here.
__result_and_scratch_storage_t::__get_usm_or_buffer_accessor_ptr<sycl::access_mode::write>( | ||
__res_acc, 2 * __n_groups); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
i dont think we need an access mode here.
// TODO what is correct access mode here for __get_scratch_acc call? | ||
// Is default sycl::access_mode::read_write is ok? |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I think this is read access.
@@ -319,6 +319,8 @@ struct __parallel_scan_submitter<_CustomName, __internal::__optional_kernel_name | |||
// 1. Local scan on each workgroup | |||
auto __submit_event = __exec.queue().submit([&](sycl::handler& __cgh) { | |||
oneapi::dpl::__ranges::__require_access(__cgh, __rng1, __rng2); //get an access to data under SYCL buffer | |||
// TODO what is correct access mode here for __get_scratch_acc call? |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
i think this can be write
@@ -340,6 +342,8 @@ struct __parallel_scan_submitter<_CustomName, __internal::__optional_kernel_name | |||
auto __iters_per_single_wg = oneapi::dpl::__internal::__dpl_ceiling_div(__n_groups, __wgroup_size); | |||
__submit_event = __exec.queue().submit([&](sycl::handler& __cgh) { | |||
__cgh.depends_on(__submit_event); | |||
// TODO what is correct access mode here for __get_scratch_acc call? | |||
// Is default sycl::access_mode::read_write is ok? |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
i think read_write.
@@ -362,7 +366,11 @@ struct __parallel_scan_submitter<_CustomName, __internal::__optional_kernel_name | |||
auto __final_event = __exec.queue().submit([&](sycl::handler& __cgh) { | |||
__cgh.depends_on(__submit_event); | |||
oneapi::dpl::__ranges::__require_access(__cgh, __rng1, __rng2); //get an access to data under SYCL buffer | |||
// TODO what is correct access mode here for __get_scratch_acc call? | |||
// Is default sycl::access_mode::read_write is ok? |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
i believe read.
// TODO what is right access mode here? | ||
// sycl::access_mode::read_write is used by default. |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
i believe write
In this PR we specify access mode in the two
__result_and_scratch_storage
methods:__result_and_scratch_storage::__get_result_acc
__result_and_scratch_storage::__get_scratch_acc
The main idea - to write
<sycl::access_mode::write>
is more correct then<sycl::access_mode::read_write>
when we only write some data and to write<sycl::access_mode::read>
is more correct then<sycl::access_mode::read_write>
when we only read some data.