Machine :Intel Xeon i7 6700(core) + Intel HD Graphics 530(skyLake) +Linux (CentOS 7.2或7.3,我的7.3)+eclipse(Neon)安装OpenCL环境,希望安装成功后将Intel i7 6700作为host,HD Graphics 530作为device。
搞了半天,才知道Linux下 HD Graphics 530并没有driver,https://downloadcenter.intel.com/product/88345/Intel-HD-Graphics-530 官网给出的都是windows下的。所以driver这步就省了。
按照:https://software.intel.com/en-us/articles/sdk-for-opencl-gsg 来安装。
一、安装Intel OpenCL driver
官网给出了脚本直接安装:https://software.intel.com/sites/default/files/managed/f6/77/install_OCL_driver.sh_.txt 我之前都是自己新建一个txt将这段脚本复制过去,结果安装时总是出错,不能复制!要直接下载。我放在 http://download.csdn.net/download/wd1603926823/10219725 可以直接下载。下载完毕以后,直接按照官网的步骤开始安装:
$ mv install_OCL_driver.sh_.txt install_OCL_driver.sh
$ chmod 755 install_OCL_driver.sh
$ sudo su
$ ./install_OCL_driver.sh install
一直选择y 即yes,然后出现:
然后出现一个error:因为我的linux kernel是3.10.0-514.el7.X86_64 所以报错。不满足install的条件。
这个提示出来,我确认我有足够的磁盘空间,于是我又运行install一次,这次就不会报错了。漫长的等待----安装完毕。
然后我按照建议1 将用户root加入到video group了。 第2点不满足就不管它了,然后重启。
也可以自己打开提示的这个网页去手动下载linux-4.7.tar.xz 然后看完 https://linoxide.com/linux-how-to/upgrade-linux-kernel-stable-4-7-centos-7-x/ 的后部分 就会安装了。
二、Intel_OpenCL_SDK
https://software.intel.com/en-us/articles/sdk-for-opencl-gsg 这里给出的是Ubuntu的,没有给CentOS的。但我还是想试试,于是下载这个(不要复制,而是直接下载),然后按照运行:
$ mv install_SDK_prereq_ubuntu.sh_.txt install_SDK_prereq_ubuntu.sh
$ sudo su
$ ./install_SDK_prereq_ubuntu.sh
结果显示:bash: ./install_SDK_prereq_ubuntu.sh: 权限不够 !!!但我是root登录的!我输入clinfo也说我未找到命令!?
后来我想了想,还是自己手动安装SDK,去官网 https://registrationcenter.intel.com/en/products/postregistration/?sn=c69g-kd7n5h3j&EmailID=1603926823@qq.com&Sequence=2151318&dnld=t 下的合适我的SDK,当然怎么找合适的,要先看 release note :https://software.intel.com/en-us/articles/opencl-code-builder-release-notes 看哪个版本适合我。 可以通过install.sh或者install_GUI.sh安装,我是通过sh install_GUI.sh安装的,在安装期间,说我缺少dkms这个包,于是我yum install epel-release dkms 安装,但装了两遍才装成功dkms,然后继续中断的安装步骤。安装完毕会显示成功,出来这个界面。
所以SDK就装完了。
装完后可以看到/opt/instel/下有4个文件(夹):ism opencl opencl-sdk和另一个文件。打开文件夹opencl-sdk可以看到有include和lib64文件夹。。。应该是真的成功了。
三、检查对OpenCL的设备支持
但输入clinfo说权限不够,于是自己去手动下载了clinfo的rpm包,然后:rpm -ivh clinfo-2.1.17.02.09-1.el7.x86_64.rpm 安装成功。然后输入clinfo 即可:哈哈哈终于出现2个平台和2个devices了哈哈哈!!!!!
平台1:Intel(R) OpenCL (设备是:Intel(R) HD Graphics 与 Intel(R) Core(TM) i7-6700 CPU);
平台2:Experimental OpenCL 2.1 CPU Only Platform (设备是:Intel(R) Core(TM) i7-6700 CPU);
Number of platforms 2
Platform Name Intel(R) OpenCL
Platform Vendor Intel(R) Corporation
Platform Version OpenCL 2.0
Platform Profile FULL_PROFILE
Platform Extensions cl_khr_3d_image_writes cl_khr_byte_addressable_store cl_khr_depth_images cl_khr_fp64 cl_khr_global_int32_base_atomics cl_khr_global_int32_extended_atomics cl_khr_icd cl_khr_image2d_from_buffer cl_khr_local_int32_base_atomics cl_khr_local_int32_extended_atomics cl_khr_spir
Platform Extensions function suffix INTEL
Platform Name Experimental OpenCL 2.1 CPU Only Platform
Platform Vendor Intel(R) Corporation
Platform Version OpenCL 2.1 LINUX
Platform Profile FULL_PROFILE
Platform Extensions cl_khr_icd 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_depth_images cl_khr_3d_image_writes cl_intel_exec_by_local_thread cl_khr_spir cl_khr_fp64 cl_khr_image2d_from_buffer
Platform Host timer resolution 1ns
Platform Extensions function suffix INTEL
Platform Name Intel(R) OpenCL
Number of devices 2
Device Name Intel(R) HD Graphics
Device Vendor Intel(R) Corporation
Device Vendor ID 0x8086
Device Version OpenCL 2.0
Driver Version r5.0.63503
Device OpenCL C Version OpenCL C 2.0
Device Type GPU
Device Available Yes
Device Profile FULL_PROFILE
Max compute units 24
Max clock frequency 1150MHz
Device Partition (core)
Max number of sub-devices 0
Supported partition types None
Max work item dimensions 3
Max work item sizes 256x256x256
Max work group size 256
Compiler Available Yes
Linker Available Yes
Preferred work group size multiple 32
Sub-group sizes (Intel) 8x16x32
Preferred / native vector sizes
char 16 / 16
short 8 / 8
int 4 / 4
long 1 / 1
half 8 / 8 (cl_khr_fp16)
float 1 / 1
double 1 / 1 (cl_khr_fp64)
Half-precision Floating-point support (cl_khr_fp16)
Denormals Yes
Infinity and NANs Yes
Round to nearest Yes
Round to zero Yes
Round to infinity Yes
IEEE754-2008 fused multiply-add Yes
Support is emulated in software No
Correctly-rounded divide and sqrt operations No
Single-precision Floating-point support (core)
Denormals Yes
Infinity and NANs Yes
Round to nearest Yes
Round to zero Yes
Round to infinity Yes
IEEE754-2008 fused multiply-add Yes
Support is emulated in software No
Correctly-rounded divide and sqrt operations Yes
Double-precision Floating-point support (cl_khr_fp64)
Denormals Yes
Infinity and NANs Yes
Round to nearest Yes
Round to zero Yes
Round to infinity Yes
IEEE754-2008 fused multiply-add Yes
Support is emulated in software No
Correctly-rounded divide and sqrt operations No
Address bits 64, Little-Endian
Global memory size 13238812672 (12.33GiB)
Error Correction support No
Max memory allocation 4294959103 (4GiB)
Unified memory for Host and Device Yes
Shared Virtual Memory (SVM) capabilities (core)
Coarse-grained buffer sharing Yes
Fine-grained buffer sharing No
Fine-grained system sharing No
Atomics No
Minimum alignment for any data type 128 bytes
Alignment of base address 1024 bits (128 bytes)
Preferred alignment for atomics
SVM 64 bytes
Global 64 bytes
Local 64 bytes
Max size for global variable 65536 (64KiB)
Preferred total size of global vars 4294959103 (4GiB)
Global Memory cache type Read/Write
Global Memory cache size 524288 (512KiB)
Global Memory cache line 64 bytes
Image support Yes
Max number of samplers per kernel 16
Max size for 1D images from buffer 268434943 pixels
Max 1D or 2D image array size 2048 images
Base address alignment for 2D image buffers 4 bytes
Pitch alignment for 2D image buffers 4 bytes
Max 2D image size 16384x16384 pixels
Max planar YUV image size 16384x16380 pixels
Max 3D image size 16384x16384x2048 pixels
Max number of read image args 128
Max number of write image args 128
Max number of read/write image args 128
Max number of pipe args 16
Max active pipe reservations 1
Max pipe packet size 1024
Local memory type Local
Local memory size 65536 (64KiB)
Max constant buffer size 4294959103 (4GiB)
Max number of constant args 8
Max size of kernel argument 1024
Queue properties (on host)
Out-of-order execution Yes
Profiling Yes
Queue properties (on device)
Out-of-order execution Yes
Profiling Yes
Preferred size 131072 (128KiB)
Max size 67108864 (64MiB)
Max queues on device 1
Max events on device 1024
Prefer user sync for interop Yes
Profiling timer resolution 83ns
Execution capabilities
Run OpenCL kernels Yes
Run native kernels No
SPIR versions 1.2
printf() buffer size 4194304 (4MiB)
Built-in kernels block_motion_estimate_intel;block_advanced_motion_estimate_check_intel;block_advanced_motion_estimate_bidirectional_check_intel
Motion Estimation accelerator version (Intel) 2
Device-side AVC Motion Estimation version 1
Supports texture sampler use Yes
Supports preemption No
Device Extensions cl_intel_accelerator cl_intel_advanced_motion_estimation cl_intel_device_side_avc_motion_estimation cl_intel_driver_diagnostics cl_intel_media_block_io cl_intel_motion_estimation cl_intel_planar_yuv cl_intel_packed_yuv cl_intel_required_subgroup_size cl_intel_subgroups cl_intel_subgroups_short cl_intel_va_api_media_sharing cl_khr_3d_image_writes cl_khr_byte_addressable_store cl_khr_depth_images cl_khr_fp16 cl_khr_fp64 cl_khr_global_int32_base_atomics cl_khr_global_int32_extended_atomics cl_khr_icd cl_khr_image2d_from_buffer cl_khr_local_int32_base_atomics cl_khr_local_int32_extended_atomics cl_khr_mipmap_image cl_khr_mipmap_image_writes cl_khr_spir cl_khr_subgroups
Device Name Intel(R) Core(TM) i7-6700 CPU @ 3.40GHz
Device Vendor Intel(R) Corporation
Device Vendor ID 0x8086
Device Version OpenCL 2.0 (Build 475)
Driver Version 1.2.0.475
Device OpenCL C Version OpenCL C 2.0
Device Type CPU
Device Available Yes
Device Profile FULL_PROFILE
Max compute units 8
Max clock frequency 3400MHz
Device Partition (core)
Max number of sub-devices 8
Supported partition types by counts, equally, by names (Intel)
Max work item dimensions 3
Max work item sizes 8192x8192x8192
Max work group size 8192
Compiler Available Yes
Linker Available Yes
Preferred work group size multiple 128
Preferred / native vector sizes
char 1 / 32
short 1 / 16
int 1 / 8
long 1 / 4
half 0 / 0 (n/a)
float 1 / 8
double 1 / 4 (cl_khr_fp64)
Half-precision Floating-point support (n/a)
Single-precision Floating-point support (core)
Denormals Yes
Infinity and NANs Yes
Round to nearest Yes
Round to zero No
Round to infinity No
IEEE754-2008 fused multiply-add No
Support is emulated in software No
Correctly-rounded divide and sqrt operations No
Double-precision Floating-point support (cl_khr_fp64)
Denormals Yes
Infinity and NANs Yes
Round to nearest Yes
Round to zero Yes
Round to infinity Yes
IEEE754-2008 fused multiply-add Yes
Support is emulated in software No
Correctly-rounded divide and sqrt operations No
Address bits 64, Little-Endian
Global memory size 16559001600 (15.42GiB)
Error Correction support No
Max memory allocation 4139750400 (3.855GiB)
Unified memory for Host and Device Yes
Shared Virtual Memory (SVM) capabilities (core)
Coarse-grained buffer sharing Yes
Fine-grained buffer sharing No
Fine-grained system sharing No
Atomics No
Minimum alignment for any data type 128 bytes
Alignment of base address 1024 bits (128 bytes)
Preferred alignment for atomics
SVM 64 bytes
Global 64 bytes
Local 0 bytes
Max size for global variable 65536 (64KiB)
Preferred total size of global vars 65536 (64KiB)
Global Memory cache type Read/Write
Global Memory cache size 262144 (256KiB)
Global Memory cache line 64 bytes
Image support Yes
Max number of samplers per kernel 480
Max size for 1D images from buffer 258734400 pixels
Max 1D or 2D image array size 2048 images
Base address alignment for 2D image buffers 64 bytes
Pitch alignment for 2D image buffers 64 bytes
Max 2D image size 16384x16384 pixels
Max 3D image size 2048x2048x2048 pixels
Max number of read image args 480
Max number of write image args 480
Max number of read/write image args 480
Max number of pipe args 16
Max active pipe reservations 32767
Max pipe packet size 1024
Local memory type Global
Local memory size 32768 (32KiB)
Max constant buffer size 131072 (128KiB)
Max number of constant args 480
Max size of kernel argument 3840 (3.75KiB)
Queue properties (on host)
Out-of-order execution Yes
Profiling Yes
Local thread execution (Intel) Yes
Queue properties (on device)
Out-of-order execution Yes
Profiling Yes
Preferred size 4294967295 (4GiB)
Max size 4294967295 (4GiB)
Max queues on device 4294967295
Max events on device 4294967295
Prefer user sync for interop No
Profiling timer resolution 1ns
Execution capabilities
Run OpenCL kernels Yes
Run native kernels Yes
SPIR versions 1.2
printf() buffer size 1048576 (1024KiB)
Built-in kernels
Device Extensions cl_khr_icd 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_depth_images cl_khr_3d_image_writes cl_intel_exec_by_local_thread cl_khr_spir cl_khr_fp64 cl_khr_image2d_from_buffer
Platform Name Experimental OpenCL 2.1 CPU Only Platform
Number of devices 1
Device Name Intel(R) Core(TM) i7-6700 CPU @ 3.40GHz
Device Vendor Intel(R) Corporation
Device Vendor ID 0x8086
Device Version OpenCL 2.1 (Build 10)
Driver Version 1.2.0.10
Device OpenCL C Version OpenCL C 2.0
Device Type CPU
Device Available Yes
Device Profile FULL_PROFILE
Max compute units 8
Max clock frequency 3400MHz
Device Partition (core)
Max number of sub-devices 8
Supported partition types by counts, equally, by names (Intel)
Max work item dimensions 3
Max work item sizes 8192x8192x8192
Max work group size 8192
Compiler Available Yes
Linker Available Yes
Preferred work group size multiple 128
Max sub-groups per work group 1
Preferred / native vector sizes
char 1 / 32
short 1 / 16
int 1 / 8
long 1 / 4
half 0 / 0 (n/a)
float 1 / 8
double 1 / 4 (cl_khr_fp64)
Half-precision Floating-point support (n/a)
Single-precision Floating-point support (core)
Denormals Yes
Infinity and NANs Yes
Round to nearest Yes
Round to zero No
Round to infinity No
IEEE754-2008 fused multiply-add No
Support is emulated in software No
Correctly-rounded divide and sqrt operations No
Double-precision Floating-point support (cl_khr_fp64)
Denormals Yes
Infinity and NANs Yes
Round to nearest Yes
Round to zero Yes
Round to infinity Yes
IEEE754-2008 fused multiply-add Yes
Support is emulated in software No
Correctly-rounded divide and sqrt operations No
Address bits 64, Little-Endian
Global memory size 16559001600 (15.42GiB)
Error Correction support No
Max memory allocation 4139750400 (3.855GiB)
Unified memory for Host and Device Yes
Shared Virtual Memory (SVM) capabilities (core)
Coarse-grained buffer sharing Yes
Fine-grained buffer sharing Yes
Fine-grained system sharing Yes
Atomics Yes
Minimum alignment for any data type 128 bytes
Alignment of base address 1024 bits (128 bytes)
Preferred alignment for atomics
SVM 64 bytes
Global 64 bytes
Local 0 bytes
Max size for global variable 65536 (64KiB)
Preferred total size of global vars 65536 (64KiB)
Global Memory cache type Read/Write
Global Memory cache size 262144 (256KiB)
Global Memory cache line 64 bytes
Image support Yes
Max number of samplers per kernel 480
Max size for 1D images from buffer 258734400 pixels
Max 1D or 2D image array size 2048 images
Base address alignment for 2D image buffers 64 bytes
Pitch alignment for 2D image buffers 64 bytes
Max 2D image size 16384x16384 pixels
Max 3D image size 2048x2048x2048 pixels
Max number of read image args 480
Max number of write image args 480
Max number of read/write image args 480
Max number of pipe args 16
Max active pipe reservations 32767
Max pipe packet size 1024
Local memory type Global
Local memory size 32768 (32KiB)
Max constant buffer size 131072 (128KiB)
Max number of constant args 480
Max size of kernel argument 3840 (3.75KiB)
Queue properties (on host)
Out-of-order execution Yes
Profiling Yes
Local thread execution (Intel) Yes
Queue properties (on device)
Out-of-order execution Yes
Profiling Yes
Preferred size 4294967295 (4GiB)
Max size 4294967295 (4GiB)
Max queues on device 4294967295
Max events on device 4294967295
Prefer user sync for interop No
Profiling timer resolution 1ns
Execution capabilities
Run OpenCL kernels Yes
Run native kernels Yes
Sub-group independent forward progress No
IL version SPIR-V_1.0
SPIR versions 1.2
printf() buffer size 1048576 (1024KiB)
Built-in kernels
Device Extensions cl_khr_icd 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_depth_images cl_khr_3d_image_writes cl_intel_exec_by_local_thread cl_khr_spir cl_khr_fp64 cl_khr_image2d_from_buffer
NULL platform behavior
clGetPlatformInfo(NULL, CL_PLATFORM_NAME, ...) No platform
clGetDeviceIDs(NULL, CL_DEVICE_TYPE_ALL, ...) No platform
clCreateContext(NULL, ...) [default] No platform
clCreateContext(NULL, ...) [other] Success [INTEL]
clCreateContextFromType(NULL, CL_DEVICE_TYPE_CPU) No platform
clCreateContextFromType(NULL, CL_DEVICE_TYPE_GPU) No platform
clCreateContextFromType(NULL, CL_DEVICE_TYPE_ACCELERATOR) No platform
clCreateContextFromType(NULL, CL_DEVICE_TYPE_CUSTOM) No platform
clCreateContextFromType(NULL, CL_DEVICE_TYPE_ALL) No platform
太开心了!!!!Linux下Intel核显for OpenCL环境搭建完毕!!!
四、用eclipse创建一个OpenCL项目测试
在相应地方加上/opt/intel/opencl-sdk/include和.../lib64即可!!!
五、Intel opencl samples
可以看看 https://software.intel.com/en-us/intel-opencl-support/code-samples 以及https://software.intel.com/en-us/articles/getting-the-most-from-opencl-12-how-to-increase-performance-by-minimizing-buffer-copies-on-intel-processor-graphics 因为很怕本来0传输的被自己写成内存到内存的传输 那么用核显就没有意义了。。。
https://software.intel.com/en-us/articles/getting-the-most-from-opencl-12-how-to-increase-performance-by-minimizing-buffer-copies-on-intel-processor-graphics
https://arrayfire.com/zero-copy-on-integrated-gpus/
https://software.intel.com/en-us/forums/opencl/topic/708049
http://blog.csdn.net/wcj0626/article/details/46360605
http://www.cnblogs.com/lifan3a/articles/4613858.html
六、Intel的调试及性能查看tool for linux
我在官网看了那个Amplifier XE要收费,后来查到有Intel VTune Performance Analyzer,我在 http://download.csdn.net/download/morre/8557459 下载的这个工具,这里也有下载链接:http://intel.brothersoft.com/intel-vtune-performance-analyzer-for-linux.html?fromsearch 。另外:http://qcd.phys.cmu.edu/QCDcluster/intel/VTLRELEASENOTES.htm 这里还有各个版本的不同比较。http://blog.csdn.net/yangsc1984/article/details/3908823 这里是别人的中文介绍。https://www.viva64.com/en/t/0091/ 这里是别人的英文介绍。 http://blog.csdn.net/honey_yyang/article/details/7848923 这个是与eclipse结合后的强大功能介绍。 https://software.intel.com/en-us/code-builder-user-manual-installing-opencl-kernel-debugger-for-linux 官网说的调试工具就在sdk里? http://opencl38.rssing.com/chan-13188063/all_p8.html 这个是论坛上别人调试时遇到的问题。 解压准备安装,但提示说需要序列号?!!!!我没有序列号 ,然后Intel官网现在已经没有这个Intel VTune Performance Analyzer 了?!!!!!现在官网上linux的工具只有:https://software.intel.com/en-us/intel-devtools-by-os/linux 只有这些。没有序列号,无法安装免费的opencl工具,所以只能装这个 https://software.intel.com/en-us/intel-vtune-amplifier-xe 使用30的,按照https://software.intel.com/en-us/vtune-amplifier-install-guide-linux-user-interface-install 来安装。
七、一个例子与以前AMD时的对比
以前用AMD 560显卡时:CPU版本耗时约19s,OpenCL版本耗时约4.5s (单线程多线程均如此);
现在用Intel skylake核显:CPU版本耗时约17.3s,单线程的OpenCL版本耗时约5s,但多线程的OpenCL版本竟然要38s?!(将OpenCL版本由单线程改成多线程时应该有问题)