1
Fork 0
mirror of https://github.com/Steffo99/unimore-hpc-assignments.git synced 2024-11-23 00:24:23 +00:00
hpc-2022-g3/common/polybenchUtilFuncts.h
Alessandro Capotondi e11b42a518 init commit
2022-11-11 13:23:45 +01:00

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