blob: c681b4c497945e6a09494a23aa2e7d1156769280 [file] [log] [blame]
Francisco Jerezc6db1b32012-04-20 16:56:19 +02001//
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 Graunkef0cb66b2013-04-21 13:52:08 -070017// 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 Jerezc6db1b32012-04-20 16:56:19 +020021//
22
Francisco Jerez099d2812013-09-15 15:29:34 -070023#ifndef CLOVER_CORE_DEVICE_HPP
24#define CLOVER_CORE_DEVICE_HPP
Francisco Jerezc6db1b32012-04-20 16:56:19 +020025
26#include <set>
27#include <vector>
28
Francisco Jerezbff60c82013-10-06 13:51:01 -070029#include "core/object.hpp"
Francisco Jerezc6db1b32012-04-20 16:56:19 +020030#include "core/format.hpp"
Dave Airlief33b4172019-04-10 10:24:46 +100031#include "core/module.hpp"
32#include "util/lazy.hpp"
Francisco Jerezc6db1b32012-04-20 16:56:19 +020033#include "pipe-loader/pipe_loader.h"
34
Dave Airlief33b4172019-04-10 10:24:46 +100035struct nir_shader;
36struct disk_cache;
37
Francisco Jerezc6db1b32012-04-20 16:56:19 +020038namespace clover {
Francisco Jerezc9e009b2013-09-15 20:06:57 -070039 class platform;
Francisco Jerezc6db1b32012-04-20 16:56:19 +020040 class root_resource;
41 class hard_event;
Francisco Jerezc9e009b2013-09-15 20:06:57 -070042
Francisco Jerezc6e7a0d2013-09-16 21:44:19 -070043 class device : public ref_counter, public _cl_device_id {
Francisco Jerezc9e009b2013-09-15 20:06:57 -070044 public:
45 device(clover::platform &platform, pipe_loader_device *ldev);
Francisco Jerezc9e009b2013-09-15 20:06:57 -070046 ~device();
47
Francisco Jerez5226eac2013-09-16 21:44:36 -070048 device(const device &dev) = delete;
49 device &
50 operator=(const device &dev) = delete;
Francisco Jerezc9e009b2013-09-15 20:06:57 -070051
Francisco Jerez369419f2013-09-16 21:11:16 -070052 bool
53 operator==(const device &dev) const;
54
Francisco Jerezc9e009b2013-09-15 20:06:57 -070055 cl_device_type type() const;
56 cl_uint vendor_id() const;
57 size_t max_images_read() const;
58 size_t max_images_write() const;
Serge Martin05fcc732016-10-01 18:51:11 +020059 size_t max_image_buffer_size() const;
Francisco Jerezc9e009b2013-09-15 20:06:57 -070060 cl_uint max_image_levels_2d() const;
61 cl_uint max_image_levels_3d() const;
Serge Martin05fcc732016-10-01 18:51:11 +020062 size_t max_image_array_number() const;
Francisco Jerezc9e009b2013-09-15 20:06:57 -070063 cl_uint max_samplers() const;
64 cl_ulong max_mem_global() const;
65 cl_ulong max_mem_local() const;
66 cl_ulong max_mem_input() const;
67 cl_ulong max_const_buffer_size() const;
68 cl_uint max_const_buffers() const;
69 size_t max_threads_per_block() const;
70 cl_ulong max_mem_alloc_size() const;
Tom Stellardca848e82014-04-18 16:28:41 +020071 cl_uint max_clock_frequency() const;
Bruno Jiménez2a0dffa2014-05-30 17:31:12 +020072 cl_uint max_compute_units() const;
Tom Stellard0ec85872014-07-23 20:37:08 -040073 bool image_support() const;
Tom Stellardc97e9022014-07-02 15:42:43 -040074 bool has_doubles() const;
Jan Veselyfdf0f1d2017-09-01 17:48:39 -040075 bool has_halves() const;
Jan Veselyf67ceef2017-09-20 16:06:10 -040076 bool has_int64_atomics() const;
Aaron Watryd364ab42017-06-02 21:51:43 -050077 bool has_unified_memory() const;
Serge Martindad042b2020-05-03 13:56:15 +020078 size_t mem_base_addr_align() const;
Karol Herbst035e8822018-05-21 12:19:42 +020079 cl_device_svm_capabilities svm_support() const;
Karol Herbstc0f7f832020-05-05 15:09:50 +020080 bool allows_user_pointers() const;
Francisco Jerezc9e009b2013-09-15 20:06:57 -070081
82 std::vector<size_t> max_block_size() const;
Grigori Goronzyd15b32e2015-05-28 13:01:51 +020083 cl_uint subgroup_size() const;
Jan Vesely083746b2016-08-28 04:08:15 -040084 cl_uint address_bits() const;
Francisco Jerezc9e009b2013-09-15 20:06:57 -070085 std::string device_name() const;
86 std::string vendor_name() const;
Aaron Watry293b3e02017-07-21 21:17:50 -050087 std::string device_version() const;
88 std::string device_clc_version() const;
Francisco Jerezc9e009b2013-09-15 20:06:57 -070089 enum pipe_shader_ir ir_format() const;
90 std::string ir_target() const;
91 enum pipe_endian endianness() const;
Pierre Moreau505ec3a2017-10-03 21:07:45 +020092 bool supports_ir(enum pipe_shader_ir ir) const;
Pierre Moreaub0336202018-01-21 18:49:00 +010093 std::string supported_extensions() const;
Francisco Jerezc9e009b2013-09-15 20:06:57 -070094
Francisco Jerez9968d9d2013-10-01 11:57:32 -070095 friend class command_queue;
Francisco Jerezc9e009b2013-09-15 20:06:57 -070096 friend class root_resource;
97 friend class hard_event;
98 friend std::set<cl_image_format>
Francisco Jerez9d06fb82013-09-15 20:50:30 -070099 supported_formats(const context &, cl_mem_object_type);
Karol Herbstdeb04ad2019-08-06 20:35:48 +0200100 const void *get_compiler_options(enum pipe_shader_ir ir) const;
Francisco Jerezc9e009b2013-09-15 20:06:57 -0700101
102 clover::platform &platform;
103
Karol Herbsta2186582019-05-22 22:34:09 +0200104 inline bool
105 has_system_svm() const {
106 return svm_support() & CL_DEVICE_SVM_FINE_GRAIN_SYSTEM;
107 }
108
Dave Airlief33b4172019-04-10 10:24:46 +1000109 lazy<std::shared_ptr<nir_shader>> clc_nir;
110 disk_cache *clc_cache;
Francisco Jerezc9e009b2013-09-15 20:06:57 -0700111 private:
112 pipe_screen *pipe;
113 pipe_loader_device *ldev;
114 };
Francisco Jerezc6db1b32012-04-20 16:56:19 +0200115}
116
Francisco Jerezc6db1b32012-04-20 16:56:19 +0200117#endif