Skip to content

GPUCommonMath: double functions, 64-bit bit counts, atomic load/store… - #15986

Open
f3sch wants to merge 1 commit into
AliceO2Group:devfrom
f3sch:gpu/math
Open

f3sch wants to merge 1 commit into
AliceO2Group:devfrom
f3sch:gpu/math

Conversation

@f3sch

@f3sch f3sch commented Oct 19, 2026

Copy link
Copy Markdown
Collaborator

…, host-device calls

Named double functions for GPUCommonMath::Sqrt,Sin,Cos,Tan,ASin,ACos,ATan,ATan2,Log,Copysign.
Clz64, Ctz64, Popcount64: 64-bit counterparts of Clz, Ctz and Popcount on the same builtins and CUDA/HIP intrinsics.
And AtomicLoad/Store.

@davidrohr davidrohr left a comment

Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

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

Why did you change all the GPUd() to GPUhd(). GPUhd() means it is executed by the host code compiled with CUDA, so that should be only the code that drives the devices?
Does that code really need the GPUCommonMath functions? IMHO in that case one can use std:: directly.

Named double functions for GPUCommonMath::Sqrt,Sin,Cos,Tan,ASin,ACos,ATan,ATan2,Log,Copysign.

Clz64, Ctz64, Popcount64: 64-bit counterparts of Clz, Ctz and Popcount on
the same builtins and CUDA/HIP intrinsics. Named rather than uint64_t
overloads, which would change existing calls with 64-bit arguments and
make calls with int arguments ambiguous.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Signed-off-by: Felix Schlepper <felix.schlepper@cern.ch>
@f3sch

f3sch commented Oct 20, 2026

Copy link
Copy Markdown
Collaborator Author

Hi @davidrohr, you right of course. I had declared functors with GPUhd() in code linked to O2 using CAMath. My compilation then failed without declaring the functions also GPUhd(), so I had 'bug' in my code... sorry. I think I never understood the difference between GPUhd() and GPUd().

Also I had the question about the deterministic mode, currently it forces some computations to be made in double precision and then downcasts to float, but this trick does not work if the computation is supposed to be in double see for example GPUCommonMath::ASin(float...), i.e. how would GPUCommonMath::ASin(double...) look like for deterministic mode?

This branch has not been deployed

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

Labels

None yet

Development

Successfully merging this pull request may close these issues.

2 participants