Jonathan Pearl
Jonathan Pearl

Reputation: 731

OpenCL clGetPlatformIDs causes access violation only when ran from Visual Studio

This is a strange one for me. I'm currently pulling a project from an old repo of mine that I've recently migrated to VS2015. The solution still builds and the executable works, but when running in visual studio I get an access violation in the call to clGetPlatformIDs() trying to read from 0x000008E0.

I honestly have no clue what it could be as it's very strange: the builds work themselves but not from VS. Debugging through I can confirm all the parameters are as expected but the function still fails. I updated the OpenCL implementation to Intel's OpenCL SDK version 6.3 but that didn't fix the problem and I don't have the symbols to dig any deeper into the function.

Code is simple, but I've posted it below anyway.

//Get Platforms
cl_platform_id * platforms = new cl_platform_id[6];
cl_uint numPlatforms = 0;
cl_uint numPlatformsToCheck = 6;
error = clGetPlatformIDs(numPlatformsToCheck, platforms, &numPlatforms);
printCLError( "Getting Platforms", error );

Upvotes: 1

Views: 969

Answers (2)

devdot
devdot

Reputation: 178

So I just had the same issue: I got an access violation exception on any OpenCL function. Fresh install of the Intel OpenCL SDK, all drivers up-to-date. Only happens when ran inside of Visual Studio.

I found a solution.

There would be an access violation in igdrcl64.dll, causing the exception. This library is part of the IntelHD Graphics drivers and there apparently used to be a bug in the DLL. But I don't have this driver installed (using NVIDIA graphics card), also the bug is supposedly fixed by now. It turns out the IntelHD driver's uninstaller does not remove all it's DLL's, so the buggy DLL's were left on my machine and not updated.

Fix: Remove the DLL's manually (only if you don't use IntelHD graphics!)

On 64-bit version of Windows OS:
C:\Windows\System32\igdbcl64.dll
C:\Windows\System32\igdfcl64.dll
C:\Windows\System32\igdrcl64.dll
C:\Windows\SysWOW64\igdbcl32.dll
C:\Windows\SysWOW64\igdfcl32.dll
C:\Windows\SysWOW64\igdrcl32.dll

On 32-bit version of Windows OS:
C:\Windows\System32\igdbcl32.dll
C:\Windows\System32\igdfcl32.dll
C:\Windows\System32\igdrcl32.dll

I hope this will help someone.

Upvotes: 2

Austin
Austin

Reputation: 1020

I think you are using clGetPlatformIDs wrong. First, call clGetPlatformIDs(numPlatformsToCheck, NULL, &numPlatforms);

Then: cl_platform_id * platforms = new cl_platform_id[numPlatforms];

Finally: error = clGetPlatformIDs(numPlatformsToCheck, platforms, NULL); printCLError( "Getting Platforms", error );

In general OpenCL query commands are:

  • Query to get number of items in a list
  • Allocate the memory for the list
  • Populate list

The issue is probably that it is either trying to find 6 platforms where there are not 6 platforms or something is funky in the library when all parameters are entered.

Upvotes: 0

Related Questions