|
65 | 65 | "uint", |
66 | 66 | "long", |
67 | 67 | "ulong", |
| 68 | + "half", |
68 | 69 | "float", |
69 | 70 | "double", |
70 | 71 | ] |
71 | 72 | int_types = ["char", "uchar", "short", "ushort", "int", "uint", "long", "ulong"] |
72 | 73 | unsigned_types = ["uchar", "ushort", "uint", "ulong"] |
73 | | -float_types = ["float", "double"] |
| 74 | +float_types = ["half", "float", "double"] |
74 | 75 | int64_types = ["long", "ulong"] |
75 | 76 | float64_types = ["double"] |
| 77 | +float16_types = ["half"] |
76 | 78 | vector_sizes = ["", "2", "3", "4", "8", "16"] |
77 | 79 | half_sizes = [("2", ""), ("4", "2"), ("8", "4"), ("16", "8")] |
78 | 80 |
|
79 | 81 | saturation = ["", "_sat"] |
80 | 82 | rounding_modes = ["_rtz", "_rte", "_rtp", "_rtn"] |
81 | | -float_prefix = {"float": "FLT_", "double": "DBL_"} |
82 | | -float_suffix = {"float": "f", "double": ""} |
83 | 83 |
|
84 | 84 | bool_type = { |
85 | 85 | "char": "char", |
|
90 | 90 | "uint": "int", |
91 | 91 | "long": "long", |
92 | 92 | "ulong": "long", |
| 93 | + "half": "short", |
93 | 94 | "float": "int", |
94 | 95 | "double": "long", |
95 | 96 | } |
|
114 | 115 | "uint": 4, |
115 | 116 | "long": 8, |
116 | 117 | "ulong": 8, |
| 118 | + "half": 2, |
117 | 119 | "float": 4, |
118 | 120 | "double": 8, |
119 | 121 | } |
|
127 | 129 | "uint": "UINT_MAX", |
128 | 130 | "long": "LONG_MAX", |
129 | 131 | "ulong": "ULONG_MAX", |
| 132 | + "half": "0x1.ffcp+15", |
130 | 133 | } |
131 | 134 |
|
132 | 135 | limit_min = { |
|
138 | 141 | "uint": "0", |
139 | 142 | "long": "LONG_MIN", |
140 | 143 | "ulong": "0", |
| 144 | + "half": "-0x1.ffcp+15", |
141 | 145 | } |
142 | 146 |
|
143 | 147 |
|
144 | 148 | def conditional_guard(src, dst): |
145 | 149 | int64_count = 0 |
146 | 150 | float64_count = 0 |
| 151 | + float16_count = 0 |
147 | 152 | if src in int64_types: |
148 | 153 | int64_count = int64_count + 1 |
149 | 154 | elif src in float64_types: |
150 | 155 | float64_count = float64_count + 1 |
| 156 | + elif src in float16_types: |
| 157 | + float16_count = float16_count + 1 |
151 | 158 | if dst in int64_types: |
152 | 159 | int64_count = int64_count + 1 |
153 | 160 | elif dst in float64_types: |
154 | 161 | float64_count = float64_count + 1 |
| 162 | + elif dst in float16_types: |
| 163 | + float16_count = float16_count + 1 |
155 | 164 | if float64_count > 0: |
156 | 165 | # In embedded profile, if cl_khr_fp64 is supported cles_khr_int64 has to be |
157 | 166 | print("#ifdef cl_khr_fp64") |
158 | 167 | return True |
| 168 | + elif float16_count > 0: |
| 169 | + print("#if defined cl_khr_fp16") |
| 170 | + return True |
159 | 171 | elif int64_count > 0: |
160 | 172 | print("#if defined cles_khr_int64 || !defined(__EMBEDDED_PROFILE__)") |
161 | 173 | return True |
@@ -198,6 +210,10 @@ def conditional_guard(src, dst): |
198 | 210 | #pragma OPENCL EXTENSION cl_khr_fp16 : enable |
199 | 211 | #endif |
200 | 212 |
|
| 213 | +#ifdef cl_khr_fp16 |
| 214 | +#pragma OPENCL EXTENSION cl_khr_fp16 : enable |
| 215 | +#endif |
| 216 | +
|
201 | 217 | #ifdef cl_khr_fp64 |
202 | 218 | #pragma OPENCL EXTENSION cl_khr_fp64 : enable |
203 | 219 |
|
|
0 commit comments