Skip to content

[ESIMD] Implement stateless memory accesses enforcement #6287

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 18 commits into from
Jun 22, 2022

Conversation

v-klochkov
Copy link
Contributor

@v-klochkov v-klochkov commented Jun 10, 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

The driver option -fsycl-esimd-stateless-access makes the compiler
to use stateless memory accesses for those ESIMD kernels and ESIMD
intrinsics that use accessors.

The option (if used) defines the macro ESIMD_FORCE_STATELESS_MEM_ACCESS
to map the calls of API using accessors to calls of API using USM 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.

Signed-off-by: Vyacheslav N Klochkov <[email protected]>
@v-klochkov v-klochkov requested a review from kbobrovs June 10, 2022 06:30
Signed-off-by: Vyacheslav N Klochkov <[email protected]>
@v-klochkov v-klochkov marked this pull request as ready for review June 14, 2022 01:02
@v-klochkov v-klochkov requested review from a team as code owners June 14, 2022 01:02
@v-klochkov v-klochkov requested a review from againull June 14, 2022 01:03
defm sycl_esimd_force_stateless_mem : BoolFOption<"sycl-esimd-force-stateless-mem",
LangOpts<"SYCLESIMDForceStatelessMem">, DefaultFalse,
PosFlag<SetTrue, [CC1Option, CoreOption], "Convert accesses via accessors to USM memory accesses in ESIMD kernels">,
NegFlag<SetFalse>>;
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Should also be a CoreOption to be available on Windows command lines

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Mike, Thank you for reviewing the PR. Can you explain what you mean, or maybe add a 'suggestion'?
Isn't it already a CoreOption (see the line 2793)?

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

The positive variant of the option is a CoreOption but the negative isn't. I don't think the Flags from the Pos side are also applied to the Neg side unless BothFlags is used to do so.

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I added the BothFlags to address this comment. Thank you!

@v-klochkov v-klochkov requested a review from a team as a code owner June 14, 2022 02:57
@@ -2788,6 +2788,11 @@ def fintelfpga : Flag<["-"], "fintelfpga">, Group<f_Group>,
Flags<[CC1Option, CoreOption]>, HelpText<"Perform ahead of time compilation for FPGA">;
def fsycl_device_only : Flag<["-"], "fsycl-device-only">, Flags<[CoreOption]>,
HelpText<"Compile SYCL kernels for device">;
defm sycl_esimd_force_stateless_mem : BoolFOption<"sycl-esimd-force-stateless-mem",
LangOpts<"SYCLESIMDForceStatelessMem">, DefaultFalse,
PosFlag<SetTrue, [CC1Option, CoreOption], "Convert accesses via accessors to USM memory accesses in ESIMD kernels">,
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

It should be also marked experimental in help message. See other examples.

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

It is marked as experimental. Thanks.

@@ -290,6 +290,28 @@ and not recommended to use in production environment.

NOTE: This flag is currently only supported with the CUDA and HIP targets.


**`-f[no]-sycl-esimd-force-stateless-mem`** [EXPERIMENTAL]
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Suggested change
**`-f[no]-sycl-esimd-force-stateless-mem`** [EXPERIMENTAL]
**`-f[no-]sycl-esimd-force-stateless-mem`** [EXPERIMENTAL]

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Fixed.

"stateful" memory accesses via SYCL accessors to "stateless" accesses
within ESIMD (Explicit SIMD) kernels by compiler.

This option disables the intrinsics and methods accepting SYCL accessors
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

It disables in -f or -fno- form? Can you clarify 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.

-f option disables those intrinsics that cannot be converted automatically. I updated the text. Thank you.

does not have the limit of 4Gb per surface.
Also, some of Intel GPUs or GPU run-time/drivers may support only
"stateless" memory accesses.

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Please add information about default value.

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Added. Thank you.

Comment on lines 304 to 307
The stateless memory access enforcement is disabled by default.

-fno-sycl-esimd-force-stateless-mem is used to tell compiler not to
enforce usage of stateless memory accesses.
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Suggested change
The stateless memory access enforcement is disabled by default.
-fno-sycl-esimd-force-stateless-mem is used to tell compiler not to
enforce usage of stateless memory accesses.
-fno-sycl-esimd-force-stateless-mem is used to tell compiler not to
enforce usage of stateless memory accesses. This is default behavior.

nit: looks a bit clearer to me this way.

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Ok, Thank you. Fixed here: 11d9c6d

Copy link
Contributor

@againull againull left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

LGTM

Copy link
Contributor

@premanandrao premanandrao left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

FE changes look okay to me.

Copy link
Contributor

@smanna12 smanna12 left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

FE changes LGTM

Copy link
Contributor

@elizabethandrews elizabethandrews left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

FE changes and doc LGTM. Thank you

@pvchupin pvchupin requested a review from mdtoguchi June 21, 2022 18:19
@v-klochkov
Copy link
Contributor Author

@hchilama - I had a comment from @mdtoguchi (#6287 (comment)), and I believe I addressed it in additional changes.
Would you please review the changes in driver, while Mike is on vacation?

@pvchupin pvchupin merged commit 1811162 into intel:sycl Jun 22, 2022
@v-klochkov v-klochkov deleted the esimd_stateless_acc branch June 22, 2022 17:57
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.

9 participants