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

add tests for cl_khr_expect_assume #1888

Merged
merged 5 commits into from
Feb 27, 2024

Conversation

bashbaug
Copy link
Contributor

@bashbaug bashbaug commented Feb 3, 2024

This PR adds tests for the cl_khr_expect_assume extension. Because this functionality is only exposed via SPIR-V (for now), only the spirv_new test is updated:

  1. Tests a kernel with OpAssumeTrue.
  2. Tests each of the supported data types for OpExpect: 8-bit integers, 16-bit integers, 32-bit integers, and 64-bit integers.
    a. For each of the supported data types, tests scalars and vectors of 2, 3, 4, 8, and 16 components.

For reference:

@svenvh svenvh self-requested a review February 7, 2024 09:11
Copy link
Member

@svenvh svenvh left a comment

Choose a reason for hiding this comment

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

The approach looks alright to me, just a few nits. My comments on expect_char.spvasm64 apply to most other expect .spvasm files too.

test_conformance/spirv_new/test_cl_khr_expect_assume.cpp Outdated Show resolved Hide resolved
test_conformance/spirv_new/test_cl_khr_expect_assume.cpp Outdated Show resolved Hide resolved
test_conformance/spirv_new/spirv_asm/expect_char.spvasm64 Outdated Show resolved Hide resolved
test_conformance/spirv_new/spirv_asm/expect_char.spvasm64 Outdated Show resolved Hide resolved
Copy link
Member

@svenvh svenvh left a comment

Choose a reason for hiding this comment

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

LGTM, thanks!

@bashbaug
Copy link
Contributor Author

@karolherbst FYI, I tried these tests on rusticl and the "expect" tests are crashing. Is this something you'd like to look at before merging this PR? I think the SPIR-V files are correct and they're passing the validator, but it's possible I messed something up.

Here is a backtrace. I'm using a rusticl I built myself, from the mesa-24.0.0 tag, so it's possible I messed up something as part of the build, too.

$ RUST_BACKTRACE=full ./test_conformance/spirv_new/test_spirv_new --spirv-binaries-path ../test_conformance/spirv_new/spirv_bin/ op_expect
 Initializing random seed to 0.
Requesting Default device based on command line for platform index 0 and device index 0
WARNING: OpenCL support via iris driver is incomplete.
For a complete and conformant OpenCL implementation, use
https://github.com/intel/compute-runtime instead
Compute Device Name = Mesa Intel(R) UHD Graphics 770 (ADL-S GT1), Compute Device Vendor = Intel, Compute Device Version = OpenCL 3.0 , CL C Version = OpenCL C 1.2 
Device latest conformance version passed: v2022-04-22-00
Supports single precision denormals: NO
sizeof( void*) = 8  (host)
sizeof( void*) = 8  (device)
This device supports SPIR-V offline compilation. SPIR-V version is 1.0
op_expect...
    testing type char
