OpenCL* for CPU
Ask questions and share information on Intel® SDK for OpenCL™ Applications and OpenCL™ implementations for Intel® CPU.
Announcements
This forum covers OpenCL* for CPU only. OpenCL* for GPU questions can be asked in the GPU Compute Software forum. Intel® FPGA SDK for OpenCL™ questions can be ask in the FPGA Intel® High Level Design forum.

Offline compile

Dan_L_2
Beginner
729 Views

Hello,

I am trying to offline compile a simple opencl test program. I am successuflly able to online compile the same kernel. and in my online compiling host program when I call clGetPlatformIDs I get back 2 values one being my my cpu the other being my gpu. but when I try and compile using the offline compiler with the -device=gpu flag I get the error "Failed to get OpenCL device...: -1 (CL_DEVICE_NOT_FOUND)". If I open code composer and look at devices the only one that shows up is my CPU. Not sure what I am doing wrong or how to go about fixing this issue. Thanks in advance for the help.

Dan
 

 

Info: I am on a intel core i5-4302y running centos 7.1 with the 14.2 opencl runtime and the 2015 SDK installed.

0 Kudos
1 Solution
Robert_I_Intel
Employee
729 Views

Hi Dan,

This is the weirdest thing I've seen so far :)  Looks like you did install Media Server Studio and then installed CPU OpenCL Runtime on top of that and you got those two platforms. The thing to do is try to uninstall CPU runtime installed last. If you don't want to risk it, you can write your own offline compiler and use the following method https://www.khronos.org/registry/cl/sdk/1.2/docs/man/xhtml/clGetProgramBuildInfo.html to get the right binary.

View solution in original post

0 Kudos
7 Replies
Robert_I_Intel
Employee
729 Views

Hi Dan,

