HIP: Heterogenous-computing Interface for Portability
 All Classes Files Functions Variables Typedefs Enumerations Enumerator Macros Groups Pages
hip_vector_types.h
Go to the documentation of this file.
1 /*
2 Copyright (c) 2015-2016 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 
28 #ifndef HIP_VECTOR_TYPES_H
29 #define HIP_VECTOR_TYPES_H
30 
31 #if defined (__HCC__) && (__hcc_workweek__ < 16032)
32 #error("This version of HIP requires a newer version of HCC.");
33 #endif
34 
35 #if __cplusplus
36 #include <hc_short_vector.hpp>
37 
38 using namespace hc::short_vector;
39 #endif
40 
41 //-- Signed
42 // Define char vector types
43 typedef hc::short_vector::char1 char1;
44 typedef hc::short_vector::char2 char2;
45 typedef hc::short_vector::char3 char3;
46 typedef hc::short_vector::char4 char4;
47 
48 // Define short vector types
49 typedef hc::short_vector::short1 short1;
50 typedef hc::short_vector::short2 short2;
51 typedef hc::short_vector::short3 short3;
52 typedef hc::short_vector::short4 short4;
53 
54 // Define int vector types
55 typedef hc::short_vector::int1 int1;
56 typedef hc::short_vector::int2 int2;
57 typedef hc::short_vector::int3 int3;
58 typedef hc::short_vector::int4 int4;
59 
60 // Define long vector types
61 typedef hc::short_vector::long1 long1;
62 typedef hc::short_vector::long2 long2;
63 typedef hc::short_vector::long3 long3;
64 typedef hc::short_vector::long4 long4;
65 
66 // Define longlong vector types
67 typedef hc::short_vector::longlong1 longlong1;
68 typedef hc::short_vector::longlong2 longlong2;
69 typedef hc::short_vector::longlong3 longlong3;
70 typedef hc::short_vector::longlong4 longlong4;
71 
72 
73 //-- Unsigned
74 // Define uchar vector types
75 typedef hc::short_vector::uchar1 uchar1;
76 typedef hc::short_vector::uchar2 uchar2;
77 typedef hc::short_vector::uchar3 uchar3;
78 typedef hc::short_vector::uchar4 uchar4;
79 
80 // Define ushort vector types
81 typedef hc::short_vector::ushort1 ushort1;
82 typedef hc::short_vector::ushort2 ushort2;
83 typedef hc::short_vector::ushort3 ushort3;
84 typedef hc::short_vector::ushort4 ushort4;
85 
86 // Define uint vector types
87 typedef hc::short_vector::uint1 uint1;
88 typedef hc::short_vector::uint2 uint2;
89 typedef hc::short_vector::uint3 uint3;
90 typedef hc::short_vector::uint4 uint4;
91 
92 // Define ulong vector types
93 typedef hc::short_vector::ulong1 ulong1;
94 typedef hc::short_vector::ulong2 ulong2;
95 typedef hc::short_vector::ulong3 ulong3;
96 typedef hc::short_vector::ulong4 ulong4;
97 
98 // Define ulonglong vector types
99 typedef hc::short_vector::ulonglong1 ulonglong1;
100 typedef hc::short_vector::ulonglong2 ulonglong2;
101 typedef hc::short_vector::ulonglong3 ulonglong3;
102 typedef hc::short_vector::ulonglong4 ulonglong4;
103 
104 
105 //-- Floating point
106 // Define float vector types
107 typedef hc::short_vector::float1 float1;
108 typedef hc::short_vector::float2 float2;
109 typedef hc::short_vector::float3 float3;
110 typedef hc::short_vector::float4 float4;
111 
112 // Define double vector types
113 typedef hc::short_vector::double1 double1;
114 typedef hc::short_vector::double2 double2;
115 typedef hc::short_vector::double3 double3;
116 typedef hc::short_vector::double4 double4;
117 
118 #if __HCC__
119 #include"hip/hcc_detail/host_defines.h"
120 #define __HIP_DEVICE__ __device__ __host__
121 #else
122 #define __HIP_DEVICE__
123 #endif
124 
125 __HIP_DEVICE__ char1 make_char1(signed char );
126 __HIP_DEVICE__ char2 make_char2(signed char, signed char );
127 __HIP_DEVICE__ char3 make_char3(signed char, signed char, signed char );
128 __HIP_DEVICE__ char4 make_char4(signed char, signed char, signed char, signed char );
129 
130 __HIP_DEVICE__ short1 make_short1(short );
131 __HIP_DEVICE__ short2 make_short2(short, short );
132 __HIP_DEVICE__ short3 make_short3(short, short, short );
133 __HIP_DEVICE__ short4 make_short4(short, short, short, short );
134 
135 __HIP_DEVICE__ int1 make_int1(int );
136 __HIP_DEVICE__ int2 make_int2(int, int );
137 __HIP_DEVICE__ int3 make_int3(int, int, int );
138 __HIP_DEVICE__ int4 make_int4(int, int, int, int );
139 
140 __HIP_DEVICE__ long1 make_long1(long );
141 __HIP_DEVICE__ long2 make_long2(long, long );
142 __HIP_DEVICE__ long3 make_long3(long, long, long );
143 __HIP_DEVICE__ long4 make_long4(long, long, long, long );
144 
145 __HIP_DEVICE__ longlong1 make_longlong1(long long );
146 __HIP_DEVICE__ longlong2 make_longlong2(long long, long long );
147 __HIP_DEVICE__ longlong3 make_longlong3(long long, long long, long long );
148 __HIP_DEVICE__ longlong4 make_longlong4(long long, long long, long long, long long );
149 
150 __HIP_DEVICE__ uchar1 make_uchar1(unsigned char );
151 __HIP_DEVICE__ uchar2 make_uchar2(unsigned char, unsigned char );
152 __HIP_DEVICE__ uchar3 make_uchar3(unsigned char, unsigned char, unsigned char );
153 __HIP_DEVICE__ uchar4 make_uchar4(unsigned char, unsigned char, unsigned char, unsigned char );
154 
155 __HIP_DEVICE__ ushort1 make_ushort1(unsigned short );
156 __HIP_DEVICE__ ushort2 make_ushort2(unsigned short, unsigned short );
157 __HIP_DEVICE__ ushort3 make_ushort3(unsigned short, unsigned short, unsigned short );
158 __HIP_DEVICE__ ushort4 make_ushort4(unsigned short, unsigned short, unsigned short, unsigned short );
159 
160 __HIP_DEVICE__ uint1 make_uint1(unsigned int );
161 __HIP_DEVICE__ uint2 make_uint2(unsigned int, unsigned int );
162 __HIP_DEVICE__ uint3 make_uint3(unsigned int, unsigned int, unsigned int );
163 __HIP_DEVICE__ uint4 make_uint4(unsigned int, unsigned int, unsigned int, unsigned int );
164 
165 __HIP_DEVICE__ ulong1 make_ulong1(unsigned long );
166 __HIP_DEVICE__ ulong2 make_ulong2(unsigned long, unsigned long );
167 __HIP_DEVICE__ ulong3 make_ulong3(unsigned long, unsigned long, unsigned long );
168 __HIP_DEVICE__ ulong4 make_ulong4(unsigned long, unsigned long, unsigned long, unsigned long );
169 
170 __HIP_DEVICE__ ulonglong1 make_ulonglong1(unsigned long long );
171 __HIP_DEVICE__ ulonglong2 make_ulonglong2(unsigned long long, unsigned long long);
172 __HIP_DEVICE__ ulonglong3 make_ulonglong3(unsigned long long, unsigned long long, unsigned long long);
173 __HIP_DEVICE__ ulonglong4 make_ulonglong4(unsigned long long, unsigned long long, unsigned long long, unsigned long long );
174 
175 __HIP_DEVICE__ float1 make_float1(float );
176 __HIP_DEVICE__ float2 make_float2(float, float );
177 __HIP_DEVICE__ float3 make_float3(float, float, float );
178 __HIP_DEVICE__ float4 make_float4(float, float, float, float );
179 
180 __HIP_DEVICE__ double1 make_double1(double );
181 __HIP_DEVICE__ double2 make_double2(double, double );
182 __HIP_DEVICE__ double3 make_double3(double, double, double );
183 __HIP_DEVICE__ double4 make_double4(double, double, double, double );
184 
185 /*
187 // Inline functions for creating vector types from basic types
188 #define ONE_COMPONENT_ACCESS(T, VT) inline VT make_ ##VT (T x) { VT t; t.x = x; return t; };
189 #define TWO_COMPONENT_ACCESS(T, VT) inline VT make_ ##VT (T x, T y) { VT t; t.x=x; t.y=y; return t; };
190 #define THREE_COMPONENT_ACCESS(T, VT) inline VT make_ ##VT (T x, T y, T z) { VT t; t.x=x; t.y=y; t.z=z; return t; };
191 #define FOUR_COMPONENT_ACCESS(T, VT) inline VT make_ ##VT (T x, T y, T z, T w) { VT t; t.x=x; t.y=y; t.z=z; t.w=w; return t; };
192 
193 
194 //signed:
195 ONE_COMPONENT_ACCESS (signed char, char1);
196 TWO_COMPONENT_ACCESS (signed char, char2);
197 THREE_COMPONENT_ACCESS(signed char, char3);
198 FOUR_COMPONENT_ACCESS (signed char, char4);
199 
200 ONE_COMPONENT_ACCESS (short, short1);
201 TWO_COMPONENT_ACCESS (short, short2);
202 THREE_COMPONENT_ACCESS(short, short3);
203 FOUR_COMPONENT_ACCESS (short, short4);
204 
205 ONE_COMPONENT_ACCESS (int, int1);
206 TWO_COMPONENT_ACCESS (int, int2);
207 THREE_COMPONENT_ACCESS(int, int3);
208 FOUR_COMPONENT_ACCESS (int, int4);
209 
210 ONE_COMPONENT_ACCESS (long int, long1);
211 TWO_COMPONENT_ACCESS (long int, long2);
212 THREE_COMPONENT_ACCESS(long int, long3);
213 FOUR_COMPONENT_ACCESS (long int, long4);
214 
215 ONE_COMPONENT_ACCESS (long long int, ulong1);
216 TWO_COMPONENT_ACCESS (long long int, ulong2);
217 THREE_COMPONENT_ACCESS(long long int, ulong3);
218 FOUR_COMPONENT_ACCESS (long long int, ulong4);
219 
220 ONE_COMPONENT_ACCESS (long long int, longlong1);
221 TWO_COMPONENT_ACCESS (long long int, longlong2);
222 THREE_COMPONENT_ACCESS(long long int, longlong3);
223 FOUR_COMPONENT_ACCESS (long long int, longlong4);
224 
225 
226 // unsigned:
227 ONE_COMPONENT_ACCESS (unsigned char, uchar1);
228 TWO_COMPONENT_ACCESS (unsigned char, uchar2);
229 THREE_COMPONENT_ACCESS(unsigned char, uchar3);
230 FOUR_COMPONENT_ACCESS (unsigned char, uchar4);
231 
232 ONE_COMPONENT_ACCESS (unsigned short, ushort1);
233 TWO_COMPONENT_ACCESS (unsigned short, ushort2);
234 THREE_COMPONENT_ACCESS(unsigned short, ushort3);
235 FOUR_COMPONENT_ACCESS (unsigned short, ushort4);
236 
237 ONE_COMPONENT_ACCESS (unsigned int, uint1);
238 TWO_COMPONENT_ACCESS (unsigned int, uint2);
239 THREE_COMPONENT_ACCESS(unsigned int, uint3);
240 FOUR_COMPONENT_ACCESS (unsigned int, uint4);
241 
242 ONE_COMPONENT_ACCESS (unsigned long int, ulong1);
243 TWO_COMPONENT_ACCESS (unsigned long int, ulong2);
244 THREE_COMPONENT_ACCESS(unsigned long int, ulong3);
245 FOUR_COMPONENT_ACCESS (unsigned long int, ulong4);
246 
247 ONE_COMPONENT_ACCESS (unsigned long long int, ulong1);
248 TWO_COMPONENT_ACCESS (unsigned long long int, ulong2);
249 THREE_COMPONENT_ACCESS(unsigned long long int, ulong3);
250 FOUR_COMPONENT_ACCESS (unsigned long long int, ulong4);
251 
252 ONE_COMPONENT_ACCESS (unsigned long long int, ulonglong1);
253 TWO_COMPONENT_ACCESS (unsigned long long int, ulonglong2);
254 THREE_COMPONENT_ACCESS(unsigned long long int, ulonglong3);
255 FOUR_COMPONENT_ACCESS (unsigned long long int, ulonglong4);
256 
257 
258 //Floating point
259 ONE_COMPONENT_ACCESS (float, float1);
260 TWO_COMPONENT_ACCESS (float, float2);
261 THREE_COMPONENT_ACCESS(float, float3);
262 FOUR_COMPONENT_ACCESS (float, float4);
263 
264 ONE_COMPONENT_ACCESS (double, double1);
265 TWO_COMPONENT_ACCESS (double, double2);
266 THREE_COMPONENT_ACCESS(double, double3);
267 FOUR_COMPONENT_ACCESS (double, double4);
268 */
269 
270 #endif
271