1 #ifndef bocl_device_info_h_ 2 #define bocl_device_info_h_ 3 //: 4 // \file 5 // \brief A wrapper for relevant device information in opencl 6 // \author Andrew Miller acm@computervisiongroup.com 7 // \date Jan 25, 2011 8 // 9 // \verbatim 10 // Modifications 11 // Yi Dong Dec, 2015 -- enlarge array size to avoid CL_DEVICE_EXTENSIONS query failure 12 // \endverbatim 13 #include <string> 14 #include <vector> 15 #include <iostream> 16 #include <cstddef> 17 #include <iosfwd> 18 #include "bocl_cl.h" 19 #include "bocl_utils.h" 20 #ifdef _MSC_VER 21 # include <vcl_msvc_warnings.h> 22 #endif 23 24 //Just in case NVIDIA extensions are not defined 25 #ifndef CL_DEVICE_COMPUTE_CAPABILITY_MAJOR_NV 26 /* cl_nv_device_attribute_query extension - no extension #define since it has no functions */ 27 #define CL_DEVICE_COMPUTE_CAPABILITY_MAJOR_NV 0x4000 28 #define CL_DEVICE_COMPUTE_CAPABILITY_MINOR_NV 0x4001 29 #define CL_DEVICE_REGISTERS_PER_BLOCK_NV 0x4002 30 #define CL_DEVICE_WARP_SIZE_NV 0x4003 31 #define CL_DEVICE_GPU_OVERLAP_NV 0x4004 32 #define CL_DEVICE_KERNEL_EXEC_TIMEOUT_NV 0x4005 33 #define CL_DEVICE_INTEGRATED_MEMORY_NV 0x4006 34 #define CL_DEVICE_PCI_BUS_ID_NV 0x4008 35 #define CL_DEVICE_PCI_SLOT_ID_NV 0x4009 36 #endif 37 38 39 //: High level wrapper OpenCL Device information 40 class bocl_device_info 41 { 42 public: 43 bocl_device_info() = default; 44 bocl_device_info(cl_device_id* device); 45 ~bocl_device_info(); 46 47 //:Store a pointer to the cl_device_id 48 cl_device_id* device_; 49 50 //: device info 51 std::string device_name_; 52 std::string device_vendor_; 53 std::string extensions_supported_; 54 std::string platform_name_; 55 std::string platform_version_; 56 std::string driver_version_; 57 cl_device_type device_type_; 58 cl_uint addr_bits_; //!< Device Address Bits (pointer size) 59 std::size_t max_work_group_size_; //!< Max allowed work-items in a group 60 cl_uint max_dimensions_; //!< Max group dimensions allowed 61 std::size_t max_work_item_sizes_[3]; //!< Max work-items sizes in each dimension 62 cl_ulong max_mem_alloc_size_; //!< Max memory alloc size for a buffer 63 cl_ulong max_parameter_size_; //!< Max buffer size that can be passed to a kernel 64 cl_ulong total_local_memory_; //!< Max local memory allowed 65 cl_ulong total_global_memory_; //!< Max global memory allowed 66 cl_uint max_compute_units_; //!< Max compute units 67 cl_uint vector_width_short_; //!< Ideal short vector size 68 cl_uint vector_width_float_; //!< Ideal float vector size 69 cl_uint max_clock_freq_; //!< Maximum clock frequency 70 cl_bool image_support_; //!< image support 71 std::size_t image2d_max_width_; //!< Image2d Max Width 72 std::size_t image2d_max_height_; //!< Image2d Max Height 73 std::size_t image3d_max_width_; //!< Image3d Max Width 74 std::size_t image3d_max_height_; //!< Image3d Max Height 75 std::size_t image3d_max_depth_; //!< Image3d Max Depth 76 77 78 //NVIDIA Specific Properties 79 bool is_nvidia_device_; 80 cl_uint compute_capability_major_, compute_capability_minor_; 81 cl_uint regs_per_block_; 82 cl_uint warp_size_; 83 cl_bool gpu_overlap_; 84 cl_bool exec_timeout_; 85 cl_bool integrated_memory_; 86 cl_uint bus_id_; 87 cl_uint slot_id_; 88 }; 89 90 //: output stream 91 std::ostream& operator <<(std::ostream &s, bocl_device_info& info); 92 93 #endif 94