• Home
  • Line#
  • Scopes#
  • Navigate#
  • Raw
  • Download
1 //
2 // Copyright 2012 Francisco Jerez
3 //
4 // Permission is hereby granted, free of charge, to any person obtaining a
5 // copy of this software and associated documentation files (the "Software"),
6 // to deal in the Software without restriction, including without limitation
7 // the rights to use, copy, modify, merge, publish, distribute, sublicense,
8 // and/or sell copies of the Software, and to permit persons to whom the
9 // Software is 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
17 // THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR
18 // OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE,
19 // ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR
20 // OTHER DEALINGS IN THE SOFTWARE.
21 //
22 
23 #include <algorithm>
24 #include "core/device.hpp"
25 #include "core/platform.hpp"
26 #include "pipe/p_screen.h"
27 #include "pipe/p_state.h"
28 #include "spirv/invocation.hpp"
29 #include "util/bitscan.h"
30 #include "util/u_debug.h"
31 #include "spirv/invocation.hpp"
32 #include "nir/invocation.hpp"
33 #include <fstream>
34 
35 using namespace clover;
36 
37 namespace {
38    template<typename T>
39    std::vector<T>
get_compute_param(pipe_screen * pipe,pipe_shader_ir ir_format,pipe_compute_cap cap)40    get_compute_param(pipe_screen *pipe, pipe_shader_ir ir_format,
41                      pipe_compute_cap cap) {
42       int sz = pipe->get_compute_param(pipe, ir_format, cap, NULL);
43       std::vector<T> v(sz / sizeof(T));
44 
45       pipe->get_compute_param(pipe, ir_format, cap, &v.front());
46       return v;
47    }
48 
49    cl_version
get_highest_supported_version(const device & dev)50    get_highest_supported_version(const device &dev) {
51       // All the checks below assume that the device supports FULL_PROFILE
52       // (which is the only profile support by clover) and that a device is
53       // not CUSTOM.
54       assert(dev.type() != CL_DEVICE_TYPE_CUSTOM);
55 
56       cl_version version = CL_MAKE_VERSION(0, 0, 0);
57 
58       const auto has_extension =
59          [extensions = dev.supported_extensions()](const char *extension_name){
60             return std::find_if(extensions.begin(), extensions.end(),
61                   [extension_name](const cl_name_version &extension){
62                      return strcmp(extension.name, extension_name) == 0;
63                }) != extensions.end();
64       };
65       const bool supports_images = dev.image_support();
66 
67       // Check requirements for OpenCL 1.0
68       if (dev.max_compute_units() < 1 ||
69           dev.max_block_size().size() < 3 ||
70           // TODO: Check CL_DEVICE_MAX_WORK_ITEM_SIZES
71           dev.max_threads_per_block() < 1 ||
72           (dev.address_bits() != 32 && dev.address_bits() != 64) ||
73           dev.max_mem_alloc_size() < std::max(dev.max_mem_global() / 4,
74                                               (cl_ulong)128 * 1024 * 1024) ||
75           dev.max_mem_input() < 256 ||
76           dev.max_const_buffer_size() < 64 * 1024 ||
77           dev.max_const_buffers() < 8 ||
78           dev.max_mem_local() < 16 * 1024 ||
79           dev.clc_version < CL_MAKE_VERSION(1, 0, 0)) {
80          return version;
81       }
82       version = CL_MAKE_VERSION(1, 0, 0);
83 
84       // Check requirements for OpenCL 1.1
85       if (!has_extension("cl_khr_byte_addressable_store") ||
86           !has_extension("cl_khr_global_int32_base_atomics") ||
87           !has_extension("cl_khr_global_int32_extended_atomics") ||
88           !has_extension("cl_khr_local_int32_base_atomics") ||
89           !has_extension("cl_khr_local_int32_extended_atomics") ||
90           // OpenCL 1.1 increased the minimum value for
91           // CL_DEVICE_MAX_PARAMETER_SIZE to 1024 bytes.
92           dev.max_mem_input() < 1024 ||
93           dev.mem_base_addr_align() < sizeof(cl_long16) ||
94           // OpenCL 1.1 increased the minimum value for
95           // CL_DEVICE_LOCAL_MEM_SIZE to 32 KB.
96           dev.max_mem_local() < 32 * 1024 ||
97           dev.clc_version < CL_MAKE_VERSION(1, 1, 0)) {
98          return version;
99       }
100       version = CL_MAKE_VERSION(1, 1, 0);
101 
102       // Check requirements for OpenCL 1.2
103       if ((dev.has_doubles() && !has_extension("cl_khr_fp64")) ||
104           dev.clc_version < CL_MAKE_VERSION(1, 2, 0) ||
105           dev.max_printf_buffer_size() < 1 * 1024 * 1024 ||
106           (supports_images &&
107            (dev.max_image_buffer_size()  < 65536 ||
108             dev.max_image_array_number() < 2048))) {
109          return version;
110       }
111       version = CL_MAKE_VERSION(1, 2, 0);
112 
113       // Check requirements for OpenCL 3.0
114       if (dev.max_mem_alloc_size() < std::max(std::min((cl_ulong)1024 * 1024 * 1024,
115                                                        dev.max_mem_global() / 4),
116                                               (cl_ulong)128 * 1024 * 1024) ||
117           // TODO: If pipes are supported, check:
118           //       * CL_DEVICE_MAX_PIPE_ARGS
119           //       * CL_DEVICE_PIPE_MAX_ACTIVE_RESERVATIONS
120           //       * CL_DEVICE_PIPE_MAX_PACKET_SIZE
121           // TODO: If on-device queues are supported, check:
122           //       * CL_DEVICE_QUEUE_ON_DEVICE_PROPERTIES
123           //       * CL_DEVICE_QUEUE_ON_DEVICE_PREFERRED_SIZE
124           //       * CL_DEVICE_QUEUE_ON_DEVICE_MAX_SIZE
125           //       * CL_DEVICE_MAX_ON_DEVICE_QUEUES
126           //       * CL_DEVICE_MAX_ON_DEVICE_EVENTS
127           dev.clc_version < CL_MAKE_VERSION(3, 0, 0) ||
128           (supports_images &&
129            (dev.max_images_write() < 64 ||
130             dev.max_image_size() < 16384))) {
131          return version;
132       }
133       version = CL_MAKE_VERSION(3, 0, 0);
134 
135       return version;
136    }
137 }
138 
device(clover::platform & platform,pipe_loader_device * ldev)139 device::device(clover::platform &platform, pipe_loader_device *ldev) :
140    platform(platform), clc_cache(NULL), ldev(ldev) {
141    pipe = pipe_loader_create_screen(ldev);
142    if (pipe && pipe->get_param(pipe, PIPE_CAP_COMPUTE)) {
143       const bool has_supported_ir = supports_ir(PIPE_SHADER_IR_NATIVE) ||
144                                     supports_ir(PIPE_SHADER_IR_NIR_SERIALIZED);
145       if (has_supported_ir) {
146          unsigned major = 1, minor = 1;
147          debug_get_version_option("CLOVER_DEVICE_CLC_VERSION_OVERRIDE",
148                                   &major, &minor);
149          clc_version = CL_MAKE_VERSION(major, minor, 0);
150 
151          version = get_highest_supported_version(*this);
152          major = CL_VERSION_MAJOR(version);
153          minor = CL_VERSION_MINOR(version);
154          debug_get_version_option("CLOVER_DEVICE_VERSION_OVERRIDE", &major,
155                                   &minor);
156          version = CL_MAKE_VERSION(major, minor, 0);
157 
158       }
159 
160       if (supports_ir(PIPE_SHADER_IR_NATIVE))
161          return;
162 #ifdef HAVE_CLOVER_SPIRV
163       if (supports_ir(PIPE_SHADER_IR_NIR_SERIALIZED)) {
164          nir::check_for_libclc(*this);
165          clc_cache = nir::create_clc_disk_cache();
166          clc_nir = lazy<std::shared_ptr<nir_shader>>([&] () { std::string log; return std::shared_ptr<nir_shader>(nir::load_libclc_nir(*this, log), ralloc_free); });
167          return;
168       }
169 #endif
170    }
171    if (pipe)
172       pipe->destroy(pipe);
173    throw error(CL_INVALID_DEVICE);
174 }
175 
~device()176 device::~device() {
177    if (clc_cache)
178       disk_cache_destroy(clc_cache);
179    if (pipe)
180       pipe->destroy(pipe);
181    if (ldev)
182       pipe_loader_release(&ldev, 1);
183 }
184 
185 bool
operator ==(const device & dev) const186 device::operator==(const device &dev) const {
187    return this == &dev;
188 }
189 
190 cl_device_type
type() const191 device::type() const {
192    switch (ldev->type) {
193    case PIPE_LOADER_DEVICE_SOFTWARE:
194       return CL_DEVICE_TYPE_CPU;
195    case PIPE_LOADER_DEVICE_PCI:
196    case PIPE_LOADER_DEVICE_PLATFORM:
197       return CL_DEVICE_TYPE_GPU;
198    default:
199       unreachable("Unknown device type.");
200    }
201 }
202 
203 cl_uint
vendor_id() const204 device::vendor_id() const {
205    switch (ldev->type) {
206    case PIPE_LOADER_DEVICE_SOFTWARE:
207    case PIPE_LOADER_DEVICE_PLATFORM:
208       return 0;
209    case PIPE_LOADER_DEVICE_PCI:
210       return ldev->u.pci.vendor_id;
211    default:
212       unreachable("Unknown device type.");
213    }
214 }
215 
216 size_t
max_images_read() const217 device::max_images_read() const {
218    return pipe->get_shader_param(pipe, PIPE_SHADER_COMPUTE,
219                                  PIPE_SHADER_CAP_MAX_SAMPLER_VIEWS);
220 }
221 
222 size_t
max_images_write() const223 device::max_images_write() const {
224    return pipe->get_shader_param(pipe, PIPE_SHADER_COMPUTE,
225                                  PIPE_SHADER_CAP_MAX_SHADER_IMAGES);
226 }
227 
228 size_t
max_image_buffer_size() const229 device::max_image_buffer_size() const {
230    return pipe->get_param(pipe, PIPE_CAP_MAX_TEXEL_BUFFER_ELEMENTS_UINT);
231 }
232 
233 cl_uint
max_image_size() const234 device::max_image_size() const {
235    return pipe->get_param(pipe, PIPE_CAP_MAX_TEXTURE_2D_SIZE);
236 }
237 
238 cl_uint
max_image_size_3d() const239 device::max_image_size_3d() const {
240    return 1 << (pipe->get_param(pipe, PIPE_CAP_MAX_TEXTURE_3D_LEVELS) - 1);
241 }
242 
243 size_t
max_image_array_number() const244 device::max_image_array_number() const {
245    return pipe->get_param(pipe, PIPE_CAP_MAX_TEXTURE_ARRAY_LAYERS);
246 }
247 
248 cl_uint
max_samplers() const249 device::max_samplers() const {
250    return pipe->get_shader_param(pipe, PIPE_SHADER_COMPUTE,
251                                  PIPE_SHADER_CAP_MAX_TEXTURE_SAMPLERS);
252 }
253 
254 cl_ulong
max_mem_global() const255 device::max_mem_global() const {
256    return get_compute_param<uint64_t>(pipe, ir_format(),
257                                       PIPE_COMPUTE_CAP_MAX_GLOBAL_SIZE)[0];
258 }
259 
260 cl_ulong
max_mem_local() const261 device::max_mem_local() const {
262    return get_compute_param<uint64_t>(pipe, ir_format(),
263                                       PIPE_COMPUTE_CAP_MAX_LOCAL_SIZE)[0];
264 }
265 
266 cl_ulong
max_mem_input() const267 device::max_mem_input() const {
268    return get_compute_param<uint64_t>(pipe, ir_format(),
269                                       PIPE_COMPUTE_CAP_MAX_INPUT_SIZE)[0];
270 }
271 
272 cl_ulong
max_const_buffer_size() const273 device::max_const_buffer_size() const {
274    return pipe->get_shader_param(pipe, PIPE_SHADER_COMPUTE,
275                                  PIPE_SHADER_CAP_MAX_CONST_BUFFER0_SIZE);
276 }
277 
278 cl_uint
max_const_buffers() const279 device::max_const_buffers() const {
280    return pipe->get_shader_param(pipe, PIPE_SHADER_COMPUTE,
281                                  PIPE_SHADER_CAP_MAX_CONST_BUFFERS);
282 }
283 
284 size_t
max_threads_per_block() const285 device::max_threads_per_block() const {
286    return get_compute_param<uint64_t>(
287       pipe, ir_format(), PIPE_COMPUTE_CAP_MAX_THREADS_PER_BLOCK)[0];
288 }
289 
290 cl_ulong
max_mem_alloc_size() const291 device::max_mem_alloc_size() const {
292    return get_compute_param<uint64_t>(pipe, ir_format(),
293                                       PIPE_COMPUTE_CAP_MAX_MEM_ALLOC_SIZE)[0];
294 }
295 
296 cl_uint
max_clock_frequency() const297 device::max_clock_frequency() const {
298    return get_compute_param<uint32_t>(pipe, ir_format(),
299                                       PIPE_COMPUTE_CAP_MAX_CLOCK_FREQUENCY)[0];
300 }
301 
302 cl_uint
max_compute_units() const303 device::max_compute_units() const {
304    return get_compute_param<uint32_t>(pipe, ir_format(),
305                                       PIPE_COMPUTE_CAP_MAX_COMPUTE_UNITS)[0];
306 }
307 
308 cl_uint
max_printf_buffer_size() const309 device::max_printf_buffer_size() const {
310    return 1024 * 1024;
311 }
312 
313 bool
image_support() const314 device::image_support() const {
315    bool supports_images = get_compute_param<uint32_t>(pipe, ir_format(),
316                                                       PIPE_COMPUTE_CAP_IMAGES_SUPPORTED)[0];
317    if (!supports_images)
318       return false;
319 
320    /* If the gallium driver supports images, but does not support the
321     * minimum requirements for opencl 1.0 images, then don't claim to
322     * support images.
323     */
324    if (max_images_read() < 128 ||
325        max_images_write() < 8 ||
326        max_image_size() < 8192 ||
327        max_image_size_3d() < 2048 ||
328        max_samplers() < 16)
329       return false;
330 
331    return true;
332 }
333 
334 bool
has_doubles() const335 device::has_doubles() const {
336    return pipe->get_param(pipe, PIPE_CAP_DOUBLES);
337 }
338 
339 bool
has_halves() const340 device::has_halves() const {
341    return pipe->get_shader_param(pipe, PIPE_SHADER_COMPUTE,
342                                  PIPE_SHADER_CAP_FP16);
343 }
344 
345 bool
has_int64_atomics() const346 device::has_int64_atomics() const {
347    return pipe->get_shader_param(pipe, PIPE_SHADER_COMPUTE,
348                                  PIPE_SHADER_CAP_INT64_ATOMICS);
349 }
350 
351 bool
has_unified_memory() const352 device::has_unified_memory() const {
353    return pipe->get_param(pipe, PIPE_CAP_UMA);
354 }
355 
356 size_t
mem_base_addr_align() const357 device::mem_base_addr_align() const {
358    uint64_t page_size = 0;
359    os_get_page_size(&page_size);
360    return std::max((size_t)page_size, sizeof(cl_long) * 16);
361 }
362 
363 cl_device_svm_capabilities
svm_support() const364 device::svm_support() const {
365    // Without CAP_RESOURCE_FROM_USER_MEMORY SVM and CL_MEM_USE_HOST_PTR
366    // interactions won't work according to spec as clover manages a GPU side
367    // copy of the host data.
368    //
369    // The biggest problem are memory buffers created with CL_MEM_USE_HOST_PTR,
370    // but the application and/or the kernel updates the memory via SVM and not
371    // the cl_mem buffer.
372    // We can't even do proper tracking on what memory might have been accessed
373    // as the host ptr to the buffer could be within a SVM region, where through
374    // the CL API there is no reliable way of knowing if a certain cl_mem buffer
375    // was accessed by a kernel or not and the runtime can't reliably know from
376    // which side the GPU buffer content needs to be updated.
377    //
378    // Another unsolvable scenario is a cl_mem object passed by cl_mem reference
379    // and SVM pointer into the same kernel at the same time.
380    if (allows_user_pointers() && pipe->get_param(pipe, PIPE_CAP_SYSTEM_SVM))
381       // we can emulate all lower levels if we support fine grain system
382       return CL_DEVICE_SVM_FINE_GRAIN_SYSTEM |
383              CL_DEVICE_SVM_COARSE_GRAIN_BUFFER |
384              CL_DEVICE_SVM_FINE_GRAIN_BUFFER;
385    return 0;
386 }
387 
388 bool
allows_user_pointers() const389 device::allows_user_pointers() const {
390    return pipe->get_param(pipe, PIPE_CAP_RESOURCE_FROM_USER_MEMORY) ||
391           pipe->get_param(pipe, PIPE_CAP_RESOURCE_FROM_USER_MEMORY_COMPUTE_ONLY);
392 }
393 
394 std::vector<size_t>
max_block_size() const395 device::max_block_size() const {
396    auto v = get_compute_param<uint64_t>(pipe, ir_format(),
397                                         PIPE_COMPUTE_CAP_MAX_BLOCK_SIZE);
398    return { v.begin(), v.end() };
399 }
400 
401 cl_uint
subgroup_size() const402 device::subgroup_size() const {
403    return get_compute_param<uint32_t>(pipe, ir_format(),
404                                       PIPE_COMPUTE_CAP_SUBGROUP_SIZE)[0];
405 }
406 
407 cl_uint
address_bits() const408 device::address_bits() const {
409    return get_compute_param<uint32_t>(pipe, ir_format(),
410                                       PIPE_COMPUTE_CAP_ADDRESS_BITS)[0];
411 }
412 
413 std::string
device_name() const414 device::device_name() const {
415    return pipe->get_name(pipe);
416 }
417 
418 std::string
vendor_name() const419 device::vendor_name() const {
420    return pipe->get_device_vendor(pipe);
421 }
422 
423 enum pipe_shader_ir
ir_format() const424 device::ir_format() const {
425    if (supports_ir(PIPE_SHADER_IR_NATIVE))
426       return PIPE_SHADER_IR_NATIVE;
427 
428    assert(supports_ir(PIPE_SHADER_IR_NIR_SERIALIZED));
429    return PIPE_SHADER_IR_NIR_SERIALIZED;
430 }
431 
432 std::string
ir_target() const433 device::ir_target() const {
434    std::vector<char> target = get_compute_param<char>(
435       pipe, ir_format(), PIPE_COMPUTE_CAP_IR_TARGET);
436    return { target.data() };
437 }
438 
439 enum pipe_endian
endianness() const440 device::endianness() const {
441    return (enum pipe_endian)pipe->get_param(pipe, PIPE_CAP_ENDIANNESS);
442 }
443 
444 std::string
device_version_as_string() const445 device::device_version_as_string() const {
446    static const std::string version_string =
447       std::to_string(CL_VERSION_MAJOR(version)) + "." +
448       std::to_string(CL_VERSION_MINOR(version));
449    return version_string;
450 }
451 
452 std::string
device_clc_version_as_string() const453 device::device_clc_version_as_string() const {
454    int major = CL_VERSION_MAJOR(clc_version);
455    int minor = CL_VERSION_MINOR(clc_version);
456 
457    /* for CL 3.0 we need this to be 1.2 until we support 2.0. */
458    if (major == 3) {
459       major = 1;
460       minor = 2;
461    }
462    static const std::string version_string =
463       std::to_string(major) + "." +
464       std::to_string(minor);
465    return version_string;
466 }
467 
468 bool
supports_ir(enum pipe_shader_ir ir) const469 device::supports_ir(enum pipe_shader_ir ir) const {
470    return pipe->get_shader_param(pipe, PIPE_SHADER_COMPUTE,
471                                  PIPE_SHADER_CAP_SUPPORTED_IRS) & (1 << ir);
472 }
473 
474 std::vector<cl_name_version>
supported_extensions() const475 device::supported_extensions() const {
476    std::vector<cl_name_version> vec;
477 
478    vec.push_back( cl_name_version{ CL_MAKE_VERSION(1, 0, 0), "cl_khr_byte_addressable_store" } );
479    vec.push_back( cl_name_version{ CL_MAKE_VERSION(1, 0, 0), "cl_khr_global_int32_base_atomics" } );
480    vec.push_back( cl_name_version{ CL_MAKE_VERSION(1, 0, 0), "cl_khr_global_int32_extended_atomics" } );
481    vec.push_back( cl_name_version{ CL_MAKE_VERSION(1, 0, 0), "cl_khr_local_int32_base_atomics" } );
482    vec.push_back( cl_name_version{ CL_MAKE_VERSION(1, 0, 0), "cl_khr_local_int32_extended_atomics" } );
483    if (has_int64_atomics()) {
484       vec.push_back( cl_name_version{ CL_MAKE_VERSION(1, 0, 0), "cl_khr_int64_base_atomics" } );
485       vec.push_back( cl_name_version{ CL_MAKE_VERSION(1, 0, 0), "cl_khr_int64_extended_atomics" } );
486    }
487    if (has_doubles())
488       vec.push_back( cl_name_version{ CL_MAKE_VERSION(1, 0, 0), "cl_khr_fp64" } );
489    if (has_halves())
490       vec.push_back( cl_name_version{ CL_MAKE_VERSION(1, 0, 0), "cl_khr_fp16" } );
491    if (svm_support())
492       vec.push_back( cl_name_version{ CL_MAKE_VERSION(1, 0, 0), "cl_arm_shared_virtual_memory" } );
493    if (!clover::spirv::supported_versions().empty() &&
494        supports_ir(PIPE_SHADER_IR_NIR_SERIALIZED))
495       vec.push_back( cl_name_version{ CL_MAKE_VERSION(1, 0, 0), "cl_khr_il_program" } );
496    vec.push_back( cl_name_version{ CL_MAKE_VERSION(1, 0, 0), "cl_khr_extended_versioning" } );
497    return vec;
498 }
499 
500 std::string
supported_extensions_as_string() const501 device::supported_extensions_as_string() const {
502    static std::string extensions_string;
503 
504    if (!extensions_string.empty())
505       return extensions_string;
506 
507    const auto extension_list = supported_extensions();
508    for (const auto &extension : extension_list) {
509       if (!extensions_string.empty())
510          extensions_string += " ";
511       extensions_string += extension.name;
512    }
513    return extensions_string;
514 }
515 
516 std::vector<cl_name_version>
supported_il_versions() const517 device::supported_il_versions() const {
518    return clover::spirv::supported_versions();
519 }
520 
521 const void *
get_compiler_options(enum pipe_shader_ir ir) const522 device::get_compiler_options(enum pipe_shader_ir ir) const {
523    return pipe->get_compiler_options(pipe, ir, PIPE_SHADER_COMPUTE);
524 }
525 
526 cl_version
device_version() const527 device::device_version() const {
528    return version;
529 }
530 
531 cl_version
device_clc_version(bool api) const532 device::device_clc_version(bool api) const {
533    /*
534     * For the API we have to limit this to 1.2,
535     * but internally we want 3.0 if it works.
536     */
537    if (!api)
538       return clc_version;
539 
540    int major = CL_VERSION_MAJOR(clc_version);
541    /* for CL 3.0 we need this to be 1.2 until we support 2.0. */
542    if (major == 3) {
543       return CL_MAKE_VERSION(1, 2, 0);
544    }
545    return clc_version;
546 }
547 
548 std::vector<cl_name_version>
opencl_c_all_versions() const549 device::opencl_c_all_versions() const {
550    std::vector<cl_name_version> vec;
551    vec.push_back( cl_name_version{ CL_MAKE_VERSION(1, 0, 0), "OpenCL C" } );
552    vec.push_back( cl_name_version{ CL_MAKE_VERSION(1, 1, 0), "OpenCL C" } );
553 
554    if (CL_VERSION_MAJOR(clc_version) == 1 &&
555        CL_VERSION_MINOR(clc_version) == 2)
556       vec.push_back( cl_name_version{ CL_MAKE_VERSION(1, 2, 0), "OpenCL C" } );
557    if (CL_VERSION_MAJOR(clc_version) == 3) {
558       vec.push_back( cl_name_version{ CL_MAKE_VERSION(1, 2, 0), "OpenCL C" } );
559       vec.push_back( cl_name_version{ CL_MAKE_VERSION(3, 0, 0), "OpenCL C" } );
560    }
561    return vec;
562 }
563 
564 std::vector<cl_name_version>
opencl_c_features() const565 device::opencl_c_features() const {
566    std::vector<cl_name_version> vec;
567 
568    vec.push_back( cl_name_version {CL_MAKE_VERSION(3, 0, 0), "__opencl_c_int64" });
569    if (has_doubles())
570       vec.push_back( cl_name_version {CL_MAKE_VERSION(3, 0, 0), "__opencl_c_fp64" });
571 
572    return vec;
573 }
574