diff --git a/test_conformance/math_brute_force/Utility.h b/test_conformance/math_brute_force/Utility.h index 7be12874..5bd6369d 100644 --- a/test_conformance/math_brute_force/Utility.h +++ b/test_conformance/math_brute_force/Utility.h @@ -229,6 +229,36 @@ void logFunctionInfo(const char *fname, unsigned int float_size, unsigned int is float getAllowedUlpError(const Func *f, const bool relaxed); +static inline cl_uint setTestScale(size_t typeSize) +{ + if (gWimpyMode) + { + return (cl_uint)typeSize * 2 * gWimpyReductionFactor; + } + else if (gIsEmbedded) + { + return EMBEDDED_REDUCTION_FACTOR; + } + else + { + return 1; + } +} + +static inline uint64_t setTestStep(size_t typeSize, size_t bufferSize) +{ + if (gWimpyMode) + { + return (1ULL << 32) * gWimpyReductionFactor / (512); + } + else if (gIsEmbedded) + { + return (BUFFER_SIZE / typeSize) * EMBEDDED_REDUCTION_FACTOR; + } + else + { + return bufferSize / typeSize; + } +} + #endif /* UTILITY_H */ - - diff --git a/test_conformance/math_brute_force/binary.cpp b/test_conformance/math_brute_force/binary.cpp index 2e61d86e..ed769ead 100644 --- a/test_conformance/math_brute_force/binary.cpp +++ b/test_conformance/math_brute_force/binary.cpp @@ -277,15 +277,10 @@ int TestFunc_Float_Float_Float_common(const Func *f, MTdata d, int isNextafter, memset( &test_info, 0, sizeof( test_info ) ); test_info.threadCount = GetThreadCount(); test_info.subBufferSize = BUFFER_SIZE / (sizeof( cl_float) * RoundUpToNextPowerOfTwo(test_info.threadCount)); - test_info.scale = 1; + test_info.scale = setTestScale(sizeof(cl_float)); if (gWimpyMode){ test_info.subBufferSize = gWimpyBufferSize / (sizeof( cl_float) * RoundUpToNextPowerOfTwo(test_info.threadCount)); - test_info.scale = (cl_uint) sizeof(cl_float) * 2 * gWimpyReductionFactor; - } - else if (gIsEmbedded) - { - test_info.scale *= EMBEDDED_REDUCTION_FACTOR; } test_info.step = (cl_uint) test_info.subBufferSize * test_info.scale; @@ -1019,16 +1014,11 @@ int TestFunc_Double_Double_Double_common(const Func *f, MTdata d, memset( &test_info, 0, sizeof( test_info ) ); test_info.threadCount = GetThreadCount(); test_info.subBufferSize = BUFFER_SIZE / (sizeof( cl_double) * RoundUpToNextPowerOfTwo(test_info.threadCount)); - test_info.scale = 1; + test_info.scale = setTestScale(sizeof(cl_double)); if (gWimpyMode){ test_info.subBufferSize = gWimpyBufferSize / (sizeof( cl_double) * RoundUpToNextPowerOfTwo(test_info.threadCount)); - test_info.scale = (cl_uint) sizeof(cl_double) * 2 * gWimpyReductionFactor; - } - else if (gIsEmbedded) - { - test_info.scale *= EMBEDDED_REDUCTION_FACTOR; } test_info.step = (cl_uint) test_info.subBufferSize * test_info.scale; diff --git a/test_conformance/math_brute_force/binaryOperator.cpp b/test_conformance/math_brute_force/binaryOperator.cpp index 26c7cc4c..13bad4fc 100644 --- a/test_conformance/math_brute_force/binaryOperator.cpp +++ b/test_conformance/math_brute_force/binaryOperator.cpp @@ -269,14 +269,9 @@ int TestFunc_Float_Float_Float_Operator(const Func *f, MTdata d, memset( &test_info, 0, sizeof( test_info ) ); test_info.threadCount = GetThreadCount(); test_info.subBufferSize = BUFFER_SIZE / (sizeof( cl_float) * RoundUpToNextPowerOfTwo(test_info.threadCount)); - test_info.scale = 1; + test_info.scale = setTestScale(sizeof(cl_float)); if (gWimpyMode) { test_info.subBufferSize = gWimpyBufferSize / (sizeof( cl_float) * RoundUpToNextPowerOfTwo(test_info.threadCount)); - test_info.scale = (cl_uint) sizeof(cl_float) * 2 * gWimpyReductionFactor; - } - else if (gIsEmbedded) - { - test_info.scale *= EMBEDDED_REDUCTION_FACTOR; } test_info.step = test_info.subBufferSize * test_info.scale; @@ -967,15 +962,10 @@ int TestFunc_Double_Double_Double_Operator(const Func *f, MTdata d, memset( &test_info, 0, sizeof( test_info ) ); test_info.threadCount = GetThreadCount(); test_info.subBufferSize = BUFFER_SIZE / (sizeof( cl_double) * RoundUpToNextPowerOfTwo(test_info.threadCount)); - test_info.scale = 1; + test_info.scale = setTestScale(sizeof(cl_double)); if (gWimpyMode) { test_info.subBufferSize = gWimpyBufferSize / (sizeof( cl_double) * RoundUpToNextPowerOfTwo(test_info.threadCount)); - test_info.scale = (cl_uint) sizeof(cl_double) * 2 * gWimpyReductionFactor; - } - else if (gIsEmbedded) - { - test_info.scale *= EMBEDDED_REDUCTION_FACTOR; } test_info.step = (cl_uint) test_info.subBufferSize * test_info.scale; diff --git a/test_conformance/math_brute_force/binary_i.cpp b/test_conformance/math_brute_force/binary_i.cpp index 1f2e9be3..81ffee3c 100644 --- a/test_conformance/math_brute_force/binary_i.cpp +++ b/test_conformance/math_brute_force/binary_i.cpp @@ -266,15 +266,11 @@ int TestFunc_Float_Float_Int(const Func *f, MTdata d, bool relaxedMode) memset( &test_info, 0, sizeof( test_info ) ); test_info.threadCount = GetThreadCount(); test_info.subBufferSize = BUFFER_SIZE / (sizeof( cl_float) * RoundUpToNextPowerOfTwo(test_info.threadCount)); - test_info.scale = 1; + test_info.scale = setTestScale(sizeof(cl_float)); + if (gWimpyMode) { test_info.subBufferSize = gWimpyBufferSize / (sizeof( cl_float) * RoundUpToNextPowerOfTwo(test_info.threadCount)); - test_info.scale = (cl_uint) sizeof(cl_float) * 2 * gWimpyReductionFactor; - } - else if (gIsEmbedded) - { - test_info.scale *= EMBEDDED_REDUCTION_FACTOR; } test_info.step = (cl_uint) test_info.subBufferSize * test_info.scale; @@ -785,15 +781,10 @@ int TestFunc_Double_Double_Int(const Func *f, MTdata d, bool relaxedMode) memset( &test_info, 0, sizeof( test_info ) ); test_info.threadCount = GetThreadCount(); test_info.subBufferSize = BUFFER_SIZE / (sizeof( cl_double) * RoundUpToNextPowerOfTwo(test_info.threadCount)); - test_info.scale = 1; + test_info.scale = setTestScale(sizeof(cl_double)); if (gWimpyMode) { test_info.subBufferSize = gWimpyBufferSize / (sizeof( cl_double) * RoundUpToNextPowerOfTwo(test_info.threadCount)); - test_info.scale = (cl_uint) sizeof(cl_double) * 2 * gWimpyReductionFactor; - } - else if (gIsEmbedded) - { - test_info.scale *= EMBEDDED_REDUCTION_FACTOR; } test_info.step = (cl_uint) test_info.subBufferSize * test_info.scale; diff --git a/test_conformance/math_brute_force/binary_two_results_i.cpp b/test_conformance/math_brute_force/binary_two_results_i.cpp index 5d794010..60d05158 100644 --- a/test_conformance/math_brute_force/binary_two_results_i.cpp +++ b/test_conformance/math_brute_force/binary_two_results_i.cpp @@ -287,21 +287,13 @@ int TestFunc_FloatI_Float_Float(const Func *f, MTdata d, bool relaxedMode) float maxErrorVal = 0.0f; float maxErrorVal2 = 0.0f; size_t bufferSize = (gWimpyMode)? gWimpyBufferSize: BUFFER_SIZE; - uint64_t step = bufferSize / sizeof( float ); + uint64_t step = setTestStep(sizeof(float), bufferSize); #if defined PARALLEL_REFERENCE cl_uint threadCount = GetThreadCount(); #endif logFunctionInfo(f->name, sizeof(cl_float), relaxedMode); - if(gWimpyMode ){ - step = (1ULL<<32) * gWimpyReductionFactor / (512); - } - else if (gIsEmbedded) - { - step = (BUFFER_SIZE / sizeof(float)) * EMBEDDED_REDUCTION_FACTOR; - } - if( gIsEmbedded ) float_ulps = f->float_embedded_ulps; else @@ -720,16 +712,9 @@ int TestFunc_DoubleI_Double_Double(const Func *f, MTdata d, bool relaxedMode) double maxErrorVal = 0.0f; double maxErrorVal2 = 0.0f; size_t bufferSize = (gWimpyMode)? gWimpyBufferSize: BUFFER_SIZE; - uint64_t step = bufferSize / sizeof( double ); + uint64_t step = setTestStep(sizeof(double), bufferSize); logFunctionInfo(f->name, sizeof(cl_double), relaxedMode); - if(gWimpyMode ){ - step = (1ULL<<32) * gWimpyReductionFactor / (512); - } - else if (gIsEmbedded) - { - step = (BUFFER_SIZE / sizeof(double)) * EMBEDDED_REDUCTION_FACTOR; - } #if defined PARALLEL_REFERENCE cl_uint threadCount = GetThreadCount(); diff --git a/test_conformance/math_brute_force/i_unary.cpp b/test_conformance/math_brute_force/i_unary.cpp index 50e1f1af..f6b709d5 100644 --- a/test_conformance/math_brute_force/i_unary.cpp +++ b/test_conformance/math_brute_force/i_unary.cpp @@ -191,18 +191,10 @@ int TestFunc_Int_Float(const Func *f, MTdata d, bool relaxedMode) cl_kernel kernels[ VECTOR_SIZE_COUNT ]; int ftz = f->ftz || 0 == (gFloatCapabilities & CL_FP_DENORM) || gForceFTZ; size_t bufferSize = (gWimpyMode)?gWimpyBufferSize:BUFFER_SIZE; - uint64_t step = bufferSize / sizeof( float ); + uint64_t step = setTestStep(sizeof(float), bufferSize); int scale = (int)((1ULL<<32) / (16 * bufferSize / sizeof( float )) + 1); logFunctionInfo(f->name, sizeof(cl_float), relaxedMode); - if( gWimpyMode ) - { - step = (1ULL<<32) * gWimpyReductionFactor / (512); - } - else if (gIsEmbedded) - { - step = (BUFFER_SIZE / sizeof(cl_float)) * EMBEDDED_REDUCTION_FACTOR; - } // This test is not using ThreadPool so we need to disable FTZ here // for reference computations @@ -416,18 +408,10 @@ int TestFunc_Int_Double(const Func *f, MTdata d, bool relaxedMode) cl_kernel kernels[ VECTOR_SIZE_COUNT ]; int ftz = f->ftz || gForceFTZ; size_t bufferSize = (gWimpyMode)?gWimpyBufferSize:BUFFER_SIZE; - uint64_t step = bufferSize / sizeof( cl_double ); + uint64_t step = setTestStep(sizeof(cl_double), bufferSize); int scale = (int)((1ULL<<32) / (16 * bufferSize / sizeof( cl_double )) + 1); logFunctionInfo(f->name, sizeof(cl_double), relaxedMode); - if( gWimpyMode ) - { - step = (1ULL<<32) * gWimpyReductionFactor / (512); - } - else if (gIsEmbedded) - { - step = (BUFFER_SIZE / sizeof(cl_double)) * EMBEDDED_REDUCTION_FACTOR; - } // This test is not using ThreadPool so we need to disable FTZ here // for reference computations diff --git a/test_conformance/math_brute_force/macro_binary.cpp b/test_conformance/math_brute_force/macro_binary.cpp index a4e4f97b..8b51d86e 100644 --- a/test_conformance/math_brute_force/macro_binary.cpp +++ b/test_conformance/math_brute_force/macro_binary.cpp @@ -253,15 +253,10 @@ int TestMacro_Int_Float_Float(const Func *f, MTdata d, bool relaxedMode) memset( &test_info, 0, sizeof( test_info ) ); test_info.threadCount = GetThreadCount(); test_info.subBufferSize = BUFFER_SIZE / (sizeof( cl_float) * RoundUpToNextPowerOfTwo(test_info.threadCount)); - test_info.scale = 1; + test_info.scale = setTestScale(sizeof(cl_float)); if (gWimpyMode) { test_info.subBufferSize = gWimpyBufferSize / (sizeof( cl_float) * RoundUpToNextPowerOfTwo(test_info.threadCount)); - test_info.scale = (cl_uint) sizeof(cl_float) * 2 * gWimpyReductionFactor; - } - else if (gIsEmbedded) - { - test_info.scale *= EMBEDDED_REDUCTION_FACTOR; } test_info.step = (cl_uint) test_info.subBufferSize * test_info.scale; @@ -770,15 +765,10 @@ int TestMacro_Int_Double_Double(const Func *f, MTdata d, bool relaxedMode) memset( &test_info, 0, sizeof( test_info ) ); test_info.threadCount = GetThreadCount(); test_info.subBufferSize = BUFFER_SIZE / (sizeof( cl_double) * RoundUpToNextPowerOfTwo(test_info.threadCount)); - test_info.scale = 1; + test_info.scale = setTestScale(sizeof(cl_double)); if (gWimpyMode) { test_info.subBufferSize = gWimpyBufferSize / (sizeof( cl_double) * RoundUpToNextPowerOfTwo(test_info.threadCount)); - test_info.scale = (cl_uint) sizeof(cl_double) * 2 * gWimpyReductionFactor; - } - else if (gIsEmbedded) - { - test_info.scale *= EMBEDDED_REDUCTION_FACTOR; } test_info.step = (cl_uint) test_info.subBufferSize * test_info.scale; diff --git a/test_conformance/math_brute_force/macro_unary.cpp b/test_conformance/math_brute_force/macro_unary.cpp index 773bf0b4..c74e1aee 100644 --- a/test_conformance/math_brute_force/macro_unary.cpp +++ b/test_conformance/math_brute_force/macro_unary.cpp @@ -224,15 +224,10 @@ int TestMacro_Int_Float(const Func *f, MTdata d, bool relaxedMode) memset( &test_info, 0, sizeof( test_info ) ); test_info.threadCount = GetThreadCount(); test_info.subBufferSize = BUFFER_SIZE / (sizeof( cl_float) * RoundUpToNextPowerOfTwo(test_info.threadCount)); - test_info.scale = 1; + test_info.scale = setTestScale(sizeof(cl_float)); if (gWimpyMode ) { test_info.subBufferSize = gWimpyBufferSize / (sizeof( cl_float) * RoundUpToNextPowerOfTwo(test_info.threadCount)); - test_info.scale = (cl_uint) sizeof(cl_float) * 2 * gWimpyReductionFactor; - } - else if (gIsEmbedded) - { - test_info.scale *= EMBEDDED_REDUCTION_FACTOR; } test_info.step = (cl_uint) test_info.subBufferSize * test_info.scale; @@ -628,15 +623,10 @@ int TestMacro_Int_Double(const Func *f, MTdata d, bool relaxedMode) memset( &test_info, 0, sizeof( test_info ) ); test_info.threadCount = GetThreadCount(); test_info.subBufferSize = BUFFER_SIZE / (sizeof( cl_double) * RoundUpToNextPowerOfTwo(test_info.threadCount)); - test_info.scale = 1; + test_info.scale = setTestScale(sizeof(cl_double)); if (gWimpyMode ) { test_info.subBufferSize = gWimpyBufferSize / (sizeof( cl_double) * RoundUpToNextPowerOfTwo(test_info.threadCount)); - test_info.scale = (cl_uint) sizeof(cl_double) * 2 * gWimpyReductionFactor; - } - else if (gIsEmbedded) - { - test_info.scale *= EMBEDDED_REDUCTION_FACTOR; } test_info.step = (cl_uint) test_info.subBufferSize * test_info.scale; diff --git a/test_conformance/math_brute_force/mad.cpp b/test_conformance/math_brute_force/mad.cpp index 314caaeb..19eb9920 100644 --- a/test_conformance/math_brute_force/mad.cpp +++ b/test_conformance/math_brute_force/mad.cpp @@ -207,16 +207,7 @@ int TestFunc_mad(const Func *f, MTdata d, bool relaxedMode) float maxErrorVal2 = 0.0f; float maxErrorVal3 = 0.0f; size_t bufferSize = (gWimpyMode)? gWimpyBufferSize: BUFFER_SIZE; - uint64_t step = bufferSize / sizeof( float ); - - if( gWimpyMode ) - { - step = (1ULL<<32) * gWimpyReductionFactor / (512); - } - else if (gIsEmbedded) - { - step = (BUFFER_SIZE / sizeof(float)) * EMBEDDED_REDUCTION_FACTOR; - } + uint64_t step = setTestStep(sizeof(float), bufferSize); // Init the kernels BuildKernelInfo build_info = { gMinVectorSizeIndex, kernels, programs, @@ -680,15 +671,7 @@ int TestFunc_mad_Double(const Func *f, MTdata d, bool relaxedMode) size_t bufferSize = (gWimpyMode)? gWimpyBufferSize: BUFFER_SIZE; logFunctionInfo(f->name, sizeof(cl_double), relaxedMode); - uint64_t step = bufferSize / sizeof( double ); - if( gWimpyMode ) - { - step = (1ULL<<32) * gWimpyReductionFactor / (512); - } - else if (gIsEmbedded) - { - step = (BUFFER_SIZE / sizeof(double)) * EMBEDDED_REDUCTION_FACTOR; - } + uint64_t step = setTestStep(sizeof(double), bufferSize); // Init the kernels BuildKernelInfo build_info = { gMinVectorSizeIndex, kernels, programs, diff --git a/test_conformance/math_brute_force/ternary.cpp b/test_conformance/math_brute_force/ternary.cpp index 4ca38327..6ba30684 100644 --- a/test_conformance/math_brute_force/ternary.cpp +++ b/test_conformance/math_brute_force/ternary.cpp @@ -228,20 +228,12 @@ int TestFunc_Float_Float_Float_Float(const Func *f, MTdata d, bool relaxedMode) float maxErrorVal3 = 0.0f; size_t bufferSize = (gWimpyMode)? gWimpyBufferSize: BUFFER_SIZE; - uint64_t step = bufferSize / sizeof( float ); + uint64_t step = setTestStep(sizeof(float), bufferSize); int skipNanInf = (0 == strcmp( "fma", f->nameInCode )) && ! gInfNanSupport; cl_uchar overflow[BUFFER_SIZE / sizeof( float )]; float float_ulps; logFunctionInfo(f->name, sizeof(cl_float), relaxedMode); - if( gWimpyMode ) - { - step = (1ULL<<32) * gWimpyReductionFactor / (512); - } - else if (gIsEmbedded) - { - step = (BUFFER_SIZE / sizeof(float)) * EMBEDDED_REDUCTION_FACTOR; - } if( gIsEmbedded ) float_ulps = f->float_embedded_ulps; @@ -878,15 +870,7 @@ int TestFunc_Double_Double_Double_Double(const Func *f, MTdata d, logFunctionInfo(f->name, sizeof(cl_double), relaxedMode); size_t bufferSize = (gWimpyMode)? gWimpyBufferSize: BUFFER_SIZE; - uint64_t step = bufferSize / sizeof( double ); - if( gWimpyMode ) - { - step = (1ULL<<32) * gWimpyReductionFactor / (512); - } - else if (gIsEmbedded) - { - step = (BUFFER_SIZE / sizeof(double)) * EMBEDDED_REDUCTION_FACTOR; - } + uint64_t step = setTestStep(sizeof(double), bufferSize); Force64BitFPUPrecision(); diff --git a/test_conformance/math_brute_force/unary.cpp b/test_conformance/math_brute_force/unary.cpp index 4605e34f..5de61c25 100644 --- a/test_conformance/math_brute_force/unary.cpp +++ b/test_conformance/math_brute_force/unary.cpp @@ -240,15 +240,10 @@ int TestFunc_Float_Float(const Func *f, MTdata d, bool relaxedMode) test_info.threadCount = GetThreadCount(); test_info.subBufferSize = BUFFER_SIZE / (sizeof( cl_float) * RoundUpToNextPowerOfTwo(test_info.threadCount)); - test_info.scale = 1; + test_info.scale = setTestScale(sizeof(cl_float)); if (gWimpyMode) { test_info.subBufferSize = gWimpyBufferSize / (sizeof( cl_float) * RoundUpToNextPowerOfTwo(test_info.threadCount)); - test_info.scale = (cl_uint) sizeof(cl_float) * 2 * gWimpyReductionFactor; - } - else if (gIsEmbedded) - { - test_info.scale *= EMBEDDED_REDUCTION_FACTOR; } test_info.step = (cl_uint) test_info.subBufferSize * test_info.scale; @@ -1032,15 +1027,10 @@ int TestFunc_Double_Double(const Func *f, MTdata d, bool relaxedMode) memset( &test_info, 0, sizeof( test_info ) ); test_info.threadCount = GetThreadCount(); test_info.subBufferSize = BUFFER_SIZE / (sizeof( cl_double) * RoundUpToNextPowerOfTwo(test_info.threadCount)); - test_info.scale = 1; + test_info.scale = setTestScale(sizeof(cl_double)); if (gWimpyMode) { test_info.subBufferSize = gWimpyBufferSize / (sizeof( cl_double) * RoundUpToNextPowerOfTwo(test_info.threadCount)); - test_info.scale = (cl_uint) sizeof(cl_double) * 2 * gWimpyReductionFactor; - } - else if (gIsEmbedded) - { - test_info.scale *= EMBEDDED_REDUCTION_FACTOR; } test_info.step = (cl_uint) test_info.subBufferSize * test_info.scale;