Skip to content

[SYCL] Add support to propagate compile flags to device backend compiler #8763

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

Conversation

asudarsa
Copy link
Contributor

@asudarsa asudarsa commented Mar 24, 2023

This change is a second attempt to add this support. An earlier attempt was here: #7373

In this change, following changes have been made:

  1. clang changes to add a new function attribute: sycl-optlevel
  2. sycl-post-link changes to process this attribute, split modules based on optimization level, and add a new property named 'optLevel' to SYCL/misc properties' property set.
  3. SYCL runtime and plugin changes to access this device image property and propagate a backend specific optimization flag to the backend compiler.
  4. Documentation
  5. 2 unit tests and 1 e2e test

Thanks

@asudarsa asudarsa requested review from a team as code owners March 24, 2023 05:48
@asudarsa asudarsa requested a review from bso-intel March 24, 2023 05:48
@@ -10,29 +10,29 @@
; RUN: sycl-post-link -split=auto -symbols -S < %s -o %t.table
; RUN: FileCheck %s -input-file=%t_0.ll --check-prefixes CHECK-M0-IR \
; RUN: --implicit-check-not kernel0 --implicit-check-not kernel1
; RUN: FileCheck %s -input-file=%t_1.ll --check-prefixes CHECK-M1-IR \
; RUN: FileCheck %s -input-file=%t_2.ll --check-prefixes CHECK-M1-IR \
Copy link
Contributor Author

Choose a reason for hiding this comment

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

These test updates were triggered by the fact that the order of the entries in the .table file changed due to the addition of the new entry in the list optional kernel features. A better way to NOT depend on the order of the entries is required in the long run.

Copy link
Contributor

Choose a reason for hiding this comment

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

FYI: that unstable ordering is going to be fixed in #8833. That PR will also allow to simplify your changes to device code split down to a single line of code

@bader
Copy link
Contributor

bader commented Mar 24, 2023

This change is a second attempt to add this support. An earlier attempt was here: #7373

Please, keep using #7373 to preserve review history.

@asudarsa
Copy link
Contributor Author

An E2E test is added here: intel/llvm-test-suite#1691

Thanks

Signed-off-by: Arvind Sudarsanam <[email protected]>
@asudarsa
Copy link
Contributor Author

This change is a second attempt to add this support. An earlier attempt was here: #7373

Please, keep using #7373 to preserve review history.

Hi @bader

This PR is a major revamp. Adding this on top of #7373 might end up confusing new reviewers. Alexey Sachkov is the main reviewer so far and we did discuss this.

Thanks

@asudarsa asudarsa temporarily deployed to aws March 24, 2023 06:37 — with GitHub Actions Inactive
@asudarsa asudarsa temporarily deployed to aws March 24, 2023 07:08 — with GitHub Actions Inactive
} else if (Plugin.getBackend() == backend::opencl) {
if (!CompileOpts.empty() && (optLevel == 0))
CompileOpts += " ";
if (optLevel == 0)
Copy link
Contributor

Choose a reason for hiding this comment

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

so for opt > 0 we ignore it for ocl? should we at least warn?

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 warning message for cases where backend does not provide optimization option. Thanks

| Front-end option | L0 backend option | OpenCL backend option |
| ---------------- | ----------------- | --------------------- |
| -O0 | -ze-opt-disable | -cl-opt-disable |
| -O1 | -ze-opt-level=1 | /* no option */ |
Copy link
Contributor

Choose a reason for hiding this comment

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

i commented this somewhere else but silently ignoring it seems confusing for the user, i recommend a warning

Copy link
Contributor

Choose a reason for hiding this comment

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

We should be really careful with adding such warning. The problem here is that we can't suggest anything to user to fix this. There is literally no equivalent for different optimization levels in OpenCL: you either pass no flags, which means compiler optimizes as it wants to; or you pass -cl-opt-disable, which mean no optimizations at all.

-O2 is a default level of optimizations and we definitely don't want to have warning with no (!) workaround emitted for almost all existing applications.

Unless we can suggest a way to fix (in user code/build script) and not just suppress the warning, it shouldn't be added, I believe.

However, it makes sense to add a section describing this behavior into our documentation somewhere

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Hi @AlexeySachkov

Thanks for detailed input on this. I am currently letting the users know about this via a warning. ""Optimization level not propagated to backend"; Do you think this is something which might confuse the user?
Do you want me to add the information in the design doc here?

Thanks again.

Copy link
Contributor

Choose a reason for hiding this comment

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

@AlexeySachkov good take, thanks

Copy link
Contributor

Choose a reason for hiding this comment

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

Thanks for detailed input on this. I am currently letting the users know about this via a warning. ""Optimization level not propagated to backend"; Do you think this is something which might confuse the user?

I think any warning should be somehow resolvable by doing something other than -Wno-this-particular-warning (i.e. suppressing it). One possible pain point is -Werror configured on customer side. Therefore, I would recommend not to add the warning at all.

Do you want me to add the information in the design doc here?

In my last sentence about documentation I mean some user-facing documentation. Just so that our customers are aware about implementation details and can build their expectations accordingly.

Signed-off-by: Arvind Sudarsanam <[email protected]>
@asudarsa asudarsa requested review from a team as code owners March 27, 2023 16:23
@asudarsa asudarsa requested a review from sergey-semenov March 27, 2023 16:23
Signed-off-by: Arvind Sudarsanam <[email protected]>
@asudarsa asudarsa temporarily deployed to aws March 27, 2023 17:29 — with GitHub Actions Inactive
@bso-intel
Copy link
Contributor

#9008 - Basic/memory_consumption.cpp fail is a known issue.

I don't think this failure is still there with your latest test.

@asudarsa
Copy link
Contributor Author

#9008 - Basic/memory_consumption.cpp fail is a known issue.

I don't think this failure is still there with your latest test.

yes. I added this comment based on the previous run. Thanks

@bader bader merged commit f45fb51 into intel:sycl Apr 13, 2023
jandres742 pushed a commit to jandres742/llvm that referenced this pull request Apr 21, 2023
jandres742 pushed a commit to jandres742/llvm that referenced this pull request Apr 24, 2023
jandres742 pushed a commit to jandres742/llvm that referenced this pull request May 3, 2023
jandres742 pushed a commit to jandres742/llvm that referenced this pull request May 16, 2023
jandres742 pushed a commit to jandres742/llvm that referenced this pull request May 23, 2023
jandres742 pushed a commit to jandres742/llvm that referenced this pull request May 26, 2023
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.