-
Notifications
You must be signed in to change notification settings - Fork 788
[ESIMD] Stateful to stateless mem access conversion design. #6187
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
Conversation
Signed-off-by: Konstantin S Bobrovsky <[email protected]>
`-esimd-force-stateless-mem-access`. Under this option, the tool | ||
configures the LowerESIMD.cpp pass to ignore the `kernel_arg_accessor_ptr` | ||
and always generate `svmptr_t` annotation for memory arguments. | ||
|
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.
Is it possible to mix kernels with stateless accessors and kernels with surface accessors in this variant?
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.
In user level code - yes, but compiler will generate stateless for all accessors.
``` | ||
|
||
The new macro is supposed to be set by users directly or via some logic based on | ||
other macros set by users. |
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.
@kbobrovs I'm assuming that ESIMD_FORCE_STATELESS_MEM_ACCESS
must be defined in order to use accessor::get_pointer()
in ESIMD kernels, right?
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.
@petercad - yes. -fsycl-esimd-force-stateless-mem-access
should ensure this automatically
```cpp | ||
T stateful_memory_api(accessor acc, uint32 offset, args...) { | ||
#ifdef ESIMD_FORCE_STATELESS_MEM_ACCESS | ||
accessor_elelemt_type *ptr = acc.get_pointer() + offset; |
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.
It'd be good to add sanity check to ensure only accessor with global address space ptr will be accepted here.
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.
good point!
T stateful_memory_api(accessor acc, uint32 offset, args...) { | ||
#ifdef ESIMD_FORCE_STATELESS_MEM_ACCESS | ||
accessor_elelemt_type *ptr = acc.get_pointer() + offset; | ||
return stateless_memory_api(ptr, args...); |
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.
If this is mapped to legacy stateless memory API, it will also work on old platform.
However, one limitation is that there is no support for cache hint control in legacy API.
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.
right. providing cache hint control for generic APIs like gather, block_load needs to be designed.
@kbobrovs, @v-klochkov, what's the plan on this PR? We're about to merge related #6287 Would you like to update and merge this one as well? |
The driver option -f[no-]sycl-esimd-force-stateless-mem is added. -fsycl-esimd-force-stateless-mem enables the automatic conversion of stateful memory accesses via SYCL accessors or surface-index to stateless within ESIMD kernels. It also disables those ESIMD intrinsics that use stateful accesses that cannot be converted to stateless. -fsycl-esimd-force-stateless-mem defines the macro __ESIMD_FORCE_STATELESS_MEM to map the calls of ESIMD API using accessors to calls of API using pointers. It also passes a switch to sycl-post-link to signal it that it should ignore the buffer_t attribute and use svmptr_t. -fno-sycl-esimd-force-stateless-mem is used to tell the compiler not to convert stateful memory accesses to stateless. Default behavior. Draft of the design document/proposal for this change-set: #6187
(picking up after long vacation :-) )
@dpcpp-specification-reviewers, please approve. |
@kbobrovs you need to add a reference to this doc at sycl/doc/index.rst |
Signed-off-by: Konstantin S Bobrovsky <[email protected]>
Thanks @pvchupin , updated. |
Signed-off-by: Konstantin S Bobrovsky [email protected]