Skip to content

[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

Merged
merged 3 commits into from
Aug 2, 2022

Conversation

kbobrovs
Copy link
Contributor

Signed-off-by: Konstantin S Bobrovsky [email protected]

@kbobrovs kbobrovs requested review from kychendev and v-klochkov May 25, 2022 02:52
`-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.

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?

Copy link
Contributor Author

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.

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?

Copy link
Contributor Author

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;
Copy link
Contributor

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.

Copy link
Contributor Author

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...);
Copy link
Contributor

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.

Copy link
Contributor Author

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 kbobrovs marked this pull request as ready for review May 31, 2022 12:31
@kbobrovs kbobrovs requested a review from a team as a code owner May 31, 2022 12:31
@pvchupin pvchupin requested a review from steffenlarsen June 21, 2022 18:17
@pvchupin
Copy link
Contributor

@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?

pvchupin pushed a commit that referenced this pull request Jun 22, 2022
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
@kbobrovs
Copy link
Contributor Author

kbobrovs commented Jul 31, 2022

(picking up after long vacation :-) )
@pvchupin, do you have any advice how to fix this error:

Warning, treated as error:
/home/runner/work/llvm/llvm/repo/sycl/doc/design/ESIMDStatelesAccessors.md:document isn't included in any toctree
ninja: build stopped: subcommand failed.
Error: Process completed with exit code 1.

@dpcpp-specification-reviewers, please approve.

@pvchupin
Copy link
Contributor

pvchupin commented Aug 2, 2022

@kbobrovs you need to add a reference to this doc at sycl/doc/index.rst

@kbobrovs kbobrovs requested a review from a team as a code owner August 2, 2022 01:13
@kbobrovs
Copy link
Contributor Author

kbobrovs commented Aug 2, 2022

Thanks @pvchupin , updated.

@pvchupin pvchupin merged commit 3e03f30 into intel:sycl Aug 2, 2022
@kbobrovs kbobrovs deleted the stateless_acc_design branch August 16, 2022 03:17
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

4 participants