Home | History | Annotate | Download | only in core
      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 #ifndef CLOVER_CORE_DEVICE_HPP
     24 #define CLOVER_CORE_DEVICE_HPP
     25 
     26 #include <set>
     27 #include <vector>
     28 
     29 #include "core/object.hpp"
     30 #include "core/format.hpp"
     31 #include "pipe-loader/pipe_loader.h"
     32 
     33 namespace clover {
     34    class platform;
     35    class root_resource;
     36    class hard_event;
     37 
     38    class device : public ref_counter, public _cl_device_id {
     39    public:
     40       device(clover::platform &platform, pipe_loader_device *ldev);
     41       ~device();
     42 
     43       device(const device &dev) = delete;
     44       device &
     45       operator=(const device &dev) = delete;
     46 
     47       bool
     48       operator==(const device &dev) const;
     49 
     50       cl_device_type type() const;
     51       cl_uint vendor_id() const;
     52       size_t max_images_read() const;
     53       size_t max_images_write() const;
     54       size_t max_image_buffer_size() const;
     55       cl_uint max_image_levels_2d() const;
     56       cl_uint max_image_levels_3d() const;
     57       size_t max_image_array_number() const;
     58       cl_uint max_samplers() const;
     59       cl_ulong max_mem_global() const;
     60       cl_ulong max_mem_local() const;
     61       cl_ulong max_mem_input() const;
     62       cl_ulong max_const_buffer_size() const;
     63       cl_uint max_const_buffers() const;
     64       size_t max_threads_per_block() const;
     65       cl_ulong max_mem_alloc_size() const;
     66       cl_uint max_clock_frequency() const;
     67       cl_uint max_compute_units() const;
     68       bool image_support() const;
     69       bool has_doubles() const;
     70 
     71       std::vector<size_t> max_block_size() const;
     72       cl_uint subgroup_size() const;
     73       cl_uint address_bits() const;
     74       std::string device_name() const;
     75       std::string vendor_name() const;
     76       enum pipe_shader_ir ir_format() const;
     77       std::string ir_target() const;
     78       enum pipe_endian endianness() const;
     79 
     80       friend class command_queue;
     81       friend class root_resource;
     82       friend class hard_event;
     83       friend std::set<cl_image_format>
     84       supported_formats(const context &, cl_mem_object_type);
     85 
     86       clover::platform &platform;
     87 
     88    private:
     89       pipe_screen *pipe;
     90       pipe_loader_device *ldev;
     91    };
     92 }
     93 
     94 #endif
     95