diff options
author | rander <rander.wang@intel.com> | 2017-04-06 11:07:07 +0800 |
---|---|---|
committer | Yang Rong <rong.r.yang@intel.com> | 2017-05-04 19:08:31 +0800 |
commit | 0c29e8b57ba4d2bba65e756fa518c03a7eab10bb (patch) | |
tree | e346accdc919c3eae0d317501401df24e6e5d953 | |
parent | acd4388c6c85c4a7bf1ef7ab570dd2d5355e742e (diff) | |
download | beignet-0c29e8b57ba4d2bba65e756fa518c03a7eab10bb.tar.gz |
backend: refine modf to pass the cft
Signed-off-by: rander.wang <rander.wang@intel.com>
Tested-by: Yang Rong <rong.r.yang@intel.com>
-rw-r--r-- | backend/src/libocl/tmpl/ocl_math.tmpl.cl | 69 | ||||
-rw-r--r-- | backend/src/libocl/tmpl/ocl_math_20.tmpl.cl | 23 |
2 files changed, 84 insertions, 8 deletions
diff --git a/backend/src/libocl/tmpl/ocl_math.tmpl.cl b/backend/src/libocl/tmpl/ocl_math.tmpl.cl index 14414af6..98e295a1 100644 --- a/backend/src/libocl/tmpl/ocl_math.tmpl.cl +++ b/backend/src/libocl/tmpl/ocl_math.tmpl.cl @@ -4509,22 +4509,79 @@ OVERLOADABLE double lgamma_r(double x, private int *signgamp) OVERLOADABLE double modf(double x, global double *i) { - double retVal = floor(x); - *i = retVal; + if(x == as_double(DF_POSITIVE_INF)) + { + *i = x; + return 0.0; + } + + if(-x == as_double(DF_POSITIVE_INF)) + { + *i = x; + return -0.0; + } + + double retVal = floor(fabs(x)); + if(x >= 0.0) + *i = retVal; + else + { + retVal = -retVal; + *i = retVal; + } + return x - retVal; } OVERLOADABLE double modf(double x, local double *i) { - double retVal = floor(x); - *i = retVal; + if(x == as_double(DF_POSITIVE_INF)) + { + *i = x; + return 0.0; + } + + if(-x == as_double(DF_POSITIVE_INF)) + { + *i = x; + return -0.0; + } + + double retVal = floor(fabs(x)); + if(x >= 0.0) + *i = retVal; + else + { + retVal = -retVal; + *i = retVal; + } + return x - retVal; } OVERLOADABLE double modf(double x, private double *i) { - double retVal = floor(x); - *i = retVal; + if(x == as_double(DF_POSITIVE_INF)) + { + *i = x; + return 0.0; + } + + if(-x == as_double(DF_POSITIVE_INF)) + { + *i = x; + return -0.0; + } + + double retVal = floor(fabs(x)); + if(x >= 0.0) + *i = retVal; + else + { + retVal = -retVal; + *i = retVal; + } + return x - retVal; } diff --git a/backend/src/libocl/tmpl/ocl_math_20.tmpl.cl b/backend/src/libocl/tmpl/ocl_math_20.tmpl.cl index e01401b3..ba35ddd5 100644 --- a/backend/src/libocl/tmpl/ocl_math_20.tmpl.cl +++ b/backend/src/libocl/tmpl/ocl_math_20.tmpl.cl @@ -4036,8 +4036,27 @@ OVERLOADABLE double lgamma_r(double x, int *signgamp) OVERLOADABLE double modf(double x, double *i) { - double retVal = floor(x); - *i = retVal; + if(x == as_double(DF_POSITIVE_INF)) + { + *i = x; + return 0.0; + } + + if(-x == as_double(DF_POSITIVE_INF)) + { + *i = x; + return -0.0; + } + + double retVal = floor(fabs(x)); + if(x >= 0.0) + *i = retVal; + else + { + retVal = -retVal; + *i = retVal; + } + return x - retVal; } |