Skip to content

GPU: provide the layout type traits on all device backends, numeric_limits for Metal - #16181

Merged
ktf merged 1 commit into
AliceO2Group:devfrom
ktf:pr16181
Nov 24, 2026
Merged

ktf merged 1 commit into
AliceO2Group:devfrom
ktf:pr16181

Conversation

@ktf

@ktf ktf commented Nov 23, 2026 •

Copy link
Copy Markdown
Member

OpenCL C++ and MSL have no <type_traits>, so GPUCommonTypeTraits now provides
is_standard_layout_v and is_trivially_copyable_v for both, spelled like its
other program-scope variables.

numeric_limits is not a type trait, so it gets its own GPUCommonNumericLimits.h,
with the same backend selection: on the host, CUDA and HIP,
metal::numeric_limits as std::numeric_limits for Metal, nothing yet for OpenCL.

@ktf
ktf requested a review from davidrohr as a code owner November 23, 2026 14:48
@ktf

ktf commented Nov 23, 2026

Copy link
Copy Markdown
Member Author

@davidrohr this will be needed by the ITS Metal port.

Comment thread GPU/Common/GPUCommonTypeTraits.h Outdated
#endif
namespace std
{
#ifdef __METAL__

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 only for metal? These are just normal type traits? So we should provide them for all GPU backends, which do not include <type_traits>? Or what am I missing?

@ktf

ktf commented Nov 24, 2026

Copy link
Copy Markdown
Member Author

using metal::numeric_limits; is only for metal for sure.

For std::is_trivially_copyable_v and std::is_standard_layout_v they come form the standard library for CUDA / HIP, no?

@davidrohr

Copy link
Copy Markdown
Collaborator

using metal::numeric_limits; is only for metal for sure.

For std::is_trivially_copyable_v and std::is_standard_layout_v they come form the standard library for CUDA / HIP, no?

CUDA and HIP include <type_traits>, so all traits come from the standard library for them.

#if !defined(GPUCA_GPUCODE_DEVICE) || defined(__CUDACC__) || defined(__HIPCC__) 

This header is basically disabled for them and just forwards to type_traits.

@ktf ktf changed the title GPU Metal: provide numeric_limits and the layout traits in GPUCommonTypeTraits GPU: provide the layout traits for OpenCL and Metal, numeric_limits for Metal Nov 24, 2026
@ktf

ktf commented Nov 24, 2026

Copy link
Copy Markdown
Member Author

Ok, I kept only using metal::numeric_limits; in the ifdef.

…imits for Metal

OpenCL C++ and MSL have no <type_traits>, so GPUCommonTypeTraits now provides
is_standard_layout_v and is_trivially_copyable_v for both, spelled like its
other program-scope variables.

numeric_limits is not a type trait, so it gets its own GPUCommonNumericLimits.h,
with the same backend selection: <limits> on the host, CUDA and HIP,
metal::numeric_limits as std::numeric_limits for Metal, nothing yet for OpenCL.
@ktf ktf changed the title GPU: provide the layout traits for OpenCL and Metal, numeric_limits for Metal GPU: provide the layout type traits on all device backends, numeric_limits for Metal Nov 24, 2026
@ktf

ktf commented Nov 24, 2026

Copy link
Copy Markdown
Member Author

@davidrohr Separate file, as discussed offline.

@ktf
ktf merged commit e45b5b8 into AliceO2Group:dev Nov 24, 2026
18 checks passed
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