Add missing runtime tests for SSE alias intrinsics#2041
Add missing runtime tests for SSE alias intrinsics#2041ArunTamil21 wants to merge 10 commits intorust-lang:mainfrom
Conversation
|
r? @folkertdev rustbot has assigned @folkertdev. Use Why was this reviewer chosen?The reviewer was selected based on:
|
There was a problem hiding this comment.
Could you remove these lines too please
stdarch/crates/stdarch-verify/tests/x86-intel.rs
Lines 250 to 253 in 0e22a37
|
Also, personally, I think it is a bit weird (and error-prone) to fully repeat the tests for aliases, considering there are quite a few of them. I would prefer a macro-based approach, but take this as a completely personal opinion. |
|
@sayantn Done, removed the lines from x86-intel.rs. Regarding the macro-based approach, I agree it's cleaner. |
|
I would prefer it to be a single PR, as this PR just copying the tests anyway. If you prefer you can keep them as different commits |
|
@sayantn Thanks for the feedback. I'll refactor the tests using a macro-based approach. |
|
I don't think we use a macro like that exactly, but you can make a simple macro like macro_rules! foo_gen {
($($test_name:ident : $alias:ident),*) => {$(
#[simd_test(blah)]
fn $test_name() {
//<< the body, but with $alias as the function name >>
}
)*}
}
foo_gen(foo, foo_alias);or you can create a "meta function" like unsafe fn test_foo_gen(actual_fn: unsafe fn()) {
// << the body, but using `actual_fn` in place of that >>
}
#[simd_test(blah)]
fn test_foo() {
test_foo_gen(foo);
}
#[simd_test(blah)]
fn test_foo_alias() {
test_foo_gen(foo_alias);
}any of these work, or if you can think of a better approach that's even better |
…tt_ss2si, _mm_cvt_si2ss, _mm_set_ps1
…s for _mm_undefined_ps, _mm_prefetch, _mm_load_ps1, _mm_store_ps1
9ac3bde to
b397dac
Compare
This comment has been minimized.
This comment has been minimized.
|
@sayantn |
|
Thanks, looks nice. But I don't think we need tests for prefetch and undefined, we already have instruction tests to ensure that they produce the correct assembly |
Already verified by assert_instr; no output to assert at runtime.
|
Thanks @sayantn for the clarification — removed both. Good to know assert_instr already covers correctness for intrinsics with no verifiable output. |
|
I apologize for not spotting this earlier, but using the "meta-function" technique doesn't work for functions that we const-test (e.g. |
|
Thanks, no need to apologize — this is a good learning for me. I’ll refactor all the alias tests to use the macro pattern for uniformity and push the changes. |
This comment has been minimized.
This comment has been minimized.
|
This PR was rebased onto a different main commit. Here's a range-diff highlighting what actually changed. Rebasing is a normal part of keeping PRs up to date, so no action is needed—this note is just to help reviewers. |
|
@sayantn The CI is failing on intrinsic verification, looks like the verifier can't pick up macro-generated test functions. Is there another way to handle it ? Edit: I traced the issue to stdarch-verify/src/lib.rs, the verifier finds tests by looking for functions starting with test_. Since these tests are now macro-generated, they don't show up as regular functions and the verifier misses them ? I might be wrong still trying to understand the codebase |
|
Sorry for the late response. Yes, we can't generate the tests from macros, as macro_rules! foo {
// body of the test
}
#[simd_test...]
fn test_bar() {
foo!(bar);
}
#[simd_test...]
fn test_baz() {
foo!(baz);
}This approach minimizes duplication, while also making sure that |
|
Updated the implementation based on your suggestion, body macros for deduplication, wrapper functions kept visible for the verifier. Both runtime tests and intrinsic verification pass locally. |
|
@sayantn Thanks for the feedback just updated the suggestions, used const fn where the intrinsic supports it, plain fn on the others, and removed unsafe from all wrapper signatures. Both runtime tests and verifier pass locally. |
Add missing runtime tests for SSE alias intrinsics
While working through issue #798, I noticed several alias intrinsics had no
runtime tests even though their underlying functions were already tested.
This PR adds tests for:
Each test follows the same pattern as the existing tests for the underlying
functions, since these aliases just call them directly.
Part of #798.