Skip to content

Commit

Permalink
test: hide some NAN checks if SIMDE_FAST_NANS
Browse files Browse the repository at this point in the history
  • Loading branch information
mr-c committed Aug 20, 2024
1 parent ff8b751 commit 3859226
Showing 1 changed file with 16 additions and 6 deletions.
22 changes: 16 additions & 6 deletions test/test.h
Original file line number Diff line number Diff line change
Expand Up @@ -129,6 +129,7 @@ simde_test_codegen_snprintf_(char* str, size_t size, const char* format, ...) {
}
}

#if !defined(SIMDE_FAST_NANS)
static void
simde_test_codegen_f16(size_t buf_len, char buf[HEDLEY_ARRAY_PARAM(buf_len)], simde_float16 value) {
simde_float32 valuef = simde_float16_to_float32(value);
Expand Down Expand Up @@ -174,6 +175,7 @@ simde_test_codegen_bf16(size_t buf_len, char buf[HEDLEY_ARRAY_PARAM(buf_len)], s
simde_test_codegen_snprintf_(buf, buf_len, "SIMDE_BFLOAT16_VALUE(%9.2f)", HEDLEY_STATIC_CAST(double, valuef));
}
}
#endif /* !defined(SIMDE_FAST_NANS) */

static void
simde_test_codegen_i8(size_t buf_len, char buf[HEDLEY_ARRAY_PARAM(buf_len)], int8_t value) {
Expand Down Expand Up @@ -414,6 +416,7 @@ simde_test_codegen_float_set_value_(size_t element_size, size_t pos, void* value
}
}

#if !defined(SIMDE_FAST_NANS)
static void
simde_test_codegen_random_vfX_full_(
size_t test_sets, size_t vectors_per_set, size_t elements_per_vector,
Expand Down Expand Up @@ -457,6 +460,7 @@ simde_test_codegen_random_vfX_full_(
simde_test_codegen_float_set_value_(elem_size, b, values, HEDLEY_STATIC_CAST(simde_float32, v), v);
}
}
#endif /* !defined(SIMDE_FAST_NANS) */

static void
simde_test_codegen_random_vf16_full(
Expand Down Expand Up @@ -731,9 +735,12 @@ SIMDE_DIAGNOSTIC_DISABLE_FLOAT_EQUAL_

static int
simde_test_equal_f32(simde_float32 a, simde_float32 b, simde_float32 slop) {
if (simde_math_isnan(a)) {
return simde_math_isnan(b);
} else if (simde_math_isinf(a)) {
#if !defined(SIMDE_FAST_NANS)
if (simde_math_isnan(a)) {
return simde_math_isnan(b);
}
#endif
if (simde_math_isinf(a)) {
return !((a < b) || (a > b));
} else if (slop == SIMDE_FLOAT32_C(0.0)) {
return !simde_memcmp(&a, &b, sizeof(simde_float32));
Expand Down Expand Up @@ -761,9 +768,12 @@ simde_test_equal_f16(simde_float16 a, simde_float16 b, simde_float16 slop) {

static int
simde_test_equal_f64(simde_float64 a, simde_float64 b, simde_float64 slop) {
if (simde_math_isnan(a)) {
return simde_math_isnan(b);
} else if (simde_math_isinf(a)) {
#if !defined(SIMDE_FAST_NANS)
if (simde_math_isnan(a)) {
return simde_math_isnan(b);
}
#endif
if (simde_math_isinf(a)) {
return !((a < b) || (a > b));
} else if (slop == SIMDE_FLOAT64_C(0.0)) {
return !simde_memcmp(&a, &b, sizeof(simde_float64));
Expand Down

0 comments on commit 3859226

Please sign in to comment.