[all-commits] [llvm/llvm-project] b7e201: [libclc] Move smoothstep to CLC and optimize its c...

Fraser Cormack via All-commits all-commits at lists.llvm.org
Thu Jan 16 03:44:31 PST 2025


  Branch: refs/heads/main
  Home:   https://github.com/llvm/llvm-project
  Commit: b7e20147ad7c29f9624d2a071bd348a7acd63461
      https://github.com/llvm/llvm-project/commit/b7e20147ad7c29f9624d2a071bd348a7acd63461
  Author: Fraser Cormack <fraser at codeplay.com>
  Date:   2025-01-16 (Thu, 16 Jan 2025)

  Changed paths:
    M libclc/clc/include/clc/clcmacro.h
    A libclc/clc/include/clc/common/clc_smoothstep.h
    A libclc/clc/include/clc/common/clc_smoothstep.inc
    M libclc/clc/include/clc/shared/clc_clamp.h
    M libclc/clc/lib/clspv/SOURCES
    M libclc/clc/lib/generic/SOURCES
    A libclc/clc/lib/generic/common/clc_smoothstep.cl
    M libclc/clc/lib/spirv/SOURCES
    M libclc/clc/lib/spirv64/SOURCES
    M libclc/generic/lib/common/smoothstep.cl

  Log Message:
  -----------
  [libclc] Move smoothstep to CLC and optimize its codegen (#123183)

This commit moves the implementation of the smoothstep function to the
CLC library, whilst optimizing the codegen.

This commit also adds support for 'half' versions of smoothstep, which
were previously missing.

The CLC smoothstep implementation now keeps everything in vectors,
rather than recursively splitting vectors by half down to the scalar
base form. This should result in more optimal codegen across the board.

This commit also removes some non-standard overloads of smoothstep with
mixed types, such as 'double smoothstep(float, float, float)'. There
aren't any mixed-(element )type versions of smoothstep as far as I can
see:

    gentype smoothstep(gentype edge0, gentype edge1, gentype x)
    gentypef smoothstep(float edge0, float edge1, gentypef x)
    gentyped smoothstep(double edge0, double edge1, gentyped x)
    gentypeh smoothstep(half edge0, half edge1, gentypeh x)

The CLC library only defines the first type, for simplicity; the OpenCL
layer is responsible for handling the scalar/scalar/vector forms. Note
that the scalar/scalar/vector forms now splat the scalars to the vector
type, rather than recursively split vectors as before. The macro that
used to 'vectorize' smoothstep in this way has been moved out of the
shared clcmacro.h header as it was only used for the smoothstep builtin.

Note that the CLC clamp function is now built for both SPIR-V targets.
This is to help build the CLC smoothstep function for the Mesa SPIR-V
target.



To unsubscribe from these emails, change your notification settings at https://github.com/llvm/llvm-project/settings/notifications


More information about the All-commits mailing list