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 
120 // Inline functions for creating vector types from basic types
121 #define ONE_COMPONENT_ACCESS(T, VT) inline VT make_ ##VT (T x) { VT t; t.x = x; return t; };
122 #define TWO_COMPONENT_ACCESS(T, VT) inline VT make_ ##VT (T x, T y) { VT t; t.x=x; t.y=y; return t; };
123 #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; };
124 #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; };
125 
126 
127 //signed:
128 ONE_COMPONENT_ACCESS (signed char, char1);
129 TWO_COMPONENT_ACCESS (signed char, char2);
130 THREE_COMPONENT_ACCESS(signed char, char3);
131 FOUR_COMPONENT_ACCESS (signed char, char4);
132 
133 ONE_COMPONENT_ACCESS (short, short1);
134 TWO_COMPONENT_ACCESS (short, short2);
135 THREE_COMPONENT_ACCESS(short, short3);
136 FOUR_COMPONENT_ACCESS (short, short4);
137 
138 ONE_COMPONENT_ACCESS (int, int1);
139 TWO_COMPONENT_ACCESS (int, int2);
140 THREE_COMPONENT_ACCESS(int, int3);
141 FOUR_COMPONENT_ACCESS (int, int4);
142 
143 ONE_COMPONENT_ACCESS (long int, long1);
144 TWO_COMPONENT_ACCESS (long int, long2);
145 THREE_COMPONENT_ACCESS(long int, long3);
146 FOUR_COMPONENT_ACCESS (long int, long4);
147 
148 ONE_COMPONENT_ACCESS (long long int, ulong1);
149 TWO_COMPONENT_ACCESS (long long int, ulong2);
150 THREE_COMPONENT_ACCESS(long long int, ulong3);
151 FOUR_COMPONENT_ACCESS (long long int, ulong4);
152 
153 ONE_COMPONENT_ACCESS (long long int, longlong1);
154 TWO_COMPONENT_ACCESS (long long int, longlong2);
155 THREE_COMPONENT_ACCESS(long long int, longlong3);
156 FOUR_COMPONENT_ACCESS (long long int, longlong4);
157 
158 
159 // unsigned:
160 ONE_COMPONENT_ACCESS (unsigned char, uchar1);
161 TWO_COMPONENT_ACCESS (unsigned char, uchar2);
162 THREE_COMPONENT_ACCESS(unsigned char, uchar3);
163 FOUR_COMPONENT_ACCESS (unsigned char, uchar4);
164 
165 ONE_COMPONENT_ACCESS (unsigned short, ushort1);
166 TWO_COMPONENT_ACCESS (unsigned short, ushort2);
167 THREE_COMPONENT_ACCESS(unsigned short, ushort3);
168 FOUR_COMPONENT_ACCESS (unsigned short, ushort4);
169 
170 ONE_COMPONENT_ACCESS (unsigned int, uint1);
171 TWO_COMPONENT_ACCESS (unsigned int, uint2);
172 THREE_COMPONENT_ACCESS(unsigned int, uint3);
173 FOUR_COMPONENT_ACCESS (unsigned int, uint4);
174 
175 ONE_COMPONENT_ACCESS (unsigned long int, ulong1);
176 TWO_COMPONENT_ACCESS (unsigned long int, ulong2);
177 THREE_COMPONENT_ACCESS(unsigned long int, ulong3);
178 FOUR_COMPONENT_ACCESS (unsigned long int, ulong4);
179 
180 ONE_COMPONENT_ACCESS (unsigned long long int, ulong1);
181 TWO_COMPONENT_ACCESS (unsigned long long int, ulong2);
182 THREE_COMPONENT_ACCESS(unsigned long long int, ulong3);
183 FOUR_COMPONENT_ACCESS (unsigned long long int, ulong4);
184 
185 ONE_COMPONENT_ACCESS (unsigned long long int, ulonglong1);
186 TWO_COMPONENT_ACCESS (unsigned long long int, ulonglong2);
187 THREE_COMPONENT_ACCESS(unsigned long long int, ulonglong3);
188 FOUR_COMPONENT_ACCESS (unsigned long long int, ulonglong4);
189 
190 
191 //Floating point
192 ONE_COMPONENT_ACCESS (float, float1);
193 TWO_COMPONENT_ACCESS (float, float2);
194 THREE_COMPONENT_ACCESS(float, float3);
195 FOUR_COMPONENT_ACCESS (float, float4);
196 
197 ONE_COMPONENT_ACCESS (double, double1);
198 TWO_COMPONENT_ACCESS (double, double2);
199 THREE_COMPONENT_ACCESS(double, double3);
200 FOUR_COMPONENT_ACCESS (double, double4);
201 
202 
203 #endif
204 
#define ONE_COMPONENT_ACCESS(T, VT)
Definition: hip_vector_types.h:121