我正在嘗試使用設備分裂擴展來編寫opencl程序。設備分裂Intel CPU
我使用的是英特爾酷睿i3 M350,但我不能夠創建子設備:
#define USE_CL_DEVICE_FISSION 1
#include <iostream>
#include "CL/cl.hpp"
using namespace std;
int main(int argc, char* argv[]) {
cl::Context context;
std::vector<cl::Platform> platforms;
cl::Platform::get(&platforms);
cl_context_properties properties[] =
{
CL_CONTEXT_PLATFORM,
(cl_context_properties)(platforms[1])(),
0
};
context = cl::Context(CL_DEVICE_TYPE_CPU, properties);
std::vector<cl::Device> devices = context.getInfo<CL_CONTEXT_DEVICES>();
cout << "Platform:\t" << platforms[1].getInfo<CL_PLATFORM_NAME>() << endl;
cout << "Version:\t" << platforms[1].getInfo<CL_PLATFORM_VERSION>() << endl;
cout << "Device:\t\t" << devices[0].getInfo<CL_DEVICE_NAME>() << endl;
cout << "Profile:\t" << devices[0].getInfo<CL_DEVICE_PROFILE>() << endl;
cout << "Driver:\t\t" << devices[0].getInfo<CL_DRIVER_VERSION>() << endl;
cout << "ComputeUnits:\t" << devices[0].getInfo<CL_DEVICE_MAX_COMPUTE_UNITS >() << endl;
if (devices[0].getInfo<CL_DEVICE_EXTENSIONS>().find("cl_ext_device_fission") == std::string::npos) {
cout << "No device fission support!" << endl;
exit(-1);
}
else {
cout << "Device Fission: Available" << endl;
}
const cl_device_partition_property_ext subDeviceProperties[] =
{
CL_DEVICE_PARTITION_EQUALLY_EXT,
1,
CL_PROPERTIES_LIST_END_EXT,
0
};
std::vector<cl::Device> subDevices;
int err = devices[0].createSubDevices(subDeviceProperties, &subDevices);
if (err != CL_SUCCESS) {
cout << "\nError: " << err << endl;
}
}
輸出是:
Platform: Intel(R) OpenCL
Version: OpenCL 1.1 LINUX
Device: Intel(R) Core(TM) i3 CPU M 350 @ 2.27GHz
Profile: FULL_PROFILE
Driver: 1.1
ComputeUnits: 4
Device Fission: Available
Error: -1057
此錯誤代碼表示:
CL_DEVICE_PARTITION_FAILED_EXT -1057
Returned by clCreateSubDevicesEXT when the total number of compute units requested exceeds CL_DEVICE_MAX_COMPUTE_UNITS, or the number of compute units for any one sub-device is less than 1.
任何想法?
謝謝,這個鏈接很有用。不過,我也嘗試了上面的分區。它可能是硬件相關的? – rdoubleui 2012-02-28 21:00:54