-
Notifications
You must be signed in to change notification settings - Fork 802
[SYCL] Don't run SYCLOptimizeBarriersPass with O0 #20037
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
base: sycl
Are you sure you want to change the base?
Conversation
Signed-off-by: Sidorov, Dmitry <[email protected]>
Not entirely sure, how to add a test for this change - with O0 SYCL code won't be having memory semantic constants be propagated in the first place. |
Signed-off-by: Sidorov, Dmitry <[email protected]>
Maybe with some kind of log to make sure the barrier does not run? |
Why do we disable it then? |
Because of the OpenMP compiler, that inserts barriers implicitly (with the constants) and OpenMP offloading reuses SYCL offloading model, making this pass running. |
Can we use an OpenMP test? |
AFAIK OpenMP solution is a part of our downstream, so adding a test here won't help much :) The only other solution I see is to add an LLVM IR test with opt -O0 passes as a RUN command, but not sure if it's 'LLVM way' of creating unit tests. |
Actually, I have an idea for SYCL'ish test, let me try it. |
sycl/test/check_device_code/narrow-barrier-explicit-spirv-call.cpp
Outdated
Show resolved
Hide resolved
Signed-off-by: Sidorov, Dmitry <[email protected]>
38937e9
to
68a84f0
Compare
@intel/llvm-gatekeepers please consider merging |
|
||
int main(int argc, char *argv[]) { | ||
sycl::queue q{sycl::property::queue::enable_profiling{}}; | ||
float *sum = sycl::malloc_shared<float>(NUMBER_OF_WORK_GROUPS, q); |
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.
This has to be freed.
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.
the test is removed
sycl/test/check_device_code/narrow-barrier-explicit-spirv-call.cpp
Outdated
Show resolved
Hide resolved
sycl/test/check_device_code/narrow-barrier-explicit-spirv-call.cpp
Outdated
Show resolved
Hide resolved
sycl/test/check_device_code/narrow-barrier-explicit-spirv-call.cpp
Outdated
Show resolved
Hide resolved
sycl/test/check_device_code/narrow-barrier-explicit-spirv-call.cpp
Outdated
Show resolved
Hide resolved
sycl/test/check_device_code/narrow-barrier-explicit-spirv-call.cpp
Outdated
Show resolved
Hide resolved
@@ -0,0 +1,68 @@ | |||
// RUN: %clangxx -fsycl-device-only -fsycl-unnamed-lambda -S -Xclang -emit-llvm -Xclang -no-enable-noundef-analysis -O2 %s -o - | FileCheck %s --check-prefix=CHECK-O2 |
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.
Sorry, I'm not really happy with the test.
The problem I see here is that the tests that reside in sycl/test/check_device_code/ are intended to check that SYCL library is using front-end provided hooks/attributes correctly, this test is explicitly using SPIR-V builtin which should not happen in these tests.
If we simply want to check that the builtin is treated properly by the optimizations, it is better to add a simpler smaller test to clang/CodeGenSYCL. This way the test will also be much faster, since inclusion of the whole sycl.hpp won't be needed. If we want to see that SYCL application as user would write it generates the right code, we can leave the test here but we should not use the builtin explicitly.
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.
Strongly disagree, the test shouldn't be placed in clang/CodeGenSYCL . There should be frontend tests only, they must not test optimizations happening later.
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.
this test is explicitly using SPIR-V builtin which should not happen in these tests
using sycl::group_builtin won't expose missing O0 check in the backend utils, as the SYCL API is using several wrapper functions to get scope, memory semantics etc before calling spirv builtin.
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.
Strongly disagree, the test shouldn't be placed in clang/CodeGenSYCL . There should be frontend tests only, they must not test optimizations happening later.
The patch makes sure that clang doesn't run a pass with O0. I don't think a test for that patch actually checks the optimization's behavior.
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.
Didn't know, that there is a test for the pipeline check, moved the check there, thanks!
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.
Strongly disagree, the test shouldn't be placed in clang/CodeGenSYCL . There should be frontend tests only, they must not test optimizations happening later.
Never heard of this limitation before. I see 200 tests in clang/test/CodeGen use -O2
. Most of these tests check LLVM IR after optimizations, not the LLVM IR emitted by the front-end.
Signed-off-by: Sidorov, Dmitry <[email protected]>
Co-authored-by: Marcos Maronas <[email protected]>
No description provided.