wiki:OpenclCpu

Version 2 (modified by davea, 11 years ago) (diff)

--

OpenCL CPU applications

OpenCL, which is used for GPU applications, can also be used for multicore CPU applications.

Depending on what drivers are installed on a client computer, one or more OpenCL implementations may be available. When you build OpenCL/CPU applications, they may be compatible with only one implementation, or there may be a preferred implementation.

You can use the plan class mechanism to control what app versions are sent. Your app plan function can call

bool HOST::get_cpu_opencl_prop(const char* vendor, OPENCL_CPU_PROP&);

to see if the host has an OpenCL/CPU implementation for the given vendor ("nvidia", "amd", or "intel"). If so, the OpenCL properties are returned.

Use this function as follows:

bool app_plan_opencl_cpu_intel(SCHEDULER_REQUEST& sreq, HOST_USAGE& hu) {
    OPENCL_CPU_PROP ocp;
    if (sreq.host.get_cpu_opencl_prop("intel", ocp)) {
        ... host has Intel OpenCL/CPU implementation
        if (!strstr(sreq.host.p_feature,"sse4.1")) {
            // interesting factoid: Intel's OpenCL/CPU implementation requires SSE4.1
            return false;
        }
    }
    ...
}