From 9181fbb0b7e5f7db4df486b8600ea78092c4ffb1 Mon Sep 17 00:00:00 2001 From: "Yaxun (Sam) Liu" Date: Mon, 18 Jun 2018 11:57:57 -0400 Subject: [PATCH] Add abs/real/imag functions for hipFloatComplex/hipDoubleComplex --- include/hip/hcc_detail/hip_complex.h | 9 ++++++++- 1 file changed, 8 insertions(+), 1 deletion(-) diff --git a/include/hip/hcc_detail/hip_complex.h b/include/hip/hcc_detail/hip_complex.h index 783833dc7e..7f4dd840b7 100644 --- a/include/hip/hcc_detail/hip_complex.h +++ b/include/hip/hcc_detail/hip_complex.h @@ -234,7 +234,6 @@ __device__ __host__ static inline hipFloatComplex hipCdivf(hipFloatComplex p, hi __device__ __host__ static inline float hipCabsf(hipFloatComplex z) { return sqrtf(hipCsqabsf(z)); } - __device__ __host__ static inline double hipCreal(hipDoubleComplex z) { return z.x; } __device__ __host__ static inline double hipCimag(hipDoubleComplex z) { return z.y; } @@ -314,4 +313,12 @@ __device__ __host__ static inline hipDoubleComplex hipCfma(hipDoubleComplex p, h return make_hipDoubleComplex(real, imag); } +#define __DEFINE_HIP_COMPLEX_FUN(func) \ +__device__ __host__ inline float func(const hipFloatComplex& z) { return hipC##func##f(z); } \ +__device__ __host__ inline double func(const hipDoubleComplex& z) { return hipC##func(z); } + +__DEFINE_HIP_COMPLEX_FUN(abs) +__DEFINE_HIP_COMPLEX_FUN(real) +__DEFINE_HIP_COMPLEX_FUN(imag) + #endif