在英特尔中打开 cl

在英特尔中打开 cl

如何在具有英特尔 HD 4000 GPU 单元的英特尔 i5 处理器上编译和运行 open cl 代码???Open cl 已安装在 /opt/intel/opencl 中,版本为 ubuntu 12.04。任何帮助都将大有帮助...谢谢

答案1

第一的:
sudo apt-get install beignet opencl-headers

将 beignet 文件夹添加到您的库搜索路径:

sudo su
echo "/usr/lib/beignet/" > /etc/ld.so.conf.d/beignet.conf
ldconfig
exit

获取一个简单的测试二进制文件:

git clone https://github.com/vpereira/CapsBasic-beignet

编辑 makefile 使其更类似于以下内容:

all: capsbasic

capsbasic: capsbasic.cpp Makefile
    g++ capsbasic.cpp -lcl -ocapsbasic -I/usr/include -L/usr/lib/beignet

clean:
    rm -f capsbasic

就是这样。OpenCL 正在为英特尔高清系列显卡工作……

lspci | grep VGA
00:02.0 VGA compatible controller: Intel Corporation 3rd Gen Core processor Graphics Controller (rev 09)

./capsbasic

Number of available platforms: 1
Platform names:
    [0] Experiment Intel Gen OCL Driver [Selected]
Number of devices available for each type:
    CL_DEVICE_TYPE_CPU: 0
    CL_DEVICE_TYPE_GPU: 1
    CL_DEVICE_TYPE_ACCELERATOR: 0

*** Detailed information for each device ***

CL_DEVICE_TYPE_GPU[0]
    CL_DEVICE_NAME: Intel HD Graphics Family
    CL_DEVICE_AVAILABLE: 1
    CL_DEVICE_VENDOR: Intel
    CL_DEVICE_PROFILE: FULL_PROFILE
    CL_DEVICE_VERSION: OpenCL 1.1
    CL_DRIVER_VERSION: 0.2
    CL_DEVICE_OPENCL_C_VERSION: OpenCL C 1.1
    CL_DEVICE_MAX_COMPUTE_UNITS: 128
    CL_DEVICE_MAX_CLOCK_FREQUENCY: 1000
    CL_DEVICE_MAX_WORK_GROUP_SIZE: 512
    CL_DEVICE_ADDRESS_BITS: 32
    CL_DEVICE_MEM_BASE_ADDR_ALIGN: 32
    CL_DEVICE_MAX_MEM_ALLOC_SIZE: 134217728
    CL_DEVICE_GLOBAL_MEM_SIZE: 4
    CL_DEVICE_MAX_CONSTANT_BUFFER_SIZE: 65536
    CL_DEVICE_GLOBAL_MEM_CACHE_SIZE: 8192
    CL_DEVICE_GLOBAL_MEM_CACHELINE_SIZE: 128
    CL_DEVICE_LOCAL_MEM_SIZE: 65536
    CL_DEVICE_PROFILING_TIMER_RESOLUTION: 80
    CL_DEVICE_IMAGE_SUPPORT: 1
    CL_DEVICE_ERROR_CORRECTION_SUPPORT: 0
    CL_DEVICE_HOST_UNIFIED_MEMORY: 0
    CL_DEVICE_EXTENSIONS: cl_khr_global_int32_base_atomics cl_khr_global_int32_extended_atomics cl_khr_local_int32_base_atomics cl_khr_local_int32_extended_atomics cl_khr_byte_addressable_store cl_khr_fp64 cl_khr_icd cl_khr_gl_sharing
    CL_DEVICE_PREFERRED_VECTOR_WIDTH_INT: 16
    CL_DEVICE_PREFERRED_VECTOR_WIDTH_LONG: 16
    CL_DEVICE_PREFERRED_VECTOR_WIDTH_FLOAT: 16
    CL_DEVICE_PREFERRED_VECTOR_WIDTH_DOUBLE: 0
    CL_DEVICE_NATIVE_VECTOR_WIDTH_INT: 16
    CL_DEVICE_NATIVE_VECTOR_WIDTH_LONG: 16
    CL_DEVICE_NATIVE_VECTOR_WIDTH_FLOAT: 16
    CL_DEVICE_NATIVE_VECTOR_WIDTH_DOUBLE: 16

答案2

为了进行编译,您需要一个编译器,例如 gcc。您可以从其存储库下载 gcc。(选择最大版本号以获得更多 C++11 功能)。

$> sudo apt-get 安装 gcc-4.7

之后,您必须将 OpenCL 库链接到您正在编译的应用程序。假设主机应用程序 (main.c) 代码和内核应用程序 (kernel.cl) 代码位于名为 test 的文件夹中。您应该执行以下操作:

$测试> gcc -I /opt/intel/include -L /opt/intel/lib/[x86 或 x86_64]/ main.c -o a.out

它应该负责编译。您应该运行输出如下:

$测试>./a.out

并处理您可能遇到的任何运行时错误(包括更正 kernel.cl 的路径等)。

相关内容