mirror of
https://github.com/KhronosGroup/OpenCL-CTS.git
synced 2026-03-19 06:09:01 +00:00
conversions: Fix verification of half subnormal cases with FTZ (#1914)
This commit is contained in:
committed by
GitHub
parent
620c689919
commit
4019a26a5b
@@ -1005,14 +1005,6 @@ double SubtractTime(uint64_t endTime, uint64_t startTime)
|
|||||||
}
|
}
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
static void setAllowZ(uint8_t *allow, uint32_t *x, cl_uint count)
|
|
||||||
{
|
|
||||||
cl_uint i;
|
|
||||||
for (i = 0; i < count; ++i)
|
|
||||||
allow[i] |= (uint8_t)((x[i] & 0x7f800000U) == 0);
|
|
||||||
}
|
|
||||||
|
|
||||||
|
|
||||||
void MapResultValuesComplete(const std::unique_ptr<CalcRefValsBase> &ptr);
|
void MapResultValuesComplete(const std::unique_ptr<CalcRefValsBase> &ptr);
|
||||||
|
|
||||||
void CL_CALLBACK CalcReferenceValuesComplete(cl_event e, cl_int status,
|
void CL_CALLBACK CalcReferenceValuesComplete(cl_event e, cl_int status,
|
||||||
@@ -1337,15 +1329,13 @@ cl_int PrepareReference(cl_uint job_id, cl_uint thread_id, void *p)
|
|||||||
// Decide if we allow a zero result in addition to the correctly rounded
|
// Decide if we allow a zero result in addition to the correctly rounded
|
||||||
// one
|
// one
|
||||||
memset(a, 0, count);
|
memset(a, 0, count);
|
||||||
if (gForceFTZ)
|
if (gForceFTZ && (inType == kfloat || outType == kfloat))
|
||||||
{
|
{
|
||||||
if (inType == kfloat || outType == kfloat)
|
info->set_allow_zero_array((uint8_t *)a, d, s, count);
|
||||||
setAllowZ((uint8_t *)a, (uint32_t *)s, count);
|
|
||||||
}
|
}
|
||||||
if (gForceHalfFTZ)
|
if (gForceHalfFTZ && (inType == khalf || outType == khalf))
|
||||||
{
|
{
|
||||||
if (inType == khalf || outType == khalf)
|
info->set_allow_zero_array((uint8_t *)a, d, s, count);
|
||||||
setAllowZ((uint8_t *)a, (uint32_t *)s, count);
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
|
|||||||
@@ -30,6 +30,7 @@ extern roundingMode qcom_rm;
|
|||||||
|
|
||||||
#include <CL/cl_half.h>
|
#include <CL/cl_half.h>
|
||||||
|
|
||||||
|
#include "harness/conversions.h"
|
||||||
#include "harness/mt19937.h"
|
#include "harness/mt19937.h"
|
||||||
#include "harness/rounding_mode.h"
|
#include "harness/rounding_mode.h"
|
||||||
#include "harness/typeWrappers.h"
|
#include "harness/typeWrappers.h"
|
||||||
@@ -82,6 +83,7 @@ struct DataInitBase : public DataInitInfo
|
|||||||
virtual void conv_array(void *out, void *in, size_t n) {}
|
virtual void conv_array(void *out, void *in, size_t n) {}
|
||||||
virtual void conv_array_sat(void *out, void *in, size_t n) {}
|
virtual void conv_array_sat(void *out, void *in, size_t n) {}
|
||||||
virtual void init(const cl_uint &, const cl_uint &) {}
|
virtual void init(const cl_uint &, const cl_uint &) {}
|
||||||
|
virtual void set_allow_zero_array(uint8_t *allow, void *out, void *in, size_t n) {}
|
||||||
};
|
};
|
||||||
|
|
||||||
template <typename InType, typename OutType, bool InFP, bool OutFP>
|
template <typename InType, typename OutType, bool InFP, bool OutFP>
|
||||||
@@ -99,6 +101,9 @@ struct DataInfoSpec : public DataInitBase
|
|||||||
void conv(OutType *out, InType *in);
|
void conv(OutType *out, InType *in);
|
||||||
void conv_sat(OutType *out, InType *in);
|
void conv_sat(OutType *out, InType *in);
|
||||||
|
|
||||||
|
// Decide if we allow a zero result in addition to the correctly rounded one
|
||||||
|
void set_allow_zero(uint8_t *allow, OutType *out, InType *in);
|
||||||
|
|
||||||
// min/max ranges for output type of data
|
// min/max ranges for output type of data
|
||||||
std::pair<OutType, OutType> ranges;
|
std::pair<OutType, OutType> ranges;
|
||||||
|
|
||||||
@@ -130,6 +135,10 @@ struct DataInfoSpec : public DataInitBase
|
|||||||
}
|
}
|
||||||
|
|
||||||
void init(const cl_uint &, const cl_uint &) override;
|
void init(const cl_uint &, const cl_uint &) override;
|
||||||
|
void set_allow_zero_array(uint8_t *allow, void *out, void *in, size_t n) override {
|
||||||
|
for (size_t i = 0; i < n; i++)
|
||||||
|
set_allow_zero(&allow[i], &((OutType *)out)[i], &((InType *)in)[i]);
|
||||||
|
}
|
||||||
InType clamp(const InType &);
|
InType clamp(const InType &);
|
||||||
inline float fclamp(float lo, float v, float hi)
|
inline float fclamp(float lo, float v, float hi)
|
||||||
{
|
{
|
||||||
@@ -717,6 +726,33 @@ void DataInfoSpec<InType, OutType, InFP, OutFP>::conv_sat(OutType *out,
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
template <typename InType, typename OutType, bool InFP, bool OutFP>
|
||||||
|
void DataInfoSpec<InType, OutType, InFP, OutFP>::set_allow_zero(uint8_t *allow,
|
||||||
|
OutType *out,
|
||||||
|
InType *in)
|
||||||
|
{
|
||||||
|
// from double
|
||||||
|
if (std::is_same<InType, cl_double>::value)
|
||||||
|
*allow |= IsDoubleSubnormal(*in);
|
||||||
|
// from float
|
||||||
|
if (std::is_same<InType, cl_float>::value)
|
||||||
|
*allow |= IsFloatSubnormal(*in);
|
||||||
|
// from half
|
||||||
|
if (is_in_half())
|
||||||
|
*allow |= IsHalfSubnormal(*in);
|
||||||
|
|
||||||
|
// handle the cases that the converted result is subnormal
|
||||||
|
// from double
|
||||||
|
if (std::is_same<OutType, cl_double>::value)
|
||||||
|
*allow |= IsDoubleSubnormal(*out);
|
||||||
|
// from float
|
||||||
|
if (std::is_same<OutType, cl_float>::value)
|
||||||
|
*allow |= IsFloatSubnormal(*out);
|
||||||
|
// from half
|
||||||
|
if (is_out_half())
|
||||||
|
*allow |= IsHalfSubnormal(*out);
|
||||||
|
}
|
||||||
|
|
||||||
template <typename InType, typename OutType, bool InFP, bool OutFP>
|
template <typename InType, typename OutType, bool InFP, bool OutFP>
|
||||||
void DataInfoSpec<InType, OutType, InFP, OutFP>::init(const cl_uint &job_id,
|
void DataInfoSpec<InType, OutType, InFP, OutFP>::init(const cl_uint &job_id,
|
||||||
const cl_uint &thread_id)
|
const cl_uint &thread_id)
|
||||||
|
|||||||
Reference in New Issue
Block a user