我想将英特尔库 embree 与 OpenCL 结合使用,但它对我不起作用。为了向您展示问题,我创建了一个小代码来获取所有 OpenCL 设备:
#include <stdio.h>
#include <stdlib.h>
#include <CL/cl.h>
int main() {
int i, j;
char* value;
size_t valueSize;
cl_uint platformCount;
cl_platform_id* platforms;
cl_uint deviceCount;
cl_device_id* devices;
cl_uint maxComputeUnits;
// get all platforms
clGetPlatformIDs(0, NULL, &platformCount);
platforms = (cl_platform_id*) malloc(sizeof(cl_platform_id) * platformCount);
clGetPlatformIDs(platformCount, platforms, NULL);
printf("Found PLatform :%i\n",platformCount);
for (i = 0; i < platformCount; i++) {
// get all devices
clGetDeviceIDs(platforms[i], CL_DEVICE_TYPE_ALL, 0, NULL, &deviceCount);
devices = (cl_device_id*) malloc(sizeof(cl_device_id) * deviceCount);
clGetDeviceIDs(platforms[i], CL_DEVICE_TYPE_ALL, deviceCount, devices, NULL);
// for each device print critical attributes
for (j = 0; j < deviceCount; j++) {
// print device name
clGetDeviceInfo(devices[j], CL_DEVICE_NAME, 0, NULL, &valueSize);
value = (char*) malloc(valueSize);
clGetDeviceInfo(devices[j], CL_DEVICE_NAME, valueSize, value, NULL);
printf("%i.%i Device: %sn\n", i+1,j+1, value);
free(value);
}
free(devices);
}
free(platforms);
return 0;
}
如果我编译这段代码:
g++ --std=c++11 -march=native -o test test.c -lOpenCL
我得到以下输出:
Found PLatform :2
1.1 Device: GeForce GTX 670n
2.1 Device: Intel(R) Xeon(R) CPU E5-2670 0 @ 2.60GHzn
如果我编译相同的代码:
g++ --std=c++11 -march=native -o test test.c -lOpenCL -l:libembree.so.2
我无法再找到我的 CPU 作为可用的 OpenCL 设备,因为我得到以下输出:
Found PLatform :1
1.1 Device: GeForce GTX 670n
谁能帮我把我的 CPU 重新作为 OpenCL 设备?