• 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 "util/bitscan.h"
29 #include "util/disk_cache.h"
30 #include "util/u_debug.h"
31 #include "nir.h"
32 #include <fstream>
33 
34 using namespace clover;
35 
36 namespace {
37    template<typename T>
38    std::vector<T>
get_compute_param(pipe_screen * pipe,pipe_shader_ir ir_format,pipe_compute_cap cap)39    get_compute_param(pipe_screen *pipe, pipe_shader_ir ir_format,
40                      pipe_compute_cap cap) {
41       int sz = pipe->get_compute_param(pipe, ir_format, cap, NULL);
42       std::vector<T> v(sz / sizeof(T));
43 
44       pipe->get_compute_param(pipe, ir_format, cap, &v.front());
45       return v;
46    }
47 
48    cl_version
get_highest_supported_version(const device & dev)49    get_highest_supported_version(const device &dev) {
50       // All the checks below assume that the device supports FULL_PROFILE
51       // (which is the only profile support by clover) and that a device is
52       // not CUSTOM.
53       assert(dev.type() != CL_DEVICE_TYPE_CUSTOM);
54 
55       cl_version version = CL_MAKE_VERSION(0, 0, 0);
56 
57       const auto has_extension =
58          [extensions = dev.supported_extensions()](const char *extension_name){
59             return std::find_if(extensions.begin(), extensions.end(),
60                   [extension_name](const cl_name_version &extension){
61                      return strcmp(extension.name, extension_name) == 0;
62                }) != extensions.end();
63       };
64       const bool supports_images = dev.image_support();
65 
66       // Check requirements for OpenCL 1.0
67       if (dev.max_compute_units() < 1 ||
68           dev.max_block_size().size() < 3 ||
69           // TODO: Check CL_DEVICE_MAX_WORK_ITEM_SIZES
70           dev.max_threads_per_block() < 1 ||
71           (dev.address_bits() != 32 && dev.address_bits() != 64) ||
72           dev.max_mem_alloc_size() < std::max(dev.max_mem_global() / 4,
73                                               (cl_ulong)128 * 1024 * 1024) ||
74           dev.max_mem_input() < 256 ||
75           dev.max_const_buffer_size() < 64 * 1024 ||
76           dev.max_const_buffers() < 8 ||
77           dev.max_mem_local() < 16 * 1024 ||
78           dev.clc_version < CL_MAKE_VERSION(1, 0, 0)) {
79          return version;
80       }
81       version = CL_MAKE_VERSION(1, 0, 0);
82 
83       // Check requirements for OpenCL 1.1
84       if (!has_extension("cl_khr_byte_addressable_store") ||
85           !has_extension("cl_khr_global_int32_base_atomics") ||
86           !has_extension("cl_khr_global_int32_extended_atomics") ||
87           !has_extension("cl_khr_local_int32_base_atomics") ||
88           !has_extension("cl_khr_local_int32_extended_atomics") ||
89           // OpenCL 1.1 increased the minimum value for
90           // CL_DEVICE_MAX_PARAMETER_SIZE to 1024 bytes.
91           dev.max_mem_input() < 1024 ||
92           dev.mem_base_addr_align() < sizeof(cl_long16) ||
93           // OpenCL 1.1 increased the minimum value for
94           // CL_DEVICE_LOCAL_MEM_SIZE to 32 KB.
95           dev.max_mem_local() < 32 * 1024 ||
96           dev.clc_version < CL_MAKE_VERSION(1, 1, 0)) {
97          return version;
98       }
99       version = CL_MAKE_VERSION(1, 1, 0);
100 
101       // Check requirements for OpenCL 1.2
102       if ((dev.has_doubles() && !has_extension("cl_khr_fp64")) ||
103           dev.clc_version < CL_MAKE_VERSION(1, 2, 0) ||
104           dev.max_printf_buffer_size() < 1 * 1024 * 1024 ||
105           (supports_images &&
106            (dev.max_image_buffer_size()  < 65536 ||
107             dev.max_image_array_number() < 2048))) {
108          return version;
109       }
110       version = CL_MAKE_VERSION(1, 2, 0);
111 
112       // Check requirements for OpenCL 3.0
113       if (dev.max_mem_alloc_size() < std::max(std::min((cl_ulong)1024 * 1024 * 1024,
114                                                        dev.max_mem_global() / 4),
115                                               (cl_ulong)128 * 1024 * 1024) ||
116           // TODO: If pipes are supported, check:
117           //       * CL_DEVICE_MAX_PIPE_ARGS
118           //       * CL_DEVICE_PIPE_MAX_ACTIVE_RESERVATIONS
119           //       * CL_DEVICE_PIPE_MAX_PACKET_SIZE
120           // TODO: If on-device queues are supported, check:
121           //       * CL_DEVICE_QUEUE_ON_DEVICE_PROPERTIES
122           //       * CL_DEVICE_QUEUE_ON_DEVICE_PREFERRED_SIZE
123           //       * CL_DEVICE_QUEUE_ON_DEVICE_MAX_SIZE
124           //       * CL_DEVICE_MAX_ON_DEVICE_QUEUES
125           //       * CL_DEVICE_MAX_ON_DEVICE_EVENTS
126           dev.clc_version < CL_MAKE_VERSION(3, 0, 0) ||
127           (supports_images &&
128            (dev.max_images_write() < 64 ||
129             dev.max_image_size() < 16384))) {
130          return version;
131       }
132       version = CL_MAKE_VERSION(3, 0, 0);
133 
134       return version;
135    }
136 
137    static cl_device_type
parse_env_device_type()138    parse_env_device_type() {
139       const char* val = getenv("CLOVER_DEVICE_TYPE");
140       if (!val) {
141          return 0;
142       }
143       if (strcmp(val, "cpu") == 0) {
144          return CL_DEVICE_TYPE_CPU;
145       }
146       if (strcmp(val, "gpu") == 0) {
147          return CL_DEVICE_TYPE_GPU;
148       }
149       if (strcmp(val, "accelerator") == 0) {
150          return CL_DEVICE_TYPE_ACCELERATOR;
151       }
152       /* CL_DEVICE_TYPE_CUSTOM isn't implemented
153       because CL_DEVICE_TYPE_CUSTOM is OpenCL 1.2
154       and Clover is OpenCL 1.1. */
155       return 0;
156    }
157 }
158 
device(clover::platform & platform,pipe_loader_device * ldev)159 device::device(clover::platform &platform, pipe_loader_device *ldev) :
160    platform(platform), clc_cache(NULL), ldev(ldev) {
161    pipe = pipe_loader_create_screen(ldev, false);
162    if (pipe && pipe->caps.compute) {
163       const bool has_supported_ir = supports_ir(PIPE_SHADER_IR_NATIVE);
164       if (has_supported_ir) {
165          unsigned major = 1, minor = 1;
166          debug_get_version_option("CLOVER_DEVICE_CLC_VERSION_OVERRIDE",
167                                   &major, &minor);
168          clc_version = CL_MAKE_VERSION(major, minor, 0);
169 
170          version = get_highest_supported_version(*this);
171          major = CL_VERSION_MAJOR(version);
172          minor = CL_VERSION_MINOR(version);
173          debug_get_version_option("CLOVER_DEVICE_VERSION_OVERRIDE", &major,
174                                   &minor);
175          version = CL_MAKE_VERSION(major, minor, 0);
176 
177       }
178 
179       if (supports_ir(PIPE_SHADER_IR_NATIVE))
180          return;
181    }
182    if (pipe)
183       pipe->destroy(pipe);
184    throw error(CL_INVALID_DEVICE);
185 }
186 
~device()187 device::~device() {
188    if (clc_cache)
189       disk_cache_destroy(clc_cache);
190    if (pipe)
191       pipe->destroy(pipe);
192    if (ldev)
193       pipe_loader_release(&ldev, 1);
194 }
195 
196 bool
operator ==(const device & dev) const197 device::operator==(const device &dev) const {
198    return this == &dev;
199 }
200 
201 cl_device_type
type() const202 device::type() const {
203    cl_device_type type = parse_env_device_type();
204    if (type != 0) {
205       return type;
206    }
207 
208    switch (ldev->type) {
209    case PIPE_LOADER_DEVICE_SOFTWARE:
210       return CL_DEVICE_TYPE_CPU;
211    case PIPE_LOADER_DEVICE_PCI:
212    case PIPE_LOADER_DEVICE_PLATFORM:
213       return CL_DEVICE_TYPE_GPU;
214    default:
215       unreachable("Unknown device type.");
216    }
217 }
218 
219 cl_uint
vendor_id() const220 device::vendor_id() const {
221    switch (ldev->type) {
222    case PIPE_LOADER_DEVICE_SOFTWARE:
223    case PIPE_LOADER_DEVICE_PLATFORM:
224       return 0;
225    case PIPE_LOADER_DEVICE_PCI:
226       return ldev->u.pci.vendor_id;
227    default:
228       unreachable("Unknown device type.");
229    }
230 }
231 
232 size_t
max_images_read() const233 device::max_images_read() const {
234    return pipe->get_shader_param(pipe, PIPE_SHADER_COMPUTE,
235                                  PIPE_SHADER_CAP_MAX_SAMPLER_VIEWS);
236 }
237 
238 size_t
max_images_write() const239 device::max_images_write() const {
240    return pipe->get_shader_param(pipe, PIPE_SHADER_COMPUTE,
241                                  PIPE_SHADER_CAP_MAX_SHADER_IMAGES);
242 }
243 
244 size_t
max_image_buffer_size() const245 device::max_image_buffer_size() const {
246    return pipe->caps.max_texel_buffer_elements;
247 }
248 
249 cl_uint
max_image_size() const250 device::max_image_size() const {
251    return pipe->caps.max_texture_2d_size;
252 }
253 
254 cl_uint
max_image_size_3d() const255 device::max_image_size_3d() const {
256    return 1 << (pipe->caps.max_texture_3d_levels - 1);
257 }
258 
259 size_t
max_image_array_number() const260 device::max_image_array_number() const {
261    return pipe->caps.max_texture_array_layers;
262 }
263 
264 cl_uint
max_samplers() const265 device::max_samplers() const {
266    return pipe->get_shader_param(pipe, PIPE_SHADER_COMPUTE,
267                                  PIPE_SHADER_CAP_MAX_TEXTURE_SAMPLERS);
268 }
269 
270 cl_ulong
max_mem_global() const271 device::max_mem_global() const {
272    return get_compute_param<uint64_t>(pipe, ir_format(),
273                                       PIPE_COMPUTE_CAP_MAX_GLOBAL_SIZE)[0];
274 }
275 
276 cl_ulong
max_mem_local() const277 device::max_mem_local() const {
278    return get_compute_param<uint64_t>(pipe, ir_format(),
279                                       PIPE_COMPUTE_CAP_MAX_LOCAL_SIZE)[0];
280 }
281 
282 cl_ulong
max_mem_input() const283 device::max_mem_input() const {
284    return get_compute_param<uint64_t>(pipe, ir_format(),
285                                       PIPE_COMPUTE_CAP_MAX_INPUT_SIZE)[0];
286 }
287 
288 cl_ulong
max_const_buffer_size() const289 device::max_const_buffer_size() const {
290    return pipe->get_shader_param(pipe, PIPE_SHADER_COMPUTE,
291                                  PIPE_SHADER_CAP_MAX_CONST_BUFFER0_SIZE);
292 }
293 
294 cl_uint
max_const_buffers() const295 device::max_const_buffers() const {
296    return pipe->get_shader_param(pipe, PIPE_SHADER_COMPUTE,
297                                  PIPE_SHADER_CAP_MAX_CONST_BUFFERS);
298 }
299 
300 size_t
max_threads_per_block() const301 device::max_threads_per_block() const {
302    return get_compute_param<uint64_t>(
303       pipe, ir_format(), PIPE_COMPUTE_CAP_MAX_THREADS_PER_BLOCK)[0];
304 }
305 
306 cl_ulong
max_mem_alloc_size() const307 device::max_mem_alloc_size() const {
308    return get_compute_param<uint64_t>(pipe, ir_format(),
309                                       PIPE_COMPUTE_CAP_MAX_MEM_ALLOC_SIZE)[0];
310 }
311 
312 cl_uint
max_clock_frequency() const313 device::max_clock_frequency() const {
314    return get_compute_param<uint32_t>(pipe, ir_format(),
315                                       PIPE_COMPUTE_CAP_MAX_CLOCK_FREQUENCY)[0];
316 }
317 
318 cl_uint
max_compute_units() const319 device::max_compute_units() const {
320    return get_compute_param<uint32_t>(pipe, ir_format(),
321                                       PIPE_COMPUTE_CAP_MAX_COMPUTE_UNITS)[0];
322 }
323 
324 cl_uint
max_printf_buffer_size() const325 device::max_printf_buffer_size() const {
326    return 1024 * 1024;
327 }
328 
329 bool
image_support() const330 device::image_support() const {
331    bool supports_images = get_compute_param<uint32_t>(pipe, ir_format(),
332                                                       PIPE_COMPUTE_CAP_IMAGES_SUPPORTED)[0];
333    if (!supports_images)
334       return false;
335 
336    /* If the gallium driver supports images, but does not support the
337     * minimum requirements for opencl 1.0 images, then don't claim to
338     * support images.
339     */
340    if (max_images_read() < 128 ||
341        max_images_write() < 8 ||
342        max_image_size() < 8192 ||
343        max_image_size_3d() < 2048 ||
344        max_samplers() < 16)
345       return false;
346 
347    return true;
348 }
349 
350 bool
has_doubles() const351 device::has_doubles() const {
352    nir_shader_compiler_options *options =
353          (nir_shader_compiler_options *)pipe->get_compiler_options(pipe,
354                                                                    PIPE_SHADER_IR_NIR,
355                                                                    PIPE_SHADER_COMPUTE);
356    return pipe->caps.doubles &&
357          !(options->lower_doubles_options & nir_lower_fp64_full_software);
358 }
359 
360 bool
has_halves() const361 device::has_halves() const {
362    return pipe->get_shader_param(pipe, PIPE_SHADER_COMPUTE,
363                                  PIPE_SHADER_CAP_FP16);
364 }
365 
366 bool
has_int64_atomics() const367 device::has_int64_atomics() const {
368    return pipe->get_shader_param(pipe, PIPE_SHADER_COMPUTE,
369                                  PIPE_SHADER_CAP_INT64_ATOMICS);
370 }
371 
372 bool
has_unified_memory() const373 device::has_unified_memory() const {
374    return pipe->caps.uma;
375 }
376 
377 size_t
mem_base_addr_align() const378 device::mem_base_addr_align() const {
379    uint64_t page_size = 0;
380    os_get_page_size(&page_size);
381    return std::max((size_t)page_size, sizeof(cl_long) * 16);
382 }
383 
384 cl_device_svm_capabilities
svm_support() const385 device::svm_support() const {
386    // Without CAP_RESOURCE_FROM_USER_MEMORY SVM and CL_MEM_USE_HOST_PTR
387    // interactions won't work according to spec as clover manages a GPU side
388    // copy of the host data.
389    //
390    // The biggest problem are memory buffers created with CL_MEM_USE_HOST_PTR,
391    // but the application and/or the kernel updates the memory via SVM and not
392    // the cl_mem buffer.
393    // We can't even do proper tracking on what memory might have been accessed
394    // as the host ptr to the buffer could be within a SVM region, where through
395    // the CL API there is no reliable way of knowing if a certain cl_mem buffer
396    // was accessed by a kernel or not and the runtime can't reliably know from
397    // which side the GPU buffer content needs to be updated.
398    //
399    // Another unsolvable scenario is a cl_mem object passed by cl_mem reference
400    // and SVM pointer into the same kernel at the same time.
401    if (allows_user_pointers() && pipe->caps.system_svm)
402       // we can emulate all lower levels if we support fine grain system
403       return CL_DEVICE_SVM_FINE_GRAIN_SYSTEM |
404              CL_DEVICE_SVM_COARSE_GRAIN_BUFFER |
405              CL_DEVICE_SVM_FINE_GRAIN_BUFFER;
406    return 0;
407 }
408 
409 bool
allows_user_pointers() const410 device::allows_user_pointers() const {
411    return pipe->caps.resource_from_user_memory ||
412           pipe->caps.resource_from_user_memory_compute_only;
413 }
414 
415 std::vector<size_t>
max_block_size() const416 device::max_block_size() const {
417    auto v = get_compute_param<uint64_t>(pipe, ir_format(),
418                                         PIPE_COMPUTE_CAP_MAX_BLOCK_SIZE);
419    return { v.begin(), v.end() };
420 }
421 
422 cl_uint
subgroup_size() const423 device::subgroup_size() const {
424    cl_uint subgroup_sizes =
425       get_compute_param<uint32_t>(pipe, ir_format(), PIPE_COMPUTE_CAP_SUBGROUP_SIZES)[0];
426    if (!subgroup_sizes)
427       return 0;
428    return 1 << (util_last_bit(subgroup_sizes) - 1);
429 }
430 
431 cl_uint
address_bits() const432 device::address_bits() const {
433    return get_compute_param<uint32_t>(pipe, ir_format(),
434                                       PIPE_COMPUTE_CAP_ADDRESS_BITS)[0];
435 }
436 
437 std::string
device_name() const438 device::device_name() const {
439    return pipe->get_name(pipe);
440 }
441 
442 std::string
vendor_name() const443 device::vendor_name() const {
444    return pipe->get_device_vendor(pipe);
445 }
446 
447 enum pipe_shader_ir
ir_format() const448 device::ir_format() const {
449    assert(supports_ir(PIPE_SHADER_IR_NATIVE));
450    return PIPE_SHADER_IR_NATIVE;
451 }
452 
453 std::string
ir_target() const454 device::ir_target() const {
455    std::vector<char> target = get_compute_param<char>(
456       pipe, ir_format(), PIPE_COMPUTE_CAP_IR_TARGET);
457    return { target.data() };
458 }
459 
460 enum pipe_endian
endianness() const461 device::endianness() const {
462    return pipe->caps.endianness;
463 }
464 
465 std::string
device_version_as_string() const466 device::device_version_as_string() const {
467    static const std::string version_string =
468       std::to_string(CL_VERSION_MAJOR(version)) + "." +
469       std::to_string(CL_VERSION_MINOR(version));
470    return version_string;
471 }
472 
473 std::string
device_clc_version_as_string() const474 device::device_clc_version_as_string() const {
475    int major = CL_VERSION_MAJOR(clc_version);
476    int minor = CL_VERSION_MINOR(clc_version);
477 
478    /* for CL 3.0 we need this to be 1.2 until we support 2.0. */
479    if (major == 3) {
480       major = 1;
481       minor = 2;
482    }
483    static const std::string version_string =
484       std::to_string(major) + "." +
485       std::to_string(minor);
486    return version_string;
487 }
488 
489 bool
supports_ir(enum pipe_shader_ir ir) const490 device::supports_ir(enum pipe_shader_ir ir) const {
491    return pipe->get_shader_param(pipe, PIPE_SHADER_COMPUTE,
492                                  PIPE_SHADER_CAP_SUPPORTED_IRS) & (1 << ir);
493 }
494 
495 std::vector<cl_name_version>
supported_extensions() const496 device::supported_extensions() const {
497    std::vector<cl_name_version> vec;
498 
499    vec.push_back( cl_name_version{ CL_MAKE_VERSION(1, 0, 0), "cl_khr_byte_addressable_store" } );
500    vec.push_back( cl_name_version{ CL_MAKE_VERSION(1, 0, 0), "cl_khr_global_int32_base_atomics" } );
501    vec.push_back( cl_name_version{ CL_MAKE_VERSION(1, 0, 0), "cl_khr_global_int32_extended_atomics" } );
502    vec.push_back( cl_name_version{ CL_MAKE_VERSION(1, 0, 0), "cl_khr_local_int32_base_atomics" } );
503    vec.push_back( cl_name_version{ CL_MAKE_VERSION(1, 0, 0), "cl_khr_local_int32_extended_atomics" } );
504    if (has_int64_atomics()) {
505       vec.push_back( cl_name_version{ CL_MAKE_VERSION(1, 0, 0), "cl_khr_int64_base_atomics" } );
506       vec.push_back( cl_name_version{ CL_MAKE_VERSION(1, 0, 0), "cl_khr_int64_extended_atomics" } );
507    }
508    if (has_doubles())
509       vec.push_back( cl_name_version{ CL_MAKE_VERSION(1, 0, 0), "cl_khr_fp64" } );
510    if (has_halves())
511       vec.push_back( cl_name_version{ CL_MAKE_VERSION(1, 0, 0), "cl_khr_fp16" } );
512    if (svm_support())
513       vec.push_back( cl_name_version{ CL_MAKE_VERSION(1, 0, 0), "cl_arm_shared_virtual_memory" } );
514    vec.push_back( cl_name_version{ CL_MAKE_VERSION(1, 0, 0), "cl_khr_extended_versioning" } );
515    return vec;
516 }
517 
518 std::string
supported_extensions_as_string() const519 device::supported_extensions_as_string() const {
520    static std::string extensions_string;
521 
522    if (!extensions_string.empty())
523       return extensions_string;
524 
525    const auto extension_list = supported_extensions();
526    for (const auto &extension : extension_list) {
527       if (!extensions_string.empty())
528          extensions_string += " ";
529       extensions_string += extension.name;
530    }
531    return extensions_string;
532 }
533 
534 std::vector<cl_name_version>
supported_il_versions() const535 device::supported_il_versions() const {
536    return {};
537 }
538 
539 const void *
get_compiler_options(enum pipe_shader_ir ir) const540 device::get_compiler_options(enum pipe_shader_ir ir) const {
541    return pipe->get_compiler_options(pipe, ir, PIPE_SHADER_COMPUTE);
542 }
543 
544 cl_version
device_version() const545 device::device_version() const {
546    return version;
547 }
548 
549 cl_version
device_clc_version(bool api) const550 device::device_clc_version(bool api) const {
551    /*
552     * For the API we have to limit this to 1.2,
553     * but internally we want 3.0 if it works.
554     */
555    if (!api)
556       return clc_version;
557 
558    int major = CL_VERSION_MAJOR(clc_version);
559    /* for CL 3.0 we need this to be 1.2 until we support 2.0. */
560    if (major == 3) {
561       return CL_MAKE_VERSION(1, 2, 0);
562    }
563    return clc_version;
564 }
565 
566 std::vector<cl_name_version>
opencl_c_all_versions() const567 device::opencl_c_all_versions() const {
568    std::vector<cl_name_version> vec;
569    vec.push_back( cl_name_version{ CL_MAKE_VERSION(1, 0, 0), "OpenCL C" } );
570    vec.push_back( cl_name_version{ CL_MAKE_VERSION(1, 1, 0), "OpenCL C" } );
571 
572    if (CL_VERSION_MAJOR(clc_version) == 1 &&
573        CL_VERSION_MINOR(clc_version) == 2)
574       vec.push_back( cl_name_version{ CL_MAKE_VERSION(1, 2, 0), "OpenCL C" } );
575    if (CL_VERSION_MAJOR(clc_version) == 3) {
576       vec.push_back( cl_name_version{ CL_MAKE_VERSION(1, 2, 0), "OpenCL C" } );
577       vec.push_back( cl_name_version{ CL_MAKE_VERSION(3, 0, 0), "OpenCL C" } );
578    }
579    return vec;
580 }
581 
582 std::vector<cl_name_version>
opencl_c_features() const583 device::opencl_c_features() const {
584    std::vector<cl_name_version> vec;
585 
586    vec.push_back( cl_name_version {CL_MAKE_VERSION(3, 0, 0), "__opencl_c_int64" });
587    if (has_doubles())
588       vec.push_back( cl_name_version {CL_MAKE_VERSION(3, 0, 0), "__opencl_c_fp64" });
589 
590    return vec;
591 }
592