Skip to content

[libclc] Move copysign to CLC library; fix & optimize #124598

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

Merged
merged 1 commit into from
Jan 28, 2025

Conversation

frasercrmck
Copy link
Contributor

@frasercrmck frasercrmck commented Jan 27, 2025

This commit moves the implementation of the copysign builtin to the CLC library.

It simultaneously optimizes it for vector types by avoiding scalarization. It does so by using the __builtin_elementwise_copysign clang builtins, which can handle vector types.

It also fixes a bug in the half/fp16 implementation of the builtin. This version was using an incorrect mask (0x7FFFF instead of 0x7FFF) and was thus preserving the original sign bit, rather than masking it out.

This commit moves the implementation of the copysign builtin to the CLC
library.

It simultaneously optimizes it for vector types by avoiding
scalarization. It does so by using the __builtin_elementwise_copysign
clang builtins, which can handle vector types.

It also fixes a bug in the half/fp16 implementation of the builtin. This
version was using an incorrect mask (0x7FFFF instead of 0x7FFF) and was
thus preserving the original sign bit, rather than masking it out.
@frasercrmck frasercrmck added the libclc libclc OpenCL library label Jan 27, 2025
@frasercrmck frasercrmck requested a review from arsenm January 27, 2025 17:47
@frasercrmck frasercrmck changed the title [libclc] Move copysign to CLC library; optimize & fix [libclc] Move copysign to CLC library; fix & optimize Jan 27, 2025
@frasercrmck frasercrmck merged commit cfc8ef0 into llvm:main Jan 28, 2025
10 checks passed
@frasercrmck frasercrmck deleted the libclc-clc-copysign branch January 28, 2025 09:18
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