2008-09-06 12:23:56 +00:00
|
|
|
// This file is part of BOINC.
|
|
|
|
// http://boinc.berkeley.edu
|
|
|
|
// Copyright (C) 2008 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/>.
|
|
|
|
|
2009-02-26 00:23:23 +00:00
|
|
|
#ifndef _USING_FCGI_
|
|
|
|
#include "boinc_fcgi.h"
|
|
|
|
#else
|
|
|
|
#include <cstdio>
|
|
|
|
#endif
|
|
|
|
|
|
|
|
#include <cstring>
|
|
|
|
#include <cstdlib>
|
2008-09-06 12:23:56 +00:00
|
|
|
#ifdef _WIN32
|
2009-02-18 21:21:12 +00:00
|
|
|
#ifndef SIM
|
2009-02-16 23:03:03 +00:00
|
|
|
#include <nvapi.h>
|
2009-02-18 21:21:12 +00:00
|
|
|
#endif
|
2008-09-06 12:23:56 +00:00
|
|
|
#else
|
|
|
|
#ifdef __APPLE__
|
|
|
|
// Suppress obsolete warning when building for OS 10.3.9
|
|
|
|
#define DLOPEN_NO_WARN
|
|
|
|
#endif
|
|
|
|
#include <dlfcn.h>
|
|
|
|
#endif
|
|
|
|
|
|
|
|
#include "error_numbers.h"
|
|
|
|
#include "filesys.h"
|
|
|
|
#include "parse.h"
|
2008-12-16 18:46:28 +00:00
|
|
|
#include "str_util.h"
|
2008-09-06 12:23:56 +00:00
|
|
|
|
|
|
|
#include "coproc.h"
|
|
|
|
|
|
|
|
using std::string;
|
|
|
|
using std::vector;
|
|
|
|
|
2009-02-26 00:23:23 +00:00
|
|
|
#ifndef _USING_FCGI_
|
|
|
|
using std::perror;
|
|
|
|
#endif
|
|
|
|
|
2008-09-06 12:23:56 +00:00
|
|
|
#ifndef _USING_FCGI_
|
|
|
|
void COPROC::write_xml(MIOFILE& f) {
|
|
|
|
f.printf(
|
|
|
|
"<coproc>\n"
|
|
|
|
" <type>%s</type>\n"
|
|
|
|
" <count>%d</count>\n"
|
|
|
|
"</coproc>\n",
|
|
|
|
type, count
|
|
|
|
);
|
|
|
|
}
|
|
|
|
#endif
|
|
|
|
|
|
|
|
int COPROC::parse(MIOFILE& fin) {
|
|
|
|
char buf[1024];
|
|
|
|
strcpy(type, "");
|
|
|
|
count = 0;
|
|
|
|
used = 0;
|
2009-01-03 06:01:17 +00:00
|
|
|
req_secs = 0;
|
2009-01-30 21:25:24 +00:00
|
|
|
estimated_delay = 0;
|
2009-01-03 06:01:17 +00:00
|
|
|
req_instances = 0;
|
2008-09-06 12:23:56 +00:00
|
|
|
while (fin.fgets(buf, sizeof(buf))) {
|
|
|
|
if (match_tag(buf, "</coproc>")) {
|
|
|
|
if (!strlen(type)) return ERR_XML_PARSE;
|
|
|
|
return 0;
|
|
|
|
}
|
|
|
|
if (parse_str(buf, "<type>", type, sizeof(type))) continue;
|
|
|
|
if (parse_int(buf, "<count>", count)) continue;
|
2009-01-03 06:01:17 +00:00
|
|
|
if (parse_double(buf, "<req_secs>", req_secs)) continue;
|
|
|
|
if (parse_int(buf, "<req_instances>", req_instances)) continue;
|
2009-01-30 21:25:24 +00:00
|
|
|
if (parse_double(buf, "<estimated_delay>", estimated_delay)) continue;
|
2008-09-06 12:23:56 +00:00
|
|
|
}
|
|
|
|
return ERR_XML_PARSE;
|
|
|
|
}
|
|
|
|
|
2008-12-16 18:46:28 +00:00
|
|
|
void COPROCS::summary_string(char* buf, int len) {
|
|
|
|
char bigbuf[8192], buf2[1024];
|
|
|
|
|
|
|
|
strcpy(bigbuf, "");
|
|
|
|
for (unsigned int i=0; i<coprocs.size(); i++) {
|
|
|
|
COPROC* cp = coprocs[i];
|
|
|
|
if (!strcmp(cp->type, "CUDA")) {
|
|
|
|
COPROC_CUDA* cp2 = (COPROC_CUDA*) cp;
|
2008-12-23 01:28:24 +00:00
|
|
|
int mem = (int)(cp2->prop.dtotalGlobalMem/MEGA);
|
2009-02-24 00:06:45 +00:00
|
|
|
sprintf(buf2, "[CUDA|%s|%d|%dMB|%d]",
|
|
|
|
cp2->prop.name, cp2->count, mem, cp2->drvVersion
|
|
|
|
);
|
2008-12-16 18:46:28 +00:00
|
|
|
strcat(bigbuf, buf2);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
bigbuf[len-1] = 0;
|
|
|
|
strcpy(buf, bigbuf);
|
|
|
|
}
|
|
|
|
|
2009-04-27 23:51:46 +00:00
|
|
|
vector<string> COPROCS::get(bool use_all) {
|
2008-09-06 12:23:56 +00:00
|
|
|
vector<string> strings;
|
2009-04-27 23:51:46 +00:00
|
|
|
COPROC_CUDA::get(*this, strings, use_all);
|
2008-09-06 12:23:56 +00:00
|
|
|
return strings;
|
|
|
|
}
|
|
|
|
|
2009-03-06 22:21:47 +00:00
|
|
|
// used only to parse scheduler request messages
|
|
|
|
//
|
2008-09-06 12:23:56 +00:00
|
|
|
int COPROCS::parse(FILE* fin) {
|
|
|
|
char buf[1024];
|
|
|
|
|
|
|
|
while (fgets(buf, sizeof(buf), fin)) {
|
|
|
|
if (match_tag(buf, "</coprocs>")) {
|
|
|
|
return 0;
|
|
|
|
}
|
|
|
|
if (strstr(buf, "<coproc_cuda>")) {
|
|
|
|
COPROC_CUDA* cc = new COPROC_CUDA;
|
|
|
|
int retval = cc->parse(fin);
|
|
|
|
if (!retval) {
|
|
|
|
coprocs.push_back(cc);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
return ERR_XML_PARSE;
|
|
|
|
}
|
|
|
|
|
2009-01-12 23:47:52 +00:00
|
|
|
COPROC* COPROCS::lookup(const char* type) {
|
2008-09-06 12:23:56 +00:00
|
|
|
for (unsigned int i=0; i<coprocs.size(); i++) {
|
|
|
|
COPROC* cp = coprocs[i];
|
|
|
|
if (!strcmp(type, cp->type)) return cp;
|
|
|
|
}
|
|
|
|
return NULL;
|
|
|
|
}
|
|
|
|
|
|
|
|
#ifdef _WIN32
|
|
|
|
|
|
|
|
|
|
|
|
#endif
|
|
|
|
|
2009-05-04 02:22:25 +00:00
|
|
|
// return 1/-1/0 if device 1 is more/less/same capable than device 2.
|
|
|
|
// If "loose", ignore FLOPS and tolerate small memory diff
|
2009-04-21 08:11:28 +00:00
|
|
|
//
|
2009-05-04 02:22:25 +00:00
|
|
|
int cuda_compare(COPROC_CUDA& c1, COPROC_CUDA& c2, bool loose) {
|
2009-04-21 08:11:28 +00:00
|
|
|
if (c1.prop.major > c2.prop.major) return 1;
|
|
|
|
if (c1.prop.major < c2.prop.major) return -1;
|
|
|
|
if (c1.prop.minor > c2.prop.minor) return 1;
|
|
|
|
if (c1.prop.minor < c2.prop.minor) return -1;
|
|
|
|
if (c1.drvVersion > c2.drvVersion) return 1;
|
|
|
|
if (c1.drvVersion < c2.drvVersion) return -1;
|
2009-05-04 02:22:25 +00:00
|
|
|
if (loose) {
|
|
|
|
if (c1.prop.totalGlobalMem > 1.4*c2.prop.totalGlobalMem) return 1;
|
|
|
|
if (c1.prop.totalGlobalMem < .7* c2.prop.totalGlobalMem) return -1;
|
|
|
|
return 0;
|
|
|
|
}
|
2009-04-22 02:09:53 +00:00
|
|
|
if (c1.prop.totalGlobalMem > c2.prop.totalGlobalMem) return 1;
|
|
|
|
if (c1.prop.totalGlobalMem < c2.prop.totalGlobalMem) return -1;
|
2009-04-21 08:11:28 +00:00
|
|
|
double s1 = c1.flops_estimate();
|
2009-04-24 14:20:02 +00:00
|
|
|
double s2 = c2.flops_estimate();
|
2009-04-21 08:11:28 +00:00
|
|
|
if (s1 > s2) return 1;
|
|
|
|
if (s1 < s2) return -1;
|
|
|
|
return 0;
|
|
|
|
}
|
|
|
|
|
2009-04-27 23:51:46 +00:00
|
|
|
void COPROC_CUDA::get(
|
|
|
|
COPROCS& coprocs, vector<string>& strings,
|
|
|
|
bool use_all // if false, use only those equivalent to most capable
|
|
|
|
) {
|
2008-09-06 12:23:56 +00:00
|
|
|
int count;
|
|
|
|
|
|
|
|
#ifdef _WIN32
|
|
|
|
|
|
|
|
typedef int (__stdcall *PCGDC)(int *count);
|
|
|
|
typedef int (__stdcall *PCGDP)(struct cudaDeviceProp *prop, int device);
|
|
|
|
|
|
|
|
PCGDC __cudaGetDeviceCount = NULL;
|
|
|
|
PCGDP __cudaGetDeviceProperties = NULL;
|
|
|
|
|
|
|
|
HMODULE cudalib = LoadLibrary("cudart.dll");
|
|
|
|
if (!cudalib) {
|
2009-04-22 02:09:53 +00:00
|
|
|
strings.push_back("Can't load library cudart.dll");
|
2009-04-22 03:59:39 +00:00
|
|
|
return;
|
2008-09-06 12:23:56 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
__cudaGetDeviceCount = (PCGDC)GetProcAddress( cudalib, "cudaGetDeviceCount" );
|
|
|
|
if (!__cudaGetDeviceCount) {
|
2009-04-22 02:09:53 +00:00
|
|
|
strings.push_back("Library doesn't have cudaGetDeviceCount()");
|
2009-04-22 03:59:39 +00:00
|
|
|
return;
|
2008-09-06 12:23:56 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
__cudaGetDeviceProperties = (PCGDP)GetProcAddress( cudalib, "cudaGetDeviceProperties" );
|
|
|
|
if (!__cudaGetDeviceProperties) {
|
2009-04-22 02:09:53 +00:00
|
|
|
strings.push_back("Library doesn't have cudaGetDeviceProperties()");
|
2009-04-22 03:59:39 +00:00
|
|
|
return;
|
2008-09-06 12:23:56 +00:00
|
|
|
}
|
|
|
|
|
2009-02-18 21:21:12 +00:00
|
|
|
#ifndef SIM
|
2009-02-17 01:51:56 +00:00
|
|
|
NvAPI_Status nvapiStatus;
|
|
|
|
NvDisplayHandle hDisplay;
|
|
|
|
NV_DISPLAY_DRIVER_VERSION Version;
|
|
|
|
memset(&Version, 0, sizeof(Version));
|
|
|
|
Version.version = NV_DISPLAY_DRIVER_VERSION_VER;
|
|
|
|
|
|
|
|
NvAPI_Initialize();
|
|
|
|
for (int i=0; ; i++) {
|
|
|
|
nvapiStatus = NvAPI_EnumNvidiaDisplayHandle(i, &hDisplay);
|
|
|
|
if (nvapiStatus != NVAPI_OK) break;
|
|
|
|
nvapiStatus = NvAPI_GetDisplayDriverVersion(hDisplay, &Version);
|
|
|
|
if (nvapiStatus == NVAPI_OK) break;
|
2009-02-16 23:03:03 +00:00
|
|
|
}
|
2009-02-18 21:21:12 +00:00
|
|
|
#endif
|
2009-02-16 23:03:03 +00:00
|
|
|
|
2008-09-06 12:23:56 +00:00
|
|
|
#else
|
|
|
|
void* cudalib;
|
|
|
|
void (*__cudaGetDeviceCount)(int*);
|
|
|
|
void (*__cudaGetDeviceProperties)(cudaDeviceProp*, int);
|
|
|
|
|
|
|
|
#ifdef __APPLE__
|
2008-10-08 09:59:45 +00:00
|
|
|
cudalib = dlopen("/usr/local/cuda/lib/libcudart.dylib", RTLD_NOW);
|
2008-09-06 12:23:56 +00:00
|
|
|
#else
|
2009-03-23 19:25:38 +00:00
|
|
|
// libcudart.so is included with the BOINC install for linux,
|
|
|
|
// so look for it in the current dir.
|
|
|
|
//
|
2008-09-06 12:23:56 +00:00
|
|
|
cudalib = dlopen("./libcudart.so", RTLD_NOW);
|
2009-03-23 19:25:38 +00:00
|
|
|
if (!cudalib) {
|
|
|
|
// If that fails, look for it in the library search path
|
|
|
|
//
|
|
|
|
cudalib = dlopen("libcudart.so", RTLD_NOW);
|
|
|
|
}
|
2008-09-06 12:23:56 +00:00
|
|
|
#endif
|
|
|
|
if (!cudalib) {
|
2009-04-20 00:00:11 +00:00
|
|
|
strings.push_back("Can't load library libcudart");
|
2009-04-22 03:59:39 +00:00
|
|
|
return;
|
2008-09-06 12:23:56 +00:00
|
|
|
}
|
|
|
|
__cudaGetDeviceCount = (void(*)(int*)) dlsym(cudalib, "cudaGetDeviceCount");
|
|
|
|
if(!__cudaGetDeviceCount) {
|
2009-04-20 00:00:11 +00:00
|
|
|
strings.push_back("Library doesn't have cudaGetDeviceCount()");
|
2009-04-22 03:59:39 +00:00
|
|
|
return;
|
2008-09-06 12:23:56 +00:00
|
|
|
}
|
|
|
|
__cudaGetDeviceProperties = (void(*)(cudaDeviceProp*, int)) dlsym( cudalib, "cudaGetDeviceProperties" );
|
|
|
|
if (!__cudaGetDeviceProperties) {
|
2009-04-20 00:00:11 +00:00
|
|
|
strings.push_back("Library doesn't have cudaGetDeviceProperties()");
|
2009-04-22 03:59:39 +00:00
|
|
|
return;
|
2008-09-06 12:23:56 +00:00
|
|
|
}
|
|
|
|
#endif
|
|
|
|
|
2009-04-22 02:09:53 +00:00
|
|
|
vector<COPROC_CUDA> gpus;
|
2008-09-06 12:23:56 +00:00
|
|
|
(*__cudaGetDeviceCount)(&count);
|
2009-04-22 02:09:53 +00:00
|
|
|
int j;
|
|
|
|
unsigned int i;
|
|
|
|
COPROC_CUDA cc;
|
2008-12-11 21:44:22 +00:00
|
|
|
string s;
|
2009-04-22 02:09:53 +00:00
|
|
|
for (j=0; j<count; j++) {
|
|
|
|
(*__cudaGetDeviceProperties)(&cc.prop, j);
|
2008-12-11 21:44:22 +00:00
|
|
|
if (cc.prop.major <= 0) continue; // major == 0 means emulation
|
|
|
|
if (cc.prop.major > 100) continue; // e.g. 9999 is an error
|
2009-02-18 21:21:12 +00:00
|
|
|
#if defined(_WIN32) && !defined(SIM)
|
2009-02-16 23:03:03 +00:00
|
|
|
cc.drvVersion = Version.drvVersion;
|
2009-02-17 01:51:56 +00:00
|
|
|
#else
|
|
|
|
cc.drvVersion = 0;
|
|
|
|
#endif
|
2009-04-22 02:09:53 +00:00
|
|
|
cc.device_num = j;
|
|
|
|
gpus.push_back(cc);
|
|
|
|
}
|
2008-12-11 21:44:22 +00:00
|
|
|
|
2009-04-22 02:09:53 +00:00
|
|
|
if (!gpus.size()) {
|
2009-06-03 20:29:49 +00:00
|
|
|
strings.push_back("No CUDA-capable NVIDIA GPUs found");
|
2009-04-22 02:09:53 +00:00
|
|
|
return;
|
|
|
|
}
|
|
|
|
|
|
|
|
// identify the most capable instance
|
|
|
|
//
|
|
|
|
COPROC_CUDA best;
|
|
|
|
for (i=0; i<gpus.size(); i++) {
|
|
|
|
if (i==0) {
|
|
|
|
best = gpus[i];
|
2009-04-24 10:56:35 +00:00
|
|
|
} else if (cuda_compare(gpus[i], best, false) > 0) {
|
2009-04-22 02:09:53 +00:00
|
|
|
best = gpus[i];
|
2008-12-11 21:44:22 +00:00
|
|
|
}
|
2008-09-06 12:23:56 +00:00
|
|
|
}
|
2009-04-22 02:09:53 +00:00
|
|
|
|
|
|
|
// see which other instances are equivalent,
|
|
|
|
// and set the "count" and "device_nums" fields
|
|
|
|
//
|
|
|
|
best.count = 0;
|
|
|
|
for (i=0; i<gpus.size(); i++) {
|
2009-06-03 20:29:49 +00:00
|
|
|
char buf[256], buf2[256];
|
2009-04-22 02:09:53 +00:00
|
|
|
cc.description(buf);
|
2009-04-27 23:51:46 +00:00
|
|
|
if (use_all || !cuda_compare(gpus[i], best, true)) {
|
2009-04-22 02:09:53 +00:00
|
|
|
best.device_nums[best.count] = gpus[i].device_num;
|
|
|
|
best.count++;
|
2009-06-04 05:18:43 +00:00
|
|
|
sprintf(buf2, "NVIDIA GPU %d: %s", i, buf);
|
2009-04-22 02:09:53 +00:00
|
|
|
} else {
|
2009-06-04 05:18:43 +00:00
|
|
|
sprintf(buf2, "NVIDIA GPU %d (not used): %s", i, buf);
|
2009-04-22 02:09:53 +00:00
|
|
|
}
|
2009-06-03 20:29:49 +00:00
|
|
|
strings.push_back(string(buf2));
|
2008-09-06 12:23:56 +00:00
|
|
|
}
|
2009-04-22 02:09:53 +00:00
|
|
|
|
2008-12-11 21:44:22 +00:00
|
|
|
COPROC_CUDA* ccp = new COPROC_CUDA;
|
2009-04-22 02:09:53 +00:00
|
|
|
*ccp = best;
|
2008-12-11 21:44:22 +00:00
|
|
|
coprocs.coprocs.push_back(ccp);
|
2008-09-06 12:23:56 +00:00
|
|
|
}
|
|
|
|
|
2009-01-14 23:56:07 +00:00
|
|
|
void COPROC_CUDA::description(char* buf) {
|
2009-04-20 00:09:29 +00:00
|
|
|
sprintf(buf, "%s (driver version %d, compute capability %d.%d, %.0fMB, est. %.0fGFLOPS)",
|
2009-02-16 23:03:03 +00:00
|
|
|
prop.name, drvVersion, prop.major, prop.minor, prop.totalGlobalMem/(1024.*1024.), flops_estimate()/1e9
|
2009-01-14 23:56:07 +00:00
|
|
|
);
|
|
|
|
}
|
|
|
|
|
2008-09-06 12:23:56 +00:00
|
|
|
// add a non-existent CUDA coproc (for debugging)
|
|
|
|
//
|
|
|
|
void fake_cuda(COPROCS& coprocs, int count) {
|
|
|
|
COPROC_CUDA* cc = new COPROC_CUDA;
|
|
|
|
strcpy(cc->type, "CUDA");
|
|
|
|
cc->count = count;
|
|
|
|
strcpy(cc->prop.name, "CUDA NVIDIA chip");
|
2009-01-10 00:48:22 +00:00
|
|
|
cc->prop.totalGlobalMem = 256*1024*1024;
|
2008-09-06 12:23:56 +00:00
|
|
|
cc->prop.sharedMemPerBlock = 100;
|
|
|
|
cc->prop.regsPerBlock = 8;
|
|
|
|
cc->prop.warpSize = 10;
|
|
|
|
cc->prop.memPitch = 10;
|
|
|
|
cc->prop.maxThreadsPerBlock = 20;
|
|
|
|
cc->prop.maxThreadsDim[0] = 2;
|
|
|
|
cc->prop.maxThreadsDim[1] = 2;
|
|
|
|
cc->prop.maxThreadsDim[2] = 2;
|
|
|
|
cc->prop.maxGridSize[0] = 10;
|
|
|
|
cc->prop.maxGridSize[1] = 10;
|
|
|
|
cc->prop.maxGridSize[2] = 10;
|
|
|
|
cc->prop.totalConstMem = 10;
|
|
|
|
cc->prop.major = 1;
|
2008-09-25 02:21:38 +00:00
|
|
|
cc->prop.minor = 2;
|
2009-01-10 00:48:22 +00:00
|
|
|
cc->prop.clockRate = 1250000;
|
2008-09-06 12:23:56 +00:00
|
|
|
cc->prop.textureAlignment = 1000;
|
2009-01-10 00:48:22 +00:00
|
|
|
cc->prop.multiProcessorCount = 14;
|
2008-09-06 12:23:56 +00:00
|
|
|
coprocs.coprocs.push_back(cc);
|
|
|
|
}
|
|
|
|
|
|
|
|
#ifndef _USING_FCGI_
|
|
|
|
void COPROC_CUDA::write_xml(MIOFILE& f) {
|
|
|
|
f.printf(
|
|
|
|
"<coproc_cuda>\n"
|
|
|
|
" <count>%d</count>\n"
|
|
|
|
" <name>%s</name>\n"
|
2009-01-03 06:01:17 +00:00
|
|
|
" <req_secs>%f</req_secs>\n"
|
|
|
|
" <req_instances>%d</req_instances>\n"
|
2009-01-30 21:25:24 +00:00
|
|
|
" <estimated_delay>%f</estimated_delay>\n"
|
2009-02-16 23:03:03 +00:00
|
|
|
" <drvVersion>%d</drvVersion>\n"
|
2008-09-06 12:23:56 +00:00
|
|
|
" <totalGlobalMem>%u</totalGlobalMem>\n"
|
|
|
|
" <sharedMemPerBlock>%u</sharedMemPerBlock>\n"
|
|
|
|
" <regsPerBlock>%d</regsPerBlock>\n"
|
|
|
|
" <warpSize>%d</warpSize>\n"
|
|
|
|
" <memPitch>%u</memPitch>\n"
|
|
|
|
" <maxThreadsPerBlock>%d</maxThreadsPerBlock>\n"
|
|
|
|
" <maxThreadsDim>%d %d %d</maxThreadsDim>\n"
|
|
|
|
" <maxGridSize>%d %d %d</maxGridSize>\n"
|
|
|
|
" <totalConstMem>%u</totalConstMem>\n"
|
|
|
|
" <major>%d</major>\n"
|
|
|
|
" <minor>%d</minor>\n"
|
|
|
|
" <clockRate>%d</clockRate>\n"
|
|
|
|
" <textureAlignment>%u</textureAlignment>\n"
|
2008-12-08 19:12:38 +00:00
|
|
|
" <deviceOverlap>%d</deviceOverlap>\n"
|
|
|
|
" <multiProcessorCount>%d</multiProcessorCount>\n"
|
2008-09-06 12:23:56 +00:00
|
|
|
"</coproc_cuda>\n",
|
|
|
|
count,
|
2009-01-10 00:48:22 +00:00
|
|
|
prop.name,
|
2009-01-03 06:01:17 +00:00
|
|
|
req_secs,
|
|
|
|
req_instances,
|
2009-01-30 21:25:24 +00:00
|
|
|
estimated_delay,
|
2009-02-16 23:03:03 +00:00
|
|
|
drvVersion,
|
2008-09-06 12:23:56 +00:00
|
|
|
(unsigned int)prop.totalGlobalMem,
|
|
|
|
(unsigned int)prop.sharedMemPerBlock,
|
|
|
|
prop.regsPerBlock,
|
|
|
|
prop.warpSize,
|
|
|
|
(unsigned int)prop.memPitch,
|
|
|
|
prop.maxThreadsPerBlock,
|
|
|
|
prop.maxThreadsDim[0], prop.maxThreadsDim[1], prop.maxThreadsDim[2],
|
|
|
|
prop.maxGridSize[0], prop.maxGridSize[1], prop.maxGridSize[2],
|
|
|
|
(unsigned int)prop.totalConstMem,
|
|
|
|
prop.major,
|
|
|
|
prop.minor,
|
|
|
|
prop.clockRate,
|
2008-12-08 19:12:38 +00:00
|
|
|
(unsigned int)prop.textureAlignment,
|
|
|
|
prop.deviceOverlap,
|
|
|
|
prop.multiProcessorCount
|
2008-09-06 12:23:56 +00:00
|
|
|
);
|
|
|
|
}
|
|
|
|
#endif
|
|
|
|
|
|
|
|
void COPROC_CUDA::clear() {
|
|
|
|
count = 0;
|
2009-01-30 21:25:24 +00:00
|
|
|
used = 0;
|
|
|
|
req_secs = 0;
|
|
|
|
req_instances = 0;
|
|
|
|
estimated_delay = -1; // mark as absent
|
2008-09-06 12:23:56 +00:00
|
|
|
strcpy(prop.name, "");
|
|
|
|
prop.totalGlobalMem = 0;
|
|
|
|
prop.sharedMemPerBlock = 0;
|
|
|
|
prop.regsPerBlock = 0;
|
|
|
|
prop.warpSize = 0;
|
|
|
|
prop.memPitch = 0;
|
|
|
|
prop.maxThreadsPerBlock = 0;
|
|
|
|
prop.maxThreadsDim[0] = 0;
|
|
|
|
prop.maxThreadsDim[1] = 0;
|
|
|
|
prop.maxThreadsDim[2] = 0;
|
|
|
|
prop.maxGridSize[0] = 0;
|
|
|
|
prop.maxGridSize[1] = 0;
|
|
|
|
prop.maxGridSize[2] = 0;
|
2008-12-19 19:33:30 +00:00
|
|
|
prop.clockRate = 0;
|
2008-09-06 12:23:56 +00:00
|
|
|
prop.totalConstMem = 0;
|
|
|
|
prop.major = 0;
|
|
|
|
prop.minor = 0;
|
|
|
|
prop.textureAlignment = 0;
|
2008-12-19 19:33:30 +00:00
|
|
|
prop.deviceOverlap = 0;
|
|
|
|
prop.multiProcessorCount = 0;
|
2008-09-06 12:23:56 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
int COPROC_CUDA::parse(FILE* fin) {
|
|
|
|
char buf[1024], buf2[256];
|
|
|
|
|
|
|
|
clear();
|
|
|
|
while (fgets(buf, sizeof(buf), fin)) {
|
2008-12-22 22:12:57 +00:00
|
|
|
if (strstr(buf, "</coproc_cuda>")) {
|
|
|
|
return 0;
|
|
|
|
}
|
2008-09-06 12:23:56 +00:00
|
|
|
if (parse_int(buf, "<count>", count)) continue;
|
2009-01-03 06:01:17 +00:00
|
|
|
if (parse_double(buf, "<req_secs>", req_secs)) continue;
|
|
|
|
if (parse_int(buf, "<req_instances>", req_instances)) continue;
|
2009-01-30 21:25:24 +00:00
|
|
|
if (parse_double(buf, "<estimated_delay>", estimated_delay)) continue;
|
2008-09-06 12:23:56 +00:00
|
|
|
if (parse_str(buf, "<name>", prop.name, sizeof(prop.name))) continue;
|
2009-02-16 23:03:03 +00:00
|
|
|
if (parse_int(buf, "<drvVersion>", drvVersion)) continue;
|
2008-12-22 22:12:57 +00:00
|
|
|
if (parse_double(buf, "<totalGlobalMem>", prop.dtotalGlobalMem)) continue;
|
2008-09-06 12:23:56 +00:00
|
|
|
if (parse_int(buf, "<sharedMemPerBlock>", (int&)prop.sharedMemPerBlock)) continue;
|
|
|
|
if (parse_int(buf, "<regsPerBlock>", prop.regsPerBlock)) continue;
|
|
|
|
if (parse_int(buf, "<warpSize>", prop.warpSize)) continue;
|
|
|
|
if (parse_int(buf, "<memPitch>", (int&)prop.memPitch)) continue;
|
|
|
|
if (parse_int(buf, "<maxThreadsPerBlock>", prop.maxThreadsPerBlock)) continue;
|
|
|
|
if (parse_str(buf, "<maxThreadsDim>", buf2, sizeof(buf2))) {
|
|
|
|
// can't use sscanf here (FCGI)
|
|
|
|
//
|
|
|
|
prop.maxThreadsDim[0] = atoi(buf2);
|
|
|
|
char* p = strchr(buf2, ' ');
|
|
|
|
if (p) {
|
2008-12-22 22:17:26 +00:00
|
|
|
p++;
|
2008-09-06 12:23:56 +00:00
|
|
|
prop.maxThreadsDim[1] = atoi(p);
|
|
|
|
p = strchr(p, ' ');
|
|
|
|
if (p) {
|
2008-12-22 22:17:26 +00:00
|
|
|
p++;
|
2008-09-06 12:23:56 +00:00
|
|
|
prop.maxThreadsDim[2] = atoi(p);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
continue;
|
|
|
|
}
|
|
|
|
if (parse_str(buf, "<maxGridSize>", buf2, sizeof(buf2))) {
|
|
|
|
prop.maxGridSize[0] = atoi(buf2);
|
|
|
|
char* p = strchr(buf2, ' ');
|
|
|
|
if (p) {
|
2008-12-22 22:17:26 +00:00
|
|
|
p++;
|
2008-09-06 12:23:56 +00:00
|
|
|
prop.maxGridSize[1] = atoi(p);
|
|
|
|
p = strchr(p, ' ');
|
|
|
|
if (p) {
|
2008-12-22 22:17:26 +00:00
|
|
|
p++;
|
2008-09-06 12:23:56 +00:00
|
|
|
prop.maxGridSize[2] = atoi(p);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
continue;
|
|
|
|
}
|
2008-12-19 19:33:30 +00:00
|
|
|
if (parse_int(buf, "<clockRate>", prop.clockRate)) continue;
|
2008-09-06 12:23:56 +00:00
|
|
|
if (parse_int(buf, "<totalConstMem>", (int&)prop.totalConstMem)) continue;
|
|
|
|
if (parse_int(buf, "<major>", prop.major)) continue;
|
|
|
|
if (parse_int(buf, "<minor>", prop.minor)) continue;
|
|
|
|
if (parse_int(buf, "<textureAlignment>", (int&)prop.textureAlignment)) continue;
|
2008-12-19 19:33:30 +00:00
|
|
|
if (parse_int(buf, "<deviceOverlap>", prop.deviceOverlap)) continue;
|
|
|
|
if (parse_int(buf, "<multiProcessorCount>", prop.multiProcessorCount)) continue;
|
2008-09-06 12:23:56 +00:00
|
|
|
}
|
|
|
|
return ERR_XML_PARSE;
|
|
|
|
}
|