在我的应用程序中,我将显示所有可用的OpenCL设备,以便用户可以选择要在其上执行计算的设备。
我在笔记本电脑上得到的结果使我感到困惑。
以下是产生这些结果的代码的摘录:
//CL_DEVICE_TYPE
{
cl_device_type devtype;
QString temp = "Unknown";
err = clGetDeviceInfo(devices[i][j], CL_DEVICE_TYPE, sizeof(devtype), &devtype, NULL);
if(err == CL_SUCCESS)
{
if(devtype == CL_DEVICE_TYPE_CPU)
temp = "CPU";
else if(devtype == CL_DEVICE_TYPE_GPU)
temp = "GPU";
else if(devtype == CL_DEVICE_TYPE_ACCELERATOR)
temp = "Accelerator";
else
temp = "Unkown";
}
ilist->append(temp);
}
//CL_DEVICE_MAX_CLOCK_FREQUENCY
{
cl_uint devfreq;
err = clGetDeviceInfo(devices[i][j], CL_DEVICE_MAX_CLOCK_FREQUENCY, sizeof(devfreq), &devfreq, NULL);
if(err == CL_SUCCESS)
ilist->append(QString::number((unsigned int)devfreq));
else
ilist->append("Unknown");
}
//CL_DEVICE_GLOBAL_MEM_SIZE
{
cl_ulong devmem;
err = clGetDeviceInfo(devices[i][j], CL_DEVICE_GLOBAL_MEM_SIZE, sizeof(devmem), &devmem, NULL);
devmem /= 1000000;
if(err == CL_SUCCESS)
ilist->append(QString::number((unsigned int)(devmem)));
else
ilist->append("Unkown");
}
//CL_DEVICE_MAX_COMPUTE_UNITS * CL_DEVICE_MAX_WORK_GROUP_SIZE
{
cl_uint devcores;
err = clGetDeviceInfo(devices[i][j], CL_DEVICE_MAX_COMPUTE_UNITS, sizeof(devcores), &devcores, NULL);
if(err == CL_SUCCESS)
{
size_t devcores2;
err = clGetDeviceInfo(devices[i][j], CL_DEVICE_MAX_WORK_GROUP_SIZE, sizeof(devcores2), &devcores2, NULL);
if(err == CL_SUCCESS)
ilist->append(QString::number(((unsigned int)(devcores)) * ((unsigned int)(devcores2))));
else
ilist->append("Unkown");
}
else
ilist->append("Unknown");
}
我不了解的是内存,并且没有显示针对CPU的并行计算。
知道为什么我会得到这些结果吗?
最佳答案
这是因为CL_DEVICE_MAX_WORK_GROUP_SIZE不是并行计算能力的指标。
关于c++ - 英特尔i5处理器是否优于ATI HD Radeon GPU?,我们在Stack Overflow上找到一个类似的问题:https://stackoverflow.com/questions/22481502/