Skip to content

Conversation

MrSidims
Copy link
Contributor

No description provided.

@MrSidims MrSidims requested review from a team as code owners September 10, 2025 11:41
@MrSidims
Copy link
Contributor Author

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]>
@maarquitos14
Copy link
Contributor

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.

Maybe with some kind of log to make sure the barrier does not run?

@Fznamznon
Copy link
Contributor

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.

Why do we disable it then?

@MrSidims
Copy link
Contributor Author

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.

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.

@Fznamznon
Copy link
Contributor

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.

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?

@MrSidims
Copy link
Contributor Author

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.

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.

@MrSidims
Copy link
Contributor Author

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.

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.

Signed-off-by: Sidorov, Dmitry <[email protected]>
Copy link
Contributor

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

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.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

the test is removed

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

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.

Copy link
Contributor Author

@MrSidims MrSidims Sep 11, 2025

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.

Copy link
Contributor Author

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.

Copy link
Contributor

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.

Copy link
Contributor Author

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!

Copy link
Contributor

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]>
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.

5 participants