Skip to content

Readability improvement by using device_clock alias - #419

Merged
oleksandr-pavlyk merged 1 commit into
NVIDIA:mainfrom
oleksandr-pavlyk:high-resolution-clock-in-device-code-is-fine
Jul 20, 2026
Merged

Readability improvement by using device_clock alias#419
oleksandr-pavlyk merged 1 commit into
NVIDIA:mainfrom
oleksandr-pavlyk:high-resolution-clock-in-device-code-is-fine

Conversation

@oleksandr-pavlyk

Copy link
Copy Markdown
Collaborator

Use alias device_clock = cuda::std::chrono::high_resolution_clock; for readability improvement, and a chance for comment to state that using it in device code for timing purposes is correct and intentional.

I looked at this as a follow-up to #371, which replaced std::chrono::high_resolution_clock with std::chrono::steady_clock.

Per https://nvidia.github.io/cccl/unstable/libcudacxx/standard_api/time_library.html type cuda::std::chrono::steady_clock is not provided, and while cuda::std::chrono::high_resolution_clock is not heterogeneously steady, but is steady within device code and suitable for device-side performance measurement.

Use `device_clock = cuda::std::chrono::high_resolution_clock;` for readability
improvement, and a chance for comment to state that using it in device
code for timing purposes is correct and intentional.

I looked at this as a follow-up to NVIDIA#371, which replaced
std::chrono::high_resolution_clock with std::chrono::steady_clock.

Per https://nvidia.github.io/cccl/unstable/libcudacxx/standard_api/time_library.html
type cuda::std::chrono::steady_clock is not provided, and while
high_resolution_clock is not heterogeneously steady, but is steady within device
code and suitable for device-side performance measurement.
@oleksandr-pavlyk oleksandr-pavlyk self-assigned this Jul 20, 2026
@oleksandr-pavlyk oleksandr-pavlyk added the type: cleanup Modernization, dead code removal, style fixes, etc. label Jul 20, 2026
@github-project-automation github-project-automation Bot moved this to Todo in CCCL Jul 20, 2026
@oleksandr-pavlyk oleksandr-pavlyk moved this from Todo to In Review in CCCL Jul 20, 2026
@oleksandr-pavlyk

Copy link
Copy Markdown
Collaborator Author

@coderabbitai full review

@coderabbitai

coderabbitai Bot commented Jul 20, 2026

Copy link
Copy Markdown
✅ Action performed

Full review finished.

@coderabbitai

coderabbitai Bot commented Jul 20, 2026

Copy link
Copy Markdown

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: 1e606b31-72d3-477c-ac8c-dc5e04fa7f0d

📥 Commits

Reviewing files that changed from the base of the PR and between c48b318 and 02c8c82.

📒 Files selected for processing (2)
  • nvbench/blocking_kernel.cu
  • nvbench/test_kernels.cuh

📝 Walkthrough

Summary by CodeRabbit

  • Refactor
    • Improved the internal timing implementation used by CUDA blocking and sleep operations.
    • Preserved existing timeout behavior and loop termination logic.

Walkthrough

Device timing measurements were refactored to use device_clock aliases in the blocking stream and sleep kernels. Timeout and busy-wait conditions retain their existing behavior.

Changes

Device timing refactor

Layer / File(s) Summary
Blocking kernel timeout timing
nvbench/blocking_kernel.cu
block_stream uses a local device_clock alias for initial and iterative timestamps while retaining the existing timeout calculation and termination conditions.
Sleep kernel clock polling
nvbench/test_kernels.cuh
sleep_kernel defines nvbench::device_clock and uses it to calculate the start time, finish deadline, and polling timestamps.

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

@oleksandr-pavlyk
oleksandr-pavlyk merged commit f45c666 into NVIDIA:main Jul 20, 2026
60 checks passed
@github-project-automation github-project-automation Bot moved this from In Review to Done in CCCL Jul 20, 2026
@oleksandr-pavlyk
oleksandr-pavlyk deleted the high-resolution-clock-in-device-code-is-fine branch July 20, 2026 16:05
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

type: cleanup Modernization, dead code removal, style fixes, etc.

Projects

Archived in project

Development

Successfully merging this pull request may close these issues.

2 participants