mirror of
https://github.com/Steffo99/unimore-hpc-assignments.git
synced 2024-11-24 09:04:23 +00:00
39 lines
No EOL
576 B
C
39 lines
No EOL
576 B
C
//polybenchUtilFuncts.h
|
|
//Scott Grauer-Gray (sgrauerg@gmail.com)
|
|
//Functions used across codes
|
|
|
|
#ifndef POLYBENCH_UTIL_FUNCTS_H
|
|
#define POLYBENCH_UTIL_FUNCTS_H
|
|
|
|
//define a small float value
|
|
#define SMALL_FLOAT_VAL 0.00000001f
|
|
|
|
|
|
float absVal(float a)
|
|
{
|
|
if(a < 0)
|
|
{
|
|
return (a * -1);
|
|
}
|
|
else
|
|
{
|
|
return a;
|
|
}
|
|
}
|
|
|
|
|
|
|
|
float percentDiff(double val1, double val2)
|
|
{
|
|
if ((absVal(val1) < 0.01) && (absVal(val2) < 0.01))
|
|
{
|
|
return 0.0f;
|
|
}
|
|
|
|
else
|
|
{
|
|
return 100.0f * (absVal(absVal(val1 - val2) / absVal(val1 + SMALL_FLOAT_VAL)));
|
|
}
|
|
}
|
|
|
|
#endif //POLYBENCH_UTIL_FUNCTS_H
|