From 616ef769ad558a2679111d3f38c49edc51aec562 Mon Sep 17 00:00:00 2001 From: Marcin Hajder Date: Thu, 15 Jun 2023 10:13:04 +0200 Subject: [PATCH] Added multiple corrections related to code review --- .../conversions/basic_test_conversions.cpp | 24 ++++------- .../conversions/basic_test_conversions.h | 20 ++++----- .../conversions/conversions_data_info.h | 42 +++++++++---------- 3 files changed, 37 insertions(+), 49 deletions(-) diff --git a/test_conformance/conversions/basic_test_conversions.cpp b/test_conformance/conversions/basic_test_conversions.cpp index 1fff7cb49c..4571be3c38 100644 --- a/test_conformance/conversions/basic_test_conversions.cpp +++ b/test_conformance/conversions/basic_test_conversions.cpp @@ -283,10 +283,9 @@ static inline void Force64BitFPUPrecision(void) } -template -int CalcRefValsPat::check_result(void *test, - uint32_t count, - int vectorSize) +template +int CalcRefValsPat::check_result(void *test, uint32_t count, + int vectorSize) { const cl_uchar *a = (const cl_uchar *)gAllowZ; @@ -449,7 +448,7 @@ cl_int ConversionsTest::SetUp(int elements) } -template +template void ConversionsTest::TestTypesConversion(const Type &inType, const Type &outType, int &testNumber) { @@ -517,8 +516,7 @@ void ConversionsTest::TestTypesConversion(const Type &inType, gMinVectorSize = 0; } - if ((error = DoTest(outType, inType, - sat, round))) + if ((error = DoTest(outType, inType, sat, round))) { vlog_error("\t *** %d) convert_%sn%s%s( %sn ) " "FAILED ** \n", @@ -531,7 +529,7 @@ void ConversionsTest::TestTypesConversion(const Type &inType, } -template +template int ConversionsTest::DoTest(Type outType, Type inType, SaturationMode sat, RoundingMode round) { @@ -539,15 +537,11 @@ 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 init_info(info); + DataInfoSpec init_info(info); WriteInputBufferInfo writeInputBufferInfo; int vectorSize; int error = 0; @@ -570,7 +564,7 @@ int ConversionsTest::DoTest(Type outType, Type inType, SaturationMode sat, for (vectorSize = gMinVectorSize; vectorSize < gMaxVectorSize; vectorSize++) { writeInputBufferInfo.calcInfo[vectorSize].reset( - new CalcRefValsPat()); + new CalcRefValsPat()); writeInputBufferInfo.calcInfo[vectorSize]->program = conv_test::MakeProgram( outType, inType, sat, round, vectorSize, @@ -604,11 +598,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; diff --git a/test_conformance/conversions/basic_test_conversions.h b/test_conformance/conversions/basic_test_conversions.h index 23f959532a..cf0e2c66a7 100644 --- a/test_conformance/conversions/basic_test_conversions.h +++ b/test_conformance/conversions/basic_test_conversions.h @@ -135,7 +135,7 @@ struct CalcRefValsBase cl_int result; }; -template +template struct CalcRefValsPat : CalcRefValsBase { int check_result(void *, uint32_t, int) override; @@ -165,12 +165,12 @@ struct WriteInputBufferInfo using TypeIter = std::tuple; -constexpr bool isTypeFp[] = { 0, 0, 0, 0, 0, 0, 1, 1, 0, 0 }; - // Helper test fixture for constructing OpenCL objects used in testing // a variety of simple command-buffer enqueue scenarios. struct ConversionsTest { + virtual ~ConversionsTest() = default; + ConversionsTest(cl_device_id device, cl_context context, cl_command_queue queue); @@ -179,11 +179,11 @@ struct ConversionsTest // Test body returning an OpenCL error code cl_int Run(); - template + template int DoTest(Type outType, Type inType, SaturationMode sat, RoundingMode round); - template + template void TestTypesConversion(const Type &inType, const Type &outType, int &tn); protected: @@ -210,7 +210,7 @@ template int MakeAndRunTest(cl_device_id device, cl_context context, cl_command_queue queue, int num_elements) { - auto test_fixture = T(device, context, queue); + T test_fixture(device, context, queue); cl_int error = test_fixture.SetUp(num_elements); test_error_ret(error, "Error in test initialization", TEST_FAIL); @@ -267,8 +267,7 @@ struct IterOverTypes : public TestType if (!testType(outType)) vlog_error("Unexpected data type!\n"); // run the conversions - test.TestTypesConversion( - inType, outType, testNumber); + test.TestTypesConversion(inType, outType, testNumber); inType = (Type)(inType + 1); } @@ -336,9 +335,8 @@ struct IterOverSelectedTypes : public TestType if (testType(inType) && testType(outType)) { // run the conversions - test.TestTypesConversion(inType, outType, - testNumber); + test.TestTypesConversion(inType, outType, + testNumber); } } diff --git a/test_conformance/conversions/conversions_data_info.h b/test_conformance/conversions/conversions_data_info.h index d1f42ce36c..b02773b1ff 100644 --- a/test_conformance/conversions/conversions_data_info.h +++ b/test_conformance/conversions/conversions_data_info.h @@ -60,7 +60,6 @@ struct DataInitInfo RoundingMode round; cl_uint threads; - static std::vector specialValuesUInt; static std::vector specialValuesFloat; static std::vector specialValuesDouble; @@ -68,13 +67,15 @@ struct DataInitInfo struct DataInitBase : public DataInitInfo { + virtual ~DataInitBase() = default; + explicit DataInitBase(const DataInitInfo &agg): DataInitInfo(agg) {} 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 init(const cl_uint &, const cl_uint &) {} }; -template +template struct DataInfoSpec : public DataInitBase { explicit DataInfoSpec(const DataInitInfo &agg); @@ -124,9 +125,8 @@ struct DataInfoSpec : public DataInitBase } }; -template -DataInfoSpec::DataInfoSpec( - const DataInitInfo &agg) +template +DataInfoSpec::DataInfoSpec(const DataInitInfo &agg) : DataInitBase(agg), mdv(0) { if (std::is_same::value) @@ -252,8 +252,8 @@ DataInfoSpec::DataInfoSpec( // clang-format on } -template -float DataInfoSpec::round_to_int(float f) +template +float DataInfoSpec::round_to_int(float f) { static const float magic[2] = { MAKE_HEX_FLOAT(0x1.0p23f, 0x1, 23), -MAKE_HEX_FLOAT(0x1.0p23f, 0x1, 23) }; @@ -281,9 +281,8 @@ float DataInfoSpec::round_to_int(float f) return f; } -template -long long -DataInfoSpec::round_to_int_and_clamp(double f) +template +long long DataInfoSpec::round_to_int_and_clamp(double f) { static const double magic[2] = { MAKE_HEX_DOUBLE(0x1.0p52, 0x1LL, 52), MAKE_HEX_DOUBLE(-0x1.0p52, -0x1LL, 52) }; @@ -314,8 +313,8 @@ DataInfoSpec::round_to_int_and_clamp(double f) return (long long)f; } -template -OutType DataInfoSpec::absolute(const OutType &x) +template +OutType DataInfoSpec::absolute(const OutType &x) { union { cl_uint u; @@ -332,8 +331,8 @@ OutType DataInfoSpec::absolute(const OutType &x) return u.f; } -template -void DataInfoSpec::conv(OutType *out, InType *in) +template +void DataInfoSpec::conv(OutType *out, InType *in) { if (std::is_same::value) { @@ -480,9 +479,8 @@ void DataInfoSpec::conv(OutType *out, InType *in) #define CLAMP(_lo, _x, _hi) \ ((_x) < (_lo) ? (_lo) : ((_x) > (_hi) ? (_hi) : (_x))) -template -void DataInfoSpec::conv_sat(OutType *out, - InType *in) +template +void DataInfoSpec::conv_sat(OutType *out, InType *in) { if (std::is_floating_point::value) { @@ -599,9 +597,9 @@ void DataInfoSpec::conv_sat(OutType *out, } } -template -void DataInfoSpec::init(const cl_uint &job_id, - const cl_uint &thread_id) +template +void DataInfoSpec::init(const cl_uint &job_id, + const cl_uint &thread_id) { uint64_t ulStart = start; void *pIn = (char *)gIn + job_id * size * gTypeSizes[inType]; @@ -761,8 +759,8 @@ void DataInfoSpec::init(const cl_uint &job_id, } } -template -InType DataInfoSpec::clamp(const InType &in) +template +InType DataInfoSpec::clamp(const InType &in) { if (std::is_integral::value) {