Skip to content

[libclc] Add (fast) normalize to CLC; add half overloads #139759

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 2 commits into
base: main
Choose a base branch
from

Conversation

frasercrmck
Copy link
Contributor

For simplicity the half overloads just call into the float versions of the builtin.

Note that in the move some floating-point constants were combined. The vector2 versions of normalize used slightly different constants to the vector3 and vector4 versions of the same builtin. For float it was 0x1.0p-65 vs 0x1.0p-66 and for double 0x1.0p-513 vs 0x1.0p-514.

I wasn't sure if this was necessary so this commit replaces the vector2 versions of the constants with the vector3/vector4 ones. The OpenCL-CTS seems okay with it. If this is incorrect then it's not very difficult to split them back out again.

@frasercrmck frasercrmck requested a review from arsenm May 13, 2025 16:08
@frasercrmck frasercrmck added the libclc libclc OpenCL library label May 13, 2025
Copy link

github-actions bot commented May 13, 2025

✅ With the latest revision this PR passed the C/C++ code formatter.

For simplicity the half overloads just call into the float versions of
the builtin.

Note that in the move some floating-point constants were combined. The
vector2 versions of normalize used slightly different constants to the
vector3 and vector4 versions of the same builtin. For float it was
0x1.0p-65 vs 0x1.0p-66 and for double 0x1.0p-513 vs 0x1.0p-514.

I wasn't sure if this was necessary so this commit replaces the vector2
versions of the constants with the vector3/vector4 ones. The OpenCL-CTS
seems okay with it. If this is incorrect then it's not very difficult to
split them back out again.
@frasercrmck frasercrmck force-pushed the libclc-clc-normalize branch from 939d417 to 8f72f0f Compare May 20, 2025 10:52
@arsenm
Copy link
Contributor

arsenm commented May 20, 2025

I wasn't sure if this was necessary so this commit replaces the vector2 versions of the constants with the vector3/vector4 ones. The OpenCL-CTS seems okay with it. If this is incorrect then it's not very difficult to split them back out again.

Does it pass with -cl-denorms-are-zero and with denormal support?

@frasercrmck
Copy link
Contributor Author

I wasn't sure if this was necessary so this commit replaces the vector2 versions of the constants with the vector3/vector4 ones. The OpenCL-CTS seems okay with it. If this is incorrect then it's not very difficult to split them back out again.

Does it pass with -cl-denorms-are-zero and with denormal support?

The OpenCL-CTS doesn't actually test the geometrics builtins with that option - that's just for bruteforce.

It passes on an OpenCL implementation which advertises support for single-precision denormals, yes.

@arsenm
Copy link
Contributor

arsenm commented May 22, 2025

The OpenCL-CTS doesn't actually test the geometrics builtins with that option - that's just for bruteforce.

Sounds like a bug

It passes on an OpenCL implementation which advertises support for single-precision denormals, yes.

Ideally would check it works with denormal flushing forced on, that's the main risk I can see. If I were to stare at this long enough I could probably guess at where the constant was derived from

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
libclc libclc OpenCL library
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants