From fbbaedfdea80415264498b2194f9eba333974c77 Mon Sep 17 00:00:00 2001 From: Jorghi12 Date: Sat, 26 May 2018 00:40:14 -0400 Subject: [PATCH 1/2] Adding double/long int signatures for abs Adding overloads for abs that are found in cuda's math_functions. [ROCm/clr commit: 13f37d550f7c238aa5b9672d67ad6fc4c61e27f2] --- projects/clr/hipamd/src/math_functions.cpp | 6 ++++++ 1 file changed, 6 insertions(+) diff --git a/projects/clr/hipamd/src/math_functions.cpp b/projects/clr/hipamd/src/math_functions.cpp index dedc40f2ae..bd0116080d 100644 --- a/projects/clr/hipamd/src/math_functions.cpp +++ b/projects/clr/hipamd/src/math_functions.cpp @@ -59,6 +59,12 @@ __device__ int abs(int x) { __device__ long long abs(long long x) { return x >= 0 ? x : -x; } +__device__ double abs(double x) { + return x >= 0 ? x : -x; +} +__device__ long int abs(long int x) { + return x >= 0 ? x : -x; +} __device__ float fabsf(float x) { return hc::precise_math::fabsf(x); } __device__ float fdimf(float x, float y) { return hc::precise_math::fdimf(x, y); } __device__ float fdividef(float x, float y) { return x / y; } From 9b43fd84d0166bd61f49a90f5934f8d52ac8240a Mon Sep 17 00:00:00 2001 From: Jorghi12 Date: Sat, 26 May 2018 16:21:14 -0400 Subject: [PATCH 2/2] Update math_functions.cpp CUDA also has a function named labs. [ROCm/clr commit: 61ff40a1cf416361eda2e432d43efd4f9c72ea74] --- projects/clr/hipamd/src/math_functions.cpp | 3 +++ 1 file changed, 3 insertions(+) diff --git a/projects/clr/hipamd/src/math_functions.cpp b/projects/clr/hipamd/src/math_functions.cpp index bd0116080d..982073275b 100644 --- a/projects/clr/hipamd/src/math_functions.cpp +++ b/projects/clr/hipamd/src/math_functions.cpp @@ -65,6 +65,9 @@ __device__ double abs(double x) { __device__ long int abs(long int x) { return x >= 0 ? x : -x; } +__device__ long long int labs(long long int x) { + return x >= 0 ? x : -x; +} __device__ float fabsf(float x) { return hc::precise_math::fabsf(x); } __device__ float fdimf(float x, float y) { return hc::precise_math::fdimf(x, y); } __device__ float fdividef(float x, float y) { return x / y; }