Skip to content
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

[NFC][SYCL][SYCLLowerIR] Add cl::opt SpecConstantMode for LIT testing #15821

Merged

Conversation

wenju-he
Copy link
Contributor

This allows testing SpecConstantsPass with different modes.

This allows testing SpecConstantsPass with different modes.
@wenju-he
Copy link
Contributor Author

3 failed sycl e2e tests in SYCL Pre Commit on Linux / test (Intel, ["Linux", "gen12"] have Invalid device error, which is probably unrelated to this PR.

Failed Tests (3):
  SYCL :: AOT/double.cpp
  SYCL :: AOT/half.cpp
  SYCL :: AOT/reqd-sg-size.cpp
******************** TEST 'SYCL :: AOT/double.cpp' FAILED ********************
Exit Code: 1

Command Output (stdout):
--
# RUN: at line 5
/__w/llvm/llvm/toolchain/bin//clang++  -Werror  -fsycl -fsycl-targets=intel_gpu_tgllp -o /__w/llvm/llvm/build-e2e/AOT/Output/double.cpp.tmp.tgllp.out /__w/llvm/llvm/llvm/sycl/test-e2e/AOT/double.cpp
# executed command: /__w/llvm/llvm/toolchain/bin//clang++ -Werror -fsycl -fsycl-targets=intel_gpu_tgllp -o /__w/llvm/llvm/build-e2e/AOT/Output/double.cpp.tmp.tgllp.out /__w/llvm/llvm/llvm/sycl/test-e2e/AOT/double.cpp
# note: command had no output on stdout or stderr
# RUN: at line 6
/__w/llvm/llvm/toolchain/bin//clang++  -Werror  -fsycl -fsycl-targets=spir64_x86_64 -o /__w/llvm/llvm/build-e2e/AOT/Output/double.cpp.tmp.x86.out /__w/llvm/llvm/llvm/sycl/test-e2e/AOT/double.cpp
# executed command: /__w/llvm/llvm/toolchain/bin//clang++ -Werror -fsycl -fsycl-targets=spir64_x86_64 -o /__w/llvm/llvm/build-e2e/AOT/Output/double.cpp.tmp.x86.out /__w/llvm/llvm/llvm/sycl/test-e2e/AOT/double.cpp
# note: command had no output on stdout or stderr
# RUN: at line 7 has no command after substitutions
# RUN: at line 7 has no command after substitutions
# RUN: at line 7
env ONEAPI_DEVICE_SELECTOR=opencl:cpu  /__w/llvm/llvm/build-e2e/AOT/Output/double.cpp.tmp.x86.out
# executed command: env ONEAPI_DEVICE_SELECTOR=opencl:cpu /__w/llvm/llvm/build-e2e/AOT/Output/double.cpp.tmp.x86.out
# .---command stdout------------
# | 5
# `-----------------------------
# RUN: at line 12
/__w/llvm/llvm/toolchain/bin//clang++  -Werror  -fsycl -fsycl-targets=intel_gpu_cfl -o /__w/llvm/llvm/build-e2e/AOT/Output/double.cpp.tmp.cfl.out /__w/llvm/llvm/llvm/sycl/test-e2e/AOT/double.cpp
# executed command: /__w/llvm/llvm/toolchain/bin//clang++ -Werror -fsycl -fsycl-targets=intel_gpu_cfl -o /__w/llvm/llvm/build-e2e/AOT/Output/double.cpp.tmp.cfl.out /__w/llvm/llvm/llvm/sycl/test-e2e/AOT/double.cpp
# .---command stdout------------
# | Could not determine device target: cfl.
# | Error: Cannot get HW Info for device cfl.
# | Invalid device error, trying to fallback to former ocloc libocloc_legacy1.so
# | Couldn't load former ocloc libocloc_legacy1.so
# | Command was: /usr/bin/ocloc -output /tmp/lit-tmp-mk_n9huv/double-cfl-66975a-435f34.out -file /tmp/lit-tmp-mk_n9huv/double-cfl-20b79e-ea7072.spv -output_no_suffix -spirv_input -device cfl
# `-----------------------------
# .---command stderr------------
# | llvm-foreach: 
# | clang++: error: gen compiler command failed with exit code 223 (use -v to see invocation)
# | clang version 20.0.0git (https://github.com/intel/llvm 522bbe86a5c2b203ed0faababdb458b009d3ae49)
# | Target: x86_64-unknown-linux-gnu
# | Thread model: posix
# | InstalledDir: /__w/llvm/llvm/toolchain/bin
# | Build config: +assertions
# | clang++: note: diagnostic msg: Error generating preprocessed source(s).
# `-----------------------------
# error: command failed with exit status: 1

--

********************
FAIL: SYCL :: AOT/half.cpp (63 of 2226)
******************** TEST 'SYCL :: AOT/half.cpp' FAILED ********************
Exit Code: 1

Command Output (stdout):
--
# RUN: at line 5
/__w/llvm/llvm/toolchain/bin//clang++  -Werror  -fsycl -fsycl-targets=intel_gpu_tgllp -o /__w/llvm/llvm/build-e2e/AOT/Output/half.cpp.tmp.tgllp.out /__w/llvm/llvm/llvm/sycl/test-e2e/AOT/half.cpp
# executed command: /__w/llvm/llvm/toolchain/bin//clang++ -Werror -fsycl -fsycl-targets=intel_gpu_tgllp -o /__w/llvm/llvm/build-e2e/AOT/Output/half.cpp.tmp.tgllp.out /__w/llvm/llvm/llvm/sycl/test-e2e/AOT/half.cpp
# .---command stdout------------
# | Compilation from IR - skipping loading of FCL
# | Build succeeded.
# `-----------------------------
# RUN: at line 6
/__w/llvm/llvm/toolchain/bin//clang++  -Werror  -fsycl -fsycl-targets=spir64_x86_64 -o /__w/llvm/llvm/build-e2e/AOT/Output/half.cpp.tmp.x86.out /__w/llvm/llvm/llvm/sycl/test-e2e/AOT/half.cpp
# executed command: /__w/llvm/llvm/toolchain/bin//clang++ -Werror -fsycl -fsycl-targets=spir64_x86_64 -o /__w/llvm/llvm/build-e2e/AOT/Output/half.cpp.tmp.x86.out /__w/llvm/llvm/llvm/sycl/test-e2e/AOT/half.cpp
# note: command had no output on stdout or stderr
# RUN: at line 7 has no command after substitutions
# RUN: at line 7 has no command after substitutions
# RUN: at line 7
env ONEAPI_DEVICE_SELECTOR=opencl:cpu  /__w/llvm/llvm/build-e2e/AOT/Output/half.cpp.tmp.x86.out
# executed command: env ONEAPI_DEVICE_SELECTOR=opencl:cpu /__w/llvm/llvm/build-e2e/AOT/Output/half.cpp.tmp.x86.out
# .---command stdout------------
# | 5
# `-----------------------------
# RUN: at line 12
/__w/llvm/llvm/toolchain/bin//clang++  -Werror  -fsycl -fsycl-targets=intel_gpu_cfl -o /__w/llvm/llvm/build-e2e/AOT/Output/half.cpp.tmp.cfl.out /__w/llvm/llvm/llvm/sycl/test-e2e/AOT/half.cpp
# executed command: /__w/llvm/llvm/toolchain/bin//clang++ -Werror -fsycl -fsycl-targets=intel_gpu_cfl -o /__w/llvm/llvm/build-e2e/AOT/Output/half.cpp.tmp.cfl.out /__w/llvm/llvm/llvm/sycl/test-e2e/AOT/half.cpp
# .---command stdout------------
# | Could not determine device target: cfl.
# | Error: Cannot get HW Info for device cfl.
# | Invalid device error, trying to fallback to former ocloc libocloc_legacy1.so
# | Couldn't load former ocloc libocloc_legacy1.so
# | Command was: /usr/bin/ocloc -output /tmp/lit-tmp-mk_n9huv/half-cfl-[40](https://github.com/intel/llvm/actions/runs/11471577595/job/31923077136?pr=15821#step:22:41)c7c8-2c9a4f.out -file /tmp/lit-tmp-mk_n9huv/half-cfl-b4e61b-228ac4.spv -output_no_suffix -spirv_input -device cfl
# `-----------------------------
# .---command stderr------------
# | llvm-foreach: 
# | clang++: error: gen compiler command failed with exit code 223 (use -v to see invocation)
# | clang version 20.0.0git (https://github.com/intel/llvm 522bbe86a5c2b203ed0faababdb458b009d3ae49)
# | Target: x86_64-unknown-linux-gnu
# | Thread model: posix
# | InstalledDir: /__w/llvm/llvm/toolchain/bin
# | Build config: +assertions
# | clang++: note: diagnostic msg: Error generating preprocessed source(s).
# `-----------------------------
# error: command failed with exit status: 1

--

********************
FAIL: SYCL :: AOT/reqd-sg-size.cpp (67 of 2226)
******************** TEST 'SYCL :: AOT/reqd-sg-size.cpp' FAILED ********************
Exit Code: 1

Command Output (stdout):
--
# RUN: at line 5
/__w/llvm/llvm/toolchain/bin//clang++  -Werror  -fsycl -fsycl-targets=intel_gpu_tgllp -o /__w/llvm/llvm/build-e2e/AOT/Output/reqd-sg-size.cpp.tmp.tgllp.out /__w/llvm/llvm/llvm/sycl/test-e2e/AOT/reqd-sg-size.cpp
# executed command: /__w/llvm/llvm/toolchain/bin//clang++ -Werror -fsycl -fsycl-targets=intel_gpu_tgllp -o /__w/llvm/llvm/build-e2e/AOT/Output/reqd-sg-size.cpp.tmp.tgllp.out /__w/llvm/llvm/llvm/sycl/test-e2e/AOT/reqd-sg-size.cpp
# .---command stdout------------
# | Compilation from IR - skipping loading of FCL
# | Build succeeded.
# | Compilation from IR - skipping loading of FCL
# | Build succeeded.
# | Compilation from IR - skipping loading of FCL
# | Build succeeded.
# `-----------------------------
# RUN: at line 6
/__w/llvm/llvm/toolchain/bin//clang++  -Werror  -fsycl -fsycl-targets=spir64_x86_64 -o /__w/llvm/llvm/build-e2e/AOT/Output/reqd-sg-size.cpp.tmp.x86.out /__w/llvm/llvm/llvm/sycl/test-e2e/AOT/reqd-sg-size.cpp
# executed command: /__w/llvm/llvm/toolchain/bin//clang++ -Werror -fsycl -fsycl-targets=spir64_x86_64 -o /__w/llvm/llvm/build-e2e/AOT/Output/reqd-sg-size.cpp.tmp.x86.out /__w/llvm/llvm/llvm/sycl/test-e2e/AOT/reqd-sg-size.cpp
# note: command had no output on stdout or stderr
# RUN: at line 11
/__w/llvm/llvm/toolchain/bin//clang++  -Werror  -fsycl -fsycl-targets=intel_gpu_cfl -o /__w/llvm/llvm/build-e2e/AOT/Output/reqd-sg-size.cpp.tmp.cfl.out /__w/llvm/llvm/llvm/sycl/test-e2e/AOT/reqd-sg-size.cpp
# executed command: /__w/llvm/llvm/toolchain/bin//clang++ -Werror -fsycl -fsycl-targets=intel_gpu_cfl -o /__w/llvm/llvm/build-e2e/AOT/Output/reqd-sg-size.cpp.tmp.cfl.out /__w/llvm/llvm/llvm/sycl/test-e2e/AOT/reqd-sg-size.cpp
# .---command stdout------------
# | Could not determine device target: cfl.
# | Error: Cannot get HW Info for device cfl.
# | Invalid device error, trying to fallback to former ocloc libocloc_legacy1.so
# | Couldn't load former ocloc libocloc_legacy1.so
# | Command was: /usr/bin/ocloc -output /tmp/lit-tmp-mk_n9huv/reqd-sg-size-cfl-3604aa-d4e8[42](https://github.com/intel/llvm/actions/runs/11471577595/job/31923077136?pr=15821#step:22:43).out -file /tmp/lit-tmp-mk_n9huv/reqd-sg-size-cfl-1d8c5f-a0cd4a.spv -output_no_suffix -spirv_input -device cfl
# | Could not determine device target: cfl.
# | Error: Cannot get HW Info for device cfl.
# | Invalid device error, trying to fallback to former ocloc libocloc_legacy1.so
# | Couldn't load former ocloc libocloc_legacy1.so
# | Command was: /usr/bin/ocloc -output /tmp/lit-tmp-mk_n9huv/reqd-sg-size-cfl-3604aa-c19a59.out -file /tmp/lit-tmp-mk_n9huv/reqd-sg-size-cfl-1d8c5f-5afed6.spv -output_no_suffix -spirv_input -device cfl
# | Could not determine device target: cfl.
# | Error: Cannot get HW Info for device cfl.
# | Invalid device error, trying to fallback to former ocloc libocloc_legacy1.so
# | Couldn't load former ocloc libocloc_legacy1.so
# | Command was: /usr/bin/ocloc -output /tmp/lit-tmp-mk_n9huv/reqd-sg-size-cfl-3604aa-b2d7d6.out -file /tmp/lit-tmp-mk_n9huv/reqd-sg-size-cfl-1d8c5f-54ac6d.spv -output_no_suffix -spirv_input -device cfl
# `-----------------------------
# .---command stderr------------
# | llvm-foreach: 
# | llvm-foreach: 
# | llvm-foreach: 
# | clang++: error: gen compiler command failed with exit code 223 (use -v to see invocation)
# | clang version 20.0.0git (https://github.com/intel/llvm 522bbe86a5c2b203ed0faababdb[45](https://github.com/intel/llvm/actions/runs/11471577595/job/31923077136?pr=15821#step:22:46)8b009d3ae49)
# | Target: x86_64-unknown-linux-gnu
# | Thread model: posix
# | InstalledDir: /__w/llvm/llvm/toolchain/bin
# | Build config: +assertions
# | clang++: note: diagnostic msg: Error generating preprocessed source(s).
# `-----------------------------
# error: command failed with exit status: 1

--

@@ -29,6 +29,19 @@

using namespace llvm;

static cl::opt<SpecConstantsPass::HandlingMode> SpecConstantMode(
"spec-constant-mode", cl::Optional, cl::Hidden,
cl::desc("Spec constant handling mode"),
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
cl::desc("Spec constant handling mode"),
cl::desc("Specialization constant handling mode"),

Copy link
Contributor Author

Choose a reason for hiding this comment

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

done

cl::values(
clEnumValN(SpecConstantsPass::HandlingMode::default_values,
"default_values",
"spec constant uses are replaced by default values"),
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
"spec constant uses are replaced by default values"),
"Specialization constant uses are replaced by default values"),

Copy link
Contributor Author

Choose a reason for hiding this comment

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

done

"default_values",
"spec constant uses are replaced by default values"),
clEnumValN(SpecConstantsPass::HandlingMode::emulation, "emulation",
"spec constant intrinsics are replaced by RT buffers"),
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
"spec constant intrinsics are replaced by RT buffers"),
"Specialization constant intrinsics are replaced by run-time buffers"),