thread '<unnamed>' panicked at 'called `Option::unwrap()` on a `None` value', ../src/gallium/frontends/rusticl/core/program.rs:268:13
stack backtrace:
   0:     0x7fa8e7c06140 - std::backtrace_rs::backtrace::libunwind::trace::hc74d68e4e9860fea
                               at /build/rustc-N04w3E/rustc-1.72.1+dfsg0ubuntu1~bpo0/library/std/src/../../backtrace/src/backtrace/libunwind.rs:93:5
   1:     0x7fa8e7c06140 - std::backtrace_rs::backtrace::trace_unsynchronized::hf8e4c2f2a5bd29df
                               at /build/rustc-N04w3E/rustc-1.72.1+dfsg0ubuntu1~bpo0/library/std/src/../../backtrace/src/backtrace/mod.rs:66:5
   2:     0x7fa8e7c06140 - std::sys_common::backtrace::_print_fmt::h4f6fe0d2839f79bc
                               at /build/rustc-N04w3E/rustc-1.72.1+dfsg0ubuntu1~bpo0/library/std/src/sys_common/backtrace.rs:65:5
   3:     0x7fa8e7c06140 - <std::sys_common::backtrace::_print::DisplayBacktrace as core::fmt::Display>::fmt::hd19378c79598340a
                               at /build/rustc-N04w3E/rustc-1.72.1+dfsg0ubuntu1~bpo0/library/std/src/sys_common/backtrace.rs:44:22
   4:     0x7fa8e7c42b5f - core::fmt::rt::Argument::fmt::h59bd005c578b819c
                               at /build/rustc-N04w3E/rustc-1.72.1+dfsg0ubuntu1~bpo0/library/core/src/fmt/rt.rs:138:9
   5:     0x7fa8e7c42b5f - core::fmt::write::hc6d0fea41b7d9e9f
                               at /build/rustc-N04w3E/rustc-1.72.1+dfsg0ubuntu1~bpo0/library/core/src/fmt/mod.rs:1094:21
   6:     0x7fa8e7c312b9 - std::io::Write::write_fmt::haa7b0f41639b47d7
                               at /build/rustc-N04w3E/rustc-1.72.1+dfsg0ubuntu1~bpo0/library/std/src/io/mod.rs:1714:15
   7:     0x7fa8e7c05f45 - std::sys_common::backtrace::_print::h5d490a94ac60fe6f
                               at /build/rustc-N04w3E/rustc-1.72.1+dfsg0ubuntu1~bpo0/library/std/src/sys_common/backtrace.rs:47:5
   8:     0x7fa8e7c05f45 - std::sys_common::backtrace::print::hbaa9c19cd32d8c11
                               at /build/rustc-N04w3E/rustc-1.72.1+dfsg0ubuntu1~bpo0/library/std/src/sys_common/backtrace.rs:34:9
   9:     0x7fa8e7c1f8d1 - std::panicking::default_hook::{{closure}}::h8910079f61b67bae
                               at /build/rustc-N04w3E/rustc-1.72.1+dfsg0ubuntu1~bpo0/library/std/src/panicking.rs:269:22
  10:     0x7fa8e7c1f56f - std::panicking::default_hook::h7edb9fd7f54e7e29
                               at /build/rustc-N04w3E/rustc-1.72.1+dfsg0ubuntu1~bpo0/library/std/src/panicking.rs:288:9
  11:     0x7fa8e7c1fd79 - std::panicking::rust_panic_with_hook::h21aae3dc3ef5bbce
                               at /build/rustc-N04w3E/rustc-1.72.1+dfsg0ubuntu1~bpo0/library/std/src/panicking.rs:705:13
  12:     0x7fa8e7c063e1 - std::panicking::begin_panic_handler::{{closure}}::ha72f1c35114340ed
                               at /build/rustc-N04w3E/rustc-1.72.1+dfsg0ubuntu1~bpo0/library/std/src/panicking.rs:595:13
  13:     0x7fa8e7c06216 - std::sys_common::backtrace::__rust_end_short_backtrace::h4b9d50b70e928d76
                               at /build/rustc-N04w3E/rustc-1.72.1+dfsg0ubuntu1~bpo0/library/std/src/sys_common/backtrace.rs:151:18
  14:     0x7fa8e7c1faa2 - rust_begin_unwind
                               at /build/rustc-N04w3E/rustc-1.72.1+dfsg0ubuntu1~bpo0/library/std/src/panicking.rs:593:5
  15:     0x7fa8e7b98813 - core::panicking::panic_fmt::h1f248589eaa015cb
                               at /build/rustc-N04w3E/rustc-1.72.1+dfsg0ubuntu1~bpo0/library/core/src/panicking.rs:67:14
  16:     0x7fa8e7b988a3 - core::panicking::panic::ha7576b296f353a40
                               at /build/rustc-N04w3E/rustc-1.72.1+dfsg0ubuntu1~bpo0/library/core/src/panicking.rs:117:5
  17:     0x7fa8e7be7ad8 - rusticl::core::program::ProgramBuild::to_nir::h3e7d8573d3869ab1
  18:     0x7fa8e7bd57e9 - rusticl::core::kernel::convert_spirv_to_nir::h63f831dfef98e9d1
  19:     0x7fa8e7be5fd7 - rusticl::core::program::ProgramBuild::build_nirs::h8362b526160a78a2
  20:     0x7fa8e7bea8ee - rusticl::core::program::Program::build::h0700b8a43b23b8cd
  21:     0x7fa8e7bc47e4 - rusticl::api::program::cl_build_program::h1289810feaa9a64c
  22:     0x5628b6befdc7 - _Z19get_program_with_ilRN15wrapper_details7WrapperIP11_cl_programXadL_Z15clRetainProgramEEXadL_Z16clReleaseProgramEEEEP13_cl_device_idP11_cl_contextPKc10spec_const
                               at /home/bashbaug/git/OpenCL-CTS/test_conformance/spirv_new/main.cpp:200:25
  23:     0x5628b6bf5152 - test_expect_type<signed char>
                               at /home/bashbaug/git/OpenCL-CTS/test_conformance/spirv_new/test_cl_khr_expect_assume.cpp:77:32
  24:     0x5628b6bf4846 - _Z14test_op_expectP13_cl_device_idP11_cl_contextP17_cl_command_queuei
                               at /home/bashbaug/git/OpenCL-CTS/test_conformance/spirv_new/test_cl_khr_expect_assume.cpp:118:40
  25:     0x5628b6c7de2e - _Z22callSingleTestFunction15test_definitionP13_cl_device_idRK19test_harness_config
                               at /home/bashbaug/git/OpenCL-CTS/test_common/harness/testHarness.cpp:939:22
  26:     0x5628b6c7d7f6 - _Z17callTestFunctionsP15test_definitionPhP11test_statusiP13_cl_device_idRK19test_harness_config
                               at /home/bashbaug/git/OpenCL-CTS/test_common/harness/testHarness.cpp:818:43
  27:     0x5628b6c7d4a0 - _Z28parseAndCallCommandLineTestsiPPKcP13_cl_device_idiP15test_definitionRK19test_harness_config
                               at /home/bashbaug/git/OpenCL-CTS/test_common/harness/testHarness.cpp:730:26
  28:     0x5628b6c7cf68 - _Z23runTestHarnessWithCheckiPPKciP15test_definitionimPF11test_statusP13_cl_device_idE
                               at /home/bashbaug/git/OpenCL-CTS/test_common/harness/testHarness.cpp:593:45
  29:     0x5628b6bf014e - main
                               at /home/bashbaug/git/OpenCL-CTS/test_conformance/spirv_new/main.cpp:262:35
  30:     0x7fa8eae29d90 - __libc_start_call_main
                               at ./csu/../sysdeps/nptl/libc_start_call_main.h:58:16
  31:     0x7fa8eae29e40 - __libc_start_main_impl
                               at ./csu/../csu/libc-start.c:392:3
  32:     0x5628b6beecd5 - _start
  33:                0x0 - <unknown>
