Francisco Jerez | c6db1b3 | 2012-04-20 16:56:19 +0200 | [diff] [blame] | 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 |
Kenneth Graunke | f0cb66b | 2013-04-21 13:52:08 -0700 | [diff] [blame] | 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. |
Francisco Jerez | c6db1b3 | 2012-04-20 16:56:19 +0200 | [diff] [blame] | 21 | // |
| 22 | |
Aaron Watry | 5e253fe | 2017-08-16 20:44:41 -0500 | [diff] [blame] | 23 | #include <unistd.h> |
Francisco Jerez | c6db1b3 | 2012-04-20 16:56:19 +0200 | [diff] [blame] | 24 | #include "core/device.hpp" |
Francisco Jerez | c4578d2 | 2014-02-18 15:07:11 +0100 | [diff] [blame] | 25 | #include "core/platform.hpp" |
Francisco Jerez | c6db1b3 | 2012-04-20 16:56:19 +0200 | [diff] [blame] | 26 | #include "pipe/p_screen.h" |
| 27 | #include "pipe/p_state.h" |
Eric Anholt | 0c31fe9 | 2019-04-29 15:38:24 -0700 | [diff] [blame] | 28 | #include "util/bitscan.h" |
Aaron Watry | 95ae6c0 | 2017-08-09 22:02:30 -0500 | [diff] [blame] | 29 | #include "util/u_debug.h" |
Francisco Jerez | c6db1b3 | 2012-04-20 16:56:19 +0200 | [diff] [blame] | 30 | |
| 31 | using namespace clover; |
| 32 | |
| 33 | namespace { |
| 34 | template<typename T> |
| 35 | std::vector<T> |
Bas Nieuwenhuizen | 1a5c8c2 | 2016-03-25 02:06:50 +0100 | [diff] [blame] | 36 | get_compute_param(pipe_screen *pipe, pipe_shader_ir ir_format, |
| 37 | pipe_compute_cap cap) { |
| 38 | int sz = pipe->get_compute_param(pipe, ir_format, cap, NULL); |
Francisco Jerez | c6db1b3 | 2012-04-20 16:56:19 +0200 | [diff] [blame] | 39 | std::vector<T> v(sz / sizeof(T)); |
| 40 | |
Bas Nieuwenhuizen | 1a5c8c2 | 2016-03-25 02:06:50 +0100 | [diff] [blame] | 41 | pipe->get_compute_param(pipe, ir_format, cap, &v.front()); |
Francisco Jerez | c6db1b3 | 2012-04-20 16:56:19 +0200 | [diff] [blame] | 42 | return v; |
| 43 | } |
| 44 | } |
| 45 | |
Francisco Jerez | c9e009b | 2013-09-15 20:06:57 -0700 | [diff] [blame] | 46 | device::device(clover::platform &platform, pipe_loader_device *ldev) : |
Francisco Jerez | 1a8ad6c | 2013-04-06 14:35:00 +0200 | [diff] [blame] | 47 | platform(platform), ldev(ldev) { |
Nicolai Hähnle | ae7283d | 2017-08-03 15:02:09 +0200 | [diff] [blame] | 48 | pipe = pipe_loader_create_screen(ldev); |
Karol Herbst | deb04ad | 2019-08-06 20:35:48 +0200 | [diff] [blame] | 49 | if (pipe && pipe->get_param(pipe, PIPE_CAP_COMPUTE)) { |
| 50 | if (supports_ir(PIPE_SHADER_IR_NATIVE)) |
| 51 | return; |
| 52 | #ifdef HAVE_CLOVER_SPIRV |
| 53 | if (supports_ir(PIPE_SHADER_IR_NIR_SERIALIZED)) |
| 54 | return; |
| 55 | #endif |
Tom Stellard | c5f0c98 | 2014-05-08 21:08:32 -0400 | [diff] [blame] | 56 | } |
Karol Herbst | deb04ad | 2019-08-06 20:35:48 +0200 | [diff] [blame] | 57 | if (pipe) |
| 58 | pipe->destroy(pipe); |
| 59 | throw error(CL_INVALID_DEVICE); |
Francisco Jerez | c6db1b3 | 2012-04-20 16:56:19 +0200 | [diff] [blame] | 60 | } |
| 61 | |
Francisco Jerez | c9e009b | 2013-09-15 20:06:57 -0700 | [diff] [blame] | 62 | device::~device() { |
Francisco Jerez | c6db1b3 | 2012-04-20 16:56:19 +0200 | [diff] [blame] | 63 | if (pipe) |
| 64 | pipe->destroy(pipe); |
| 65 | if (ldev) |
| 66 | pipe_loader_release(&ldev, 1); |
| 67 | } |
| 68 | |
Francisco Jerez | 369419f | 2013-09-16 21:11:16 -0700 | [diff] [blame] | 69 | bool |
| 70 | device::operator==(const device &dev) const { |
| 71 | return this == &dev; |
| 72 | } |
| 73 | |
Francisco Jerez | c6db1b3 | 2012-04-20 16:56:19 +0200 | [diff] [blame] | 74 | cl_device_type |
Francisco Jerez | c9e009b | 2013-09-15 20:06:57 -0700 | [diff] [blame] | 75 | device::type() const { |
Francisco Jerez | c6db1b3 | 2012-04-20 16:56:19 +0200 | [diff] [blame] | 76 | switch (ldev->type) { |
| 77 | case PIPE_LOADER_DEVICE_SOFTWARE: |
| 78 | return CL_DEVICE_TYPE_CPU; |
| 79 | case PIPE_LOADER_DEVICE_PCI: |
Emil Velikov | 2645842 | 2014-01-11 05:19:36 +0000 | [diff] [blame] | 80 | case PIPE_LOADER_DEVICE_PLATFORM: |
Francisco Jerez | c6db1b3 | 2012-04-20 16:56:19 +0200 | [diff] [blame] | 81 | return CL_DEVICE_TYPE_GPU; |
| 82 | default: |
Francisco Jerez | 27c51b5 | 2014-10-08 17:29:14 +0300 | [diff] [blame] | 83 | unreachable("Unknown device type."); |
Francisco Jerez | c6db1b3 | 2012-04-20 16:56:19 +0200 | [diff] [blame] | 84 | } |
| 85 | } |
| 86 | |
| 87 | cl_uint |
Francisco Jerez | c9e009b | 2013-09-15 20:06:57 -0700 | [diff] [blame] | 88 | device::vendor_id() const { |
Francisco Jerez | c6db1b3 | 2012-04-20 16:56:19 +0200 | [diff] [blame] | 89 | switch (ldev->type) { |
| 90 | case PIPE_LOADER_DEVICE_SOFTWARE: |
Emil Velikov | 2645842 | 2014-01-11 05:19:36 +0000 | [diff] [blame] | 91 | case PIPE_LOADER_DEVICE_PLATFORM: |
Francisco Jerez | c6db1b3 | 2012-04-20 16:56:19 +0200 | [diff] [blame] | 92 | return 0; |
| 93 | case PIPE_LOADER_DEVICE_PCI: |
Francisco Jerez | 03e3bc4 | 2012-05-16 15:43:29 +0200 | [diff] [blame] | 94 | return ldev->u.pci.vendor_id; |
Francisco Jerez | c6db1b3 | 2012-04-20 16:56:19 +0200 | [diff] [blame] | 95 | default: |
Francisco Jerez | 27c51b5 | 2014-10-08 17:29:14 +0300 | [diff] [blame] | 96 | unreachable("Unknown device type."); |
Francisco Jerez | c6db1b3 | 2012-04-20 16:56:19 +0200 | [diff] [blame] | 97 | } |
| 98 | } |
| 99 | |
| 100 | size_t |
Francisco Jerez | c9e009b | 2013-09-15 20:06:57 -0700 | [diff] [blame] | 101 | device::max_images_read() const { |
Marek Olšák | b73bec0 | 2015-07-05 14:34:13 +0200 | [diff] [blame] | 102 | return PIPE_MAX_SHADER_IMAGES; |
Francisco Jerez | c6db1b3 | 2012-04-20 16:56:19 +0200 | [diff] [blame] | 103 | } |
| 104 | |
| 105 | size_t |
Francisco Jerez | c9e009b | 2013-09-15 20:06:57 -0700 | [diff] [blame] | 106 | device::max_images_write() const { |
Marek Olšák | b73bec0 | 2015-07-05 14:34:13 +0200 | [diff] [blame] | 107 | return PIPE_MAX_SHADER_IMAGES; |
Francisco Jerez | c6db1b3 | 2012-04-20 16:56:19 +0200 | [diff] [blame] | 108 | } |
| 109 | |
Serge Martin | 05fcc73 | 2016-10-01 18:51:11 +0200 | [diff] [blame] | 110 | size_t |
| 111 | device::max_image_buffer_size() const { |
| 112 | return pipe->get_param(pipe, PIPE_CAP_MAX_TEXTURE_BUFFER_SIZE); |
| 113 | } |
| 114 | |
Francisco Jerez | c6db1b3 | 2012-04-20 16:56:19 +0200 | [diff] [blame] | 115 | cl_uint |
Francisco Jerez | c9e009b | 2013-09-15 20:06:57 -0700 | [diff] [blame] | 116 | device::max_image_levels_2d() const { |
Eric Anholt | 0c31fe9 | 2019-04-29 15:38:24 -0700 | [diff] [blame] | 117 | return util_last_bit(pipe->get_param(pipe, PIPE_CAP_MAX_TEXTURE_2D_SIZE)); |
Francisco Jerez | c6db1b3 | 2012-04-20 16:56:19 +0200 | [diff] [blame] | 118 | } |
| 119 | |
| 120 | cl_uint |
Francisco Jerez | c9e009b | 2013-09-15 20:06:57 -0700 | [diff] [blame] | 121 | device::max_image_levels_3d() const { |
Francisco Jerez | c6db1b3 | 2012-04-20 16:56:19 +0200 | [diff] [blame] | 122 | return pipe->get_param(pipe, PIPE_CAP_MAX_TEXTURE_3D_LEVELS); |
| 123 | } |
| 124 | |
Serge Martin | 05fcc73 | 2016-10-01 18:51:11 +0200 | [diff] [blame] | 125 | size_t |
| 126 | device::max_image_array_number() const { |
| 127 | return pipe->get_param(pipe, PIPE_CAP_MAX_TEXTURE_ARRAY_LAYERS); |
| 128 | } |
| 129 | |
Francisco Jerez | c6db1b3 | 2012-04-20 16:56:19 +0200 | [diff] [blame] | 130 | cl_uint |
Francisco Jerez | c9e009b | 2013-09-15 20:06:57 -0700 | [diff] [blame] | 131 | device::max_samplers() const { |
Francisco Jerez | c6db1b3 | 2012-04-20 16:56:19 +0200 | [diff] [blame] | 132 | return pipe->get_shader_param(pipe, PIPE_SHADER_COMPUTE, |
| 133 | PIPE_SHADER_CAP_MAX_TEXTURE_SAMPLERS); |
| 134 | } |
| 135 | |
| 136 | cl_ulong |
Francisco Jerez | c9e009b | 2013-09-15 20:06:57 -0700 | [diff] [blame] | 137 | device::max_mem_global() const { |
Bas Nieuwenhuizen | 1a5c8c2 | 2016-03-25 02:06:50 +0100 | [diff] [blame] | 138 | return get_compute_param<uint64_t>(pipe, ir_format(), |
Francisco Jerez | c6db1b3 | 2012-04-20 16:56:19 +0200 | [diff] [blame] | 139 | PIPE_COMPUTE_CAP_MAX_GLOBAL_SIZE)[0]; |
| 140 | } |
| 141 | |
| 142 | cl_ulong |
Francisco Jerez | c9e009b | 2013-09-15 20:06:57 -0700 | [diff] [blame] | 143 | device::max_mem_local() const { |
Bas Nieuwenhuizen | 1a5c8c2 | 2016-03-25 02:06:50 +0100 | [diff] [blame] | 144 | return get_compute_param<uint64_t>(pipe, ir_format(), |
Francisco Jerez | c6db1b3 | 2012-04-20 16:56:19 +0200 | [diff] [blame] | 145 | PIPE_COMPUTE_CAP_MAX_LOCAL_SIZE)[0]; |
| 146 | } |
| 147 | |
| 148 | cl_ulong |
Francisco Jerez | c9e009b | 2013-09-15 20:06:57 -0700 | [diff] [blame] | 149 | device::max_mem_input() const { |
Bas Nieuwenhuizen | 1a5c8c2 | 2016-03-25 02:06:50 +0100 | [diff] [blame] | 150 | return get_compute_param<uint64_t>(pipe, ir_format(), |
Francisco Jerez | c6db1b3 | 2012-04-20 16:56:19 +0200 | [diff] [blame] | 151 | PIPE_COMPUTE_CAP_MAX_INPUT_SIZE)[0]; |
| 152 | } |
| 153 | |
| 154 | cl_ulong |
Francisco Jerez | c9e009b | 2013-09-15 20:06:57 -0700 | [diff] [blame] | 155 | device::max_const_buffer_size() const { |
Francisco Jerez | c6db1b3 | 2012-04-20 16:56:19 +0200 | [diff] [blame] | 156 | return pipe->get_shader_param(pipe, PIPE_SHADER_COMPUTE, |
Marek Olšák | 04f2c88 | 2014-07-24 20:32:08 +0200 | [diff] [blame] | 157 | PIPE_SHADER_CAP_MAX_CONST_BUFFER_SIZE); |
Francisco Jerez | c6db1b3 | 2012-04-20 16:56:19 +0200 | [diff] [blame] | 158 | } |
| 159 | |
| 160 | cl_uint |
Francisco Jerez | c9e009b | 2013-09-15 20:06:57 -0700 | [diff] [blame] | 161 | device::max_const_buffers() const { |
Francisco Jerez | c6db1b3 | 2012-04-20 16:56:19 +0200 | [diff] [blame] | 162 | return pipe->get_shader_param(pipe, PIPE_SHADER_COMPUTE, |
| 163 | PIPE_SHADER_CAP_MAX_CONST_BUFFERS); |
| 164 | } |
| 165 | |
Christoph Bumiller | 5c9bccc | 2012-05-12 19:32:46 +0200 | [diff] [blame] | 166 | size_t |
Francisco Jerez | c9e009b | 2013-09-15 20:06:57 -0700 | [diff] [blame] | 167 | device::max_threads_per_block() const { |
Christoph Bumiller | 5c9bccc | 2012-05-12 19:32:46 +0200 | [diff] [blame] | 168 | return get_compute_param<uint64_t>( |
Bas Nieuwenhuizen | 1a5c8c2 | 2016-03-25 02:06:50 +0100 | [diff] [blame] | 169 | pipe, ir_format(), PIPE_COMPUTE_CAP_MAX_THREADS_PER_BLOCK)[0]; |
Christoph Bumiller | 5c9bccc | 2012-05-12 19:32:46 +0200 | [diff] [blame] | 170 | } |
| 171 | |
Tom Stellard | 71682cf | 2012-09-17 14:29:49 +0000 | [diff] [blame] | 172 | cl_ulong |
Francisco Jerez | c9e009b | 2013-09-15 20:06:57 -0700 | [diff] [blame] | 173 | device::max_mem_alloc_size() const { |
Bas Nieuwenhuizen | 1a5c8c2 | 2016-03-25 02:06:50 +0100 | [diff] [blame] | 174 | return get_compute_param<uint64_t>(pipe, ir_format(), |
Tom Stellard | 71682cf | 2012-09-17 14:29:49 +0000 | [diff] [blame] | 175 | PIPE_COMPUTE_CAP_MAX_MEM_ALLOC_SIZE)[0]; |
| 176 | } |
| 177 | |
Tom Stellard | ca848e8 | 2014-04-18 16:28:41 +0200 | [diff] [blame] | 178 | cl_uint |
| 179 | device::max_clock_frequency() const { |
Bas Nieuwenhuizen | 1a5c8c2 | 2016-03-25 02:06:50 +0100 | [diff] [blame] | 180 | return get_compute_param<uint32_t>(pipe, ir_format(), |
Tom Stellard | ca848e8 | 2014-04-18 16:28:41 +0200 | [diff] [blame] | 181 | PIPE_COMPUTE_CAP_MAX_CLOCK_FREQUENCY)[0]; |
| 182 | } |
| 183 | |
Bruno Jiménez | 2a0dffa | 2014-05-30 17:31:12 +0200 | [diff] [blame] | 184 | cl_uint |
| 185 | device::max_compute_units() const { |
Bas Nieuwenhuizen | 1a5c8c2 | 2016-03-25 02:06:50 +0100 | [diff] [blame] | 186 | return get_compute_param<uint32_t>(pipe, ir_format(), |
Bruno Jiménez | 2a0dffa | 2014-05-30 17:31:12 +0200 | [diff] [blame] | 187 | PIPE_COMPUTE_CAP_MAX_COMPUTE_UNITS)[0]; |
| 188 | } |
| 189 | |
Tom Stellard | 0ec8587 | 2014-07-23 20:37:08 -0400 | [diff] [blame] | 190 | bool |
| 191 | device::image_support() const { |
Bas Nieuwenhuizen | 1a5c8c2 | 2016-03-25 02:06:50 +0100 | [diff] [blame] | 192 | return get_compute_param<uint32_t>(pipe, ir_format(), |
Tom Stellard | 0ec8587 | 2014-07-23 20:37:08 -0400 | [diff] [blame] | 193 | PIPE_COMPUTE_CAP_IMAGES_SUPPORTED)[0]; |
| 194 | } |
| 195 | |
Tom Stellard | c97e902 | 2014-07-02 15:42:43 -0400 | [diff] [blame] | 196 | bool |
| 197 | device::has_doubles() const { |
Nicolai Hähnle | a020cb3 | 2017-01-27 10:35:13 +0100 | [diff] [blame] | 198 | return pipe->get_param(pipe, PIPE_CAP_DOUBLES); |
Tom Stellard | c97e902 | 2014-07-02 15:42:43 -0400 | [diff] [blame] | 199 | } |
| 200 | |
Aaron Watry | d364ab4 | 2017-06-02 21:51:43 -0500 | [diff] [blame] | 201 | bool |
Jan Vesely | fdf0f1d | 2017-09-01 17:48:39 -0400 | [diff] [blame] | 202 | device::has_halves() const { |
| 203 | return pipe->get_shader_param(pipe, PIPE_SHADER_COMPUTE, |
| 204 | PIPE_SHADER_CAP_FP16); |
| 205 | } |
| 206 | |
| 207 | bool |
Jan Vesely | f67ceef | 2017-09-20 16:06:10 -0400 | [diff] [blame] | 208 | device::has_int64_atomics() const { |
| 209 | return pipe->get_shader_param(pipe, PIPE_SHADER_COMPUTE, |
| 210 | PIPE_SHADER_CAP_INT64_ATOMICS); |
| 211 | } |
| 212 | |
| 213 | bool |
Aaron Watry | d364ab4 | 2017-06-02 21:51:43 -0500 | [diff] [blame] | 214 | device::has_unified_memory() const { |
| 215 | return pipe->get_param(pipe, PIPE_CAP_UMA); |
| 216 | } |
| 217 | |
Aaron Watry | 5e253fe | 2017-08-16 20:44:41 -0500 | [diff] [blame] | 218 | cl_uint |
| 219 | device::mem_base_addr_align() const { |
| 220 | return sysconf(_SC_PAGESIZE); |
| 221 | } |
| 222 | |
Karol Herbst | 035e882 | 2018-05-21 12:19:42 +0200 | [diff] [blame] | 223 | cl_device_svm_capabilities |
| 224 | device::svm_support() const { |
| 225 | // Without CAP_RESOURCE_FROM_USER_MEMORY SVM and CL_MEM_USE_HOST_PTR |
| 226 | // interactions won't work according to spec as clover manages a GPU side |
| 227 | // copy of the host data. |
| 228 | // |
| 229 | // The biggest problem are memory buffers created with CL_MEM_USE_HOST_PTR, |
| 230 | // but the application and/or the kernel updates the memory via SVM and not |
| 231 | // the cl_mem buffer. |
| 232 | // We can't even do proper tracking on what memory might have been accessed |
| 233 | // as the host ptr to the buffer could be within a SVM region, where through |
| 234 | // the CL API there is no reliable way of knowing if a certain cl_mem buffer |
| 235 | // was accessed by a kernel or not and the runtime can't reliably know from |
| 236 | // which side the GPU buffer content needs to be updated. |
| 237 | // |
| 238 | // Another unsolvable scenario is a cl_mem object passed by cl_mem reference |
| 239 | // and SVM pointer into the same kernel at the same time. |
| 240 | if (pipe->get_param(pipe, PIPE_CAP_RESOURCE_FROM_USER_MEMORY) && |
| 241 | pipe->get_param(pipe, PIPE_CAP_SYSTEM_SVM)) |
Karol Herbst | a218658 | 2019-05-22 22:34:09 +0200 | [diff] [blame^] | 242 | // we can emulate all lower levels if we support fine grain system |
| 243 | return CL_DEVICE_SVM_FINE_GRAIN_SYSTEM | |
| 244 | CL_DEVICE_SVM_COARSE_GRAIN_BUFFER | |
| 245 | CL_DEVICE_SVM_FINE_GRAIN_BUFFER; |
Karol Herbst | 035e882 | 2018-05-21 12:19:42 +0200 | [diff] [blame] | 246 | return 0; |
| 247 | } |
| 248 | |
Francisco Jerez | c6db1b3 | 2012-04-20 16:56:19 +0200 | [diff] [blame] | 249 | std::vector<size_t> |
Francisco Jerez | c9e009b | 2013-09-15 20:06:57 -0700 | [diff] [blame] | 250 | device::max_block_size() const { |
Bas Nieuwenhuizen | 1a5c8c2 | 2016-03-25 02:06:50 +0100 | [diff] [blame] | 251 | auto v = get_compute_param<uint64_t>(pipe, ir_format(), |
| 252 | PIPE_COMPUTE_CAP_MAX_BLOCK_SIZE); |
Francisco Jerez | b70736f | 2012-05-12 19:33:33 +0200 | [diff] [blame] | 253 | return { v.begin(), v.end() }; |
Francisco Jerez | c6db1b3 | 2012-04-20 16:56:19 +0200 | [diff] [blame] | 254 | } |
| 255 | |
Grigori Goronzy | d15b32e | 2015-05-28 13:01:51 +0200 | [diff] [blame] | 256 | cl_uint |
| 257 | device::subgroup_size() const { |
Bas Nieuwenhuizen | 1a5c8c2 | 2016-03-25 02:06:50 +0100 | [diff] [blame] | 258 | return get_compute_param<uint32_t>(pipe, ir_format(), |
| 259 | PIPE_COMPUTE_CAP_SUBGROUP_SIZE)[0]; |
Grigori Goronzy | d15b32e | 2015-05-28 13:01:51 +0200 | [diff] [blame] | 260 | } |
| 261 | |
Jan Vesely | 083746b | 2016-08-28 04:08:15 -0400 | [diff] [blame] | 262 | cl_uint |
| 263 | device::address_bits() const { |
| 264 | return get_compute_param<uint32_t>(pipe, ir_format(), |
| 265 | PIPE_COMPUTE_CAP_ADDRESS_BITS)[0]; |
| 266 | } |
| 267 | |
Francisco Jerez | c6db1b3 | 2012-04-20 16:56:19 +0200 | [diff] [blame] | 268 | std::string |
Francisco Jerez | c9e009b | 2013-09-15 20:06:57 -0700 | [diff] [blame] | 269 | device::device_name() const { |
Francisco Jerez | c6db1b3 | 2012-04-20 16:56:19 +0200 | [diff] [blame] | 270 | return pipe->get_name(pipe); |
| 271 | } |
| 272 | |
| 273 | std::string |
Francisco Jerez | c9e009b | 2013-09-15 20:06:57 -0700 | [diff] [blame] | 274 | device::vendor_name() const { |
Giuseppe Bilotta | 7932b30 | 2015-03-22 07:21:02 +0100 | [diff] [blame] | 275 | return pipe->get_device_vendor(pipe); |
Francisco Jerez | c6db1b3 | 2012-04-20 16:56:19 +0200 | [diff] [blame] | 276 | } |
| 277 | |
Tom Stellard | 613323b | 2012-04-23 12:09:08 -0400 | [diff] [blame] | 278 | enum pipe_shader_ir |
Francisco Jerez | c9e009b | 2013-09-15 20:06:57 -0700 | [diff] [blame] | 279 | device::ir_format() const { |
Karol Herbst | deb04ad | 2019-08-06 20:35:48 +0200 | [diff] [blame] | 280 | if (supports_ir(PIPE_SHADER_IR_NATIVE)) |
| 281 | return PIPE_SHADER_IR_NATIVE; |
| 282 | |
| 283 | assert(supports_ir(PIPE_SHADER_IR_NIR_SERIALIZED)); |
| 284 | return PIPE_SHADER_IR_NIR_SERIALIZED; |
Tom Stellard | 613323b | 2012-04-23 12:09:08 -0400 | [diff] [blame] | 285 | } |
| 286 | |
Francisco Jerez | c6db1b3 | 2012-04-20 16:56:19 +0200 | [diff] [blame] | 287 | std::string |
Francisco Jerez | c9e009b | 2013-09-15 20:06:57 -0700 | [diff] [blame] | 288 | device::ir_target() const { |
| 289 | std::vector<char> target = get_compute_param<char>( |
Bas Nieuwenhuizen | 1a5c8c2 | 2016-03-25 02:06:50 +0100 | [diff] [blame] | 290 | pipe, ir_format(), PIPE_COMPUTE_CAP_IR_TARGET); |
Tom Stellard | 613323b | 2012-04-23 12:09:08 -0400 | [diff] [blame] | 291 | return { target.data() }; |
Francisco Jerez | c6db1b3 | 2012-04-20 16:56:19 +0200 | [diff] [blame] | 292 | } |
Tom Stellard | 8c9d3c6 | 2013-07-09 21:21:40 -0700 | [diff] [blame] | 293 | |
| 294 | enum pipe_endian |
Francisco Jerez | c9e009b | 2013-09-15 20:06:57 -0700 | [diff] [blame] | 295 | device::endianness() const { |
Tom Stellard | 8c9d3c6 | 2013-07-09 21:21:40 -0700 | [diff] [blame] | 296 | return (enum pipe_endian)pipe->get_param(pipe, PIPE_CAP_ENDIANNESS); |
| 297 | } |
Aaron Watry | 293b3e0 | 2017-07-21 21:17:50 -0500 | [diff] [blame] | 298 | |
| 299 | std::string |
| 300 | device::device_version() const { |
Aaron Watry | 95ae6c0 | 2017-08-09 22:02:30 -0500 | [diff] [blame] | 301 | static const std::string device_version = |
| 302 | debug_get_option("CLOVER_DEVICE_VERSION_OVERRIDE", "1.1"); |
| 303 | return device_version; |
Aaron Watry | 293b3e0 | 2017-07-21 21:17:50 -0500 | [diff] [blame] | 304 | } |
| 305 | |
| 306 | std::string |
| 307 | device::device_clc_version() const { |
Aaron Watry | 95ae6c0 | 2017-08-09 22:02:30 -0500 | [diff] [blame] | 308 | static const std::string device_clc_version = |
| 309 | debug_get_option("CLOVER_DEVICE_CLC_VERSION_OVERRIDE", "1.1"); |
| 310 | return device_clc_version; |
Aaron Watry | 293b3e0 | 2017-07-21 21:17:50 -0500 | [diff] [blame] | 311 | } |
Pierre Moreau | 505ec3a | 2017-10-03 21:07:45 +0200 | [diff] [blame] | 312 | |
| 313 | bool |
| 314 | device::supports_ir(enum pipe_shader_ir ir) const { |
| 315 | return pipe->get_shader_param(pipe, PIPE_SHADER_COMPUTE, |
| 316 | PIPE_SHADER_CAP_SUPPORTED_IRS) & (1 << ir); |
| 317 | } |
Pierre Moreau | b033620 | 2018-01-21 18:49:00 +0100 | [diff] [blame] | 318 | |
| 319 | std::string |
| 320 | device::supported_extensions() const { |
| 321 | return |
| 322 | "cl_khr_byte_addressable_store" |
| 323 | " cl_khr_global_int32_base_atomics" |
| 324 | " cl_khr_global_int32_extended_atomics" |
| 325 | " cl_khr_local_int32_base_atomics" |
| 326 | " cl_khr_local_int32_extended_atomics" |
| 327 | + std::string(has_int64_atomics() ? " cl_khr_int64_base_atomics" : "") |
| 328 | + std::string(has_int64_atomics() ? " cl_khr_int64_extended_atomics" : "") |
| 329 | + std::string(has_doubles() ? " cl_khr_fp64" : "") |
| 330 | + std::string(has_halves() ? " cl_khr_fp16" : ""); |
| 331 | } |
Karol Herbst | deb04ad | 2019-08-06 20:35:48 +0200 | [diff] [blame] | 332 | |
| 333 | const void * |
| 334 | device::get_compiler_options(enum pipe_shader_ir ir) const { |
| 335 | return pipe->get_compiler_options(pipe, ir, PIPE_SHADER_COMPUTE); |
| 336 | } |