mirror of https://github.com/BOINC/boinc.git
client: generalize naming scheme for OpenCL devices, add more general have_rsrc() functions
This commit is contained in:
parent
64d76198ea
commit
7fb69fe924
|
@ -261,8 +261,8 @@ void COPROCS::correlate_gpus(
|
|||
// Create descriptions for other OpenCL GPUs
|
||||
//
|
||||
for (j=0; j<num_other_opencl_types; j++) {
|
||||
strcpy(coprocs[n_rsc++].type, proc_type_name_xml(PROC_TYPE_OTHER_COPROC));
|
||||
snprintf(buf2, sizeof(buf2), "device type %c number", 'A'+j);
|
||||
strcpy(coprocs[n_rsc++].type, proc_type_name_xml(PROC_TYPE_A+j));
|
||||
snprintf(buf2, sizeof(buf2), "%s number", proc_type_name(PROC_TYPE_A+j));
|
||||
for (i=0; i<other_opencls[j].size(); i++) {
|
||||
other_opencls[j][i].description(buf, sizeof(buf), buf2);
|
||||
descs.push_back(string(buf));
|
||||
|
|
|
@ -59,6 +59,21 @@
|
|||
using std::perror;
|
||||
#endif
|
||||
|
||||
const char* proc_type_names_xml[NPROC_TYPES] = {
|
||||
"CPU", "NVIDIA", "ATI", "intel_gpu",
|
||||
"DEVICE_TYPE_A", "DEVICE_TYPE_B", "DEVICE_TYPE_C",
|
||||
"DEVICE_TYPE_D", "DEVICE_TYPE_E", "DEVICE_TYPE_F",
|
||||
"DEVICE_TYPE_G"
|
||||
};
|
||||
|
||||
const char* proc_type_names[NPROC_TYPES] = {
|
||||
"CPU", "NVIDIA GPU", "AMD/ATI GPU", "Intel GPU",
|
||||
"Device type A", "Device type B", "Device type C",
|
||||
"Device type D", "Device type E", "Device type F",
|
||||
"Device type G"
|
||||
};
|
||||
|
||||
|
||||
int COPROC_REQ::parse(XML_PARSER& xp) {
|
||||
strcpy(type, "");
|
||||
count = 0;
|
||||
|
@ -265,6 +280,24 @@ void COPROCS::write_xml(MIOFILE& mf, bool scheduler_rpc) {
|
|||
#endif
|
||||
}
|
||||
|
||||
bool COPROCS::have_rsrc(int typeIndex) {
|
||||
for (int i=0; i<n_rsc; i++) {
|
||||
if (!strcmp(coprocs[i].type, proc_type_name_xml(typeIndex))) {
|
||||
return true;
|
||||
}
|
||||
}
|
||||
return false;
|
||||
}
|
||||
|
||||
bool COPROCS::have_rsrc(char* typeName) {
|
||||
for (int i=0; i<n_rsc; i++) {
|
||||
if (!strcmp(coprocs[i].type, typeName)) {
|
||||
return true;
|
||||
}
|
||||
}
|
||||
return false;
|
||||
}
|
||||
|
||||
void COPROC_NVIDIA::description(char* buf, int buflen) {
|
||||
char vers[256], cuda_vers[256];
|
||||
if (display_driver_version) {
|
||||
|
@ -908,32 +941,23 @@ void COPROC_INTEL::fake(double ram, double avail_ram, int n) {
|
|||
// coproc_intel_gpu
|
||||
//
|
||||
const char* proc_type_name_xml(int pt) {
|
||||
switch(pt) {
|
||||
case PROC_TYPE_CPU: return "CPU";
|
||||
case PROC_TYPE_NVIDIA_GPU: return "NVIDIA";
|
||||
case PROC_TYPE_AMD_GPU: return "ATI";
|
||||
case PROC_TYPE_INTEL_GPU: return "intel_gpu";
|
||||
case PROC_TYPE_OTHER_COPROC: return "OTHER_COPROC";
|
||||
if (pt >= NPROC_TYPES) {
|
||||
return "unknown";
|
||||
}
|
||||
return "unknown";
|
||||
return proc_type_names_xml[pt];
|
||||
}
|
||||
|
||||
const char* proc_type_name(int pt) {
|
||||
switch(pt) {
|
||||
case PROC_TYPE_CPU: return "CPU";
|
||||
case PROC_TYPE_NVIDIA_GPU: return "NVIDIA GPU";
|
||||
case PROC_TYPE_AMD_GPU: return "AMD/ATI GPU";
|
||||
case PROC_TYPE_INTEL_GPU: return "Intel GPU";
|
||||
case PROC_TYPE_OTHER_COPROC: return "OTHER COPROC";
|
||||
if (pt >= NPROC_TYPES) {
|
||||
return "unknown";
|
||||
}
|
||||
return "unknown";
|
||||
return proc_type_names[pt];
|
||||
}
|
||||
|
||||
int coproc_type_name_to_num(const char* name) {
|
||||
if (!strcmp(name, "CUDA")) return PROC_TYPE_NVIDIA_GPU;
|
||||
if (!strcmp(name, "NVIDIA")) return PROC_TYPE_NVIDIA_GPU;
|
||||
if (!strcmp(name, "ATI")) return PROC_TYPE_AMD_GPU;
|
||||
if (!strcmp(name, "intel_gpu")) return PROC_TYPE_INTEL_GPU;
|
||||
if (!strcmp(name, "OTHER_COPROC")) return PROC_TYPE_OTHER_COPROC;
|
||||
int i;
|
||||
for (i=1; i<NPROC_TYPES; i++) {
|
||||
if (!strcmp(name, proc_type_names_xml[i])) return i;
|
||||
}
|
||||
return 0;
|
||||
}
|
||||
|
|
33
lib/coproc.h
33
lib/coproc.h
|
@ -88,12 +88,23 @@
|
|||
|
||||
// arguments to proc_type_name() and proc_type_name_xml().
|
||||
//
|
||||
#define PROC_TYPE_CPU 0
|
||||
#define PROC_TYPE_NVIDIA_GPU 1
|
||||
#define PROC_TYPE_AMD_GPU 2
|
||||
#define PROC_TYPE_INTEL_GPU 3
|
||||
#define PROC_TYPE_OTHER_COPROC 4
|
||||
#define NPROC_TYPES 5
|
||||
enum {
|
||||
PROC_TYPE_CPU=0,
|
||||
PROC_TYPE_NVIDIA_GPU,
|
||||
PROC_TYPE_AMD_GPU,
|
||||
PROC_TYPE_INTEL_GPU,
|
||||
PROC_TYPE_A,
|
||||
PROC_TYPE_B,
|
||||
PROC_TYPE_C,
|
||||
PROC_TYPE_D,
|
||||
PROC_TYPE_E,
|
||||
PROC_TYPE_F,
|
||||
PROC_TYPE_G,
|
||||
NPROC_TYPES
|
||||
};
|
||||
|
||||
extern const char* proc_type_names_xml[NPROC_TYPES];
|
||||
extern const char* proc_type_names[NPROC_TYPES];
|
||||
|
||||
extern const char* proc_type_name(int);
|
||||
// user-readable name
|
||||
|
@ -105,7 +116,13 @@ extern int coproc_type_name_to_num(const char* name);
|
|||
#define GPU_TYPE_NVIDIA proc_type_name_xml(PROC_TYPE_NVIDIA_GPU)
|
||||
#define GPU_TYPE_ATI proc_type_name_xml(PROC_TYPE_AMD_GPU)
|
||||
#define GPU_TYPE_INTEL proc_type_name_xml(PROC_TYPE_INTEL_GPU)
|
||||
#define COPROC_TYPE_OTHER proc_type_name_xml(PROC_TYPE_OTHER_COPROC)
|
||||
#define COPROC_TYPE_A proc_type_name_xml(PROC_TYPE_A)
|
||||
#define COPROC_TYPE_B proc_type_name_xml(PROC_TYPE_B)
|
||||
#define COPROC_TYPE_C proc_type_name_xml(PROC_TYPE_C)
|
||||
#define COPROC_TYPE_D proc_type_name_xml(PROC_TYPE_D)
|
||||
#define COPROC_TYPE_E proc_type_name_xml(PROC_TYPE_E)
|
||||
#define COPROC_TYPE_F proc_type_name_xml(PROC_TYPE_F)
|
||||
#define COPROC_TYPE_G proc_type_name_xml(PROC_TYPE_G)
|
||||
|
||||
// represents a requirement for a coproc.
|
||||
// This is a parsed version of the <coproc> elements in an <app_version>
|
||||
|
@ -456,6 +473,8 @@ struct COPROCS {
|
|||
inline bool have_intel_gpu() {
|
||||
return (intel_gpu.count > 0);
|
||||
}
|
||||
bool have_rsrc(int typeIndex);
|
||||
bool have_rsrc(char* typeName);
|
||||
int add(COPROC& c) {
|
||||
if (n_rsc >= MAX_RSC) return ERR_BUFFER_OVERFLOW;
|
||||
for (int i=1; i<n_rsc; i++) {
|
||||
|
|
Loading…
Reference in New Issue