Skip to content

Port thrust complex.cu tests to catch2_test_complex.cu - #6625

Merged
bernhardmgruber merged 8 commits into
NVIDIA:mainfrom
dunga1k58bh:port-thrust-complex-tests-to-catch2
Nov 17, 2025
Merged

bernhardmgruber merged 8 commits into
NVIDIA:mainfrom
dunga1k58bh:port-thrust-complex-tests-to-catch2

Conversation

@dunga1k58bh

@dunga1k58bh dunga1k58bh commented Nov 13, 2025 •

Copy link
Copy Markdown
Contributor

Description

closes #6589

  • Port all 15 test structs from complex.cu to catch2_test_complex.cu
  • Fix mistake in ComplexMemberOperators: change b_thrust vs b_thrust
    comparison to b_thrust vs b_std (line 385 in original file)

Checklist

  • New or existing tests cover these changes.
  • The documentation is up to date with these changes.

- Port all 15 test structs from complex.cu to catch2_test_complex2.cu
- Fix bug in ComplexMemberOperators: change b_thrust vs b_thrust
  comparison to b_thrust vs b_std (line 385 in original file)
- Initialize variable in ComplexStreamOperators to avoid -Wuninitialized
@dunga1k58bh
dunga1k58bh requested a review from a team as a code owner November 13, 2025 20:57
@dunga1k58bh
dunga1k58bh requested a review from miscco November 13, 2025 20:57
@github-project-automation github-project-automation Bot moved this to Todo in CCCL Nov 13, 2025
@copy-pr-bot

copy-pr-bot Bot commented Nov 13, 2025

Copy link
Copy Markdown
Contributor

This pull request requires additional validation before any workflows can run on NVIDIA's runners.

Pull request vetters can view their responsibilities here.

Contributors can view more details about this message here.

@cccl-authenticator-app cccl-authenticator-app Bot moved this from Todo to In Review in CCCL Nov 13, 2025
@bernhardmgruber

Copy link
Copy Markdown
Contributor

/ok to test 90b6333

@bernhardmgruber

Copy link
Copy Markdown
Contributor

@dunga1k58bh thank you for taking a stab at this! This is super helpful!

@github-actions

This comment has been minimized.

@dunga1k58bh

Copy link
Copy Markdown
Contributor Author

@bernhardmgruber A pull request failed, but I think it's due to an environment configuration error. What should I do now?

Command ''sccache' '--start-server'' failed with status 2. Retrying in 30 seconds...
Attempt 5 of 5: Running command ''sccache' '--start-server''
sccache: Starting sccache v0.12.0-rapids.10...
sccache: error: Server startup failed: cache storage failed to read: PermissionDenied (permanent) at read => S3Error { code: "SignatureDoesNotMatch", message: "The request signature we calculated does not match the signature you provided. Check your key and signing method.", resource: "", request_id: "PYVQVY1EB7K9VKAF" }

@github-project-automation github-project-automation Bot moved this from In Review to Done in CCCL Nov 14, 2025
@dunga1k58bh dunga1k58bh reopened this Nov 14, 2025
@github-project-automation github-project-automation Bot moved this from Done to Needs Triage in CCCL Nov 14, 2025
@dunga1k58bh
dunga1k58bh marked this pull request as draft November 14, 2025 15:16
@cccl-authenticator-app cccl-authenticator-app Bot moved this from Needs Triage to In Progress in CCCL Nov 14, 2025
@dunga1k58bh
dunga1k58bh marked this pull request as ready for review November 14, 2025 15:18
@cccl-authenticator-app cccl-authenticator-app Bot moved this from In Progress to In Review in CCCL Nov 14, 2025
@bernhardmgruber

Copy link
Copy Markdown
Contributor

/ok to test 3747cf2

@bernhardmgruber

Copy link
Copy Markdown
Contributor

@bernhardmgruber A pull request failed, but I think it's due to an environment configuration error. What should I do now?

We sometimes have CI hickups that require us to manually rerun the CI. Sorry about that! Just wait or ping a maintainer if this happens!

@github-actions

This comment has been minimized.

@dunga1k58bh

Copy link
Copy Markdown
Contributor Author

@bernhardmgruber Failed due to out of memory

2025-11-16T00:38:31.6520669Z 1 catastrophic error detected in the compilation of "C:/cccl/thrust/testing/catch2_test_transform.cu".
2025-11-16T00:38:31.6521194Z Compilation terminated.
2025-11-16T00:38:31.6526890Z Catastrophic error: out of memory

@bernhardmgruber

Copy link
Copy Markdown
Contributor

I see an OOM error at compile-time:

  C:\cccl\libcudacxx\include\cuda/std/__fwd/subrange.h(47): catastrophic error: out of memory
              enable_if_t<(_Kind == subrange_kind::sized || !sized_sentinel_for<_Sent, _Iter>), int> = 0>
                           ^
            detected during:
              instantiation of

so I guess the compiler hit a limit on the runner.

Comment thread thrust/testing/catch2_test_complex.cu Outdated

std::stringstream out;
out << a;
thrust::complex<T> b(T(0), T(0));

@bernhardmgruber bernhardmgruber Nov 16, 2025 •

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.

Important: the previous code default constructed b here:

thrust::complex<T> b;

please retain this.

Was there a particular reason, this needed to be changed?

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

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

When I use the default constructor, I get a warning due to -Werror=maybe-uninitialized, because some values may not be initialized. Anyway, I changed it to use default initialization instead.

/home/coder/cccl/thrust/testing/catch2_test_complex.cu: In function ‘void CATCH2_INTERNAL_TEMPLATE_TEST_36() [with TestType = float]’:
/home/coder/cccl/thrust/testing/catch2_test_complex.cu:655:22: note: ‘b.thrust::complex<float>::data.thrust::complex<float>::storage::x’ was declared here
  655 |   thrust::complex<T> b;
      |                      ^
In constructor ‘Catch::Approx::Approx(const T&) [with T = float; <template-parameter-1-2> = void]’,
    inlined from ‘cuda::std::__4::enable_if_t<((bool)(is_complex<T1> && is_complex<T2>))> {anonymous}::require_almost_equal(const T1&, const T2&) [with T1 = thrust::complex<float>; T2 = thrust::complex<float>]’ at /home/coder/cccl/thrust/testing/catch2_test_complex.cu:62:3,
    inlined from ‘void CATCH2_INTERNAL_TEMPLATE_TEST_36() [with TestType = float]’ at /home/coder/cccl/thrust/testing/catch2_test_complex.cu:657:23:
/home/coder/cccl/build/cuda13.0-gcc14/thrust-cpp20/_deps/catch2-src/src/catch2/catch_approx.hpp:42:77: error: ‘b.thrust::complex<float>::data.thrust::complex<float>::storage::y’ may be used uninitialized [-Werror=maybe-uninitialized]
   42 |         explicit Approx( T const& value ): Approx(static_cast<double>(value))
      |                                                                             ^
/home/coder/cccl/thrust/testing/catch2_test_complex.cu: In function ‘void CATCH2_INTERNAL_TEMPLATE_TEST_36() [with TestType = float]’:
/home/coder/cccl/thrust/testing/catch2_test_complex.cu:655:22: note: ‘b.thrust::complex<float>::data.thrust::complex<float>::storage::y’ was declared here
  655 |   thrust::complex<T> b;
      |                      ^

Comment thread thrust/testing/catch2_test_complex.cu Resolved
Comment on lines +67 to +78
template <typename T1, typename T2>
::cuda::std::enable_if_t<is_complex<T1>::value && is_complex<T2>::value> REQUIRE_ALMOST_EQUAL(const T1& a, const T2& b)
{
CHECK(a.real() == Catch::Approx(b.real()).margin(DEFAULT_ABSOLUTE_TOL).epsilon(DEFAULT_RELATIVE_TOL));
CHECK(a.imag() == Catch::Approx(b.imag()).margin(DEFAULT_ABSOLUTE_TOL).epsilon(DEFAULT_RELATIVE_TOL));
}

template <typename T1, typename T2>
::cuda::std::enable_if_t<!is_complex<T1>::value && !is_complex<T2>::value> REQUIRE_ALMOST_EQUAL(const T1& a, const T2& b)
{
CHECK(a == Catch::Approx(b).margin(DEFAULT_ABSOLUTE_TOL).epsilon(DEFAULT_RELATIVE_TOL));
}

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.

Important: let's use normal function name spelling, so we don't clash if we introduce a macro REQUIRE_ALMOST_EQUAL (which I may plan to do).

Suggested change
template <typename T1, typename T2>
::cuda::std::enable_if_t<is_complex<T1>::value && is_complex<T2>::value> REQUIRE_ALMOST_EQUAL(const T1& a, const T2& b)
{
CHECK(a.real() == Catch::Approx(b.real()).margin(DEFAULT_ABSOLUTE_TOL).epsilon(DEFAULT_RELATIVE_TOL));
CHECK(a.imag() == Catch::Approx(b.imag()).margin(DEFAULT_ABSOLUTE_TOL).epsilon(DEFAULT_RELATIVE_TOL));
}
template <typename T1, typename T2>
::cuda::std::enable_if_t<!is_complex<T1>::value && !is_complex<T2>::value> REQUIRE_ALMOST_EQUAL(const T1& a, const T2& b)
{
CHECK(a == Catch::Approx(b).margin(DEFAULT_ABSOLUTE_TOL).epsilon(DEFAULT_RELATIVE_TOL));
}
template <typename T1, typename T2>
::cuda::std::enable_if_t<is_complex<T1>::value && is_complex<T2>::value> require_almost_equal(const T1& a, const T2& b)
{
CHECK(a.real() == Catch::Approx(b.real()).margin(DEFAULT_ABSOLUTE_TOL).epsilon(DEFAULT_RELATIVE_TOL));
CHECK(a.imag() == Catch::Approx(b.imag()).margin(DEFAULT_ABSOLUTE_TOL).epsilon(DEFAULT_RELATIVE_TOL));
}
template <typename T1, typename T2>
::cuda::std::enable_if_t<!is_complex<T1>::value && !is_complex<T2>::value> require_almost_equal(const T1& a, const T2& b)
{
CHECK(a == Catch::Approx(b).margin(DEFAULT_ABSOLUTE_TOL).epsilon(DEFAULT_RELATIVE_TOL));
}

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

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

I have updated the code based on your suggestion.

@github-actions

This comment has been minimized.

- Replace custom `is_complex` struct with variable template for modern
  C++
- Use normal function name spelling `require_almost_equal`
- Initialize variable `b` in stream operator test to avoid uninitialized
  warning

This ensures type traits work in both host and device code and follows
modern C++ best practices with variable templates.
@bernhardmgruber

Copy link
Copy Markdown
Contributor

/ok to test 1bfcc1e

@github-actions

Copy link
Copy Markdown
Contributor

🥳 CI Workflow Results

🟩 Finished in 2h 16m: Pass: 100%/70 | Total: 22h 43m | Max: 2h 13m | Hits: 99%/115481

See results here.

@bernhardmgruber bernhardmgruber 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.

Great work, thx!

@bernhardmgruber
bernhardmgruber merged commit 2f82c4d into NVIDIA:main Nov 17, 2025
86 checks passed
@github-project-automation github-project-automation Bot moved this from In Review to Done in CCCL Nov 17, 2025
Naraenda pushed a commit to ROCm/rocm-libraries that referenced this pull request Oct 26, 2026
… to catch2_test_complex.cu (NVIDIA/cccl#6625)

Upstream: NVIDIA/cccl@2f82c4d

HIP counterpart (system/hip): none. N/A: upstream moves testing/complex.cu to Catch2 testing/catch2_test_complex.cu; rocThrust has no Catch2 harness, so the catch2 file is not added and legacy testing/complex.cu is kept (same coverage). test/ counterpart: test/test_complex.cpp already covers these cases; unchanged. Not compiled, tests not run (per human)

Co-Authored-By: Claude <noreply@anthropic.com>
Naraenda pushed a commit to ROCm/rocm-libraries that referenced this pull request Oct 29, 2026
… to catch2_test_complex.cu (NVIDIA/cccl#6625)

Upstream: NVIDIA/cccl@2f82c4d

HIP counterpart (system/hip): none. N/A: upstream moves testing/complex.cu to Catch2 testing/catch2_test_complex.cu; rocThrust has no Catch2 harness, so the catch2 file is not added and legacy testing/complex.cu is kept (same coverage). test/ counterpart: test/test_complex.cpp already covers these cases; unchanged. Not compiled, tests not run (per human)

Co-Authored-By: Claude <noreply@anthropic.com>
Naraenda pushed a commit to ROCm/rocm-libraries that referenced this pull request Oct 29, 2026
… to catch2_test_complex.cu (NVIDIA/cccl#6625)

Upstream: NVIDIA/cccl@2f82c4d

HIP counterpart (system/hip): none. N/A: upstream moves testing/complex.cu to Catch2 testing/catch2_test_complex.cu; rocThrust has no Catch2 harness, so the catch2 file is not added and legacy testing/complex.cu is kept (same coverage). test/ counterpart: test/test_complex.cpp already covers these cases; unchanged. Not compiled, tests not run (per human)

Co-Authored-By: Claude <noreply@anthropic.com>
Naraenda pushed a commit to ROCm/rocm-libraries that referenced this pull request Oct 30, 2026
… to catch2_test_complex.cu (NVIDIA/cccl#6625)

Upstream: NVIDIA/cccl@2f82c4d

HIP counterpart (system/hip): none. N/A: upstream moves testing/complex.cu to Catch2 testing/catch2_test_complex.cu; rocThrust has no Catch2 harness, so the catch2 file is not added and legacy testing/complex.cu is kept (same coverage). test/ counterpart: test/test_complex.cpp already covers these cases; unchanged. Not compiled, tests not run (per human)

Co-Authored-By: Claude <noreply@anthropic.com>
Beanavil pushed a commit to ROCm/rocm-libraries that referenced this pull request Oct 30, 2026
… to catch2_test_complex.cu (NVIDIA/cccl#6625)

Upstream: NVIDIA/cccl@2f82c4d

HIP counterpart (system/hip): none. N/A: upstream moves testing/complex.cu to Catch2 testing/catch2_test_complex.cu; rocThrust has no Catch2 harness, so the catch2 file is not added and legacy testing/complex.cu is kept (same coverage). test/ counterpart: test/test_complex.cpp already covers these cases; unchanged. Not compiled, tests not run (per human)

Co-Authored-By: Claude <noreply@anthropic.com>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

Archived in project

Development

Successfully merging this pull request may close these issues.

Convert Thrust test complex.cu to Catch2

2 participants