MCPcopy Create free account
hub / github.com/KhronosGroup/OpenCL-CTS / generateRef

Function generateRef

test_conformance/printf/util_printf.cpp:2180–2265  ·  view source on GitHub ↗

Generate reference results. Results are only generated for test cases that can easily be generated by using CPU printf. If that is not the case, results are constants that have been hard-coded. */

Source from the content-addressed store, hash-verified

2178 snprintf(refResult, refSize, params.genericFormats.front().c_str(),
2179 cl_half_to_float(val));
2180}
2181
2182static void floatRefBuilder(printDataGenParameters& params, char* refResult, const size_t refSize)
2183{
2184 snprintf(refResult, refSize, params.genericFormats.front().c_str(),
2185 strtof(params.dataRepresentation, NULL));
2186}
2187
2188static bool floatRefTest(const char* refResult, const char* analysisBuffer)
2189{
2190 float test = strtof(analysisBuffer, NULL);
2191 float expected = strtof(refResult, NULL);
2192 return test == expected;
2193}
2194
2195static void doubleRefBuilder(printDataGenParameters& params, char* refResult,
2196 const size_t refSize)
2197{
2198 snprintf(refResult, refSize, params.genericFormats.front().c_str(),
2199 strtod(params.dataRepresentation, NULL));
2200}
2201
2202static bool doubleRefTest(const char* refResult, const char* analysisBuffer)
2203{
2204 double test = strtod(analysisBuffer, NULL);
2205 double expected = strtod(refResult, NULL);
2206 return test == expected;
2207}
2208
2209static void octalRefBuilder(printDataGenParameters& params, char* refResult, const size_t refSize)
2210{
2211 const unsigned long int data = strtoul(params.dataRepresentation, NULL, 10);
2212 snprintf(refResult, refSize, params.genericFormats.front().c_str(), data);
2213}
2214
2215static void unsignedRefBuilder(printDataGenParameters& params, char* refResult, const size_t refSize)
2216{
2217 const unsigned long int data = strtoul(params.dataRepresentation, NULL, 10);
2218 snprintf(refResult, refSize, params.genericFormats.front().c_str(), data);
2219}
2220
2221static void hexRefBuilder(printDataGenParameters& params, char* refResult, const size_t refSize)
2222{
2223 const unsigned long int data = strtoul(params.dataRepresentation, NULL, 0);
2224 snprintf(refResult, refSize, params.genericFormats.front().c_str(), data);
2225}
2226
2227/*
2228 Generate reference results.
2229
2230 Results are only generated for test cases
2231 that can easily be generated by using CPU
2232 printf.
2233
2234 If that is not the case, results are constants
2235 that have been hard-coded.
2236*/
2237void generateRef(const cl_device_id device)

Callers 1

InitCLFunction · 0.85

Calls 5

is_extension_availableFunction · 0.85
get_roundFunction · 0.85
set_roundFunction · 0.85
sizeMethod · 0.45

Tested by 1

InitCLFunction · 0.68