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 #if defined (__HCC__) && (__hcc_workweek__ < 16032)
29 #error("This version of HIP requires a newer version of HCC.");
30 #endif
31 
32 #include <hc_short_vector.hpp>
33 
34 //-- Signed
35 // Define char vector types
36 typedef hc::short_vector::char1 char1;
37 typedef hc::short_vector::char2 char2;
38 typedef hc::short_vector::char3 char3;
39 typedef hc::short_vector::char4 char4;
40 
41 // Define short vector types
42 typedef hc::short_vector::short1 short1;
43 typedef hc::short_vector::short2 short2;
44 typedef hc::short_vector::short3 short3;
45 typedef hc::short_vector::short4 short4;
46 
47 // Define int vector types
48 typedef hc::short_vector::int1 int1;
49 typedef hc::short_vector::int2 int2;
50 typedef hc::short_vector::int3 int3;
51 typedef hc::short_vector::int4 int4;
52 
53 // Define long vector types
54 typedef hc::short_vector::long1 long1;
55 typedef hc::short_vector::long2 long2;
56 typedef hc::short_vector::long3 long3;
57 typedef hc::short_vector::long4 long4;
58 
59 // Define longlong vector types
60 typedef hc::short_vector::longlong1 longlong1;
61 typedef hc::short_vector::longlong2 longlong2;
62 typedef hc::short_vector::longlong3 longlong3;
63 typedef hc::short_vector::longlong4 longlong4;
64 
65 
66 //-- Unsigned
67 // Define uchar vector types
68 typedef hc::short_vector::uchar1 uchar1;
69 typedef hc::short_vector::uchar2 uchar2;
70 typedef hc::short_vector::uchar3 uchar3;
71 typedef hc::short_vector::uchar4 uchar4;
72 
73 // Define ushort vector types
74 typedef hc::short_vector::ushort1 ushort1;
75 typedef hc::short_vector::ushort2 ushort2;
76 typedef hc::short_vector::ushort3 ushort3;
77 typedef hc::short_vector::ushort4 ushort4;
78 
79 // Define uint vector types
80 typedef hc::short_vector::uint1 uint1;
81 typedef hc::short_vector::uint2 uint2;
82 typedef hc::short_vector::uint3 uint3;
83 typedef hc::short_vector::uint4 uint4;
84 
85 // Define ulong vector types
86 typedef hc::short_vector::ulong1 ulong1;
87 typedef hc::short_vector::ulong2 ulong2;
88 typedef hc::short_vector::ulong3 ulong3;
89 typedef hc::short_vector::ulong4 ulong4;
90 
91 // Define ulonglong vector types
92 typedef hc::short_vector::ulonglong1 ulonglong1;
93 typedef hc::short_vector::ulonglong2 ulonglong2;
94 typedef hc::short_vector::ulonglong3 ulonglong3;
95 typedef hc::short_vector::ulonglong4 ulonglong4;
96 
97 
98 //-- Floating point
99 // Define float vector types
100 typedef hc::short_vector::float1 float1;
101 typedef hc::short_vector::float2 float2;
102 typedef hc::short_vector::float3 float3;
103 typedef hc::short_vector::float4 float4;
104 
105 // Define double vector types
106 typedef hc::short_vector::double1 double1;
107 typedef hc::short_vector::double2 double2;
108 typedef hc::short_vector::double3 double3;
109 typedef hc::short_vector::double4 double4;
110 
111 
113 // Inline functions for creating vector types from basic types
114 #define ONE_COMPONENT_ACCESS(T, VT) inline VT make_ ##VT (T x) { VT t; t.x = x; return t; };
115 #define TWO_COMPONENT_ACCESS(T, VT) inline VT make_ ##VT (T x, T y) { VT t; t.x=x; t.y=y; return t; };
116 #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; };
117 #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; };
118 
119 
120 //signed:
121 ONE_COMPONENT_ACCESS (signed char, char1);
122 TWO_COMPONENT_ACCESS (signed char, char2);
123 THREE_COMPONENT_ACCESS(signed char, char3);
124 FOUR_COMPONENT_ACCESS (signed char, char4);
125 
126 ONE_COMPONENT_ACCESS (short, short1);
127 TWO_COMPONENT_ACCESS (short, short2);
128 THREE_COMPONENT_ACCESS(short, short3);
129 FOUR_COMPONENT_ACCESS (short, short4);
130 
131 ONE_COMPONENT_ACCESS (int, int1);
132 TWO_COMPONENT_ACCESS (int, int2);
133 THREE_COMPONENT_ACCESS(int, int3);
134 FOUR_COMPONENT_ACCESS (int, int4);
135 
136 ONE_COMPONENT_ACCESS (long int, long1);
137 TWO_COMPONENT_ACCESS (long int, long2);
138 THREE_COMPONENT_ACCESS(long int, long3);
139 FOUR_COMPONENT_ACCESS (long int, long4);
140 
141 ONE_COMPONENT_ACCESS (long long int, ulong1);
142 TWO_COMPONENT_ACCESS (long long int, ulong2);
143 THREE_COMPONENT_ACCESS(long long int, ulong3);
144 FOUR_COMPONENT_ACCESS (long long int, ulong4);
145 
146 ONE_COMPONENT_ACCESS (long long int, longlong1);
147 TWO_COMPONENT_ACCESS (long long int, longlong2);
148 THREE_COMPONENT_ACCESS(long long int, longlong3);
149 FOUR_COMPONENT_ACCESS (long long int, longlong4);
150 
151 
152 // unsigned:
153 ONE_COMPONENT_ACCESS (unsigned char, uchar1);
154 TWO_COMPONENT_ACCESS (unsigned char, uchar2);
155 THREE_COMPONENT_ACCESS(unsigned char, uchar3);
156 FOUR_COMPONENT_ACCESS (unsigned char, uchar4);
157 
158 ONE_COMPONENT_ACCESS (unsigned short, ushort1);
159 TWO_COMPONENT_ACCESS (unsigned short, ushort2);
160 THREE_COMPONENT_ACCESS(unsigned short, ushort3);
161 FOUR_COMPONENT_ACCESS (unsigned short, ushort4);
162 
163 ONE_COMPONENT_ACCESS (unsigned int, uint1);
164 TWO_COMPONENT_ACCESS (unsigned int, uint2);
165 THREE_COMPONENT_ACCESS(unsigned int, uint3);
166 FOUR_COMPONENT_ACCESS (unsigned int, uint4);
167 
168 ONE_COMPONENT_ACCESS (unsigned long int, ulong1);
169 TWO_COMPONENT_ACCESS (unsigned long int, ulong2);
170 THREE_COMPONENT_ACCESS(unsigned long int, ulong3);
171 FOUR_COMPONENT_ACCESS (unsigned long int, ulong4);
172 
173 ONE_COMPONENT_ACCESS (unsigned long long int, ulong1);
174 TWO_COMPONENT_ACCESS (unsigned long long int, ulong2);
175 THREE_COMPONENT_ACCESS(unsigned long long int, ulong3);
176 FOUR_COMPONENT_ACCESS (unsigned long long int, ulong4);
177 
178 ONE_COMPONENT_ACCESS (unsigned long long int, ulonglong1);
179 TWO_COMPONENT_ACCESS (unsigned long long int, ulonglong2);
180 THREE_COMPONENT_ACCESS(unsigned long long int, ulonglong3);
181 FOUR_COMPONENT_ACCESS (unsigned long long int, ulonglong4);
182 
183 
184 //Floating point
185 ONE_COMPONENT_ACCESS (float, float1);
186 TWO_COMPONENT_ACCESS (float, float2);
187 THREE_COMPONENT_ACCESS(float, float3);
188 FOUR_COMPONENT_ACCESS (float, float4);
189 
190 ONE_COMPONENT_ACCESS (double, double1);
191 TWO_COMPONENT_ACCESS (double, double2);
192 THREE_COMPONENT_ACCESS(double, double3);
193 FOUR_COMPONENT_ACCESS (double, double4);
#define ONE_COMPONENT_ACCESS(T, VT)
Definition: hip_vector_types.h:114