Not sure how you are able to see two platforms with the configuration you have unless you have a discrete graphics card there as well (our offline compiler wouldn't work with the third party graphics cards and their OpenCL runtimes). Could you please download, build and run the following program https://software.intel.com/en-us/articles/caps-basic and let me know what the output is.

The only way for you to see Intel Processor Graphics device on your chip is to install Intel(R) Media Server Studio https://software.intel.com/en-us/intel-media-server-studio and to follow instructions for installing an OpenCL driver for the GPU (involves patching the kernel). We are working on releasing a standalone driver for the GPU, but it will only happen at the beginning of next year.

0 Kudos
Dan_L_2
Beginner
729 Views

Here is the the output from the caps-basic program

Platform names:
    [0] Intel(R) OpenCL [Selected]
    [1] Intel(R) OpenCL
Number of devices available for each type:
    CL_DEVICE_TYPE_CPU: 1
    CL_DEVICE_TYPE_GPU: 0
    CL_DEVICE_TYPE_ACCELERATOR: 0

*** Detailed information for each device ***

CL_DEVICE_TYPE_CPU[0]
    CL_DEVICE_NAME: Intel(R) Core(TM) i5-4302Y CPU @ 1.60GHz
    CL_DEVICE_AVAILABLE: 1
    CL_DEVICE_VENDOR: Intel(R) Corporation
    CL_DEVICE_PROFILE: FULL_PROFILE
    CL_DEVICE_VERSION: OpenCL 1.2 (Build 8)
    CL_DRIVER_VERSION: 1.2.0.8
    CL_DEVICE_OPENCL_C_VERSION: OpenCL C 1.2
    CL_DEVICE_MAX_COMPUTE_UNITS: 4
    CL_DEVICE_MAX_CLOCK_FREQUENCY: 1600
    CL_DEVICE_MAX_WORK_GROUP_SIZE: 8192
    CL_DEVICE_ADDRESS_BITS: 64
    CL_DEVICE_MEM_BASE_ADDR_ALIGN: 1024
    CL_DEVICE_MAX_MEM_ALLOC_SIZE: 2064343040
    CL_DEVICE_GLOBAL_MEM_SIZE: 8257372160
    CL_DEVICE_MAX_CONSTANT_BUFFER_SIZE: 131072
    CL_DEVICE_GLOBAL_MEM_CACHE_SIZE: 262144
    CL_DEVICE_GLOBAL_MEM_CACHELINE_SIZE: 64
    CL_DEVICE_LOCAL_MEM_SIZE: 32768
    CL_DEVICE_PROFILING_TIMER_RESOLUTION: 1
    CL_DEVICE_IMAGE_SUPPORT: 1
    CL_DEVICE_ERROR_CORRECTION_SUPPORT: 0
    CL_DEVICE_HOST_UNIFIED_MEMORY: 1
    CL_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_spir cl_intel_exec_by_local_thread cl_khr_depth_images cl_khr_3d_image_writes cl_khr_fp64
    CL_DEVICE_PREFERRED_VECTOR_WIDTH_INT: 1
    CL_DEVICE_PREFERRED_VECTOR_WIDTH_LONG: 1
    CL_DEVICE_PREFERRED_VECTOR_WIDTH_FLOAT: 1
    CL_DEVICE_PREFERRED_VECTOR_WIDTH_DOUBLE: 1
    CL_DEVICE_NATIVE_VECTOR_WIDTH_INT: 8
    CL_DEVICE_NATIVE_VECTOR_WIDTH_LONG: 4
    CL_DEVICE_NATIVE_VECTOR_WIDTH_FLOAT: 8
    CL_DEVICE_NATIVE_VECTOR_WIDTH_DOUBLE: 4

This is the output when run with the second platform selected:

igdrcl: using XCB-DRI2 authentication...
Number of available platforms: 2
Platform names:
    [0] Intel(R) OpenCL
    [1] Intel(R) OpenCL [Selected]
Number of devices available for each type:
    CL_DEVICE_TYPE_CPU: 1
    CL_DEVICE_TYPE_GPU: 1
    CL_DEVICE_TYPE_ACCELERATOR: 0

*** Detailed information for each device ***

CL_DEVICE_TYPE_CPU[0]
    CL_DEVICE_NAME: Intel(R) Core(TM) i5-4302Y CPU @ 1.60GHz
    CL_DEVICE_AVAILABLE: 1
    CL_DEVICE_VENDOR: Intel(R) Corporation
    CL_DEVICE_PROFILE: FULL_PROFILE
    CL_DEVICE_VERSION: OpenCL 1.2 (Build 8)
    CL_DRIVER_VERSION: 1.2.0.8
    CL_DEVICE_OPENCL_C_VERSION: OpenCL C 1.2
    CL_DEVICE_MAX_COMPUTE_UNITS: 4
    CL_DEVICE_MAX_CLOCK_FREQUENCY: 1600
    CL_DEVICE_MAX_WORK_GROUP_SIZE: 8192
    CL_DEVICE_ADDRESS_BITS: 64
    CL_DEVICE_MEM_BASE_ADDR_ALIGN: 1024
    CL_DEVICE_MAX_MEM_ALLOC_SIZE: 2064343040
    CL_DEVICE_GLOBAL_MEM_SIZE: 8257372160
    CL_DEVICE_MAX_CONSTANT_BUFFER_SIZE: 131072
    CL_DEVICE_GLOBAL_MEM_CACHE_SIZE: 262144
    CL_DEVICE_GLOBAL_MEM_CACHELINE_SIZE: 64
    CL_DEVICE_LOCAL_MEM_SIZE: 32768
    CL_DEVICE_PROFILING_TIMER_RESOLUTION: 1
    CL_DEVICE_IMAGE_SUPPORT: 1
    CL_DEVICE_ERROR_CORRECTION_SUPPORT: 0
    CL_DEVICE_HOST_UNIFIED_MEMORY: 1
    CL_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_spir cl_intel_exec_by_local_thread cl_khr_depth_images cl_khr_3d_image_writes cl_khr_fp64
    CL_DEVICE_PREFERRED_VECTOR_WIDTH_INT: 1
    CL_DEVICE_PREFERRED_VECTOR_WIDTH_LONG: 1
    CL_DEVICE_PREFERRED_VECTOR_WIDTH_FLOAT: 1
    CL_DEVICE_PREFERRED_VECTOR_WIDTH_DOUBLE: 1
    CL_DEVICE_NATIVE_VECTOR_WIDTH_INT: 8
    CL_DEVICE_NATIVE_VECTOR_WIDTH_LONG: 4
    CL_DEVICE_NATIVE_VECTOR_WIDTH_FLOAT: 8
    CL_DEVICE_NATIVE_VECTOR_WIDTH_DOUBLE: 4

CL_DEVICE_TYPE_GPU[0]
    CL_DEVICE_NAME: Intel(R) HD Graphics
    CL_DEVICE_AVAILABLE: 1
    CL_DEVICE_VENDOR: Intel(R) Corporation
    CL_DEVICE_PROFILE: FULL_PROFILE
    CL_DEVICE_VERSION: OpenCL 1.2
    CL_DRIVER_VERSION: 16.4.2.1.39163
    CL_DEVICE_OPENCL_C_VERSION: OpenCL C 1.2
    CL_DEVICE_MAX_COMPUTE_UNITS: 20
    CL_DEVICE_MAX_CLOCK_FREQUENCY: 850
    CL_DEVICE_MAX_WORK_GROUP_SIZE: 512
    CL_DEVICE_ADDRESS_BITS: 64
    CL_DEVICE_MEM_BASE_ADDR_ALIGN: 1024
    CL_DEVICE_MAX_MEM_ALLOC_SIZE: 427399577
    CL_DEVICE_GLOBAL_MEM_SIZE: 1709598311
    CL_DEVICE_MAX_CONSTANT_BUFFER_SIZE: 65536
    CL_DEVICE_GLOBAL_MEM_CACHE_SIZE: 262144
    CL_DEVICE_GLOBAL_MEM_CACHELINE_SIZE: 64
    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: 1
    CL_DEVICE_EXTENSIONS: cl_intel_accelerator cl_intel_advanced_motion_estimation cl_intel_motion_estimation cl_intel_subgroups cl_intel_va_api_media_sharing cl_khr_3d_image_writes cl_khr_byte_addressable_store cl_khr_global_int32_base_atomics cl_khr_global_int32_extended_atomics cl_khr_icd cl_khr_local_int32_base_atomics cl_khr_local_int32_extended_atomics cl_khr_spir
    CL_DEVICE_PREFERRED_VECTOR_WIDTH_INT: 1
    CL_DEVICE_PREFERRED_VECTOR_WIDTH_LONG: 1
    CL_DEVICE_PREFERRED_VECTOR_WIDTH_FLOAT: 1
    CL_DEVICE_PREFERRED_VECTOR_WIDTH_DOUBLE: 0
    CL_DEVICE_NATIVE_VECTOR_WIDTH_INT: 1
    CL_DEVICE_NATIVE_VECTOR_WIDTH_LONG: 1
    CL_DEVICE_NATIVE_VECTOR_WIDTH_FLOAT: 1
    CL_DEVICE_NATIVE_VECTOR_WIDTH_DOUBLE: 0

My guess is the first platform is being selected by the ioc64 compiler. How do I make the second platform the one chosen by the compiler?

0 Kudos
Robert_I_Intel
Employee
730 Views

Hi Dan,

This is the weirdest thing I've seen so far :)  Looks like you did install Media Server Studio and then installed CPU OpenCL Runtime on top of that and you got those two platforms. The thing to do is try to uninstall CPU runtime installed last. If you don't want to risk it, you can write your own offline compiler and use the following method https://www.khronos.org/registry/cl/sdk/1.2/docs/man/xhtml/clGetProgramBuildInfo.html to get the right binary.

0 Kudos
Dan_L_2
Beginner
729 Views

So I reinstalled centos and installed the Media server studio. I am now unable to link programs to the shared library /opt/intel/opencl/libOpenCL.so

Am I missing a step?


install centos

download and install Media Server Studio

compile test programs

 

Thanks in advance.

Dan

0 Kudos
Jeffrey_M_Intel1
Employee
729 Views

There may be a better way, but here is how I compile the samples with MSS OpenCL:

$ cd  intel_ocl_samples_linux/CapsBasic
$ export PKG_CONFIG_PATH=/opt/intel/opencl/

$ vi Makefile

(add pkg-config to the makefile so it supplies -I and -L paths)

capsbasic: capsbasic.cpp Makefile
        g++ capsbasic.cpp -lOpenCL -ocapsbasic $(OPT) `pkg-config --cflags --libs OpenCL`

$ make
$./capsbasic

 

0 Kudos
Dan_L_2
Beginner
729 Views

Awesome Thanks Jeffrey!

another question in my offline compile quest.


ioc64 has the following commands 

-cmd=build Creates executable IR from source code. Default command in case nothing is specified.

-cmd=compile Creates compiled object IR from source code.

-cmd=link Creates executable IR or library from object IR and libraries.

And the following options

-asm=[<file_path>] Generates assembly code.

-llvm[=<file_path>] Generates LLVM code.

-llvm-spir32[=<file_path>] Generates 32-bit LLVM SPIR code.

-llvm-spir64[=<file_path>] Generates 64-bit LLVM SPIR code.

-ir[=<file_path>] Generates intermediate representation binary.

-spir32[=<file_path>] Generates 32-bit SPIR code.

-spir64[=<file_path>] Generates 64-bit SPIR code.

 

which set of options to I need to use to compile as lowlevel a binary for my intel GPU (i would prefer the lowest level binary as it only needs to run on this machine)

if i run

ioc64 -cmd=build -input=kernel.cl -device=gpu 

No output is created. Which option generates a "gpu binary" (if such a thing exists) or as close to one as it gets.

Thanks for your help!

Dan
 

0 Kudos
Jeffrey_M_Intel1
Employee
729 Views

You can add -ir to get output compatible with clCreateProgramWithBinary.

More info here: http://logan.tw/posts/2014/11/21/pre-compile-the-opencl-kernel-program-part-1/

Hoping to post more on the other output formats soon.

0 Kudos
Reply