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.
1663 Discussions

Resource Sharing sample crashed.

benny_w_
Beginner
183 Views

The Resource Sharing sample​ (https://software.intel.com/en-us/articles/intel-directx-interop​) crashed on my computer.

Does it mean extension exists not equal to device exists? 

device:

Intel(R) Core(TM) i5-4200M CPU @ 2.50GHz
Intel(R) HD Graphics 4600

the CL_PLATFORM_EXTENSIONS has cl_khr_dx9_media_sharing​, but m_clGetDeviceIDsFromDX9MediaAdapterKHR return CL_DEVICE_NOT_FOUND

 

I:\driver\tmp\Release>DXVASurfaceSharing.exe
Platform extensions: cl_intel_dx9_media_sharing cl_khr_3d_image_writes cl_khr_byte_addressable_store cl_khr_d3d11_sharing cl_khr_depth_images cl_khr_dx9_media_sharing cl_khr_gl_sharing 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
Platform:Intel(R) OpenCL
cl_intel_dx9_media_sharing cl_khr_3d_image_writes cl_khr_byte_addressable_store cl_khr_d3d11_sharing cl_khr_depth_images cl_khr_dx9_media_sharing cl_khr_gl_sharing 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
Platform Devices:

 

0 Kudos
8 Replies
Jeffrey_M_Intel1
Employee
183 Views

Thanks for this report.  I'm looking into it and hope to get back to you soon.  

Jeffrey_M_Intel1
Employee
183 Views

There is an older Media SDK tutorial set with OpenCL interoperability examples here which works better in my tests.  See the simple_7_* directories for decode, encode, and transcode examples using the sharing extensions.

The sharing API initialization happens in ocl_process.cpp OCLProcess::OCLInit.

If the extension is available for the device in clGetPlatformInfo with CL_PLATFORM_EXTENSIONS the spec says "Extensions defined here must be supported by all devices associated with this platform."  However, here to get the behavior you want you will need to find the GPU device as illustrated in the example code.

Updates to these samples are needed.  While I can't give a timeline right now for when the new/updated samples will be available I hope that this is enough to get you started. 

 

 

benny_w_
Beginner
183 Views

Hi Jeffrey,
​     Which SDK should I install? The sample compile failed, there isn't a cl_dx9_media_sharing.h under $(INTELOCLSDKROOT)\include​.

​     I found the oclinit code almost same. Copy the OCLInit​ into the Resource Sharing sample​, call it first, also failed with following message

              OpenCL platform "Intel(R) OpenCL" is used
               Get device IDs failed !!!! (-1)

 

 

 


 

 

 

Jeffrey_M_Intel1
Employee
183 Views

I just double checked with a reinstall of the latest Windows Intel(R) SDK for OpenCL(TM) Applications download from registrationcenter.intel.com (2016 R2).  This should be the default download if you have an existing account or if you download for the first time from https://software.intel.com/en-us/intel-opencl.  In my check the file is there.

However, it looks like you may want to validate your install.  Does the Platform/Device Capabilities Viewer Sample work?

 

benny_w_
Beginner
183 Views

reinstall the SDK, compile Resource Sharing sample failed, change #include  cl\cl_d3d9.h to #include <CL/cl_dx9_media_sharing.h>​.
get same result.

following is Device Capabilities Viewer Sample's output

Number of available platforms: 3
Platform names:
    [0] Intel(R) OpenCL [Selected]
    [1] NVIDIA CUDA
    [2] Experimental OpenCL 2.1 CPU Only Platform
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-4200M CPU @ 2.50GHz
    CL_DEVICE_AVAILABLE: 1
    CL_DEVICE_VENDOR: Intel(R) Corporation
    CL_DEVICE_PROFILE: FULL_PROFILE
    CL_DEVICE_VERSION: OpenCL 1.2 (Build 10094)
    CL_DRIVER_VERSION: 5.2.0.10094
    CL_DEVICE_OPENCL_C_VERSION: OpenCL C 1.2
    CL_DEVICE_MAX_COMPUTE_UNITS: 4
    CL_DEVICE_MAX_CLOCK_FREQUENCY: 2500
    CL_DEVICE_MAX_WORK_GROUP_SIZE: 8192
    CL_DEVICE_ADDRESS_BITS: 32
    CL_DEVICE_MEM_BASE_ADDR_ALIGN: 1024
    CL_DEVICE_MAX_MEM_ALLOC_SIZE: 536838144
    CL_DEVICE_GLOBAL_MEM_SIZE: 2147352576
    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: 410
    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_depth_images cl_khr_3d_image_writes cl_intel_exec_by_local_thread cl_khr_spir cl_khr_dx9_media_sharing cl_intel_dx9_media_sharing cl_khr_d3d11_sharing cl_khr_gl_sharing 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 4600
    CL_DEVICE_AVAILABLE: 1
    CL_DEVICE_VENDOR: Intel(R) Corporation
    CL_DEVICE_PROFILE: FULL_PROFILE
    CL_DEVICE_VERSION: OpenCL 1.2
    CL_DRIVER_VERSION: 20.19.15.4416
    CL_DEVICE_OPENCL_C_VERSION: OpenCL C 1.2
    CL_DEVICE_MAX_COMPUTE_UNITS: 20
    CL_DEVICE_MAX_CLOCK_FREQUENCY: 1150
    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: 390280806
    CL_DEVICE_GLOBAL_MEM_SIZE: 1561123226
    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_ctz cl_intel_d3d11_nv12_media_sharing cl_intel_dx9_media_sharing cl_intel_motion_estimation cl_intel_simultaneous_sharing cl_intel_subgroups cl_khr_3d_image_writes cl_khr_byte_addressable_store cl_khr_d3d10_sharing cl_khr_d3d11_sharing cl_khr_depth_images cl_khr_dx9_media_sharing cl_khr_gl_depth_images cl_khr_gl_event cl_khr_gl_msaa_sharing cl_khr_global_int32_base_atomics cl_khr_global_int32_extended_atomics cl_khr_gl_sharing cl_khr_icd cl_khr_image2d_from_buffer 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

 

Jeffrey_M_Intel1
Employee
183 Views

Thanks for checking.  A few more things to try:

  • As a debugging experiment (not a permanent solution) disable the discrete GPU.  
  • Can you run sample_multi_transcode or sample_encode from the Media SDK samples?   These have an OpenCL option for a rotate filter and also demonstrate directX resource sharing.

Both may indicate a path forward.  If you can run with only Intel processor graphics there may be hope that updates to the OpenCL initialization for this example could help you get started.  If you can run the Media SDK samples these may be a better template until we can get some updated sharing examples published.

 

benny_w_
Beginner
183 Views

Thanks Jeffery,
Disable the discrete GPU, both samples run successfully!
But why?

 

 

 

 

 

Jeffrey_M_Intel1
Employee
183 Views

The first thing to check is the initialization code.  As samples they are intended to be starting points without production-level "hardening".  There is a good chance that some improvements could be made for multi-GPU configurations. 

Reply