Skip to content

Improve <cuda/std/ctime> implementation #4682

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Open
wants to merge 1 commit into
base: main
Choose a base branch
from

Conversation

davebayer
Copy link
Contributor

This PR simplifies the <cuda/std/ctime> implementation by:

  • using functions from std:: namespace that don't have problems with being renamed by a macro and
  • introduction of a CCCL_CLOCKS_PER_SEC macro as an target independent alternative to CLOCKS_PER_SEC

@davebayer davebayer requested review from a team as code owners May 13, 2025 05:35
@davebayer davebayer requested a review from elstehle May 13, 2025 05:35
@github-project-automation github-project-automation bot moved this to Todo in CCCL May 13, 2025
Copy link

copy-pr-bot bot commented May 13, 2025

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.

@davebayer davebayer requested a review from ericniebler May 13, 2025 05:35
@cccl-authenticator-app cccl-authenticator-app bot moved this from Todo to In Review in CCCL May 13, 2025
Comment on lines +51 to +56
[[nodiscard]] _CCCL_FORCEINLINE _CCCL_VISIBILITY_HIDDEN _CCCL_HOST_DEVICE clock_t __cccl_clocks_per_sec_impl() noexcept
{
NV_IF_ELSE_TARGET(NV_IS_HOST, (return CLOCKS_PER_SEC;), (return clock_t(1'000'000'000);))
}

#define CCCL_CLOCKS_PER_SEC _CUDA_VSTD::__cccl_clocks_per_sec_impl()
Copy link
Contributor Author

Choose a reason for hiding this comment

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

Alternatively, we could introduce cuda::clocks_per_sec() function, that would be probably a more suitable solution..

Copy link
Contributor

Choose a reason for hiding this comment

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

I believe we want something that is valid both on host device if we ever need it

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Yeah, that's what I meant, making this function public in cuda:: namespace, the implementation could stay the same

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.

2 participants