Skip to content

[libclc] Move min/max/clamp into the CLC builtins library (#114386) #15948

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 3 commits into from
Nov 5, 2024

Conversation

frasercrmck
Copy link
Contributor

[libclc] Move min/max/clamp into the CLC builtins library (#114386)

These functions are "shared" between integer and floating-point types,
hence the directory name. They are used in several CLC internal
functions such as __clc_ldexp.

Note that clspv and spirv targets don't want to define these functions,
so pre-processor macros replace calls to __clc_min with regular min, for
example. This means they can use as much of the generic CLC source files
as possible, but where CLC functions would usually call out to an
external __clc_min symbol, they call out to an external min symbol. Then
they opt out of defining __clc_min itself in their CLC builtins library.

Preprocessor definitions for these targets have also been changed
somewhat: what used to be CLC_SPIRV (the 32-bit target) is now
CLC_SPIRV32, and CLC_SPIRV now represents either CLC_SPIRV32 or
CLC_SPIRV64. Same goes for CLC_CLSPV.

There are no differences (measured with llvm-diff) in any of the final
builtins libraries for nvptx, amdgpu, or clspv. Neither are there
differences in the SPIR-V targets' LLVM IR before it's actually lowered
to SPIR-V.


This is a cherry-pick of 3 upstream commits: fba9f05, 86974e1, and d12a8da. It starts to move our downstream libspirv implementations towards reusing upstream's shared CLC implementations. See the removal of libspirv's __clc_(clamp|min|max).

These functions are "shared" between integer and floating-point types,
hence the directory name. They are used in several CLC internal
functions such as __clc_ldexp.

Note that clspv and spirv targets don't want to define these functions,
so pre-processor macros replace calls to __clc_min with regular min, for
example. This means they can use as much of the generic CLC source files
as possible, but where CLC functions would usually call out to an
external __clc_min symbol, they call out to an external min symbol. Then
they opt out of defining __clc_min itself in their CLC builtins library.

Preprocessor definitions for these targets have also been changed
somewhat: what used to be CLC_SPIRV (the 32-bit target) is now
CLC_SPIRV32, and CLC_SPIRV now represents either CLC_SPIRV32 or
CLC_SPIRV64. Same goes for CLC_CLSPV.

There are no differences (measured with llvm-diff) in any of the final
builtins libraries for nvptx, amdgpu, or clspv. Neither are there
differences in the SPIR-V targets' LLVM IR before it's actually lowered
to SPIR-V.
@frasercrmck frasercrmck requested a review from a team as a code owner October 31, 2024 17:48
@frasercrmck
Copy link
Contributor Author

CC @jsji @maarquitos14. Since this is effectively a mini-pulldown, can we merge it as such, by retaining the original series of commits?

@frasercrmck frasercrmck changed the title Cherry pick libclc 3 [libclc] Move min/max/clamp into the CLC builtins library (#114386) Oct 31, 2024
@jsji
Copy link
Contributor

jsji commented Oct 31, 2024

CC @jsji @maarquitos14. Since this is effectively a mini-pulldown, can we merge it as such, by retaining the original series of commits?

OK for me.

jsji added a commit that referenced this pull request Nov 3, 2024
…15948

[libclc] Move min/max/clamp into the CLC builtins library (#114386)

These functions are "shared" between integer and floating-point types,
hence the directory name. They are used in several CLC internal
functions such as __clc_ldexp.

Note that clspv and spirv targets don't want to define these functions,
so pre-processor macros replace calls to __clc_min with regular min, for
example. This means they can use as much of the generic CLC source files
as possible, but where CLC functions would usually call out to an
external __clc_min symbol, they call out to an external min symbol. Then
they opt out of defining __clc_min itself in their CLC builtins library.

Preprocessor definitions for these targets have also been changed
somewhat: what used to be CLC_SPIRV (the 32-bit target) is now
CLC_SPIRV32, and CLC_SPIRV now represents either CLC_SPIRV32 or
CLC_SPIRV64. Same goes for CLC_CLSPV.

There are no differences (measured with llvm-diff) in any of the final
builtins libraries for nvptx, amdgpu, or clspv. Neither are there
differences in the SPIR-V targets' LLVM IR before it's actually lowered
to SPIR-V.

This is a cherry-pick of 3 upstream commits: fba9f05, 86974e1, and d12a8da. It starts to move our downstream libspirv implementations towards reusing upstream's shared CLC implementations. See the removal of libspirv's __clc_(clamp|min|max).

 Conflicts:
	libclc/generic/lib/math/clc_ldexp.cl
	libclc/generic/libspirv/math/clc_hypot.cl
@frasercrmck
Copy link
Contributor Author

CC @jsji @maarquitos14. Since this is effectively a mini-pulldown, can we merge it as such, by retaining the original series of commits?

OK for me.

Thanks! How would we go about merging this, then?

@jsji
Copy link
Contributor

jsji commented Nov 5, 2024

CC @jsji @maarquitos14. Since this is effectively a mini-pulldown, can we merge it as such, by retaining the original series of commits?

OK for me.

Thanks! How would we go about merging this, then?

@intel/llvm-gatekeepers Please merge. Thanks.

@sarnex sarnex merged commit 730cd3a into intel:sycl Nov 5, 2024
14 checks passed
@frasercrmck frasercrmck deleted the cherry-pick-libclc-3 branch November 5, 2024 22:07
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

4 participants