Merge pull request 'Tests for float16' (#157) from float16_tests into master

Reviewed-on: https://git.madvoxel.net/OpenVulkano/OpenVulkano/pulls/157
Reviewed-by: Georg Hagen <georg.hagen@madvoxel.com>
This commit is contained in:
Vladyslav_Baranovskyi_EXT
2024-11-07 19:15:49 +01:00
2 changed files with 204 additions and 12 deletions

View File

@@ -236,15 +236,22 @@ namespace std
return hash<uint16_t>()(key.m_data);
}
};
}
#endif
#undef __has_keyword
namespace std
{
template <>
class numeric_limits<float16>
{
public:
// General -- meaningful for all specializations.
static const bool is_specialized = true;
static float16 min() { return float16(0, 1, 0); }
static float16 max() { return float16(~0, 30, 0); }
static float16 min() { uint16_t v = 0x400; return *(float16 *)&v;/*return float16(0, 1, 0);*/ }
static float16 max() { uint16_t v = 0x7bff; return *(float16 *)&v;/*return float16(~0, 30, 0);*/ }
static const int radix = 2;
static const int digits = 10; // conservative assumption
static const int digits10 = 2; // conservative assumption
@@ -257,8 +264,8 @@ namespace std
// Floating point specific.
static float16 epsilon() { return float16(0.00097656f); } // from OpenEXR, needs to be confirmed
static float16 round_error() { return float16(0.00097656f/2); }
static float16 epsilon() { uint16_t v = 0x13ff; return *(float16 *)&v;/*return float16(0.00097656f);*/ } // from OpenEXR, needs to be confirmed
static float16 round_error() { uint16_t v = 0xfff; return *(float16 *)&v;/*return float16(0.00097656f/2);*/ }
static const int min_exponent10 = -9;
static const int max_exponent10 = 9;
static const int min_exponent = -15;
@@ -272,16 +279,12 @@ namespace std
static const bool tinyness_before = false;
static const float_round_style round_style = round_to_nearest;
static float16 denorm_min() { return float16(1, 0, 1); }
static float16 infinity() { return float16(0, 31, 0); }
static float16 quiet_NaN() { return float16(1, 31, 0); }
static float16 signaling_NaN () { return float16(1, 31, 0); }
static float16 denorm_min() { uint16_t v = 0x8001; return *(float16 *)&v;/*return float16(1, 0, 1);*/ }
static float16 infinity() { uint16_t v = 0x7c00; return *(float16 *)&v;/*return float16(0, 31, 0);*/ }
static float16 quiet_NaN() { uint16_t v = 0x7c01; return *(float16 *)&v;/*return float16(1, 31, 0);*/ }
static float16 signaling_NaN () { uint16_t v = 0x7c01; return *(float16 *)&v;/*return float16(1, 31, 0);*/ }
};
}
#endif
#undef __has_keyword
typedef float16 fp16;
typedef float16 half;