- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
Hey guys, just starting with openCL, I am following a book called "OpenCL Parallel Programming Development Cookbook" to get started with OpenCL.
I am using Visual C++ (because thats all I have on me, I might try spin up a linux box later when I have some more time) on Visual Studio 2015, windows 10 64bit.
I just installed the latest drivers for both the intel and amd gpus and installed the latest intel openCL sdk.
so I get this error:
Unhandled exception at 0x5A423656 (OpenCL.dll) in TestOpenCLProject"T.exe: 0xC0000005: Access violation reading location 0xCCCCCCCC.
at this line:
error = clGetPlatformInfo(id, param_name, 0, NULL, ¶mSize);
When I Run this code
... void displayPlatformInfo(cl_platform_id id, cl_platform_info param_name, const char* paramNameAsStr) { cl_int error = 0; size_t paramSize = 0; error = clGetPlatformInfo(id, param_name, 0, NULL, ¶mSize); char* moreInfo = (char*)alloca(sizeof(char) * paramSize); error = clGetPlatformInfo(id, param_name, paramSize, moreInfo, NULL); if (error != CL_SUCCESS) { perror("Unable to find any OpenCl platform information"); return; } printf("%s: %s\n", paramNameAsStr, moreInfo); } int main(void) { /* OpenCL 1.2 data structures */ cl_platform_id* platforms; /* OpenCl 1.1 scalar data types */ cl_uint numOfPlatforms; cl_int error; ... error = clGetPlatformIDs(0, NULL, &numOfPlatforms); if (error < 0) { perror("Unable to find any OpenCl platofrms"); exit(1); } ... platforms = (cl_platform_id*)alloca(sizeof(cl_platform_id) * numOfPlatforms); printf("Number of OpenCL platforms found: %d\n", numOfPlatforms); ... for (cl_uint i = 0; i < numOfPlatforms; ++i) { displayPlatformInfo(platforms, CL_PLATFORM_PROFILE, "CL_PLATFORM_PROFILE"); displayPlatformInfo(platforms, CL_PLATFORM_VERSION, "CL_PLATFORM_VERSION"); displayPlatformInfo(platforms, CL_PLATFORM_NAME, "CL_PLATFORM_NAME"); displayPlatformInfo(platforms, CL_PLATFORM_VENDOR, "CL_PLATFORM_VENDOR"); displayPlatformInfo(platforms, CL_PLATFORM_EXTENSIONS, "CL_PLATFORM_EXTENSIONS"); } std::cout << "\nPress Enter to Continue"; std::cin.ignore(); return 0; }
Im not particularly adept with c++ and the book seems to be writing for C so that may be where the error lies but if anyone can help me that would be great
Link Copied
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
I apologise for the double post, I cant edit the OP cause im not authorized.
Aapparently the intel drivers did not install because it could not find any intel GPU despite this being an i7-3740qm which is supposed to have an hd-4000 gpu.
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
Found the solution.
Adding this to line 34:
clGetPlatformIDs(numOfPlatforms, platforms, NULL);
platforms was not initalized(?) correctly i.e. there was no data in it.. its odd that the book omitted this step surely you need to do this in C too.
Anyone know if its correct in C without the extra line and if so why?
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
Very glad you were able to find a way to get started. As a "hello world" to double check that everything is installed correctly I usually start with the "platform/device capabilities viewer sample" from https://software.intel.com/en-us/intel-opencl-support/code-samples, which looks close to what you're trying here. There are a lot of great starting points on that page known to work with Intel(R) SDK for OpenCL(TM) Applications.
You've probably already explored this, but the basic pattern used by many of the OpenCL init functions is to call them twice. The first time fills in the size of the array you will need (the 3rd parameter, which you set to null) so you can allocate an array of the right size. If you are OK with always allocating a constant size bigger than you'll need you can skip the "get the size" step and go directly to filling in the data.
- Subscribe to RSS Feed
- Mark Topic as New
- Mark Topic as Read
- Float this Topic for Current User
- Bookmark
- Subscribe
- Printer Friendly Page