From ab5516248147677ff112bf0a13d7cb04e45a970f Mon Sep 17 00:00:00 2001 From: Ben Sander Date: Tue, 11 Apr 2017 01:16:28 +0000 Subject: [PATCH] Add integer abs (initial implementation, can be optimized with OCML) Change-Id: I1f568c8c0e2333af1fda4c313dc48ea0c5b6ab00 [ROCm/clr commit: 8bd34535b4422c36c40bc8f51e54c1e7a20805ab] --- projects/clr/hipamd/include/hip/hcc_detail/math_functions.h | 1 + projects/clr/hipamd/src/math_functions.cpp | 4 ++++ 2 files changed, 5 insertions(+) diff --git a/projects/clr/hipamd/include/hip/hcc_detail/math_functions.h b/projects/clr/hipamd/include/hip/hcc_detail/math_functions.h index c3b8186fd3..9faff2743a 100644 --- a/projects/clr/hipamd/include/hip/hcc_detail/math_functions.h +++ b/projects/clr/hipamd/include/hip/hcc_detail/math_functions.h @@ -51,6 +51,7 @@ __device__ float exp10f(float x); __device__ float exp2f(float x); __device__ float expf(float x); __device__ float expm1f(float x); +__device__ int abs(int x); __device__ float fabsf(float x); __device__ float fdimf(float x, float y); __device__ float fdividef(float x, float y); diff --git a/projects/clr/hipamd/src/math_functions.cpp b/projects/clr/hipamd/src/math_functions.cpp index 92cc8689fc..3472216309 100644 --- a/projects/clr/hipamd/src/math_functions.cpp +++ b/projects/clr/hipamd/src/math_functions.cpp @@ -114,6 +114,10 @@ __device__ float expm1f(float x) { return hc::precise_math::expm1f(x); } +__device__ int abs(int x) +{ + return x >= 0 ? x : -x; // TODO - optimize with OCML +} __device__ float fabsf(float x) { return hc::precise_math::fabsf(x);