Skip to content

Conversation

@CodersAcademy006
Copy link

This PR adds kernel-based tests for device-side compile-time constants in Numba-CUDA:

  • Integer, float, and boolean literals

  • Constant expressions (e.g., 2 + 3, 4 * 5)

  • Mixed constant arithmetic

  • Constant indexing

Tests are skipped under cudasim due to divergent semantics, and NumPy is used as the reference oracle. The scope is intentionally limited to safe, well-defined CUDA constant lowering (no globals, closures, or runtime values).

This continues the systematic porting of CPU-side tests to CUDA, directly contributing to issue #515.

…ide compile-time constants: integer, float, boolean literals, constant expressions, and constant indexing. Skips under cudasim. NumPy is used as the reference. Scope is intentionally limited to safe, well-defined CUDA constant lowering.
@copy-pr-bot
Copy link

copy-pr-bot bot commented Jan 20, 2026

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.

@greptile-apps
Copy link
Contributor

greptile-apps bot commented Jan 20, 2026

Greptile Summary

Added comprehensive test coverage for CUDA device-side compile-time constants, including integer/float/boolean literals, constant expressions, mixed arithmetic, and constant indexing. Tests are properly skipped under cudasim where semantics differ, use NumPy as reference oracle, and follow repository conventions with correct SPDX header and test structure.

  • Integer constant test (42)
  • Float constant test (3.5)
  • Boolean constant test (True)
  • Arithmetic expression test (2 + 3 * 4 = 14)
  • Mixed type arithmetic test (1.5 + 2 = 3.5)
  • Constant indexing test (inp[2])

The implementation follows established patterns from other CUDA tests in the repository, properly uses CUDATestCase, includes appropriate skip_on_cudasim decorator, and provides a reusable _launch_1d helper method. This directly contributes to issue #515 by porting CPU-side auto-constant tests to CUDA.

Confidence Score: 5/5

  • This PR is safe to merge with no identified issues
  • The test file is well-structured, follows all repository conventions including proper SPDX header, uses appropriate testing patterns (CUDATestCase, skip_on_cudasim), and provides comprehensive coverage of compile-time constant scenarios. The arithmetic is correct, tests are isolated and independent, and the implementation aligns with the stated goal of porting CPU tests to CUDA.
  • No files require special attention

Important Files Changed

Filename Overview
numba_cuda/numba/cuda/tests/test_auto_constants.py New test suite for compile-time constants with proper structure, correct SPDX header, and comprehensive coverage of integer, float, boolean, arithmetic, and indexing scenarios

Copy link
Contributor

@greptile-apps greptile-apps bot left a comment

Choose a reason for hiding this comment

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

1 file reviewed, 1 comment

Edit Code Review Agent Settings | Greptile

Co-authored-by: greptile-apps[bot] <165735046+greptile-apps[bot]@users.noreply.github.com>
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.

1 participant