Skip to content

Provide std::common_type specializations for half precision#9251

Open
aprokop wants to merge 1 commit into
kokkos:developfrom
aprokop:half_common_type
Open

Provide std::common_type specializations for half precision#9251
aprokop wants to merge 1 commit into
kokkos:developfrom
aprokop:half_common_type

Conversation

@aprokop

@aprokop aprokop commented Jun 5, 2026

Copy link
Copy Markdown
Contributor

Provide std::common_type specializations for half precision types.

Related issues / PRs

Fix #9249

Changelog Entry

Unsure

@aprokop

aprokop commented Jun 5, 2026

Copy link
Copy Markdown
Contributor Author

Not sure how robust this is. Also, this currently does not address the complex.

@masterleinad masterleinad added the SNL-CI-APPROVAL Required for non-SNL contributions to run on SNL CI label Jun 5, 2026

@tretre91 tretre91 left a comment

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

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

LGTM

Comment thread core/unit_test/TestHalfCommonType.cpp
@masterleinad

Copy link
Copy Markdown
Contributor

Can you fix the DCO and rebase?

Signed-off-by: Andrey Prokopenko <prokopenkoav@ornl.gov>
@aprokop aprokop force-pushed the half_common_type branch from f172cb6 to f35d849 Compare June 9, 2026 14:20
@aprokop

aprokop commented Jun 9, 2026

Copy link
Copy Markdown
Contributor Author

Can you fix the DCO and rebase?

Done.

@ndellingwood ndellingwood added SNL-CI-APPROVAL Required for non-SNL contributions to run on SNL CI and removed SNL-CI-APPROVAL Required for non-SNL contributions to run on SNL CI labels Jun 9, 2026

@masterleinad masterleinad left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

I would just use whatever type you get with float if the other type isn't half_t, bhalf_t or float. If that returns float, return the original type.
I'm still not sure if common_type<Kokkos::Experimental::half_t, Kokkos::Experimental::bhalf_t> should be defined.

@JBludau

JBludau commented Jun 9, 2026

Copy link
Copy Markdown
Contributor

I'm still not sure if common_type<Kokkos::Experimental::half_t, Kokkos::Experimental::bhalf_t> should be defined.

I think they should, if I read https://en.cppreference.com/cpp/types/common_type it just talks about convertability.

@masterleinad masterleinad left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

If you also check for int and long double, I'm fine with this.

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

Labels

SNL-CI-APPROVAL Required for non-SNL contributions to run on SNL CI

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Provide std::common_type for half types

5 participants