[libclc] Use float sw_fma for spirv*-mesa-mesa3d targets (#199626)
This partially reverts39f3d72b72, which changes almost all targets to use __builtin_elementwise_fma. The same revert was done for clspv in1d719edd99. Restore __clc_runtime_has_hw_fma32 so that Mesa can dynamically change its behavior to enable native fma for specific hardware. Fixes #198542
This commit is contained in:
parent
479818a38c
commit
767f01e091
13 changed files with 86 additions and 4 deletions
|
|
@ -0,0 +1,16 @@
|
|||
//===----------------------------------------------------------------------===//
|
||||
//
|
||||
// Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions.
|
||||
// See https://llvm.org/LICENSE.txt for license information.
|
||||
// SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception
|
||||
//
|
||||
//===----------------------------------------------------------------------===//
|
||||
|
||||
#ifndef __CLC_INTERNAL_MATH_CLC_RUNTIME_HAS_HW_FMA32_H__
|
||||
#define __CLC_INTERNAL_MATH_CLC_RUNTIME_HAS_HW_FMA32_H__
|
||||
|
||||
#include "clc/internal/clc.h"
|
||||
|
||||
_CLC_DECL bool __attribute__((noinline)) __clc_runtime_has_hw_fma32(void);
|
||||
|
||||
#endif // __CLC_INTERNAL_MATH_CLC_RUNTIME_HAS_HW_FMA32_H__
|
||||
|
|
@ -9,6 +9,8 @@
|
|||
#ifndef __CLC_INTERNAL_MATH_CLC_SW_FMA_H__
|
||||
#define __CLC_INTERNAL_MATH_CLC_SW_FMA_H__
|
||||
|
||||
#include "clc/internal/clc.h"
|
||||
|
||||
#define __CLC_FUNCTION __clc_sw_fma
|
||||
#define __CLC_FLOAT_ONLY
|
||||
#define __CLC_BODY "clc/shared/ternary_decl.inc"
|
||||
|
|
|
|||
|
|
@ -9,6 +9,8 @@
|
|||
#ifndef __CLC_MATH_CLC_FMA_H__
|
||||
#define __CLC_MATH_CLC_FMA_H__
|
||||
|
||||
#include "clc/internal/clc.h"
|
||||
|
||||
#define __CLC_FUNCTION __clc_fma
|
||||
#define __CLC_BODY "clc/shared/ternary_decl.inc"
|
||||
|
||||
|
|
|
|||
|
|
@ -6,9 +6,7 @@
|
|||
//
|
||||
//===----------------------------------------------------------------------===//
|
||||
|
||||
#include "clc/internal/clc.h"
|
||||
#include "clc/math/clc_fma.h"
|
||||
#include "clc/math/math.h"
|
||||
|
||||
#define __CLC_FUNCTION __clc_fma
|
||||
#define __CLC_IMPL_FUNCTION(x) __builtin_elementwise_fma
|
||||
|
|
|
|||
|
|
@ -3,7 +3,10 @@ if(LIBCLC_TARGET_OS AND EXISTS ${CMAKE_CURRENT_SOURCE_DIR}/${LIBCLC_TARGET_OS})
|
|||
endif()
|
||||
|
||||
libclc_add_sources(${LIBCLC_CLC_TARGET} FILES
|
||||
math/clc_fma.cl
|
||||
math/clc_fmax.cl
|
||||
math/clc_fmin.cl
|
||||
math/clc_runtime_has_hw_fma32.cl
|
||||
math/clc_sw_fma.cl
|
||||
subnormal_config.cl
|
||||
)
|
||||
|
|
|
|||
15
libclc/clc/lib/spirv/math/clc_fma.cl
Normal file
15
libclc/clc/lib/spirv/math/clc_fma.cl
Normal file
|
|
@ -0,0 +1,15 @@
|
|||
//===----------------------------------------------------------------------===//
|
||||
//
|
||||
// Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions.
|
||||
// See https://llvm.org/LICENSE.txt for license information.
|
||||
// SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception
|
||||
//
|
||||
//===----------------------------------------------------------------------===//
|
||||
|
||||
#include "clc/internal/math/clc_runtime_has_hw_fma32.h"
|
||||
#include "clc/internal/math/clc_sw_fma.h"
|
||||
#include "clc/math/clc_fma.h"
|
||||
#include "clc/math/math.h"
|
||||
|
||||
#define __CLC_BODY "clc_fma.inc"
|
||||
#include "clc/math/gentype.inc"
|
||||
16
libclc/clc/lib/spirv/math/clc_fma.inc
Normal file
16
libclc/clc/lib/spirv/math/clc_fma.inc
Normal file
|
|
@ -0,0 +1,16 @@
|
|||
//===----------------------------------------------------------------------===//
|
||||
//
|
||||
// Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions.
|
||||
// See https://llvm.org/LICENSE.txt for license information.
|
||||
// SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception
|
||||
//
|
||||
//===----------------------------------------------------------------------===//
|
||||
|
||||
_CLC_DEF _CLC_OVERLOAD __CLC_GENTYPE __clc_fma(__CLC_GENTYPE a, __CLC_GENTYPE b,
|
||||
__CLC_GENTYPE c) {
|
||||
#if __CLC_FPSIZE == 32
|
||||
if (!__clc_runtime_has_hw_fma32())
|
||||
return __clc_sw_fma(a, b, c);
|
||||
#endif
|
||||
return __builtin_elementwise_fma(a, b, c);
|
||||
}
|
||||
13
libclc/clc/lib/spirv/math/clc_runtime_has_hw_fma32.cl
Normal file
13
libclc/clc/lib/spirv/math/clc_runtime_has_hw_fma32.cl
Normal file
|
|
@ -0,0 +1,13 @@
|
|||
//===----------------------------------------------------------------------===//
|
||||
//
|
||||
// Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions.
|
||||
// See https://llvm.org/LICENSE.txt for license information.
|
||||
// SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception
|
||||
//
|
||||
//===----------------------------------------------------------------------===//
|
||||
|
||||
#include "clc/internal/math/clc_runtime_has_hw_fma32.h"
|
||||
|
||||
bool __attribute__((noinline)) __clc_runtime_has_hw_fma32(void) {
|
||||
return false;
|
||||
}
|
||||
|
|
@ -1,4 +1,3 @@
|
|||
libclc_add_sources(${LIBCLC_CLC_TARGET} FILES
|
||||
integer/clc_mul_hi.cl
|
||||
math/clc_sw_fma.cl
|
||||
)
|
||||
|
|
|
|||
|
|
@ -7,7 +7,6 @@
|
|||
//===----------------------------------------------------------------------===//
|
||||
|
||||
#include "clc/math/clc_fma.h"
|
||||
#include "clc/math/math.h"
|
||||
|
||||
#define __CLC_FUNCTION fma
|
||||
#define __CLC_BODY "clc/shared/ternary_def.inc"
|
||||
|
|
|
|||
|
|
@ -4,6 +4,10 @@ if(LIBCLC_TARGET_OS AND EXISTS ${CMAKE_CURRENT_SOURCE_DIR}/${LIBCLC_TARGET_OS})
|
|||
endif()
|
||||
|
||||
# Non-Vulkan SPIR-V uses a curated subset of generic builtins.
|
||||
libclc_add_sources(${LIBCLC_OPENCL_TARGET} FILES
|
||||
math/fma.cl
|
||||
)
|
||||
|
||||
libclc_add_sources(${LIBCLC_OPENCL_TARGET}
|
||||
BASE_DIR ${CMAKE_CURRENT_SOURCE_DIR}/../generic
|
||||
FILES
|
||||
|
|
|
|||
15
libclc/opencl/lib/spirv/math/fma.cl
Normal file
15
libclc/opencl/lib/spirv/math/fma.cl
Normal file
|
|
@ -0,0 +1,15 @@
|
|||
//===----------------------------------------------------------------------===//
|
||||
//
|
||||
// Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions.
|
||||
// See https://llvm.org/LICENSE.txt for license information.
|
||||
// SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception
|
||||
//
|
||||
//===----------------------------------------------------------------------===//
|
||||
|
||||
#include "clc/math/clc_fma.h"
|
||||
|
||||
#define __CLC_FLOAT_ONLY
|
||||
#define __CLC_FUNCTION fma
|
||||
#define __CLC_BODY "clc/shared/ternary_def.inc"
|
||||
|
||||
#include "clc/math/gentype.inc"
|
||||
Loading…
Reference in a new issue