MCPcopy Create free account
hub / github.com/clMathLibraries/clFFT / compare

Function compare

src/callback-client/callback-client.cpp:487–517  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

485//Compare reference and opencl output
486template < typename T1, typename T2>
487bool compare(T1 *refData, std::vector< T2 > data,
488 size_t length, const float epsilon)
489{
490 float error = 0.0f;
491 T1 ref;
492 T1 diff;
493 float normRef = 0.0f;
494 float normError = 0.0f;
495
496 for(size_t i = 0; i < length; ++i)
497 {
498 diff[0] = refData[i][0] - data[i];
499 error += (float)(diff[0] * diff[0]);
500 ref[0] += refData[i][0] * refData[i][0];
501 }
502 if (error != 0)
503 {
504 normRef =::sqrtf((float) ref[0]);
505 if (::fabs((float) ref[0]) < 1e-7f)
506 {
507 return false;
508 }
509 normError = ::sqrtf((float) error);
510 error = normError / normRef;
511
512 if (error > epsilon)
513 return false;
514 }
515
516 return true;
517 }
518
519// Compute reference output using fftw for float type
520fftwf_complex* get_R2C_fftwf_output(size_t* lengths, size_t fftbatchLength, int batch_size,

Callers

nothing calls this directly

Calls

no outgoing calls

Tested by

no test coverage detected