HIP: Heterogenous-computing Interface for Portability
hip_complex.h
1 /*
2 Copyright (c) 2015 - present Advanced Micro Devices, Inc. All rights reserved.
3 
4 Permission is hereby granted, free of charge, to any person obtaining a copy
5 of this software and associated documentation files (the "Software"), to deal
6 in the Software without restriction, including without limitation the rights
7 to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
8 copies of the Software, and to permit persons to whom the Software is
9 furnished to do so, subject to the following conditions:
10 
11 The above copyright notice and this permission notice shall be included in
12 all copies or substantial portions of the Software.
13 
14 THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
15 IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
16 FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
17 AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
18 LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
19 OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
20 THE SOFTWARE.
21 */
22 
23 #ifndef HIP_INCLUDE_HIP_NVIDIA_DETAIL_HIP_COMPLEX_H
24 #define HIP_INCLUDE_HIP_NVIDIA_DETAIL_HIP_COMPLEX_H
25 
26 #include "cuComplex.h"
27 
28 typedef cuFloatComplex hipFloatComplex;
29 
30 __device__ __host__ static inline float hipCrealf(hipFloatComplex z) { return cuCrealf(z); }
31 
32 __device__ __host__ static inline float hipCimagf(hipFloatComplex z) { return cuCimagf(z); }
33 
34 __device__ __host__ static inline hipFloatComplex make_hipFloatComplex(float a, float b) {
35  return make_cuFloatComplex(a, b);
36 }
37 
38 __device__ __host__ static inline hipFloatComplex hipConjf(hipFloatComplex z) { return cuConjf(z); }
39 
40 __device__ __host__ static inline float hipCsqabsf(hipFloatComplex z) {
41  return cuCabsf(z) * cuCabsf(z);
42 }
43 
44 __device__ __host__ static inline hipFloatComplex hipCaddf(hipFloatComplex p, hipFloatComplex q) {
45  return cuCaddf(p, q);
46 }
47 
48 __device__ __host__ static inline hipFloatComplex hipCsubf(hipFloatComplex p, hipFloatComplex q) {
49  return cuCsubf(p, q);
50 }
51 
52 __device__ __host__ static inline hipFloatComplex hipCmulf(hipFloatComplex p, hipFloatComplex q) {
53  return cuCmulf(p, q);
54 }
55 
56 __device__ __host__ static inline hipFloatComplex hipCdivf(hipFloatComplex p, hipFloatComplex q) {
57  return cuCdivf(p, q);
58 }
59 
60 __device__ __host__ static inline float hipCabsf(hipFloatComplex z) { return cuCabsf(z); }
61 
62 typedef cuDoubleComplex hipDoubleComplex;
63 
64 __device__ __host__ static inline double hipCreal(hipDoubleComplex z) { return cuCreal(z); }
65 
66 __device__ __host__ static inline double hipCimag(hipDoubleComplex z) { return cuCimag(z); }
67 
68 __device__ __host__ static inline hipDoubleComplex make_hipDoubleComplex(double a, double b) {
69  return make_cuDoubleComplex(a, b);
70 }
71 
72 __device__ __host__ static inline hipDoubleComplex hipConj(hipDoubleComplex z) { return cuConj(z); }
73 
74 __device__ __host__ static inline double hipCsqabs(hipDoubleComplex z) {
75  return cuCabs(z) * cuCabs(z);
76 }
77 
78 __device__ __host__ static inline hipDoubleComplex hipCadd(hipDoubleComplex p, hipDoubleComplex q) {
79  return cuCadd(p, q);
80 }
81 
82 __device__ __host__ static inline hipDoubleComplex hipCsub(hipDoubleComplex p, hipDoubleComplex q) {
83  return cuCsub(p, q);
84 }
85 
86 __device__ __host__ static inline hipDoubleComplex hipCmul(hipDoubleComplex p, hipDoubleComplex q) {
87  return cuCmul(p, q);
88 }
89 
90 __device__ __host__ static inline hipDoubleComplex hipCdiv(hipDoubleComplex p, hipDoubleComplex q) {
91  return cuCdiv(p, q);
92 }
93 
94 __device__ __host__ static inline double hipCabs(hipDoubleComplex z) { return cuCabs(z); }
95 
96 typedef cuFloatComplex hipComplex;
97 
98 __device__ __host__ static inline hipComplex make_Complex(float x, float y) {
99  return make_cuComplex(x, y);
100 }
101 
102 __device__ __host__ static inline hipFloatComplex hipComplexDoubleToFloat(hipDoubleComplex z) {
103  return cuComplexDoubleToFloat(z);
104 }
105 
106 __device__ __host__ static inline hipDoubleComplex hipComplexFloatToDouble(hipFloatComplex z) {
107  return cuComplexFloatToDouble(z);
108 }
109 
110 __device__ __host__ static inline hipComplex hipCfmaf(hipComplex p, hipComplex q, hipComplex r) {
111  return cuCfmaf(p, q, r);
112 }
113 
114 __device__ __host__ static inline hipDoubleComplex hipCfma(hipDoubleComplex p, hipDoubleComplex q,
115  hipDoubleComplex r) {
116  return cuCfma(p, q, r);
117 }
118 
119 #endif
double2
Definition: hip_vector_types.h:1581
__host__
#define __host__
Definition: host_defines.h:59
float2
Definition: hip_vector_types.h:1574