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

clCreateContext fails on CPU but not on GPU

Olivier_P_
Beginner
815 Views

On a laptop running under Windows 10 64 bits and dual Intel GPU / NVIDIA GPU configuration, my OpenCL program returns a CL_OUT_OF_HOST_MEMORY when creating an OpenCL context with the "Intel (R) OpenCL" platform and a "Intel(R) Core(TM) i7-6700HQ CPU @ 2.60GHz - OpenCL 2.0 (Build 359)" device while the create context succeeds when I choose the "Intel(R) HD Graphics 530" device on the same platform and same code. Now the strange thing is that with one of the Intel OpenCL sample code, on the same machine and system, the context is created normally in both cases. Under VS 2015, at the time of context creation, heap allocation is only around 3 Mb so it feels weird to read that the host is out of memory!

Does anybody know what could be causing this error when choosing the CPU device under certain conditions?

0 Kudos
2 Replies
Olivier_P_
Beginner
815 Views

I have found what is causing this but without really understanding why. In fact it is just a clue but not really a complete solution. My project links with two Matlab libraries, libmat.lib / libmx.lib that are interface libraries to two DLLs delivered with Matlab. When I strip down my project by removing any Matlab code dependencies and removing these two libraries from the link... the OpenCL context is created successfully on the CPU. The weird thing is that this happens while the context is created before any Matlab code is called in the program, so there is something probably going on in the Matlab DLLs at initialization time that has an impact on the OpenCL context creation.

0 Kudos
Olivier_P_
Beginner
815 Views

Here is the conclusion to this bug. Instead of linking to the two Matlab libraries and loading the DLLs implicitely, I've switched to loading them explicitely after creating the OpenCL context. It solved the issue of the context failing when choosing the CPU device. I still have no idea why.

This is also related to this bug on linux Ubuntu.

0 Kudos
Reply