1
Fork 0
mirror of https://github.com/Steffo99/unimore-hpc-assignments.git synced 2024-11-26 10:04:23 +00:00
hpc-2022-g3/common/polybenchUtilFuncts.h

39 lines
576 B
C
Raw Normal View History

2022-11-11 12:23:45 +00:00
//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