Revert F16C series (MR 6774)

This reverts commit 4fb2eddfdf.
This reverts commit 7a1deb16f8.
This reverts commit 2b6a172343.
This reverts commit 5af81393e4.
This reverts commit 87900afe5b.

A couple of problems were discovered after this series was merged that
cause breakage in different configurations:

   (1) It seems that using -mf16c also enables AVX, leading to SIGILL on
   platforms that do not support AVX.
   (2) Since clang only warns about unknown flags, and as I understand
   it Meson's handling in cc.has_argument() is broken, the F16C code is
   wrongly enabled when clang is used, even for example on ARM, leading
   to a compilation error.

Closes: https://gitlab.freedesktop.org/mesa/mesa/-/issues/3583
Reviewed-by: Eric Anholt <eric@anholt.net>
Reviewed-by: Rob Clark <robdclark@chromium.org>
Part-of: <https://gitlab.freedesktop.org/mesa/mesa/-/merge_requests/6969>
This commit is contained in:
Matt Turner
2020-10-01 13:48:16 -07:00
committed by Marge Bot
parent 4a0164ed85
commit 1aac47db69
45 changed files with 266 additions and 216 deletions
+3 -3
View File
@@ -360,7 +360,7 @@ def conversion_expr(src_channel,
# Promote half to float
if src_type == FLOAT and src_size == 16:
value = '_mesa_half_to_float(%s)' % value
value = 'util_half_to_float(%s)' % value
src_size = 32
# Special case for float <-> ubytes for more accurate results
@@ -436,7 +436,7 @@ def conversion_expr(src_channel,
src_size = 32
if dst_channel.size == 16:
value = '_mesa_float_to_float16_rtz(%s)' % value
value = 'util_float_to_half_rtz(%s)' % value
elif dst_channel.size == 64 and src_size < 64:
value = '(double)%s' % value
@@ -715,7 +715,7 @@ def generate(formats):
print()
print('#include "pipe/p_compiler.h"')
print('#include "util/u_math.h"')
print('#include "util/half_float.h"')
print('#include "util/u_half.h"')
print('#include "u_format.h"')
print('#include "u_format_other.h"')
print('#include "util/format_srgb.h"')
-3
View File
@@ -914,11 +914,8 @@ util_format_test_cases[] =
{PIPE_FORMAT_R16_FLOAT, PACKED_1x16(0xffff), PACKED_1x16(0x03FF), UNPACKED_1x1( 6.09756E-5, 0.0, 0.0, 1.0)},
#endif
/* This fails with _mesa_float_to_float16_rtz, but passes with _mesa_float_to_float16_rtne. */
#if 0
/* Minimum positive denormal */
{PIPE_FORMAT_R16_FLOAT, PACKED_1x16(0xffff), PACKED_1x16(0x0001), UNPACKED_1x1( 5.96046E-8, 0.0, 0.0, 1.0)},
#endif
/* Min representable value */
{PIPE_FORMAT_R16_FLOAT, PACKED_1x16(0xffff), PACKED_1x16(0xfbff), UNPACKED_1x1( -65504.0, 0.0, 0.0, 1.0)},
+6 -28
View File
@@ -28,10 +28,10 @@
#include <math.h>
#include <assert.h>
#include "half_float.h"
#include "util/u_half.h"
#include "rounding.h"
#include "softfloat.h"
#include "macros.h"
#include "u_math.h"
typedef union { float f; int32_t i; uint32_t u; } fi_type;
@@ -54,7 +54,7 @@ typedef union { float f; int32_t i; uint32_t u; } fi_type;
* result in the same value as if the expression were executed on the GPU.
*/
uint16_t
_mesa_float_to_half_slow(float val)
_mesa_float_to_half(float val)
{
const fi_type fi = {val};
const int flt_m = fi.i & 0x7fffff;
@@ -129,9 +129,9 @@ _mesa_float_to_half_slow(float val)
}
uint16_t
_mesa_float_to_float16_rtz_slow(float val)
_mesa_float_to_float16_rtz(float val)
{
return _mesa_float_to_half_rtz_slow(val);
return _mesa_float_to_half_rtz(val);
}
/**
@@ -140,31 +140,9 @@ _mesa_float_to_float16_rtz_slow(float val)
* http://www.opengl.org/discussion_boards/ubb/Forum3/HTML/008786.html
*/
float
_mesa_half_to_float_slow(uint16_t val)
_mesa_half_to_float(uint16_t val)
{
union fi infnan;
union fi magic;
union fi f32;
infnan.ui = 0x8f << 23;
infnan.f = 65536.0f;
magic.ui = 0xef << 23;
/* Exponent / Mantissa */
f32.ui = (val & 0x7fff) << 13;
/* Adjust */
f32.f *= magic.f;
/* XXX: The magic mul relies on denorms being available */
/* Inf / NaN */
if (f32.f >= infnan.f)
f32.ui |= 0xff << 23;
/* Sign */
f32.ui |= (uint32_t)(val & 0x8000) << 16;
return f32.f;
return util_half_to_float(val);
}
/**
+4 -42
View File
@@ -28,14 +28,6 @@
#include <stdbool.h>
#include <stdint.h>
#include <string.h>
#include "util/u_cpu_detect.h"
#ifdef USE_F16C
#include <immintrin.h>
#define F16C_NEAREST 0
#define F16C_TRUNCATE 3
#endif
#ifdef __cplusplus
extern "C" {
@@ -44,48 +36,18 @@ extern "C" {
#define FP16_ONE ((uint16_t) 0x3c00)
#define FP16_ZERO ((uint16_t) 0)
uint16_t _mesa_float_to_half_slow(float val);
float _mesa_half_to_float_slow(uint16_t val);
uint16_t _mesa_float_to_half(float val);
float _mesa_half_to_float(uint16_t val);
uint8_t _mesa_half_to_unorm8(uint16_t v);
uint16_t _mesa_uint16_div_64k_to_half(uint16_t v);
/*
* _mesa_float_to_float16_rtz_slow is no more than a wrapper to the counterpart
* _mesa_float_to_float16_rtz is no more than a wrapper to the counterpart
* softfloat.h call. Still, softfloat.h conversion API is meant to be kept
* private. In other words, only use the API published here, instead of
* calling directly the softfloat.h one.
*/
uint16_t _mesa_float_to_float16_rtz_slow(float val);
static inline uint16_t
_mesa_float_to_half(float val)
{
#ifdef USE_F16C
if (util_cpu_caps.has_f16c)
return _cvtss_sh(val, F16C_NEAREST);
#endif
return _mesa_float_to_half_slow(val);
}
static inline float
_mesa_half_to_float(uint16_t val)
{
#ifdef USE_F16C
if (util_cpu_caps.has_f16c)
return _cvtsh_ss(val);
#endif
return _mesa_half_to_float_slow(val);
}
static inline uint16_t
_mesa_float_to_float16_rtz(float val)
{
#ifdef USE_F16C
if (util_cpu_caps.has_f16c)
return _cvtss_sh(val, F16C_TRUNCATE);
#endif
return _mesa_float_to_float16_rtz_slow(val);
}
uint16_t _mesa_float_to_float16_rtz(float val);
static inline uint16_t
_mesa_float_to_float16_rtne(float val)
+1 -1
View File
@@ -1435,7 +1435,7 @@ _mesa_double_to_f32(double val, bool rtz)
* From f32_to_f16()
*/
uint16_t
_mesa_float_to_half_rtz_slow(float val)
_mesa_float_to_half_rtz(float val)
{
const fi_type fi = {val};
const uint32_t flt_m = fi.u & 0x7fffff;
+1 -1
View File
@@ -56,7 +56,7 @@ double _mesa_double_mul_rtz(double a, double b);
double _mesa_double_fma_rtz(double a, double b, double c);
float _mesa_float_fma_rtz(float a, float b, float c);
float _mesa_double_to_f32(double x, bool rtz);
uint16_t _mesa_float_to_half_rtz_slow(float x);
uint16_t _mesa_float_to_half_rtz(float x);
#ifdef __cplusplus
} /* extern C */
+1 -2
View File
@@ -30,8 +30,7 @@
#include <stdio.h>
#include <float.h>
#include "util/half_float.h"
#include "util/u_math.h"
#include "util/u_half.h"
#include "util/format/u_format.h"
#include "util/format/u_format_tests.h"
#include "util/format/u_format_s3tc.h"