Skip to content

Commit

Permalink
Corrections related to code review (bureforce KhronosGroup#142)
Browse files Browse the repository at this point in the history
  • Loading branch information
shajder committed Nov 28, 2023
1 parent c49e825 commit 6f85906
Show file tree
Hide file tree
Showing 2 changed files with 9 additions and 12 deletions.
18 changes: 6 additions & 12 deletions test_conformance/math_brute_force/i_unary_half.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -19,6 +19,7 @@
#include "test_functions.h"
#include "utility.h"

#include <algorithm>
#include <cstring>
#include <memory>
#include <cinttypes>
Expand Down Expand Up @@ -48,9 +49,8 @@ int TestFunc_Int_Half(const Func *f, MTdata d, bool relaxedMode)
int ftz = f->ftz || 0 == (gHalfCapabilities & CL_FP_DENORM) || gForceFTZ;
size_t bufferSize = BUFFER_SIZE;
uint64_t step = getTestStep(sizeof(cl_half), BUFFER_SIZE);
size_t bufferElements = bufferSize / sizeof(cl_int);

int scale = (int)((1ULL << 16) / (16 * bufferElements) + 1);
size_t bufferElements = std::min(bufferSize / sizeof(cl_int),
size_t(1ULL << (sizeof(cl_half) * 8)));

logFunctionInfo(f->name, sizeof(cl_half), relaxedMode);
// This test is not using ThreadPool so we need to disable FTZ here
Expand All @@ -74,15 +74,9 @@ int TestFunc_Int_Half(const Func *f, MTdata d, bool relaxedMode)
{
// Init input array
cl_ushort *p = (cl_ushort *)gIn;
if (gWimpyMode)
{
for (size_t j = 0; j < bufferElements; j++)
p[j] = (cl_ushort)i + j * scale;
}
else
{
for (size_t j = 0; j < bufferElements; j++) p[j] = (cl_ushort)i + j;
}

for (size_t j = 0; j < bufferElements; j++) p[j] = (cl_ushort)i + j;

if ((error = clEnqueueWriteBuffer(gQueue, gInBuffer, CL_FALSE, 0,
bufferSize, gIn, 0, NULL, NULL)))
{
Expand Down
3 changes: 3 additions & 0 deletions test_conformance/math_brute_force/unary_two_results_half.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -201,6 +201,9 @@ int TestFunc_Half2_Half(const Func *f, MTdata d, bool relaxedMode)
ref1[j] = HFF((float)f->func.f_fpf(HTF(pIn[j]), &dd));
ref2[j] = HFF((float)dd);

// ensure correct rounding of fract result is not reaching 1
if (isFract && HTF(ref1[j]) >= 1.f) ref1[j] = 0x3bff;

overflow[j] =
FE_OVERFLOW == (FE_OVERFLOW & fetestexcept(FE_OVERFLOW));
}
Expand Down

0 comments on commit 6f85906

Please sign in to comment.