1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 128 129 130 131 132 133 134 135 136 137 138 139 140 141 142 143 144 145 146 147 148 149 150 151 152 153 154 155 156 157 158 159 160 161 162 163 164 165 166 167 168 169 170 171 172 173 174 175 176 177 178 179 180 181 182 183 184 185 186 187 188 189 190 191 192 193 194 195 196 197 198 199 200 201 202 203 204 205 206 207 208 209 210 211 212 213 214 215 216 217 218 219 220 221 222 223 224 225 226 227 228 229 230 231 232 233 234 235 236 237 238 239 240 241 242 243 244 245 246 247 248 249 250 251 252 253 254 255 256 257 258 259 260 261 262 263 264 265 266 267 268 269 270 271 272 273 274 275 276 277 278 279 280 281 282 283 284 285 286 287 288 289 290 291 292 293 294 295 296 297 298 299 300 301 302 303 304 305 306 307 308 309 310 311 312 313 314 315 316 317 318 319 320 321 322 323 324 325 326 327 328 329 330 331 332 333 334 335 336 337 338 339 340 341 342 343 344 345 346 347 348 349 350 351 352 353 354 355 356 357
|
// This file is part of BOINC.
// http://boinc.berkeley.edu
// Copyright (C) 2013 University of California
//
// BOINC is free software; you can redistribute it and/or modify it
// under the terms of the GNU Lesser General Public License
// as published by the Free Software Foundation,
// either version 3 of the License, or (at your option) any later version.
//
// BOINC is distributed in the hope that it will be useful,
// but WITHOUT ANY WARRANTY; without even the implied warranty of
// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.
// See the GNU Lesser General Public License for more details.
//
// You should have received a copy of the GNU Lesser General Public License
// along with BOINC. If not, see <http://www.gnu.org/licenses/>.
#if defined(_WIN32) && !defined(__STDWX_H__)
#include "boinc_win.h"
#elif defined(_WIN32) && defined(__STDWX_H__)
#include "stdwx.h"
#else
#ifdef _USING_FCGI_
#include "boinc_fcgi.h"
#else
#include <cstdio>
#endif
#include <cstring>
#include <cstdlib>
#include <cmath>
#endif
#ifdef _WIN32
#include "win_util.h"
#ifdef _MSC_VER
#define snprintf _snprintf
#endif
#endif
#include "miofile.h"
#include "parse.h"
#include "str_replace.h"
#include "util.h"
#include "opencl_boinc.h"
#ifndef _USING_FCGI_
void OPENCL_DEVICE_PROP::write_xml(MIOFILE& f, const char* tag, bool temp_file) {
f.printf(
" <%s>\n"
" <name>%s</name>\n"
" <vendor>%s</vendor>\n"
" <vendor_id>%lu</vendor_id>\n"
" <available>%d</available>\n"
" <half_fp_config>%llu</half_fp_config>\n"
" <single_fp_config>%llu</single_fp_config>\n"
" <double_fp_config>%llu</double_fp_config>\n"
" <endian_little>%d</endian_little>\n"
" <execution_capabilities>%llu</execution_capabilities>\n"
" <extensions>%s</extensions>\n"
" <global_mem_size>%llu</global_mem_size>\n"
" <local_mem_size>%llu</local_mem_size>\n"
" <max_clock_frequency>%lu</max_clock_frequency>\n"
" <max_compute_units>%lu</max_compute_units>\n"
" <nv_compute_capability_major>%lu</nv_compute_capability_major>\n"
" <nv_compute_capability_minor>%lu</nv_compute_capability_minor>\n"
" <amd_simd_per_compute_unit>%lu</amd_simd_per_compute_unit>\n"
" <amd_simd_width>%lu</amd_simd_width>\n"
" <amd_simd_instruction_width>%lu</amd_simd_instruction_width>\n"
" <opencl_platform_version>%s</opencl_platform_version>\n"
" <opencl_device_version>%s</opencl_device_version>\n"
" <opencl_driver_version>%s</opencl_driver_version>\n",
tag,
name,
vendor,
(unsigned long)vendor_id,
available ? 1 : 0,
half_fp_config,
single_fp_config,
double_fp_config,
endian_little ? 1 : 0,
execution_capabilities,
extensions,
global_mem_size,
local_mem_size,
(unsigned long)max_clock_frequency,
(unsigned long)max_compute_units,
(unsigned long)nv_compute_capability_major,
(unsigned long)nv_compute_capability_minor,
(unsigned long)amd_simd_per_compute_unit,
(unsigned long)amd_simd_width,
(unsigned long)amd_simd_instruction_width,
opencl_platform_version,
opencl_device_version,
opencl_driver_version
);
if (temp_file) {
f.printf(
" <device_num>%d</device_num>\n"
" <peak_flops>%f</peak_flops>\n"
" <opencl_available_ram>%f</opencl_available_ram>\n"
" <opencl_device_index>%d</opencl_device_index>\n"
" <warn_bad_cuda>%d</warn_bad_cuda>\n",
device_num,
peak_flops,
opencl_available_ram,
opencl_device_index,
warn_bad_cuda
);
}
f.printf(" </%s>\n", tag);
}
#endif
int OPENCL_DEVICE_PROP::parse(XML_PARSER& xp, const char* end_tag) {
int n;
unsigned long long ull;
while (!xp.get_tag()) {
if (xp.match_tag(end_tag)) {
get_device_version_int();
get_opencl_driver_revision();
return 0;
}
if (xp.parse_str("name", name, sizeof(name))) continue;
if (xp.parse_str("vendor", vendor, sizeof(vendor))) continue;
if (xp.parse_ulonglong("vendor_id", ull)) {
vendor_id = ull;
continue;
}
if (xp.parse_int("available", n)) {
available = n;
continue;
}
if (xp.parse_ulonglong("half_fp_config", ull)) {
half_fp_config = ull;
continue;
}
if (xp.parse_ulonglong("single_fp_config", ull)) {
single_fp_config = ull;
continue;
}
if (xp.parse_ulonglong("double_fp_config", ull)) {
double_fp_config = ull;
continue;
}
if (xp.parse_int("endian_little", n)) {
endian_little = n;
continue;
}
if (xp.parse_ulonglong("execution_capabilities", ull)) {
execution_capabilities = ull;
continue;
}
if (xp.parse_str("extensions",
extensions,
sizeof(extensions)
)) {
continue;
}
if (xp.parse_ulonglong("global_mem_size", ull)) {
global_mem_size = ull;
continue;
}
if (xp.parse_ulonglong("local_mem_size", ull)) {
local_mem_size = ull;
continue;
}
if (xp.parse_int("max_clock_frequency", n)) {
max_clock_frequency = n;
continue;
}
if (xp.parse_int("max_compute_units", n)) {
max_compute_units = n;
continue;
}
if (xp.parse_int("nv_compute_capability_major", n)) {
nv_compute_capability_major = n;
continue;
}
if (xp.parse_int("nv_compute_capability_minor", n)) {
nv_compute_capability_minor = n;
continue;
}
if (xp.parse_int("amd_simd_per_compute_unit", n)) {
amd_simd_per_compute_unit = n;
continue;
}
if (xp.parse_int("amd_simd_width", n)) {
amd_simd_width = n;
continue;
}
if (xp.parse_int("amd_simd_instruction_width", n)) {
amd_simd_instruction_width = n;
continue;
}
if (xp.parse_str("opencl_platform_version",
opencl_platform_version,
sizeof(opencl_platform_version)
)) {
continue;
}
if (xp.parse_str("opencl_device_version",
opencl_device_version,
sizeof(opencl_device_version)
)) {
continue;
}
if (xp.parse_str("opencl_driver_version",
opencl_driver_version,
sizeof(opencl_driver_version)
)) {
continue;
}
// The following are used only in the
// COPROC_INFO_FILENAME temporary file
if (xp.parse_int("device_num", n)) {
device_num = n;
continue;
}
if (xp.parse_double("peak_flops", peak_flops)) continue;
if (xp.parse_double("opencl_available_ram", opencl_available_ram)) continue;
if (xp.parse_int("opencl_device_index", n)) {
opencl_device_index = n;
continue;
}
if (xp.parse_bool("warn_bad_cuda", warn_bad_cuda)) continue;
}
return ERR_XML_PARSE;
}
int OPENCL_DEVICE_PROP::get_device_version_int() {
int maj, min;
int n = sscanf(
opencl_device_version, "OpenCL %d.%d", &maj, &min
);
if (n != 2) {
return ERR_NOT_FOUND;
}
opencl_device_version_int = 100*maj + min;
return 0;
}
int OPENCL_DEVICE_PROP::get_opencl_driver_revision() {
// gets the OpenCL runtime revision
// Thus far this is only necessary for ATI/AMD because there are bad
// driver sets only distinguisable by the runtime library version.
// Fortunately this info is in the opencl_device_version string.
float rev=0;
char *p=opencl_device_version+sizeof(opencl_device_version)-1;
// find the last opening bracket
while ((p > opencl_device_version) && (*p!='(')) p--;
if (p!=opencl_device_version) {
int n=sscanf(
p, "(%f", &rev
);
// I don't care about errors because for non-ATI GPUs this should
// be zero.
if (n!=1) {
rev=0;
}
}
opencl_driver_revision=floor(rev*100+0.5);
return 0;
}
void OPENCL_DEVICE_PROP::description(char* buf, int buflen, const char* type) {
char s1[256], s2[256];
int n;
// openCL_device_version may have a trailing space
strlcpy(s1, opencl_device_version, sizeof(s1));
n = (int)strlen(s1) - 1;
if ((n > 0) && (s1[n] == ' ')) s1[n] = '\0';
snprintf(s2, sizeof(s2),
"%s (driver version %s, device version %s, %.0fMB, %.0fMB available, %.0f GFLOPS peak)",
name, opencl_driver_version,
s1, global_mem_size/MEGA,
opencl_available_ram/MEGA, peak_flops/1.e9
);
switch(is_used) {
case COPROC_IGNORED:
snprintf(buf, buflen,
"OpenCL: %s %d (ignored by config): %s",
type, device_num, s2
);
break;
case COPROC_USED:
snprintf(buf, buflen,
"OpenCL: %s %d: %s",
type, device_num, s2
);
break;
case COPROC_UNUSED:
default:
snprintf(buf, buflen,
"OpenCL: %s %d (not used): %s",
type, device_num, s2
);
break;
}
}
////////////////// OPENCL CPU STARTS HERE /////////////////
// CPU OpenCL does not really describe a coprocessor but
// this is here to take advantage of the other OpenCL code.
void OPENCL_CPU_PROP::clear() {
platform_vendor[0] = 0;
opencl_prop.clear();
}
void OPENCL_CPU_PROP::write_xml(MIOFILE& f) {
#ifndef _USING_FCGI_
f.printf(
"<opencl_cpu_prop>\n"
" <platform_vendor>%s</platform_vendor>\n",
platform_vendor
);
opencl_prop.write_xml(f, "opencl_cpu_info");
f.printf("</opencl_cpu_prop>\n");
#endif
}
int OPENCL_CPU_PROP::parse(XML_PARSER& xp) {
int retval;
clear();
while (!xp.get_tag()) {
if (xp.match_tag("/opencl_cpu_prop")) {
if (!strlen(platform_vendor)) return ERR_XML_PARSE;
return 0;
}
if (xp.parse_str("platform_vendor", platform_vendor, sizeof(platform_vendor))) continue;
if (xp.match_tag("opencl_cpu_info")) {
retval = opencl_prop.parse(xp, "/opencl_cpu_info");
if (retval) return retval;
continue;
}
}
return ERR_XML_PARSE;
}
void OPENCL_CPU_PROP::description(char* buf, int buflen) {
char s1[256];
int n;
// openCL_device_version may have a trailing space
strlcpy(s1, opencl_prop.opencl_device_version, sizeof(s1));
n = (int)strlen(s1) - 1;
if ((n > 0) && (s1[n] == ' ')) s1[n] = '\0';
snprintf(buf, buflen,
"OpenCL CPU: %s (OpenCL driver vendor: %s, driver version %s, device version %s)",
opencl_prop.name, platform_vendor, opencl_prop.opencl_driver_version, s1
);
}
|