- client: add support for CPU OpenCL apps.

Add OPENCL_DEVICE_PROP cpu_opencl_prop to HOST_INFO;
    this store info about the host's ability to run CPU OpenCL apps.
    Detect this, and report it in scheduler requests.
This commit is contained in:
David Anderson 2013-04-16 22:42:29 -07:00
parent 06d8009a57
commit 35390ef974
5 changed files with 36 additions and 18 deletions

View File

@ -36,10 +36,11 @@ using std::vector;
using std::string;
#include "coproc.h"
#include "util.h"
#include "str_replace.h"
#include "util.h"
#include "client_msgs.h"
#include "client_state.h"
#include "gpu_detect.h"
#ifdef _WIN32
@ -410,7 +411,11 @@ void COPROCS::get_opencl(
warnings.push_back("clGetDeviceInfo failed to get device type for Intel device");
continue;
}
if (device_type == CL_DEVICE_TYPE_CPU) continue;
if (device_type == CL_DEVICE_TYPE_CPU) {
gstate.host_info.have_cpu_opencl = true;
gstate.host_info.cpu_opencl_prop = prop;
continue;
}
prop.device_num = (int)(intel_gpu_opencls.size());
prop.opencl_device_index = device_index;
@ -429,7 +434,7 @@ void COPROCS::get_opencl(
intel_gpu_opencls.push_back(prop);
// At present Intel GPUs only support OpenCL and do not have a native
// GPGPU framework, so treat each detected Intel OpenCL GPU device as
// GPGPU framework, so treat each detected Intel OpenCL GPU device as
// a native device.
intel_gpus.push_back(c);
}
@ -438,7 +443,7 @@ void COPROCS::get_opencl(
#ifdef __APPLE__
// Work around a bug in OpenCL which returns only
// Work around a bug in OpenCL which returns only
// 1/2 of total global RAM size.
// This bug applies only to ATI GPUs, not to NVIDIA
// This has already been fixed on latest Catalyst

View File

@ -120,9 +120,9 @@ void COPROC::write_request(MIOFILE& f) {
);
}
void OPENCL_DEVICE_PROP::write_xml(MIOFILE& f) {
void OPENCL_DEVICE_PROP::write_xml(MIOFILE& f, const char* tag) {
f.printf(
" <coproc_opencl>\n"
" <%s>\n"
" <name>%s</name>\n"
" <vendor>%s</vendor>\n"
" <vendor_id>%lu</vendor_id>\n"
@ -140,7 +140,8 @@ void OPENCL_DEVICE_PROP::write_xml(MIOFILE& f) {
" <opencl_platform_version>%s</opencl_platform_version>\n"
" <opencl_device_version>%s</opencl_device_version>\n"
" <opencl_driver_version>%s</opencl_driver_version>\n"
" </coproc_opencl>\n",
" </%s>\n",
tag,
name,
vendor,
vendor_id,
@ -157,7 +158,8 @@ void OPENCL_DEVICE_PROP::write_xml(MIOFILE& f) {
max_compute_units,
opencl_platform_version,
opencl_device_version,
opencl_driver_version
opencl_driver_version,
tag
);
}
@ -192,12 +194,12 @@ int COPROC::parse(XML_PARSER& xp) {
#endif
int OPENCL_DEVICE_PROP::parse(XML_PARSER& xp) {
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("/coproc_opencl")) {
if (xp.match_tag(end_tag)) {
get_device_version_int();
get_opencl_driver_revision();
return 0;
@ -507,7 +509,7 @@ void COPROC_NVIDIA::write_xml(MIOFILE& f, bool scheduler_rpc) {
);
if (have_opencl) {
opencl_prop.write_xml(f);
opencl_prop.write_xml(f, "coproc_opencl");
}
if (!scheduler_rpc) {
@ -626,7 +628,7 @@ int COPROC_NVIDIA::parse(XML_PARSER& xp) {
}
}
if (xp.match_tag("coproc_opencl")) {
retval = opencl_prop.parse(xp);
retval = opencl_prop.parse(xp, "/coproc_opencl");
if (retval) return retval;
continue;
}
@ -776,7 +778,7 @@ void COPROC_ATI::write_xml(MIOFILE& f, bool scheduler_rpc) {
}
if (have_opencl) {
opencl_prop.write_xml(f);
opencl_prop.write_xml(f, "coproc_opencl");
}
f.printf("</coproc_ati>\n");
@ -889,7 +891,7 @@ int COPROC_ATI::parse(XML_PARSER& xp) {
continue;
}
if (xp.match_tag("coproc_opencl")) {
retval = opencl_prop.parse(xp);
retval = opencl_prop.parse(xp, "/coproc_opencl");
if (retval) return retval;
continue;
}
@ -966,7 +968,7 @@ void COPROC_INTEL::write_xml(MIOFILE& f, bool scheduler_rpc) {
);
if (have_opencl) {
opencl_prop.write_xml(f);
opencl_prop.write_xml(f, "coproc_opencl");
}
f.printf("</coproc_intel_gpu>\n");
@ -1007,7 +1009,7 @@ int COPROC_INTEL::parse(XML_PARSER& xp) {
if (xp.parse_str("version", version, sizeof(version))) continue;
if (xp.match_tag("coproc_opencl")) {
retval = opencl_prop.parse(xp);
retval = opencl_prop.parse(xp, "/coproc_opencl");
if (retval) return retval;
continue;
}

View File

@ -164,9 +164,9 @@ struct OPENCL_DEVICE_PROP {
int opencl_device_index; // temp used in scan process
#ifndef _USING_FCGI_
void write_xml(MIOFILE&);
void write_xml(MIOFILE&, const char* tag);
#endif
int parse(XML_PARSER&);
int parse(XML_PARSER&, const char* end_tag);
void description(char* buf, const char* type);
};

View File

@ -70,6 +70,7 @@ void HOST_INFO::clear_host_info() {
strcpy(os_version, "");
strcpy(virtualbox_version, "");
have_cpu_opencl = false;
}
int HOST_INFO::parse(XML_PARSER& xp, bool benchmarks_only) {
@ -118,6 +119,10 @@ int HOST_INFO::parse(XML_PARSER& xp, bool benchmarks_only) {
if (xp.match_tag("coprocs")) {
this->coprocs.parse(xp);
}
if (xp.match_tag("cpu_opencl_prop")) {
int retval = cpu_opencl_prop.parse(xp, "/cpu_opencl_prop");
if (!retval) have_cpu_opencl = true;
}
}
return ERR_XML_PARSE;
}
@ -200,6 +205,9 @@ int HOST_INFO::write(
if (include_coprocs) {
this->coprocs.write_xml(out, false);
}
if (have_cpu_opencl) {
cpu_opencl_prop.write_xml(out, "cpu_opencl_prop");
}
out.printf(
"</host_info>\n"
);

View File

@ -67,6 +67,9 @@ public:
COPROCS coprocs;
bool have_cpu_opencl;
OPENCL_DEVICE_PROP cpu_opencl_prop;
#ifdef ANDROID
int battery_charge_pct;
int battery_state;