Skip to content

EXPECT*KK macro rework - #3258

Merged
ndellingwood merged 12 commits into
kokkos:developfrom
jgfouca:jgfouca/kk_expect_macro_rework
Aug 24, 2026
Merged

EXPECT*KK macro rework#3258
ndellingwood merged 12 commits into
kokkos:developfrom
jgfouca:jgfouca/kk_expect_macro_rework

Conversation

@jgfouca

@jgfouca jgfouca commented Aug 19, 2026

Copy link
Copy Markdown
Contributor

Change list:

  • Move as much code as possible out of macros and into an Impl struct that all the macros can use
  • Use templates to be able to support all types (Views, SIMD, etc)
  • Remove redundant KK_EXPECT_NEAR macro

Fixes remaining issues involved with #3232 , namely:
:247:5: error: cannot convert 'val_type' (aka 'Vector<SIMD<float>, 4>') to 'double' without a conversion operator

@jgfouca
jgfouca requested review from brian-kelley, lucbv and ndellingwood and a balanced review from Copilot August 19, 2026 19:41
@jgfouca jgfouca self-assigned this Aug 19, 2026
Comment thread blas/unit_test/Test_Blas1_scal.hpp

Copilot AI left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

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

Pull request overview

Refactors near-comparison test macros to support scalars, SIMD vectors, and rank-1 Kokkos Views.

Changes:

  • Moves comparison logic into templated helpers.
  • Removes KK_EXPECT_NEAR and updates callers.
  • Corrects remaining TestUtils namespace references.

Reviewed changes

Copilot reviewed 4 out of 4 changed files in this pull request and generated 1 comment.

File Description
test_common/KokkosKernels_TestUtils.hpp Adds generalized comparison helpers and simplifies macros.
blas/unit_test/Test_Blas1_scal.hpp Corrects random-bound utility namespace.
batched/dense/unit_test/Test_Batched_Swap.hpp Migrates assertions to EXPECT_NEAR_KK.
batched/dense/unit_test/Test_Batched_Nrm.hpp Migrates assertions to EXPECT_NEAR_KK.

💡 Add a code-review agent skill or configure MCP servers for context-aware, tailored reviews. Learn more in the docs.

Comment thread test_common/KokkosKernels_TestUtils.hpp Outdated
Comment on lines +65 to +68
return testing::AssertionFailure() << "Expected: " << expr1 << " is near " << expr2 << " (within " << expr_tol
<< ")\n"
<< " Actual: " << abs_diff << "\n"
<< "Expected: " << abs_tol << "\n";
Signed-off-by: James Foucar <jgfouca@sandia.gov>
Signed-off-by: James Foucar <jgfouca@sandia.gov>
Signed-off-by: James Foucar <jgfouca@sandia.gov>
@jgfouca
jgfouca force-pushed the jgfouca/kk_expect_macro_rework branch from 3f53afa to 43a5e01 Compare August 19, 2026 20:04
@jgfouca

jgfouca commented Aug 19, 2026

Copy link
Copy Markdown
Contributor Author

@ndellingwood , done.

Signed-off-by: James Foucar <jgfouca@sandia.gov>

@ndellingwood ndellingwood left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

Thanks @jgfouca !

@yasahi-hpc yasahi-hpc left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

It is quite nice to refactor test utils.
Since it will print too many error messages if it fails, I think we will eventually need a matcher approach for View to View element-wise comparison like this

Comment thread test_common/KokkosKernels_TestUtils.hpp Outdated
Comment thread test_common/KokkosKernels_TestUtils.hpp Outdated
Comment thread test_common/KokkosKernels_TestUtils.hpp Outdated
Comment thread test_common/KokkosKernels_TestUtils.hpp Outdated
Comment thread test_common/KokkosKernels_TestUtils.hpp Outdated
Comment thread test_common/KokkosKernels_TestUtils.hpp Outdated
Comment thread test_common/KokkosKernels_TestUtils.hpp Outdated
Comment thread test_common/KokkosKernels_TestUtils.hpp Outdated
Comment thread test_common/KokkosKernels_TestUtils.hpp Outdated
Comment thread test_common/KokkosKernels_TestUtils.hpp
Signed-off-by: James Foucar <jgfouca@sandia.gov>
Signed-off-by: James Foucar <jgfouca@sandia.gov>
Signed-off-by: James Foucar <jgfouca@sandia.gov>
Signed-off-by: James Foucar <jgfouca@sandia.gov>
Signed-off-by: James Foucar <jgfouca@sandia.gov>
@jgfouca
jgfouca requested a review from yasahi-hpc August 20, 2026 17:03
@jgfouca

jgfouca commented Aug 20, 2026

Copy link
Copy Markdown
Contributor Author

Thanks, @yasahi-hpc. Those were good suggestions. I think my recent pushes addressed all your comments.

Signed-off-by: James Foucar <jgfouca@sandia.gov>

@yasahi-hpc yasahi-hpc left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

Thanks for the quick response @jgfouca
Mostly looks good to me.
Not strict blockers except for the fix in the assertion message.
Others are replacements of SFINAE with requires.

Comment thread test_common/KokkosKernels_TestUtils.hpp Outdated
Comment thread test_common/KokkosKernels_TestUtils.hpp Outdated
Comment thread test_common/KokkosKernels_TestUtils.hpp Outdated
Comment thread test_common/KokkosKernels_TestUtils.hpp Outdated
Comment thread test_common/KokkosKernels_TestUtils.hpp Outdated
Comment thread test_common/KokkosKernels_TestUtils.hpp Outdated
Comment thread test_common/KokkosKernels_TestUtils.hpp Outdated
Comment thread test_common/KokkosKernels_TestUtils.hpp Outdated
Use requires instead of enable_if and improve assert messages.

Signed-off-by: James Foucar <jgfouca@sandia.gov>
@jgfouca
jgfouca force-pushed the jgfouca/kk_expect_macro_rework branch from 6aec5b9 to 0b5b104 Compare August 21, 2026 19:06
Signed-off-by: James Foucar <jgfouca@sandia.gov>
@jgfouca
jgfouca requested a review from yasahi-hpc August 21, 2026 19:08
@jgfouca

jgfouca commented Aug 21, 2026

Copy link
Copy Markdown
Contributor Author

@yasahi-hpc , done

@yasahi-hpc yasahi-hpc left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

Thanks @jgfouca
LGTM

@jgfouca

jgfouca commented Aug 24, 2026

Copy link
Copy Markdown
Contributor Author

@brian-kelley , @lucbv , @ndellingwood , I think this is ready to merge. It's on the higher priority side since it fixes a build error.

@ndellingwood
ndellingwood merged commit de93c98 into kokkos:develop Aug 24, 2026
28 of 30 checks passed
@jgfouca
jgfouca deleted the jgfouca/kk_expect_macro_rework branch August 25, 2026 17:36
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