Monday, March 24, 2014

OpenCL on Ubuntu 12.04 + Intel CPU



Reference


Install

Install OpenCL Driver & related files (intel_sdk_for_ocl_applications_2014_beta_sdk_4.0.1.17537_x64.tgz) downloaded from http://software.intel.com/en-us/vcsource/tools/opencl-sdk-beta



Before installing the packages, debian package manager said that we need to install libnuma1.

./intel_sdk_for_ocl_applications_2014_beta_sdk_4.0.1.17537_x64
├── EULA.txt
├── install-cpu.sh
├── opencl-1.2-base-4.0.1.17537-1.x86_64.deb
├── opencl-1.2-devel-4.0.1.17537-1.x86_64.deb
├── opencl-1.2-intel-cpu-4.0.1.17537-1.x86_64.deb
├── opencl-1.2-intel-devel-4.0.1.17537-1.x86_64.deb
├── opencl-1.2-intel-devel-android-4.0.1.17537-1.x86_64.deb
└── uninstall.sh

Why OpenCL(libOpenCL.so) needs NUMA(libnuma)? libnuma1 is pre-required package of opencl-1.2-base-4.0.1.17537-1.x86_64.deb. You can check by "dpkg-dev --control opencl-1.2-base-4.0.1.17537-1.x86_64.deb ." and "vim control".

Package: opencl-base
Version: 1.2-4.0.1.17537
Depends: bash, dpkg, libnuma1
Section: extras
Maintainer: Intel Corporation
Architecture: all
Priority: optional
Description: OpenCL* (Open Computing Language) is an open standard for general-purpose
  parallel programming. OpenCL* provides a uniform programming environment for software
  developers to write portable code for client computer systems, high-performance computing
  servers, and other compute systems. This package contains OpenCL installable client driver
  loader. The OpenCL* installable client driver (ICD) enables different OpenCL* implementations
  to coexist on the same system. ICD also  enables applications to select between OpenCL*
  implementations at run time.

$ dpkg-deb -x ./opencl-1.2-base-4.0.1.17537-1.x86_64.deb .
$ tree
...
├── opt
│   └── intel
│       └── opencl-1.2-4.0.1.17537
│           └── lib64
│               ├── libOpenCL.so -> libOpenCL.so.1
│               ├── libOpenCL.so.1 -> libOpenCL.so.1.2
│               └── libOpenCL.so.1.2


$ ls -al /usr/lib/x86_64-linux-gnu/libOpenCL.so
lrwxrwxrwx 1 root root 37 Mar 22 23:10 /usr/lib/x86_64-linux-gnu/libOpenCL.so -> /etc/alternatives/opencl-libOpenCL.so

$ ls -al /etc/alternatives/opencl-libOpenCL.so
lrwxrwxrwx 1 root root 52 Mar 22 23:10 /etc/alternatives/opencl-libOpenCL.so -> /opt/intel/opencl-1.2-4.0.1.17537/lib64/libOpenCL.so


Querying Profile by using OpenCL Query functions

My laptop is MSI GE60 with Intel Core i7 4800MQ, whose spec is : http://ark.intel.com/products/75128/Intel-Core-i7-4800MQ-Processor-6M-Cache-up-to-3_70-GHz
Unfortunately we cannot use  CL_DEVICE_TYPE_GPU YET (2014-03-23)

The following is the result of my own tiny sample (https://github.com/stereoboy/opencl_samples).
num of platform ids: 1
-<0>------------------- Platform ID[0xa79f60]
CL_PLATFORM_PROFILE = FULL_PROFILE
CL_PLATFORM_VERSION = OpenCL 1.2 LINUX
CL_PLATFORM_NAME = Intel(R) OpenCL
CL_PLATFORM_VENDOR = Intel(R) Corporation
CL_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_spir cl_intel_exec_by_local_thread cl_khr_depth_images cl_khr_3d_image_writes cl_khr_fp64
num of device ids: 1
-<0>------------------- Device ID[0xa7abc8]
CL_DEVICE_NAME = Intel(R) Core(TM) i7-4800MQ CPU @ 2.70GHz
CL_DEVICE_TYPE = 2
CL_DEVICE_VENDOR = Intel(R) Corporation
CL_DEVICE_VERSION = OpenCL 1.2 (Build 83073)
CL_DEVICE_MAX_COMPUTE_UNITS = 8
CL_DEVICE_GLOBAL_MEM_SIZE = 0

Intel OpenCL does not support Ubuntu 12.04 + Intel GPU. Look at the "Supported Hardware" list in the release notes (http://software.intel.com/en-us/articles/intel-sdk-for-opencl-applications-2014-beta-release-notes)

Running OpenCL on NVidia Optimus (uncompleted)

https://wiki.ubuntu.com/Bumblebee