Skip to content

Commit

Permalink
Adapted modifications from related PR KhronosGroup#1719 to avoid merg…
Browse files Browse the repository at this point in the history
…ing conflicts
  • Loading branch information
shajder committed Jun 23, 2023
1 parent 0ffbeb1 commit f815d9e
Show file tree
Hide file tree
Showing 4 changed files with 40 additions and 194 deletions.
70 changes: 4 additions & 66 deletions test_conformance/conversions/basic_test_conversions.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -17,10 +17,6 @@
#include "harness/compat.h"
#include "harness/rounding_mode.h"
#include "harness/ThreadPool.h"
#include "harness/testHarness.h"
#include "harness/kernelHelpers.h"
#include "harness/mt19937.h"
#include "harness/kernelHelpers.h"

#if defined(__APPLE__)
#include <sys/sysctl.h>
Expand All @@ -43,8 +39,6 @@

#include <sstream>
#include <stdarg.h>
#include <stdio.h>
#include <string.h>
#if !defined(_WIN32)
#include <libgen.h>
#include <sys/mman.h>
Expand All @@ -58,11 +52,6 @@

#include "basic_test_conversions.h"

#if (defined(_WIN32) && defined(_MSC_VER))
// need for _controlfp_s and rouinding modes in RoundingMode
#include "harness/testHarness.h"
#endif

#if defined(_WIN32)
#include <mmintrin.h>
#include <emmintrin.h>
Expand Down Expand Up @@ -113,16 +102,11 @@ MTdata gMTdata;
const char **argList = NULL;
int argCount = 0;

////////////////////////////////////////////////////////////////////////////////////////

double SubtractTime(uint64_t endTime, uint64_t startTime);

////////////////////////////////////////////////////////////////////////////////////////

cl_half_rounding_mode DataInitInfo::halfRoundingMode = CL_HALF_RTE;
cl_half_rounding_mode ConversionsTest::defaultHalfRoundingMode = CL_HALF_RTE;

////////////////////////////////////////////////////////////////////////////////////////
// clang-format off
// for readability sake keep this section unformatted

Expand Down Expand Up @@ -279,7 +263,6 @@ std::vector<double> DataInitInfo::specialValuesDouble = {
MAKE_HEX_DOUBLE(0x1.ffffffff00001p62, 0x1ffffffff00001LL, 10),
};
// clang-format on
////////////////////////////////////////////////////////////////////////////////////////

// Windows (since long double got deprecated) sets the x87 to 53-bit precision
// (that's x87 default state). This causes problems with the tests that
Expand All @@ -304,8 +287,6 @@ static inline void Force64BitFPUPrecision(void)
#endif
}

////////////////////////////////////////////////////////////////////////////////////////

template <typename InType, typename OutType, bool InFP, bool OutFP>
int CalcRefValsPat<InType, OutType, InFP, OutFP>::check_result(void *test,
uint32_t count,
Expand Down Expand Up @@ -370,8 +351,6 @@ int CalcRefValsPat<InType, OutType, InFP, OutFP>::check_result(void *test,
return 0;
}

////////////////////////////////////////////////////////////////////////////////////////

cl_uint RoundUpToNextPowerOfTwo(cl_uint x)
{
if (0 == (x & (x - 1))) return x;
Expand All @@ -381,8 +360,6 @@ cl_uint RoundUpToNextPowerOfTwo(cl_uint x)
return x + x;
}

////////////////////////////////////////////////////////////////////////////////////////

cl_int CustomConversionsTest::Run()
{
int startMinVectorSize = gMinVectorSize;
Expand Down Expand Up @@ -447,7 +424,8 @@ cl_int CustomConversionsTest::Run()
gMinVectorSize = 0;
}

IterOverSelectedTypes iter(typeIterator, *this, inType, outType);
IterOverSelectedTypes iter(typeIterator, *this, inType, outType, round,
sat);

iter.Run();

Expand All @@ -462,8 +440,6 @@ cl_int CustomConversionsTest::Run()
return gFailCount;
}

////////////////////////////////////////////////////////////////////////////////////////

ConversionsTest::ConversionsTest(cl_device_id device, cl_context context,
cl_command_queue queue)
: context(context), device(device), queue(queue), num_elements(0),
Expand All @@ -472,8 +448,6 @@ ConversionsTest::ConversionsTest(cl_device_id device, cl_context context,
cl_double(0), cl_ulong(0), cl_long(0) })
{}

////////////////////////////////////////////////////////////////////////////////////////

cl_int ConversionsTest::Run()
{
IterOverTypes iter(typeIterator, *this);
Expand All @@ -483,8 +457,6 @@ cl_int ConversionsTest::Run()
return gFailCount;
}

////////////////////////////////////////////////////////////////////////////////////////

cl_int ConversionsTest::SetUp(int elements)
{
num_elements = elements;
Expand Down Expand Up @@ -512,16 +484,14 @@ cl_int ConversionsTest::SetUp(int elements)
return CL_SUCCESS;
}

////////////////////////////////////////////////////////////////////////////////////////