fatal runtime error: failed to initiate panic, error 5
Aborted (core dumped)

@karolherbst
Copy link
Contributor

I think that's the mesa internal spirv parser hitting something unknown or unexpected. I can take a look shortly and see what's up. Thanks for the ping.

@karolherbst
Copy link
Contributor

$ ./build/test_conformance/spirv_new/test_spirv_new op_expect
Reading SPIR-V files from default 'spirv_bin' path.
In case you want to set other directory use '--spirv-binaries-path' argument.
To skip the SPIR-V version check use the '--skip-spirv-version-check' argument.
 Initializing random seed to 0.
Requesting Default device based on command line for platform index 0 and device index 0
WARNING: OpenCL support via iris driver is incomplete.
For a complete and conformant OpenCL implementation, use
https://github.com/intel/compute-runtime instead
Compute Device Name = Mesa Intel(R) UHD Graphics (CML GT2), Compute Device Vendor = Intel, Compute Device Version = OpenCL 3.0 , CL C Version = OpenCL C 1.2 
Device latest conformance version passed: v0000-01-01-00
Supports single precision denormals: NO
sizeof( void*) = 8  (host)
sizeof( void*) = 8  (device)
This device supports SPIR-V offline compilation. SPIR-V version is 1.4
op_expect...
    testing type char
    testing type short
    testing type int
    testing type long
op_expect passed
PASSED sub-test.
PASSED test.

The only apparently difference I see is the This device supports SPIR-V offline compilation. SPIR-V version is 1.0 part... Is there a way I can force the SPIR-V version to be 1.0?

@karolherbst
Copy link
Contributor

Actually.. that's returned by the runtime and the CTS just prints the result of CL_DEVICE_IL_VERSION and returns the highest match... so now I'm even more confused why you get 1.0

@karolherbst
Copy link
Contributor

@bashbaug mind sharing the output of clinfo?

@karolherbst
Copy link
Contributor

@bashbaug nevermind... this is actually a regression it seems? I was debugging a different bug which ends up in the same trace and I think something broke. on main everything seems fine.

Sadly it's also broken with 24.0.1, so I'll need to figure out what broke where. In any case... rusticl seems to pass the tests here (ignoring the regression)

@karolherbst
Copy link
Contributor

for reference, the issue was fixed by https://gitlab.freedesktop.org/mesa/mesa/-/merge_requests/27265

@bashbaug
Copy link
Contributor Author

Thanks for the quick follow-up. If everything is working on your mainline it sounds like we're good to merge this, then?

@karolherbst
Copy link
Contributor

Thanks for the quick follow-up. If everything is working on your mainline it sounds like we're good to merge this, then?

yeah, I've submitted a MR to backport the fixes here: https://gitlab.freedesktop.org/mesa/mesa/-/merge_requests/27740

apparently the initial implementation wasn't entirely correct. Oh well, at least that's sorted out now. And thanks for making me aware of this. I didn't know there was a bug and the fix wasn't marked for backporting either...

@bashbaug
Copy link
Contributor Author

Regarding:

Actually.. that's returned by the runtime and the CTS just prints the result of CL_DEVICE_IL_VERSION and returns the highest match... so now I'm even more confused why you get 1.0

This is due to a bug in the CTS test reporting (already fixed) where the supported SPIR-V versions were checked from the lowest version to the highest version and the first match was printed. All should be well if I merge or rebase to pick up the latest changes.

@bashbaug
Copy link
Contributor Author

I'll need to add a test case checking OpExpectKHR with boolean sources to close #1424, but I'd like to do that in a different PR if everything looks good here.

@bashbaug
Copy link
Contributor Author

Merging as discussed in the February 27th teleconference.

@bashbaug bashbaug merged commit 0052af2 into KhronosGroup:main Feb 27, 2024
7 checks passed
@bashbaug bashbaug deleted the cl_khr_expect_assume branch March 1, 2024 04:36
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants