Skip to content

[cub] Replace assert with CHECK or REQUIRE in tests#8999

Open
davebayer wants to merge 1 commit into
NVIDIA:mainfrom
davebayer:cub_replace_assert_with_catch2_macros
Open

[cub] Replace assert with CHECK or REQUIRE in tests#8999
davebayer wants to merge 1 commit into
NVIDIA:mainfrom
davebayer:cub_replace_assert_with_catch2_macros

Conversation

@davebayer
Copy link
Copy Markdown
Contributor

@davebayer davebayer commented May 15, 2026

Using assert outside of libcu++ for testing is not safe, because we compile with optimizations enabled and that meanst NDEBUG is defined, thus assert expands to noop. This PR replaces them with catch2 test macros.

@davebayer davebayer requested a review from a team as a code owner May 15, 2026 06:30
@davebayer davebayer requested a review from pauleonix May 15, 2026 06:30
@github-project-automation github-project-automation Bot moved this to Todo in CCCL May 15, 2026
@cccl-authenticator-app cccl-authenticator-app Bot moved this from Todo to In Review in CCCL May 15, 2026
@coderabbitai
Copy link
Copy Markdown

coderabbitai Bot commented May 15, 2026

Review Change Stack

No actionable comments were generated in the recent review. 🎉

ℹ️ Recent review info
⚙️ Run configuration

Configuration used: Path: .coderabbit.yaml

Review profile: CHILL

Plan: Enterprise

Run ID: e9f3b29a-be24-4564-a7ed-037df8f97b65

📥 Commits

Reviewing files that changed from the base of the PR and between f6b8406 and 329af26.

📒 Files selected for processing (9)
  • cub/cub/detail/integer_utils.cuh
  • cub/test/catch2_test_block_load_to_shared.cu
  • cub/test/catch2_test_block_radix_sort_custom.cu
  • cub/test/catch2_test_device_decoupled_look_back.cu
  • cub/test/catch2_test_device_segmented_scan.cu
  • cub/test/catch2_test_warp_scan.cu
  • cub/test/catch2_test_warp_scan_api.cu
  • cub/test/catch2_test_warp_scan_partial_helper.cuh
  • cub/test/internal/catch2_test_integer_utils.cu
💤 Files with no reviewable changes (2)
  • cub/cub/detail/integer_utils.cuh
  • cub/test/internal/catch2_test_integer_utils.cu
✅ Files skipped from review due to trivial changes (1)
  • cub/test/catch2_test_warp_scan.cu
🚧 Files skipped from review as they are similar to previous changes (3)
  • cub/test/catch2_test_warp_scan_partial_helper.cuh
  • cub/test/catch2_test_device_decoupled_look_back.cu
  • cub/test/catch2_test_block_radix_sort_custom.cu

📝 Walkthrough

Summary by CodeRabbit

  • Tests
    • Replaced C runtime asserts with Catch2 CHECK/REQUIRE across multiple test files for clearer test failures and diagnostics.
  • Chores
    • Removed internal integer/floating-point utility helpers from the codebase.

important: Walkthrough

Eight CUDA test files convert C assert() uses to Catch2 CHECK()/REQUIRE() and adjust includes. Affected tests include block load, radix sort (many variants), decoupled look-back scan, segmented scan precondition, warp-scan helpers/API, and integer utility tests.

important: Changes

Catch2 assertion framework migration

Layer / File(s) Summary
Include setup and precondition assertions
cub/test/catch2_test_block_radix_sort_custom.cu, cub/test/catch2_test_device_decoupled_look_back.cu, cub/test/catch2_test_device_segmented_scan.cu, cub/test/catch2_test_warp_scan_partial_helper.cuh, cub/test/catch2_test_warp_scan.cu
Top-of-file includes remove NDEBUG/<cassert> patterns and precondition validations (small_size > 0, result.size() alignment/size) use Catch2 REQUIRE.
Block-level kernels: alignment and radix-sort checks
cub/test/catch2_test_block_load_to_shared.cu, cub/test/catch2_test_block_radix_sort_custom.cu
Device-side shared-memory alignment check and all block radix-sort kernel key/value verifications (ascending/descending, bit-subrange, blocked-to-striped, paired key/value tests) use Catch2 CHECK/REQUIRE instead of assert.
Scan-related kernel checks
cub/test/catch2_test_device_decoupled_look_back.cu, cub/test/catch2_test_warp_scan_api.cu
Decoupled look-back tile data/aggregate validations use CHECK; warp-scan API custom functors validate operand ranges with CHECK.
Integer/floating-point utility tests
cub/test/internal/catch2_test_integer_utils.cu
Integer split/merge, special-value boundary checks (fix assignment-in-assert), and floating-point comparable-integer round-trip tests migrate from assert to Catch2 CHECK.

important: Possibly related PRs

  • NVIDIA/cccl#8928: Introduces device-capable Catch2 macro support (CHECK, REQUIRE) used by these test migrations.

important: Suggested reviewers

  • wmaxey
  • caugonnet
  • srinivasyadav18

Comment @coderabbitai help to get the list of available commands and usage tips.

Copy link
Copy Markdown

@coderabbitai coderabbitai Bot left a comment

Choose a reason for hiding this comment

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

Actionable comments posted: 2


ℹ️ Review info
⚙️ Run configuration

Configuration used: Path: .coderabbit.yaml

Review profile: CHILL

Plan: Enterprise

Run ID: 0274cd35-7d0c-401a-865f-079699d7dda5

📥 Commits

Reviewing files that changed from the base of the PR and between db93bd1 and f6b8406.

📒 Files selected for processing (8)
  • cub/test/catch2_test_block_load_to_shared.cu
  • cub/test/catch2_test_block_radix_sort_custom.cu
  • cub/test/catch2_test_device_decoupled_look_back.cu
  • cub/test/catch2_test_device_segmented_scan.cu
  • cub/test/catch2_test_warp_scan.cu
  • cub/test/catch2_test_warp_scan_api.cu
  • cub/test/catch2_test_warp_scan_partial_helper.cuh
  • cub/test/internal/catch2_test_integer_utils.cu

Comment thread cub/test/catch2_test_block_load_to_shared.cu
Comment thread cub/test/internal/catch2_test_integer_utils.cu Outdated
@davebayer davebayer force-pushed the cub_replace_assert_with_catch2_macros branch from f6b8406 to 329af26 Compare May 15, 2026 07:32
@@ -1,142 +0,0 @@
// SPDX-FileCopyrightText: Copyright (c) 2025, NVIDIA CORPORATION & AFFILIATES. All rights reserved.
// SPDX-License-Identifier: BSD-3-Clause
#include <cub/detail/integer_utils.cuh>
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've removed the source file & test. The functionality is not used anywhere in cub, plus it was never actually tested, because the assert expanded to noop instead of the test due to missing #undef NDEBUG

@github-actions
Copy link
Copy Markdown
Contributor

😬 CI Workflow Results

🟥 Finished in 1h 27m: Pass: 14%/283 | Total: 1d 12h | Max: 1h 26m | Hits: 65%/117550

See results here.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

Status: In Review

Development

Successfully merging this pull request may close these issues.

3 participants