Copy link
Contributor Author

Choose a reason for hiding this comment

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

done

"spec constant intrinsics are replaced by RT buffers"),
clEnumValN(
SpecConstantsPass::HandlingMode::native, "native",
"spec constant intrinsics are lowered to spirv intrinsics")));
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
"spec constant intrinsics are lowered to spirv intrinsics")));
"Specialization constant intrinsics are lowered to SPIR-V intrinsics")));

Copy link
Contributor Author

Choose a reason for hiding this comment

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

done

@@ -1,7 +1,6 @@
; RUN: sycl-post-link -properties -split=auto -spec-const=native -S -o %t.table %s -generate-device-image-default-spec-consts
Copy link
Contributor

Choose a reason for hiding this comment

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

Is the sycl-post-link test not expected to work anymore? I somehow feel it will be better to add a new test 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.

sycl-post-link test is still expected to work.
This test was only checking output of SpecConstantPass, while other tests in llvm/test/tools/sycl-post-link/ folder are also checking sycl-post-link tool output. So I move this test into llvm/test/SYCLLowerIR/SpecConstants/SYCL-alloca.ll

After reading your comment, I also feel it is better to keep the test to check sycl-post-link is correctly passing parameters to SpecConstantPass. So I added it back in the second commit.

@@ -29,6 +29,19 @@

using namespace llvm;

static cl::opt<SpecConstantsPass::HandlingMode> SpecConstantMode(
Copy link
Contributor

Choose a reason for hiding this comment

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

is there a default value that can be set 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.

added default value: cl::init(SpecConstantsPass::HandlingMode::emulation)

Copy link
Contributor

@asudarsa asudarsa left a comment

Choose a reason for hiding this comment

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

Looks good overall. Just a few suggestions.

Thanks

Copy link
Contributor

@asudarsa asudarsa left a comment

Choose a reason for hiding this comment

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

Thanks for the updates. LGTM.

@wenju-he
Copy link
Contributor Author

@intel/llvm-gatekeepers please merge, thanks

@steffenlarsen steffenlarsen merged commit cbdee7a into intel:sycl Oct 24, 2024
13 checks passed
@wenju-he wenju-he deleted the SpecConstantsPass-cl-opt-SpecConstantMode branch October 24, 2024 06:35
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.

3 participants