template <typename InType, typename OutType, bool InFP, bool OutFP>
void ConversionsTest::TestTypesConversion(const Type &inType,
const Type &outType, int &testNumber)
const Type &outType, int &testNumber,
int startMinVectorSize)
{
SaturationMode sat;
RoundingMode round;
int error;
int startMinVectorSize = gMinVectorSize;

// skip longs on embedded
if (!gHasLong
Expand Down Expand Up @@ -609,8 +579,6 @@ void ConversionsTest::TestTypesConversion(const Type &inType,
}
}

////////////////////////////////////////////////////////////////////////////////////////

template <typename InType, typename OutType, bool InFP, bool OutFP>
int ConversionsTest::DoTest(Type outType, Type inType, SaturationMode sat,
RoundingMode round)
Expand All @@ -619,12 +587,8 @@ int ConversionsTest::DoTest(Type outType, Type inType, SaturationMode sat,
cl_ulong wall_start = mach_absolute_time();
#endif

#if 0
uint64_t lastCase = 1ULL << (8 * gTypeSizes[inType]);
#else
cl_uint threads = GetThreadCount();
uint64_t lastCase = 1000000ULL;
#endif

DataInitInfo info = { 0, 0, outType, inType, sat, round, threads };
DataInfoSpec<InType, OutType, InFP, OutFP> init_info(info);
Expand Down Expand Up @@ -689,11 +653,9 @@ int ConversionsTest::DoTest(Type outType, Type inType, SaturationMode sat,
init_info.round = round = kRoundTowardZero;
}

#if 0
// Figure out how many elements are in a work block
// we handle 64-bit types a bit differently.
if (8 * gTypeSizes[inType] > 32) lastCase = 0x100000000ULL;
#endif

if (!gWimpyMode && gIsEmbedded)
step = blockCount * EMBEDDED_REDUCTION_FACTOR;
Expand Down Expand Up @@ -996,16 +958,13 @@ double SubtractTime(uint64_t endTime, uint64_t startTime)
}
#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 CL_CALLBACK CalcReferenceValuesComplete(cl_event e, cl_int status,
Expand Down Expand Up @@ -1046,7 +1005,6 @@ void MapResultValuesComplete(const std::unique_ptr<CalcRefValsBase> &info)
// destroyed automatically soon after we exit.
}


void CL_CALLBACK CalcReferenceValuesComplete(cl_event e, cl_int status,
void *data)
{
Expand Down Expand Up @@ -1172,12 +1130,8 @@ void CL_CALLBACK CalcReferenceValuesComplete(cl_event e, cl_int status,
// CalcReferenceValuesComplete exit.
}

//////////////////////////////////////////////////////////////////////////////////////////

namespace conv_test {

////////////////////////////////////////////////////////////////////////////////

cl_int InitData(cl_uint job_id, cl_uint thread_id, void *p)
{
DataInitBase *info = (DataInitBase *)p;
Expand All @@ -1187,8 +1141,6 @@ cl_int InitData(cl_uint job_id, cl_uint thread_id, void *p)
return CL_SUCCESS;
}

////////////////////////////////////////////////////////////////////////////////

cl_int PrepareReference(cl_uint job_id, cl_uint thread_id, void *p)
{
DataInitBase *info = (DataInitBase *)p;
Expand All @@ -1205,7 +1157,6 @@ cl_int PrepareReference(cl_uint job_id, cl_uint thread_id, void *p)
void *a = (cl_uchar *)gAllowZ + job_id * count;
void *d = (cl_uchar *)gRef + job_id * count * gTypeSizes[info->outType];


if (outType != inType)
{
// create the reference while we wait
Expand Down Expand Up @@ -1344,8 +1295,6 @@ cl_int PrepareReference(cl_uint job_id, cl_uint thread_id, void *p)
return CL_SUCCESS;
}

////////////////////////////////////////////////////////////////////////////////

uint64_t GetTime(void)
{
#if defined(__APPLE__)
Expand All @@ -1360,8 +1309,6 @@ uint64_t GetTime(void)
#endif
}

////////////////////////////////////////////////////////////////////////////////

// Note: not called reentrantly
void WriteInputBufferComplete(void *data)
{
Expand Down Expand Up @@ -1422,8 +1369,6 @@ void WriteInputBufferComplete(void *data)
// automatically soon after we exit.
}

////////////////////////////////////////////////////////////////////////////////

cl_program MakeProgram(Type outType, Type inType, SaturationMode sat,
RoundingMode round, int vectorSize, cl_kernel *outKernel)
{
Expand Down Expand Up @@ -1554,8 +1499,6 @@ cl_program MakeProgram(Type outType, Type inType, SaturationMode sat,
return program;
}

//////////////////////////////////////////////////////////////////////////////////////////

int RunKernel(cl_kernel kernel, void *inBuf, void *outBuf, size_t blockCount)
{
// The global dimensions are just the blockCount to execute since we haven't
Expand All @@ -1581,8 +1524,6 @@ int RunKernel(cl_kernel kernel, void *inBuf, void *outBuf, size_t blockCount)
return 0;
}

////////////////////////////////////////////////////////////////////////////////////////

int GetTestCase(const char *name, Type *outType, Type *inType,
SaturationMode *sat, RoundingMode *round)
{
Expand Down Expand Up @@ -1639,6 +1580,3 @@ int GetTestCase(const char *name, Type *outType, Type *inType,
}

} // namespace conv_test


////////////////////////////////////////////////////////////////////////////////////////
Loading

0 comments on commit f815d9e

Please sign in to comment.