1 // This file is part of BOINC. 2 // http://boinc.berkeley.edu 3 // Copyright (C) 2013 University of California 4 // 5 // BOINC is free software; you can redistribute it and/or modify it 6 // under the terms of the GNU Lesser General Public License 7 // as published by the Free Software Foundation, 8 // either version 3 of the License, or (at your option) any later version. 9 // 10 // BOINC is distributed in the hope that it will be useful, 11 // but WITHOUT ANY WARRANTY; without even the implied warranty of 12 // MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. 13 // See the GNU Lesser General Public License for more details. 14 // 15 // You should have received a copy of the GNU Lesser General Public License 16 // along with BOINC. If not, see <http://www.gnu.org/licenses/>. 17 18 #ifndef BOINC_OPENCL_BOINC_H 19 #define BOINC_OPENCL_BOINC_H 20 21 #include "cl_boinc.h" 22 #include "miofile.h" 23 #include "parse.h" 24 25 #define MAX_OPENCL_PLATFORMS 16 26 #define MAX_OPENCL_CPU_PLATFORMS 4 27 28 enum COPROC_USAGE { 29 COPROC_IGNORED, 30 COPROC_UNUSED, 31 COPROC_USED 32 }; 33 34 // there's some duplication between the values in 35 // the OPENCL_DEVICE_PROP struct and the NVIDIA/ATI structs 36 // 37 struct OPENCL_DEVICE_PROP { 38 cl_device_id device_id; 39 char name[256]; // Device name 40 char vendor[256]; // Device vendor (NVIDIA, ATI, AMD, etc.) 41 cl_uint vendor_id; // Vendor's unique ID for this device on this host 42 cl_bool available; // Is this device available? 43 cl_device_fp_config half_fp_config; // Half precision capabilities 44 cl_device_fp_config single_fp_config; // Single precision 45 cl_device_fp_config double_fp_config; // Double precision 46 cl_bool endian_little; // TRUE if little-endian 47 cl_device_exec_capabilities execution_capabilities; 48 char extensions[1024]; // List of device extensions 49 cl_ulong global_mem_size; // in bytes (OpenCL can report 4GB Max) 50 cl_ulong local_mem_size; 51 cl_uint max_clock_frequency; // in MHz 52 cl_uint max_compute_units; 53 54 // 55 // cl_nv_device_attribute_query 56 // 57 cl_uint nv_compute_capability_major; 58 cl_uint nv_compute_capability_minor; 59 60 // 61 // cl_amd_device_attribute_query 62 // 63 cl_uint amd_simd_per_compute_unit; 64 cl_uint amd_simd_width; 65 cl_uint amd_simd_instruction_width; 66 67 char opencl_platform_version[64]; // Version of OpenCL supported 68 // the device's platform 69 char opencl_device_version[64]; // OpenCL version supported by device; 70 // example: "OpenCL 1.1 beta" 71 int opencl_device_version_int; // same, encoded as e.g. 101 72 int get_device_version_int(); // call this to encode 73 int opencl_driver_revision; // OpenCL runtime revision is available 74 int get_opencl_driver_revision(); // call this to encode 75 char opencl_driver_version[32]; // For example: "CLH 1.0" 76 int device_num; // temp used in scan process 77 double peak_flops; // temp used in scan process 78 COPROC_USAGE is_used; // temp used in scan process 79 double opencl_available_ram; // temp used in scan process 80 int opencl_device_index; // zero-based device number within this OpenCL platform 81 bool warn_bad_cuda; // If true, warn we can't use GPU due to CUDA version 82 83 void write_xml(MIOFILE&, const char* tag, bool temp_file=false); 84 int parse(XML_PARSER&, const char* end_tag); 85 void description(char* buf, int buflen, const char* type); clearOPENCL_DEVICE_PROP86 void clear() { 87 memset(this, 0, sizeof(*this)); 88 } 89 }; 90 91 // NOTE: OpenCL has only 32 bits for global_mem_size, so 92 // it can report a max of only 4GB. 93 // Get the CPU RAM size from gstate.hostinfo.m_nbytes. 94 // 95 struct OPENCL_CPU_PROP { 96 char platform_vendor[256]; 97 OPENCL_DEVICE_PROP opencl_prop; 98 OPENCL_CPU_PROPOPENCL_CPU_PROP99 OPENCL_CPU_PROP() { 100 clear(); 101 } 102 void clear(); 103 void write_xml(MIOFILE&); 104 int parse(XML_PARSER&); 105 void description(char* buf, int buflen); 106 }; 107 108 #endif 109