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. */
| 2178 | snprintf(refResult, refSize, params.genericFormats.front().c_str(), |
| 2179 | cl_half_to_float(val)); |
| 2180 | } |
| 2181 | |
| 2182 | static 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 | |
| 2188 | static 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 | |
| 2195 | static 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 | |
| 2202 | static 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 | |
| 2209 | static 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 | |
| 2215 | static 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 | |
| 2221 | static 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 | */ |
| 2237 | void generateRef(const cl_device_id device) |