ViennaCL - The Vienna Computing Library  1.5.0
viennacl/ocl/device.hpp
Go to the documentation of this file.
00001 #ifndef VIENNACL_OCL_DEVICE_HPP_
00002 #define VIENNACL_OCL_DEVICE_HPP_
00003 
00004 /* =========================================================================
00005    Copyright (c) 2010-2013, Institute for Microelectronics,
00006                             Institute for Analysis and Scientific Computing,
00007                             TU Wien.
00008    Portions of this software are copyright by UChicago Argonne, LLC.
00009 
00010                             -----------------
00011                   ViennaCL - The Vienna Computing Library
00012                             -----------------
00013 
00014    Project Head:    Karl Rupp                   rupp@iue.tuwien.ac.at
00015 
00016    (A list of authors and contributors can be found in the PDF manual)
00017 
00018    License:         MIT (X11), see file LICENSE in the base directory
00019 ============================================================================= */
00020 
00025 #ifdef __APPLE__
00026 #include <OpenCL/cl.h>
00027 #else
00028 #include <CL/cl.h>
00029 #endif
00030 
00031 #include<stdio.h>
00032 
00033 #include <vector>
00034 #include <string>
00035 #include <sstream>
00036 #include <assert.h>
00037 #include "viennacl/ocl/device_utils.hpp"
00038 #include "viennacl/ocl/handle.hpp"
00039 #include "viennacl/ocl/error.hpp"
00040 
00041 namespace viennacl
00042 {
00043   namespace ocl
00044   {
00045 
00049     class device
00050     {
00051       public:
00052         explicit device() : device_(0) { flush_cache(); }
00053 
00054         explicit device(cl_device_id dev) : device_(dev)
00055         {
00056           #if defined(VIENNACL_DEBUG_ALL) || defined(VIENNACL_DEBUG_DEVICE)
00057           std::cout << "ViennaCL: Creating device object (CTOR with cl_device_id)" << std::endl;
00058           #endif
00059           flush_cache();
00060         }
00061 
00062         device(const device & other) : device_(0)
00063         {
00064           #if defined(VIENNACL_DEBUG_ALL) || defined(VIENNACL_DEBUG_DEVICE)
00065           std::cout << "ViennaCL: Creating device object (Copy CTOR)" << std::endl;
00066           #endif
00067           if (device_ != other.device_)
00068           {
00069             device_ = other.device_;
00070             flush_cache();
00071           }
00072         }
00073 
00075         cl_uint address_bits() const
00076         {
00077           if (!address_bits_valid_)
00078           {
00079             cl_int err = clGetDeviceInfo(device_, CL_DEVICE_ADDRESS_BITS, sizeof(cl_uint), static_cast<void *>(&address_bits_), NULL);
00080             VIENNACL_ERR_CHECK(err);
00081             address_bits_valid_ = true;
00082           }
00083           return address_bits_;
00084         }
00085 
00087         cl_bool available() const
00088         {
00089           if (!available_valid_)
00090           {
00091             cl_int err = clGetDeviceInfo(device_, CL_DEVICE_AVAILABLE, sizeof(cl_bool), static_cast<void *>(&available_), NULL);
00092             VIENNACL_ERR_CHECK(err);
00093             available_valid_ = true;
00094           }
00095           return available_;
00096         }
00097 
00099         cl_bool compiler_available() const
00100         {
00101           if (!compiler_available_valid_)
00102           {
00103             cl_int err = clGetDeviceInfo(device_, CL_DEVICE_COMPILER_AVAILABLE , sizeof(cl_bool), static_cast<void *>(&compiler_available_), NULL);
00104             VIENNACL_ERR_CHECK(err);
00105             compiler_available_valid_ = true;
00106           }
00107           return compiler_available_;
00108         }
00109 
00110 #ifdef CL_DEVICE_DOUBLE_FP_CONFIG
00111 
00124         cl_device_fp_config double_fp_config() const
00125         {
00126           if (!double_fp_config_valid_)
00127           {
00128             cl_int err = clGetDeviceInfo(device_, CL_DEVICE_DOUBLE_FP_CONFIG, sizeof(cl_device_fp_config), static_cast<void *>(&double_fp_config_), NULL);
00129             VIENNACL_ERR_CHECK(err);
00130             double_fp_config_valid_ = true;
00131           }
00132           return double_fp_config_;
00133         }
00134 #endif
00135 
00137         cl_bool endian_little() const
00138         {
00139           if (!endian_little_valid_)
00140           {
00141             cl_int err = clGetDeviceInfo(device_, CL_DEVICE_ENDIAN_LITTLE, sizeof(cl_bool), static_cast<void *>(&endian_little_), NULL);
00142             VIENNACL_ERR_CHECK(err);
00143             endian_little_valid_ = true;
00144           }
00145           return endian_little_;
00146         }
00147 
00149         cl_bool error_correction_support() const
00150         {
00151           if (!error_correction_support_valid_)
00152           {
00153             cl_int err = clGetDeviceInfo(device_, CL_DEVICE_ERROR_CORRECTION_SUPPORT , sizeof(cl_bool), static_cast<void *>(&error_correction_support_), NULL);
00154             VIENNACL_ERR_CHECK(err);
00155             error_correction_support_valid_ = true;
00156           }
00157           return error_correction_support_;
00158         }
00159 
00167         cl_device_exec_capabilities execution_capabilities() const
00168         {
00169           if (!execution_capabilities_valid_)
00170           {
00171             cl_int err = clGetDeviceInfo(device_, CL_DEVICE_EXECUTION_CAPABILITIES  , sizeof(cl_device_exec_capabilities), static_cast<void *>(&execution_capabilities_), NULL);
00172             VIENNACL_ERR_CHECK(err);
00173             execution_capabilities_valid_ = true;
00174           }
00175           return execution_capabilities_;
00176         }
00177 
00189         std::string extensions() const
00190         {
00191           if (!extensions_valid_)
00192           {
00193             cl_int err = clGetDeviceInfo(device_, CL_DEVICE_EXTENSIONS, sizeof(char) * 2048, static_cast<void *>(&extensions_), NULL);
00194             VIENNACL_ERR_CHECK(err);
00195             extensions_valid_ = true;
00196           }
00197           return extensions_;
00198         }
00199 
00201         cl_ulong global_mem_cache_size() const
00202         {
00203           if (!global_mem_cache_size_valid_)
00204           {
00205             cl_int err = clGetDeviceInfo(device_,  CL_DEVICE_GLOBAL_MEM_CACHE_SIZE, sizeof(cl_ulong), static_cast<void *>(&global_mem_cache_size_), NULL);
00206             VIENNACL_ERR_CHECK(err);
00207             global_mem_cache_size_valid_ = true;
00208           }
00209           return global_mem_cache_size_;
00210         }
00211 
00213         cl_device_mem_cache_type global_mem_cache_type() const
00214         {
00215           if (!global_mem_cache_type_valid_)
00216           {
00217             cl_int err = clGetDeviceInfo(device_, CL_DEVICE_GLOBAL_MEM_CACHE_TYPE, sizeof(cl_device_mem_cache_type), static_cast<void *>(&global_mem_cache_type_), NULL);
00218             VIENNACL_ERR_CHECK(err);
00219             global_mem_cache_type_valid_ = true;
00220           }
00221           return global_mem_cache_type_;
00222         }
00223 
00225         cl_uint global_mem_cacheline_size() const
00226         {
00227           if (!global_mem_cacheline_size_valid_)
00228           {
00229             cl_int err = clGetDeviceInfo(device_,  CL_DEVICE_GLOBAL_MEM_CACHELINE_SIZE, sizeof(cl_uint), static_cast<void *>(&global_mem_cacheline_size_), NULL);
00230             VIENNACL_ERR_CHECK(err);
00231             global_mem_cacheline_size_valid_ = true;
00232           }
00233           return global_mem_cacheline_size_;
00234         }
00235 
00237         cl_ulong global_mem_size() const
00238         {
00239           if (!global_mem_size_valid_)
00240           {
00241             cl_int err = clGetDeviceInfo(device_,  CL_DEVICE_GLOBAL_MEM_SIZE, sizeof(cl_ulong), static_cast<void *>(&global_mem_size_), NULL);
00242             VIENNACL_ERR_CHECK(err);
00243             global_mem_size_valid_ = true;
00244           }
00245           return global_mem_size_;
00246         }
00247 
00248 #ifdef CL_DEVICE_HALF_FP_CONFIG
00249 
00261         cl_device_fp_config half_fp_config() const
00262         {
00263           if (!half_fp_config_valid_)
00264           {
00265             cl_int err = clGetDeviceInfo(device_, CL_DEVICE_HALF_FP_CONFIG, sizeof(cl_device_fp_config), static_cast<void *>(&half_fp_config_), NULL);
00266             VIENNACL_ERR_CHECK(err);
00267             half_fp_config_valid_ = true;
00268           }
00269           return half_fp_config_;
00270         }
00271 #endif
00272 
00274         cl_bool host_unified_memory() const
00275         {
00276           if (!host_unified_memory_valid_)
00277           {
00278             cl_int err = clGetDeviceInfo(device_, CL_DEVICE_HOST_UNIFIED_MEMORY, sizeof(cl_bool), static_cast<void *>(&host_unified_memory_), NULL);
00279             VIENNACL_ERR_CHECK(err);
00280             host_unified_memory_valid_ = true;
00281           }
00282           return host_unified_memory_;
00283         }
00284 
00286         cl_bool image_support() const
00287         {
00288           if (!image_support_valid_)
00289           {
00290             cl_int err = clGetDeviceInfo(device_, CL_DEVICE_IMAGE_SUPPORT, sizeof(cl_bool), static_cast<void *>(&image_support_), NULL);
00291             VIENNACL_ERR_CHECK(err);
00292             image_support_valid_ = true;
00293           }
00294           return image_support_;
00295         }
00296 
00298         size_t image2d_max_height() const
00299         {
00300           if (!image2d_max_height_valid_)
00301           {
00302             cl_int err = clGetDeviceInfo(device_, CL_DEVICE_IMAGE2D_MAX_HEIGHT, sizeof(size_t), static_cast<void *>(&image2d_max_height_), NULL);
00303             VIENNACL_ERR_CHECK(err);
00304             image2d_max_height_valid_ = true;
00305           }
00306           return image2d_max_height_;
00307         }
00308 
00310         size_t image2d_max_width() const
00311         {
00312           if (!image2d_max_width_valid_)
00313           {
00314             cl_int err = clGetDeviceInfo(device_, CL_DEVICE_IMAGE2D_MAX_WIDTH, sizeof(size_t), static_cast<void *>(&image2d_max_width_), NULL);
00315             VIENNACL_ERR_CHECK(err);
00316             image2d_max_width_valid_ = true;
00317           }
00318           return image2d_max_width_;
00319         }
00320 
00322         size_t image3d_max_depth() const
00323         {
00324           if (!image3d_max_depth_valid_)
00325           {
00326             cl_int err = clGetDeviceInfo(device_, CL_DEVICE_IMAGE3D_MAX_DEPTH, sizeof(size_t), static_cast<void *>(&image3d_max_depth_), NULL);
00327             VIENNACL_ERR_CHECK(err);
00328             image3d_max_depth_valid_ = true;
00329           }
00330           return image3d_max_depth_;
00331         }
00332 
00334         size_t image3d_max_height() const
00335         {
00336           if (!image3d_max_height_valid_)
00337           {
00338             cl_int err = clGetDeviceInfo(device_, CL_DEVICE_IMAGE3D_MAX_HEIGHT, sizeof(size_t), static_cast<void *>(&image3d_max_height_), NULL);
00339             VIENNACL_ERR_CHECK(err);
00340             image3d_max_height_valid_ = true;
00341           }
00342           return image3d_max_height_;
00343         }
00344 
00346         size_t image3d_max_width() const
00347         {
00348           if (!image3d_max_width_valid_)
00349           {
00350             cl_int err = clGetDeviceInfo(device_, CL_DEVICE_IMAGE3D_MAX_WIDTH, sizeof(size_t), static_cast<void *>(&image3d_max_width_), NULL);
00351             VIENNACL_ERR_CHECK(err);
00352             image3d_max_width_valid_ = true;
00353           }
00354           return image3d_max_width_;
00355         }
00356 
00358         cl_ulong local_mem_size() const
00359         {
00360           if (!local_mem_size_valid_)
00361           {
00362             cl_int err = clGetDeviceInfo(device_, CL_DEVICE_LOCAL_MEM_SIZE, sizeof(cl_ulong), static_cast<void *>(&local_mem_size_), NULL);
00363             VIENNACL_ERR_CHECK(err);
00364             local_mem_size_valid_ = true;
00365           }
00366           return local_mem_size_;
00367         }
00368 
00370         cl_device_local_mem_type local_mem_type() const
00371         {
00372           if (!local_mem_type_valid_)
00373           {
00374             cl_int err = clGetDeviceInfo(device_, CL_DEVICE_LOCAL_MEM_TYPE, sizeof(cl_device_local_mem_type), static_cast<void *>(&local_mem_type_), NULL);
00375             VIENNACL_ERR_CHECK(err);
00376             local_mem_type_valid_ = true;
00377           }
00378           return local_mem_type_;
00379         }
00380 
00382         cl_uint max_clock_frequency() const
00383         {
00384           if (!max_clock_frequency_valid_)
00385           {
00386             cl_int err = clGetDeviceInfo(device_, CL_DEVICE_MAX_CLOCK_FREQUENCY, sizeof(cl_uint), static_cast<void *>(&max_clock_frequency_), NULL);
00387             VIENNACL_ERR_CHECK(err);
00388             max_clock_frequency_valid_ = true;
00389           }
00390           return max_clock_frequency_;
00391         }
00392 
00394         cl_uint max_compute_units() const
00395         {
00396           if (!max_compute_units_valid_)
00397           {
00398             cl_int err = clGetDeviceInfo(device_, CL_DEVICE_MAX_COMPUTE_UNITS, sizeof(cl_uint), static_cast<void *>(&max_compute_units_), NULL);
00399             VIENNACL_ERR_CHECK(err);
00400             max_compute_units_valid_ = true;
00401           }
00402           return max_compute_units_;
00403         }
00404 
00406         cl_uint max_constant_args() const
00407         {
00408           if (!max_constant_args_valid_)
00409           {
00410             cl_int err = clGetDeviceInfo(device_, CL_DEVICE_MAX_CONSTANT_ARGS, sizeof(cl_uint), static_cast<void *>(&max_constant_args_), NULL);
00411             VIENNACL_ERR_CHECK(err);
00412             max_constant_args_valid_ = true;
00413           }
00414           return max_constant_args_;
00415         }
00416 
00418         cl_ulong max_constant_buffer_size() const
00419         {
00420           if (!max_constant_buffer_size_valid_)
00421           {
00422             cl_int err = clGetDeviceInfo(device_, CL_DEVICE_MAX_CONSTANT_BUFFER_SIZE, sizeof(cl_ulong), static_cast<void *>(&max_constant_buffer_size_), NULL);
00423             VIENNACL_ERR_CHECK(err);
00424             max_constant_buffer_size_valid_ = true;
00425           }
00426           return max_constant_buffer_size_;
00427         }
00428 
00430         cl_ulong max_mem_alloc_size() const
00431         {
00432           if (!max_mem_alloc_size_valid_)
00433           {
00434             cl_int err = clGetDeviceInfo(device_, CL_DEVICE_MAX_MEM_ALLOC_SIZE, sizeof(cl_ulong), static_cast<void *>(&max_mem_alloc_size_), NULL);
00435             VIENNACL_ERR_CHECK(err);
00436             max_mem_alloc_size_valid_ = true;
00437           }
00438           return max_mem_alloc_size_;
00439         }
00440 
00445         size_t max_parameter_size() const
00446         {
00447           if (!max_parameter_size_valid_)
00448           {
00449             cl_int err = clGetDeviceInfo(device_, CL_DEVICE_MAX_PARAMETER_SIZE, sizeof(size_t), static_cast<void *>(&max_parameter_size_), NULL);
00450             VIENNACL_ERR_CHECK(err);
00451             max_parameter_size_valid_ = true;
00452           }
00453           return max_parameter_size_;
00454         }
00455 
00457         cl_uint max_read_image_args() const
00458         {
00459           if (!max_read_image_args_valid_)
00460           {
00461             cl_int err = clGetDeviceInfo(device_, CL_DEVICE_MAX_READ_IMAGE_ARGS, sizeof(cl_uint), static_cast<void *>(&max_read_image_args_), NULL);
00462             VIENNACL_ERR_CHECK(err);
00463             max_read_image_args_valid_ = true;
00464           }
00465           return max_read_image_args_;
00466         }
00467 
00469         cl_uint max_samplers() const
00470         {
00471           if (!max_samplers_valid_)
00472           {
00473             cl_int err = clGetDeviceInfo(device_, CL_DEVICE_MAX_SAMPLERS, sizeof(cl_uint), static_cast<void *>(&max_samplers_), NULL);
00474             VIENNACL_ERR_CHECK(err);
00475             max_samplers_valid_ = true;
00476           }
00477           return max_samplers_;
00478         }
00479 
00481         size_t max_work_group_size() const
00482         {
00483           if (!max_work_group_size_valid_)
00484           {
00485             cl_int err = clGetDeviceInfo(device_, CL_DEVICE_MAX_WORK_GROUP_SIZE, sizeof(size_t), static_cast<void *>(&max_work_group_size_), NULL);
00486             VIENNACL_ERR_CHECK(err);
00487             max_work_group_size_valid_ = true;
00488           }
00489           return max_work_group_size_;
00490         }
00491 
00493         cl_uint max_work_item_dimensions() const
00494         {
00495           if (!max_work_item_dimensions_valid_)
00496           {
00497             cl_int err = clGetDeviceInfo(device_, CL_DEVICE_MAX_WORK_ITEM_DIMENSIONS, sizeof(cl_uint), static_cast<void *>(&max_work_item_dimensions_), NULL);
00498             VIENNACL_ERR_CHECK(err);
00499             max_work_item_dimensions_valid_ = true;
00500           }
00501           return max_work_item_dimensions_;
00502         }
00503 
00508         std::vector<size_t> max_work_item_sizes() const
00509         {
00510           std::vector<size_t> result(max_work_item_dimensions());
00511 
00512           assert(result.size() < 16 && bool("Supported work item dimensions exceed available capacity!"));
00513 
00514           if (!max_work_item_sizes_valid_)
00515           {
00516             cl_int err = clGetDeviceInfo(device_, CL_DEVICE_MAX_WORK_ITEM_SIZES, sizeof(size_t) * 16, static_cast<void *>(&max_work_item_sizes_), NULL);
00517             VIENNACL_ERR_CHECK(err);
00518             max_work_item_sizes_valid_ = true;
00519           }
00520 
00521           for (vcl_size_t i=0; i<result.size(); ++i)
00522             result[i] = max_work_item_sizes_[i];
00523 
00524           return result;
00525         }
00526 
00528         cl_uint max_write_image_args() const
00529         {
00530           if (!max_write_image_args_valid_)
00531           {
00532             cl_int err = clGetDeviceInfo(device_, CL_DEVICE_MAX_WRITE_IMAGE_ARGS, sizeof(cl_uint), static_cast<void *>(&max_write_image_args_), NULL);
00533             VIENNACL_ERR_CHECK(err);
00534             max_write_image_args_valid_ = true;
00535           }
00536           return max_write_image_args_;
00537         }
00538 
00540         cl_uint mem_base_addr_align() const
00541         {
00542           if (!mem_base_addr_align_valid_)
00543           {
00544             cl_int err = clGetDeviceInfo(device_, CL_DEVICE_MEM_BASE_ADDR_ALIGN, sizeof(cl_uint), static_cast<void *>(&mem_base_addr_align_), NULL);
00545             VIENNACL_ERR_CHECK(err);
00546             mem_base_addr_align_valid_ = true;
00547           }
00548           return mem_base_addr_align_;
00549         }
00550 
00552         cl_uint min_data_type_align_size() const
00553         {
00554           if (!min_data_type_align_size_valid_)
00555           {
00556             cl_int err = clGetDeviceInfo(device_, CL_DEVICE_MIN_DATA_TYPE_ALIGN_SIZE, sizeof(cl_uint), static_cast<void *>(&min_data_type_align_size_), NULL);
00557             VIENNACL_ERR_CHECK(err);
00558             min_data_type_align_size_valid_ = true;
00559           }
00560           return min_data_type_align_size_;
00561         }
00562 
00564         std::string name() const
00565         {
00566           if (!name_valid_)
00567           {
00568             cl_int err = clGetDeviceInfo(device_, CL_DEVICE_NAME, sizeof(char) * 256, static_cast<void *>(name_), NULL);
00569             VIENNACL_ERR_CHECK(err);
00570             name_valid_ = true;
00571           }
00572           return name_;
00573         }
00574 
00576         device_architecture_family architecture_family() const
00577         {
00578           if( !architecture_family_valid_)
00579           {
00580             architecture_family_ = get_device_architecture(vendor_id(), name());
00581             architecture_family_valid_ = true;
00582           }
00583           return architecture_family_;
00584         }
00585 
00587         cl_uint native_vector_width_char() const
00588         {
00589           if (!native_vector_width_char_valid_)
00590           {
00591             cl_int err = clGetDeviceInfo(device_, CL_DEVICE_NATIVE_VECTOR_WIDTH_CHAR, sizeof(cl_uint), static_cast<void *>(&native_vector_width_char_), NULL);
00592             VIENNACL_ERR_CHECK(err);
00593             native_vector_width_char_valid_ = true;
00594           }
00595           return native_vector_width_char_;
00596         }
00597 
00599         cl_uint native_vector_width_short() const
00600         {
00601           if (!native_vector_width_short_valid_)
00602           {
00603             cl_int err = clGetDeviceInfo(device_, CL_DEVICE_NATIVE_VECTOR_WIDTH_SHORT, sizeof(cl_uint), static_cast<void *>(&native_vector_width_short_), NULL);
00604             VIENNACL_ERR_CHECK(err);
00605             native_vector_width_short_valid_ = true;
00606           }
00607           return native_vector_width_short_;
00608         }
00609 
00611         cl_uint native_vector_width_int() const
00612         {
00613           if (!native_vector_width_int_valid_)
00614           {
00615             cl_int err = clGetDeviceInfo(device_, CL_DEVICE_NATIVE_VECTOR_WIDTH_INT, sizeof(cl_uint), static_cast<void *>(&native_vector_width_int_), NULL);
00616             VIENNACL_ERR_CHECK(err);
00617             native_vector_width_int_valid_ = true;
00618           }
00619           return native_vector_width_int_;
00620         }
00621 
00623         cl_uint native_vector_width_long() const
00624         {
00625           if (!native_vector_width_long_valid_)
00626           {
00627             cl_int err = clGetDeviceInfo(device_, CL_DEVICE_NATIVE_VECTOR_WIDTH_LONG, sizeof(cl_uint), static_cast<void *>(&native_vector_width_long_), NULL);
00628             VIENNACL_ERR_CHECK(err);
00629             native_vector_width_long_valid_ = true;
00630           }
00631           return native_vector_width_long_;
00632         }
00633 
00635         cl_uint native_vector_width_float() const
00636         {
00637           if (!native_vector_width_float_valid_)
00638           {
00639             cl_int err = clGetDeviceInfo(device_, CL_DEVICE_NATIVE_VECTOR_WIDTH_FLOAT, sizeof(cl_uint), static_cast<void *>(&native_vector_width_float_), NULL);
00640             VIENNACL_ERR_CHECK(err);
00641             native_vector_width_float_valid_ = true;
00642           }
00643           return native_vector_width_float_;
00644         }
00645 
00650         cl_uint native_vector_width_double() const
00651         {
00652           if (!native_vector_width_double_valid_)
00653           {
00654             cl_int err = clGetDeviceInfo(device_, CL_DEVICE_NATIVE_VECTOR_WIDTH_DOUBLE, sizeof(cl_uint), static_cast<void *>(&native_vector_width_double_), NULL);
00655             VIENNACL_ERR_CHECK(err);
00656             native_vector_width_double_valid_ = true;
00657           }
00658           return native_vector_width_double_;
00659         }
00660 
00665         cl_uint native_vector_width_half() const
00666         {
00667           if (!native_vector_width_half_valid_)
00668           {
00669             cl_int err = clGetDeviceInfo(device_, CL_DEVICE_NATIVE_VECTOR_WIDTH_HALF, sizeof(cl_uint), static_cast<void *>(&native_vector_width_half_), NULL);
00670             VIENNACL_ERR_CHECK(err);
00671             native_vector_width_half_valid_ = true;
00672           }
00673           return native_vector_width_half_;
00674         }
00675 
00684         std::string opencl_c_version() const
00685         {
00686           if (!opencl_c_version_valid_)
00687           {
00688             cl_int err = clGetDeviceInfo(device_, CL_DEVICE_OPENCL_C_VERSION, sizeof(char) * 128, static_cast<void *>(opencl_c_version_), NULL);
00689             VIENNACL_ERR_CHECK(err);
00690             opencl_c_version_valid_ = true;
00691           }
00692           return opencl_c_version_;
00693         }
00694 
00696         cl_platform_id platform() const
00697         {
00698           if (!platform_valid_)
00699           {
00700             cl_int err = clGetDeviceInfo(device_, CL_DEVICE_PLATFORM, sizeof(cl_platform_id), static_cast<void *>(&platform_), NULL);
00701             VIENNACL_ERR_CHECK(err);
00702             platform_valid_ = true;
00703           }
00704           return platform_;
00705         }
00706 
00708         cl_uint preferred_vector_width_char() const
00709         {
00710           if (!preferred_vector_width_char_valid_)
00711           {
00712             cl_int err = clGetDeviceInfo(device_, CL_DEVICE_PREFERRED_VECTOR_WIDTH_CHAR, sizeof(cl_uint), static_cast<void *>(&preferred_vector_width_char_), NULL);
00713             VIENNACL_ERR_CHECK(err);
00714             preferred_vector_width_char_valid_ = true;
00715           }
00716           return preferred_vector_width_char_;
00717         }
00718 
00720         cl_uint preferred_vector_width_short() const
00721         {
00722           if (!preferred_vector_width_short_valid_)
00723           {
00724             cl_int err = clGetDeviceInfo(device_, CL_DEVICE_PREFERRED_VECTOR_WIDTH_SHORT, sizeof(cl_uint), static_cast<void *>(&preferred_vector_width_short_), NULL);
00725             VIENNACL_ERR_CHECK(err);
00726             preferred_vector_width_short_valid_ = true;
00727           }
00728           return preferred_vector_width_short_;
00729         }
00730 
00732         cl_uint preferred_vector_width_int() const
00733         {
00734           if (!preferred_vector_width_int_valid_)
00735           {
00736             cl_int err = clGetDeviceInfo(device_, CL_DEVICE_PREFERRED_VECTOR_WIDTH_INT, sizeof(cl_uint), static_cast<void *>(&preferred_vector_width_int_), NULL);
00737             VIENNACL_ERR_CHECK(err);
00738             preferred_vector_width_int_valid_ = true;
00739           }
00740           return preferred_vector_width_int_;
00741         }
00742 
00744         cl_uint preferred_vector_width_long() const
00745         {
00746           if (!preferred_vector_width_long_valid_)
00747           {
00748             cl_int err = clGetDeviceInfo(device_, CL_DEVICE_PREFERRED_VECTOR_WIDTH_LONG, sizeof(cl_uint), static_cast<void *>(&preferred_vector_width_long_), NULL);
00749             VIENNACL_ERR_CHECK(err);
00750             preferred_vector_width_long_valid_ = true;
00751           }
00752           return preferred_vector_width_long_;
00753         }
00754 
00756         cl_uint preferred_vector_width_float() const
00757         {
00758           if (!preferred_vector_width_float_valid_)
00759           {
00760             cl_int err = clGetDeviceInfo(device_, CL_DEVICE_PREFERRED_VECTOR_WIDTH_FLOAT, sizeof(cl_uint), static_cast<void *>(&preferred_vector_width_float_), NULL);
00761             VIENNACL_ERR_CHECK(err);
00762             preferred_vector_width_float_valid_ = true;
00763           }
00764           return preferred_vector_width_float_;
00765         }
00766 
00771         cl_uint preferred_vector_width_double() const
00772         {
00773           if (!preferred_vector_width_double_valid_)
00774           {
00775             cl_int err = clGetDeviceInfo(device_, CL_DEVICE_PREFERRED_VECTOR_WIDTH_DOUBLE, sizeof(cl_uint), static_cast<void *>(&preferred_vector_width_double_), NULL);
00776             VIENNACL_ERR_CHECK(err);
00777             preferred_vector_width_double_valid_ = true;
00778           }
00779           return preferred_vector_width_double_;
00780         }
00781 
00786         cl_uint preferred_vector_width_half() const
00787         {
00788           if (!preferred_vector_width_half_valid_)
00789           {
00790             cl_int err = clGetDeviceInfo(device_, CL_DEVICE_PREFERRED_VECTOR_WIDTH_HALF, sizeof(cl_uint), static_cast<void *>(&preferred_vector_width_half_), NULL);
00791             VIENNACL_ERR_CHECK(err);
00792             preferred_vector_width_half_valid_ = true;
00793           }
00794           return preferred_vector_width_half_;
00795         }
00796 
00803         std::string profile() const
00804         {
00805           if (!profile_valid_)
00806           {
00807             cl_int err = clGetDeviceInfo(device_, CL_DEVICE_PROFILE, sizeof(char) * 32, static_cast<void *>(profile_), NULL);
00808             VIENNACL_ERR_CHECK(err);
00809             profile_valid_ = true;
00810           }
00811           return profile_;
00812         }
00813 
00815         size_t profiling_timer_resolution() const
00816         {
00817           if (!profiling_timer_resolution_valid_)
00818           {
00819             cl_int err = clGetDeviceInfo(device_, CL_DEVICE_PROFILING_TIMER_RESOLUTION, sizeof(size_t), static_cast<void *>(&profiling_timer_resolution_), NULL);
00820             VIENNACL_ERR_CHECK(err);
00821             profiling_timer_resolution_valid_ = true;
00822           }
00823           return profiling_timer_resolution_;
00824         }
00825 
00834         cl_command_queue_properties queue_properties() const
00835         {
00836           if (!queue_properties_valid_)
00837           {
00838             cl_int err = clGetDeviceInfo(device_, CL_DEVICE_QUEUE_PROPERTIES, sizeof(cl_command_queue_properties), static_cast<void *>(&queue_properties_), NULL);
00839             VIENNACL_ERR_CHECK(err);
00840             queue_properties_valid_ = true;
00841           }
00842           return queue_properties_;
00843         }
00844 
00858         cl_device_fp_config single_fp_config() const
00859         {
00860           if (!single_fp_config_valid_)
00861           {
00862             cl_int err = clGetDeviceInfo(device_, CL_DEVICE_SINGLE_FP_CONFIG, sizeof(cl_device_fp_config), static_cast<void *>(&single_fp_config_), NULL);
00863             VIENNACL_ERR_CHECK(err);
00864             single_fp_config_valid_ = true;
00865           }
00866           return single_fp_config_;
00867         }
00868 
00873         cl_device_type type() const
00874         {
00875           if (!type_valid_)
00876           {
00877             cl_int err = clGetDeviceInfo(device_, CL_DEVICE_TYPE, sizeof(cl_device_type), static_cast<void *>(&type_), NULL);
00878             VIENNACL_ERR_CHECK(err);
00879             type_valid_ = true;
00880           }
00881           return type_;
00882         }
00883 
00885         std::string vendor() const
00886         {
00887           if (!vendor_valid_)
00888           {
00889             cl_int err = clGetDeviceInfo(device_, CL_DEVICE_VENDOR, sizeof(char) * 256, static_cast<void *>(vendor_), NULL);
00890             VIENNACL_ERR_CHECK(err);
00891             vendor_valid_ = true;
00892           }
00893           return vendor_;
00894         }
00895 
00897         cl_uint vendor_id() const
00898         {
00899           if (!vendor_id_valid_)
00900           {
00901             cl_int err = clGetDeviceInfo(device_, CL_DEVICE_VENDOR_ID, sizeof(cl_uint), static_cast<void *>(&vendor_id_), NULL);
00902             VIENNACL_ERR_CHECK(err);
00903             vendor_id_valid_ = true;
00904           }
00905           return vendor_id_;
00906         }
00907 
00909         std::string version() const
00910         {
00911           if (!version_valid_)
00912           {
00913             cl_int err = clGetDeviceInfo(device_, CL_DEVICE_VERSION, sizeof(char) * 256, static_cast<void *>(version_), NULL);
00914             VIENNACL_ERR_CHECK(err);
00915             version_valid_ = true;
00916           }
00917           return version_;
00918         }
00919 
00921         std::string driver_version() const
00922         {
00923           if (!driver_version_valid_)
00924           {
00925             cl_int err = clGetDeviceInfo(device_, CL_DRIVER_VERSION, sizeof(char) * 256, static_cast<void *>(driver_version_), NULL);
00926             VIENNACL_ERR_CHECK(err);
00927             driver_version_valid_ = true;
00928           }
00929           return driver_version_;
00930         }
00931 
00933 
00934 
00936         bool double_support() const
00937         {
00938           std::string ext = extensions();
00939 
00940           if (ext.find("cl_khr_fp64") != std::string::npos || ext.find("cl_amd_fp64") != std::string::npos)
00941             return true;
00942 
00943           return false;
00944         }
00945 
00947         std::string double_support_extension() const
00948         {
00949           std::string ext = extensions();
00950 
00951           if (ext.find("cl_amd_fp64") != std::string::npos) //AMD extension
00952             return "cl_amd_fp64";
00953 
00954           if (ext.find("cl_khr_fp64") != std::string::npos) //Khronos-certified standard extension for double precision
00955             return "cl_khr_fp64";
00956 
00957           return "";
00958         }
00959 
00961         cl_device_id id() const
00962         {
00963           assert(device_ != 0 && bool("Device ID invalid!"));
00964           return device_;
00965         }
00966 
00975         std::string info(vcl_size_t indent = 0, char indent_char = ' ') const
00976         {
00977           std::string line_indent(indent, indent_char);
00978           std::ostringstream oss;
00979           oss << line_indent << "Name:                " << name() << std::endl;
00980           oss << line_indent << "Vendor:              " << vendor() << std::endl;
00981           oss << line_indent << "Type:                " << device_type_to_string(type()) << std::endl;
00982           oss << line_indent << "Available:           " << available() << std::endl;
00983           oss << line_indent << "Max Compute Units:   " << max_compute_units() << std::endl;
00984           oss << line_indent << "Max Work Group Size: " << max_work_group_size() << std::endl;
00985           oss << line_indent << "Global Mem Size:     " << global_mem_size() << std::endl;
00986           oss << line_indent << "Local Mem Size:      " << local_mem_size() << std::endl;
00987           oss << line_indent << "Local Mem Type:      " << local_mem_type() << std::endl;
00988           oss << line_indent << "Host Unified Memory: " << host_unified_memory() << std::endl;
00989 
00990           return oss.str();
00991         }
00992 
00998         std::string full_info(vcl_size_t indent = 0, char indent_char = ' ') const
00999         {
01000           std::string line_indent(indent, indent_char);
01001           std::ostringstream oss;
01002           oss << line_indent << "Address Bits:                  " << address_bits() << std::endl;
01003           oss << line_indent << "Available:                     " << available() << std::endl;
01004           oss << line_indent << "Compiler Available:            " << compiler_available() << std::endl;
01005 #ifdef CL_DEVICE_DOUBLE_FP_CONFIG
01006           oss << line_indent << "Double FP Config:              " << fp_config_to_string(double_fp_config()) << std::endl;
01007 #endif
01008           oss << line_indent << "Endian Little:                 " << endian_little() << std::endl;
01009           oss << line_indent << "Error Correction Support:      " << error_correction_support() << std::endl;
01010           oss << line_indent << "Execution Capabilities:        " << exec_capabilities_to_string(execution_capabilities()) << std::endl;
01011           oss << line_indent << "Extensions:                    " << extensions() << std::endl;
01012           oss << line_indent << "Global Mem Cache Size:         " << global_mem_cache_size() << " Bytes" << std::endl;
01013           oss << line_indent << "Global Mem Cache Type:         " << mem_cache_type_to_string(global_mem_cache_type()) << std::endl;
01014           oss << line_indent << "Global Mem Cacheline Size:     " << global_mem_cacheline_size() << " Bytes" << std::endl;
01015           oss << line_indent << "Global Mem Size:               " << global_mem_size() << " Bytes" << std::endl;
01016 #ifdef CL_DEVICE_HALF_FP_CONFIG
01017           oss << line_indent << "Half PF Config:                " << fp_config_to_string(half_fp_config()) << std::endl;
01018 #endif
01019           oss << line_indent << "Host Unified Memory:           " << host_unified_memory() << std::endl;
01020           oss << line_indent << "Image Support:                 " << image_support() << std::endl;
01021           oss << line_indent << "Image2D Max Height:            " << image2d_max_height() << std::endl;
01022           oss << line_indent << "Image2D Max Width:             " << image2d_max_width() << std::endl;
01023           oss << line_indent << "Image3D Max Depth:             " << image3d_max_depth() << std::endl;
01024           oss << line_indent << "Image3D Max Height:            " << image3d_max_height() << std::endl;
01025           oss << line_indent << "Image3D Max Width:             " << image3d_max_width() << std::endl;
01026           oss << line_indent << "Local Mem Size:                " << local_mem_size() << " Bytes" << std::endl;
01027           oss << line_indent << "Local Mem Type:                " << local_mem_type_to_string(local_mem_type()) << std::endl;
01028           oss << line_indent << "Max Clock Frequency:           " << max_clock_frequency() << " MHz" << std::endl;
01029           oss << line_indent << "Max Compute Units:             " << max_compute_units() << std::endl;
01030           oss << line_indent << "Max Constant Args:             " << max_constant_args() << std::endl;
01031           oss << line_indent << "Max Constant Buffer Size:      " << max_constant_buffer_size() << " Bytes" << std::endl;
01032           oss << line_indent << "Max Mem Alloc Size:            " << max_mem_alloc_size() << " Bytes" << std::endl;
01033           oss << line_indent << "Max Parameter Size:            " << max_parameter_size() << " Bytes" << std::endl;
01034           oss << line_indent << "Max Read Image Args:           " << max_read_image_args() << std::endl;
01035           oss << line_indent << "Max Samplers:                  " << max_samplers() << std::endl;
01036           oss << line_indent << "Max Work Group Size:           " << max_work_group_size() << std::endl;
01037           oss << line_indent << "Max Work Item Dimensions:      " << max_work_item_dimensions() << std::endl;
01038           oss << line_indent << "Max Work Item Sizes:           " << convert_to_string(max_work_item_sizes()) << std::endl;
01039           oss << line_indent << "Max Write Image Args:          " << max_write_image_args() << std::endl;
01040           oss << line_indent << "Mem Base Addr Align:           " << mem_base_addr_align() << std::endl;
01041           oss << line_indent << "Min Data Type Align Size:      " << min_data_type_align_size() << " Bytes" << std::endl;
01042           oss << line_indent << "Name:                          " << name() << std::endl;
01043           oss << line_indent << "Native Vector Width char:      " << native_vector_width_char() << std::endl;
01044           oss << line_indent << "Native Vector Width short:     " << native_vector_width_short() << std::endl;
01045           oss << line_indent << "Native Vector Width int:       " << native_vector_width_int() << std::endl;
01046           oss << line_indent << "Native Vector Width long:      " << native_vector_width_long() << std::endl;
01047           oss << line_indent << "Native Vector Width float:     " << native_vector_width_float() << std::endl;
01048           oss << line_indent << "Native Vector Width double:    " << native_vector_width_double() << std::endl;
01049           oss << line_indent << "Native Vector Width half:      " << native_vector_width_half() << std::endl;
01050           oss << line_indent << "OpenCL C Version:              " << opencl_c_version() << std::endl;
01051           oss << line_indent << "Platform:                      " << platform() << std::endl;
01052           oss << line_indent << "Preferred Vector Width char:   " << preferred_vector_width_char() << std::endl;
01053           oss << line_indent << "Preferred Vector Width short:  " << preferred_vector_width_short() << std::endl;
01054           oss << line_indent << "Preferred Vector Width int:    " << preferred_vector_width_int() << std::endl;
01055           oss << line_indent << "Preferred Vector Width long:   " << preferred_vector_width_long() << std::endl;
01056           oss << line_indent << "Preferred Vector Width float:  " << preferred_vector_width_float() << std::endl;
01057           oss << line_indent << "Preferred Vector Width double: " << preferred_vector_width_double() << std::endl;
01058           oss << line_indent << "Preferred Vector Width half:   " << preferred_vector_width_half() << std::endl;
01059           oss << line_indent << "Profile:                       " << profile() << std::endl;
01060           oss << line_indent << "Profiling Timer Resolution:    " << profiling_timer_resolution() << " ns" << std::endl;
01061           oss << line_indent << "Queue Properties:              " << queue_properties_to_string(queue_properties()) << std::endl;
01062           oss << line_indent << "Single FP Config:              " << fp_config_to_string(single_fp_config()) << std::endl;
01063           oss << line_indent << "Type:                          " << device_type_to_string(type()) << std::endl;
01064           oss << line_indent << "Vendor:                        " << vendor() << std::endl;
01065           oss << line_indent << "Vendor ID:                     " << vendor_id() << std::endl;
01066           oss << line_indent << "Version:                       " << version() << std::endl;
01067           oss << line_indent << "Driver Version:                " << driver_version() << std::endl;
01068 
01069           return oss.str();
01070         }
01071 
01072         bool operator==(device const & other) const
01073         {
01074           return device_ == other.device_;
01075         }
01076 
01077         bool operator==(cl_device_id other) const
01078         {
01079           return device_ == other;
01080         }
01081 
01082       private:
01083 
01085         std::string fp_config_to_string(cl_device_fp_config conf) const
01086         {
01087           std::ostringstream oss;
01088           if (conf & CL_FP_DENORM)
01089             oss << "CL_FP_DENORM ";
01090           if (conf & CL_FP_INF_NAN)
01091             oss << "CL_FP_INF_NAN ";
01092           if (conf & CL_FP_ROUND_TO_NEAREST)
01093             oss << "CL_FP_ROUND_TO_NEAREST ";
01094           if (conf & CL_FP_ROUND_TO_ZERO)
01095             oss << "CL_FP_ROUND_TO_ZERO ";
01096           if (conf & CL_FP_ROUND_TO_INF)
01097             oss << "CL_FP_ROUND_TO_INF ";
01098           if (conf & CL_FP_FMA)
01099             oss << "CL_FP_FMA ";
01100           if (conf & CL_FP_SOFT_FLOAT)
01101             oss << "CL_FP_SOFT_FLOAT ";
01102 
01103           return oss.str();
01104         }
01105 
01106         std::string exec_capabilities_to_string(cl_device_exec_capabilities cap) const
01107         {
01108           std::ostringstream oss;
01109           if (cap & CL_EXEC_KERNEL)
01110             oss << "CL_EXEC_KERNEL ";
01111           if (cap & CL_EXEC_NATIVE_KERNEL)
01112             oss << "CL_EXEC_NATIVE_KERNEL ";
01113 
01114           return oss.str();
01115         }
01116 
01117         std::string mem_cache_type_to_string(cl_device_mem_cache_type cachetype) const
01118         {
01119           std::ostringstream oss;
01120           if (cachetype == CL_NONE)
01121             oss << "CL_NONE ";
01122           else if (cachetype == CL_READ_ONLY_CACHE)
01123             oss << "CL_READ_ONLY_CACHE ";
01124           else if (cachetype == CL_READ_WRITE_CACHE)
01125             oss << "CL_READ_WRITE_CACHE ";
01126 
01127           return oss.str();
01128         }
01129 
01130         std::string local_mem_type_to_string(cl_device_local_mem_type loc_mem_type) const
01131         {
01132           std::ostringstream oss;
01133           if (loc_mem_type & CL_LOCAL)
01134             oss << "CL_LOCAL ";
01135           if (loc_mem_type & CL_GLOBAL)
01136             oss << "CL_GLOBAL ";
01137 
01138           return oss.str();
01139         }
01140 
01141         std::string convert_to_string(std::vector<size_t> const & vec) const
01142         {
01143           std::ostringstream oss;
01144           for (vcl_size_t i=0; i<vec.size(); ++i)
01145             oss << vec[i] << " ";
01146 
01147           return oss.str();
01148         }
01149 
01150         std::string queue_properties_to_string(cl_command_queue_properties queue_prop) const
01151         {
01152           std::ostringstream oss;
01153           if (queue_prop & CL_QUEUE_OUT_OF_ORDER_EXEC_MODE_ENABLE)
01154             oss << "CL_QUEUE_OUT_OF_ORDER_EXEC_MODE_ENABLE ";
01155           if (queue_prop & CL_QUEUE_PROFILING_ENABLE)
01156             oss << "CL_QUEUE_PROFILING_ENABLE ";
01157 
01158           return oss.str();
01159         }
01160 
01161         std::string device_type_to_string(cl_device_type dev_type) const
01162         {
01163           std::ostringstream oss;
01164           if (dev_type & CL_DEVICE_TYPE_GPU)
01165             oss << "GPU ";
01166           if (dev_type & CL_DEVICE_TYPE_CPU)
01167             oss << "CPU ";
01168           if (dev_type & CL_DEVICE_TYPE_ACCELERATOR)
01169             oss << "Accelerator ";
01170           if (dev_type & CL_DEVICE_TYPE_DEFAULT)
01171             oss << "(default)";
01172 
01173           return oss.str();
01174         }
01175 
01176         void flush_cache()
01177         {
01178           address_bits_valid_       = false;
01179           architecture_family_valid_ = false;
01180           available_valid_          = false;
01181           compiler_available_valid_ = false;
01182 #ifdef CL_DEVICE_DOUBLE_FP_CONFIG
01183           double_fp_config_valid_   = false;
01184 #endif
01185           endian_little_valid_      = false;
01186           error_correction_support_valid_  = false;
01187           execution_capabilities_valid_    = false;
01188           extensions_valid_                = false;
01189           global_mem_cache_size_valid_     = false;
01190           global_mem_cache_type_valid_     = false;
01191           global_mem_cacheline_size_valid_ = false;
01192           global_mem_size_valid_           = false;
01193 #ifdef CL_DEVICE_HALF_FP_CONFIG
01194           half_fp_config_valid_      = false;
01195 #endif
01196           host_unified_memory_valid_ = false;
01197           image_support_valid_       = false;
01198           image2d_max_height_valid_  = false;
01199           image2d_max_width_valid_   = false;
01200           image3d_max_depth_valid_   = false;
01201           image3d_max_height_valid_  = false;
01202           image3d_max_width_valid_   = false;
01203           local_mem_size_valid_      = false;
01204           local_mem_type_valid_      = false;
01205           max_clock_frequency_valid_ = false;
01206           max_compute_units_valid_   = false;
01207           max_constant_args_valid_   = false;
01208           max_constant_buffer_size_valid_ = false;
01209           max_mem_alloc_size_valid_  = false;
01210           max_parameter_size_valid_  = false;
01211           max_read_image_args_valid_ = false;
01212           max_samplers_valid_        = false;
01213           max_work_group_size_valid_ = false;
01214           max_work_item_dimensions_valid_ = false;
01215           max_work_item_sizes_valid_  = false;
01216           max_write_image_args_valid_ = false;
01217           mem_base_addr_align_valid_  = false;
01218           min_data_type_align_size_valid_ = false;
01219           name_valid_ = false;
01220           native_vector_width_char_valid_   = false;
01221           native_vector_width_short_valid_  = false;
01222           native_vector_width_int_valid_    = false;
01223           native_vector_width_long_valid_   = false;
01224           native_vector_width_float_valid_  = false;
01225           native_vector_width_double_valid_ = false;
01226           native_vector_width_half_valid_   = false;
01227           opencl_c_version_valid_ = false;
01228           platform_valid_ = false;
01229           preferred_vector_width_char_valid_   = false;
01230           preferred_vector_width_short_valid_  = false;
01231           preferred_vector_width_int_valid_    = false;
01232           preferred_vector_width_long_valid_   = false;
01233           preferred_vector_width_float_valid_  = false;
01234           preferred_vector_width_double_valid_ = false;
01235           preferred_vector_width_half_valid_   = false;
01236           profile_valid_ = false;
01237           profiling_timer_resolution_valid_ = false;
01238           queue_properties_valid_ = false;
01239           single_fp_config_valid_ = false;
01240           type_valid_             = false;
01241           vendor_valid_           = false;
01242           vendor_id_valid_        = false;
01243           version_valid_          = false;
01244           driver_version_valid_   = false;
01245         }
01246 
01247         cl_device_id    device_;
01248 
01249         //
01250         // Device information supported by OpenCL 1.0 to follow
01251         // cf. http://www.khronos.org/registry/cl/sdk/1.0/docs/man/xhtml/clGetDeviceInfo.html
01252         // Note that all members are declared 'mutable', as they represent a caching mechanism in order to circumvent repeated potentially expensive calls to the OpenCL SDK
01253         //
01254 
01255         mutable bool    address_bits_valid_;
01256         mutable cl_uint address_bits_;
01257 
01258         mutable bool    available_valid_;
01259         mutable cl_bool available_;
01260 
01261         mutable bool    compiler_available_valid_;
01262         mutable cl_bool compiler_available_;
01263 
01264 #ifdef CL_DEVICE_DOUBLE_FP_CONFIG
01265         mutable bool                double_fp_config_valid_;
01266         mutable cl_device_fp_config double_fp_config_;
01267 #endif
01268 
01269         mutable bool    endian_little_valid_;
01270         mutable cl_bool endian_little_;
01271 
01272         mutable bool    error_correction_support_valid_;
01273         mutable cl_bool error_correction_support_;
01274 
01275         mutable bool                        execution_capabilities_valid_;
01276         mutable cl_device_exec_capabilities execution_capabilities_;
01277 
01278         mutable bool extensions_valid_;
01279         mutable char extensions_[2048];    // don't forget to adjust member function accordingly when changing array size
01280 
01281         mutable bool     global_mem_cache_size_valid_;
01282         mutable cl_ulong global_mem_cache_size_;
01283 
01284         mutable bool                     global_mem_cache_type_valid_;
01285         mutable cl_device_mem_cache_type global_mem_cache_type_;
01286 
01287         mutable bool    global_mem_cacheline_size_valid_;
01288         mutable cl_uint global_mem_cacheline_size_;
01289 
01290         mutable bool     global_mem_size_valid_;
01291         mutable cl_ulong global_mem_size_;
01292 
01293 #ifdef CL_DEVICE_HALF_FP_CONFIG
01294         mutable bool                half_fp_config_valid_;
01295         mutable cl_device_fp_config half_fp_config_;
01296 #endif
01297 
01298         mutable bool    host_unified_memory_valid_;
01299         mutable cl_bool host_unified_memory_;
01300 
01301         mutable bool    image_support_valid_;
01302         mutable cl_bool image_support_;
01303 
01304         mutable bool   image2d_max_height_valid_;
01305         mutable size_t image2d_max_height_;
01306 
01307         mutable bool   image2d_max_width_valid_;
01308         mutable size_t image2d_max_width_;
01309 
01310         mutable bool   image3d_max_depth_valid_;
01311         mutable size_t image3d_max_depth_;
01312 
01313         mutable bool   image3d_max_height_valid_;
01314         mutable size_t image3d_max_height_;
01315 
01316         mutable bool   image3d_max_width_valid_;
01317         mutable size_t image3d_max_width_;
01318 
01319         mutable bool     local_mem_size_valid_;
01320         mutable cl_ulong local_mem_size_;
01321 
01322         mutable bool                     local_mem_type_valid_;
01323         mutable cl_device_local_mem_type local_mem_type_;
01324 
01325         mutable bool    max_clock_frequency_valid_;
01326         mutable cl_uint max_clock_frequency_;
01327 
01328         mutable bool    max_compute_units_valid_;
01329         mutable cl_uint max_compute_units_;
01330 
01331         mutable bool    max_constant_args_valid_;
01332         mutable cl_uint max_constant_args_;
01333 
01334         mutable bool     max_constant_buffer_size_valid_;
01335         mutable cl_ulong max_constant_buffer_size_;
01336 
01337         mutable bool     max_mem_alloc_size_valid_;
01338         mutable cl_ulong max_mem_alloc_size_;
01339 
01340         mutable bool   max_parameter_size_valid_;
01341         mutable size_t max_parameter_size_;
01342 
01343         mutable bool    max_read_image_args_valid_;
01344         mutable cl_uint max_read_image_args_;
01345 
01346         mutable bool    max_samplers_valid_;
01347         mutable cl_uint max_samplers_;
01348 
01349         mutable bool   max_work_group_size_valid_;
01350         mutable size_t max_work_group_size_;
01351 
01352         mutable bool    max_work_item_dimensions_valid_;
01353         mutable cl_uint max_work_item_dimensions_;
01354 
01355         mutable bool   max_work_item_sizes_valid_;
01356         mutable size_t max_work_item_sizes_[16];   //we do not support execution models with more than 16 dimensions. This should totally suffice in practice, though.
01357 
01358         mutable bool    max_write_image_args_valid_;
01359         mutable cl_uint max_write_image_args_;
01360 
01361         mutable bool    mem_base_addr_align_valid_;
01362         mutable cl_uint mem_base_addr_align_;
01363 
01364         mutable bool    min_data_type_align_size_valid_;
01365         mutable cl_uint min_data_type_align_size_;
01366 
01367         mutable bool name_valid_;
01368         mutable char name_[256];    // don't forget to adjust member function accordingly when changing array size
01369 
01370         mutable bool    native_vector_width_char_valid_;
01371         mutable cl_uint native_vector_width_char_;
01372 
01373         mutable bool    native_vector_width_short_valid_;
01374         mutable cl_uint native_vector_width_short_;
01375 
01376         mutable bool    native_vector_width_int_valid_;
01377         mutable cl_uint native_vector_width_int_;
01378 
01379         mutable bool    native_vector_width_long_valid_;
01380         mutable cl_uint native_vector_width_long_;
01381 
01382         mutable bool    native_vector_width_float_valid_;
01383         mutable cl_uint native_vector_width_float_;
01384 
01385         mutable bool    native_vector_width_double_valid_;
01386         mutable cl_uint native_vector_width_double_;
01387 
01388         mutable bool    native_vector_width_half_valid_;
01389         mutable cl_uint native_vector_width_half_;
01390 
01391         mutable bool opencl_c_version_valid_;
01392         mutable char opencl_c_version_[128];    // don't forget to adjust member function accordingly when changing array size
01393 
01394         mutable bool           platform_valid_;
01395         mutable cl_platform_id platform_;
01396 
01397         mutable bool    preferred_vector_width_char_valid_;
01398         mutable cl_uint preferred_vector_width_char_;
01399 
01400         mutable bool    preferred_vector_width_short_valid_;
01401         mutable cl_uint preferred_vector_width_short_;
01402 
01403         mutable bool    preferred_vector_width_int_valid_;
01404         mutable cl_uint preferred_vector_width_int_;
01405 
01406         mutable bool    preferred_vector_width_long_valid_;
01407         mutable cl_uint preferred_vector_width_long_;
01408 
01409         mutable bool    preferred_vector_width_float_valid_;
01410         mutable cl_uint preferred_vector_width_float_;
01411 
01412         mutable bool    preferred_vector_width_double_valid_;
01413         mutable cl_uint preferred_vector_width_double_;
01414 
01415         mutable bool    preferred_vector_width_half_valid_;
01416         mutable cl_uint preferred_vector_width_half_;
01417 
01418         mutable bool profile_valid_;
01419         mutable char profile_[32];    // don't forget to adjust member function accordingly when changing array size
01420 
01421         mutable bool   profiling_timer_resolution_valid_;
01422         mutable size_t profiling_timer_resolution_;
01423 
01424         mutable bool                        queue_properties_valid_;
01425         mutable cl_command_queue_properties queue_properties_;
01426 
01427         mutable bool                single_fp_config_valid_;
01428         mutable cl_device_fp_config single_fp_config_;
01429 
01430         mutable bool           type_valid_;
01431         mutable cl_device_type type_;
01432 
01433         mutable bool vendor_valid_;
01434         mutable char vendor_[256];    // don't forget to adjust member function accordingly when changing array size
01435 
01436         mutable bool    vendor_id_valid_;
01437         mutable cl_uint vendor_id_;
01438 
01439         mutable bool version_valid_;
01440         mutable char version_[256];    // don't forget to adjust member function accordingly when changing array size
01441 
01442         mutable bool driver_version_valid_;
01443         mutable char driver_version_[256];    // don't forget to adjust member function accordingly when changing array size
01444 
01445         mutable bool architecture_family_valid_;
01446         mutable device_architecture_family architecture_family_;
01447     };
01448 
01449   } //namespace ocl
01450 } //namespace viennacl
01451 
01452 #endif