<?xml version="1.0" encoding="UTF-8"?>
<rss xmlns:content="http://purl.org/rss/1.0/modules/content/" xmlns:dc="http://purl.org/dc/elements/1.1/" xmlns:rdf="http://www.w3.org/1999/02/22-rdf-syntax-ns#" xmlns:taxo="http://purl.org/rss/1.0/modules/taxonomy/" version="2.0">
  <channel>
    <title>topic clGetPlatformInfo 0xC0000005: Access violation in OpenCL* for CPU</title>
    <link>https://community.intel.com/t5/OpenCL-for-CPU/clGetPlatformInfo-0xC0000005-Access-violation/m-p/1119088#M5454</link>
    <description>&lt;P&gt;Hey guys, just starting with openCL, I am following a book called "OpenCL Parallel Programming Development Cookbook" to get started with OpenCL.&lt;/P&gt;

&lt;P&gt;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.&lt;/P&gt;

&lt;P&gt;I just installed the latest drivers for both the intel and amd gpus and installed the latest intel openCL sdk.&lt;/P&gt;

&lt;P&gt;so I get this error:&lt;BR /&gt;
	&lt;SPAN style="font-size: 1em; line-height: 1.5;"&gt;Unhandled exception at 0x5A423656 (OpenCL.dll) in TestOpenCLProject"T.exe: 0xC0000005: Access violation reading location 0xCCCCCCCC.&lt;BR /&gt;
	at this line:&lt;/SPAN&gt;&lt;BR /&gt;
	&amp;nbsp;&lt;/P&gt;

&lt;PRE class="brush:cpp;" style="font-size: 13.008px; line-height: 19.512px;"&gt;	error = clGetPlatformInfo(id, param_name, 0, NULL, &amp;amp;paramSize);&lt;/PRE&gt;

&lt;P&gt;&amp;nbsp;&lt;/P&gt;

&lt;P&gt;&lt;SPAN style="font-size: 1em; line-height: 1.5;"&gt;When I Run this code&lt;/SPAN&gt;&lt;/P&gt;

&lt;PRE class="brush:cpp;"&gt;...

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, &amp;amp;paramSize);
	
	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, &amp;amp;numOfPlatforms);
	if (error &amp;lt; 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 &amp;lt; numOfPlatforms; ++i)
	{
		displayPlatformInfo(platforms&lt;I&gt;, CL_PLATFORM_PROFILE, "CL_PLATFORM_PROFILE");
		displayPlatformInfo(platforms&lt;I&gt;, CL_PLATFORM_VERSION, "CL_PLATFORM_VERSION");
		displayPlatformInfo(platforms&lt;I&gt;, CL_PLATFORM_NAME, "CL_PLATFORM_NAME");
		displayPlatformInfo(platforms&lt;I&gt;, CL_PLATFORM_VENDOR, "CL_PLATFORM_VENDOR");
		displayPlatformInfo(platforms&lt;I&gt;, CL_PLATFORM_EXTENSIONS, "CL_PLATFORM_EXTENSIONS");
	}
	std::cout &amp;lt;&amp;lt; "\nPress Enter to Continue";
	std::cin.ignore();
	return 0;
}
&lt;/I&gt;&lt;/I&gt;&lt;/I&gt;&lt;/I&gt;&lt;/I&gt;&lt;/PRE&gt;

&lt;P&gt;&lt;SPAN style="font-size: 1em; line-height: 1.5;"&gt;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&lt;/SPAN&gt;&lt;/P&gt;

&lt;P&gt;&amp;nbsp;&lt;/P&gt;</description>
    <pubDate>Thu, 01 Sep 2016 05:24:38 GMT</pubDate>
    <dc:creator>Matthew_M_6</dc:creator>
    <dc:date>2016-09-01T05:24:38Z</dc:date>
    <item>
      <title>clGetPlatformInfo 0xC0000005: Access violation</title>
      <link>https://community.intel.com/t5/OpenCL-for-CPU/clGetPlatformInfo-0xC0000005-Access-violation/m-p/1119088#M5454</link>
      <description>&lt;P&gt;Hey guys, just starting with openCL, I am following a book called "OpenCL Parallel Programming Development Cookbook" to get started with OpenCL.&lt;/P&gt;

&lt;P&gt;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.&lt;/P&gt;

&lt;P&gt;I just installed the latest drivers for both the intel and amd gpus and installed the latest intel openCL sdk.&lt;/P&gt;

&lt;P&gt;so I get this error:&lt;BR /&gt;
	&lt;SPAN style="font-size: 1em; line-height: 1.5;"&gt;Unhandled exception at 0x5A423656 (OpenCL.dll) in TestOpenCLProject"T.exe: 0xC0000005: Access violation reading location 0xCCCCCCCC.&lt;BR /&gt;
	at this line:&lt;/SPAN&gt;&lt;BR /&gt;
	&amp;nbsp;&lt;/P&gt;

&lt;PRE class="brush:cpp;" style="font-size: 13.008px; line-height: 19.512px;"&gt;	error = clGetPlatformInfo(id, param_name, 0, NULL, &amp;amp;paramSize);&lt;/PRE&gt;

&lt;P&gt;&amp;nbsp;&lt;/P&gt;

&lt;P&gt;&lt;SPAN style="font-size: 1em; line-height: 1.5;"&gt;When I Run this code&lt;/SPAN&gt;&lt;/P&gt;

&lt;PRE class="brush:cpp;"&gt;...

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, &amp;amp;paramSize);
	
	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, &amp;amp;numOfPlatforms);
	if (error &amp;lt; 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 &amp;lt; numOfPlatforms; ++i)
	{
		displayPlatformInfo(platforms&lt;I&gt;, CL_PLATFORM_PROFILE, "CL_PLATFORM_PROFILE");
		displayPlatformInfo(platforms&lt;I&gt;, CL_PLATFORM_VERSION, "CL_PLATFORM_VERSION");
		displayPlatformInfo(platforms&lt;I&gt;, CL_PLATFORM_NAME, "CL_PLATFORM_NAME");
		displayPlatformInfo(platforms&lt;I&gt;, CL_PLATFORM_VENDOR, "CL_PLATFORM_VENDOR");
		displayPlatformInfo(platforms&lt;I&gt;, CL_PLATFORM_EXTENSIONS, "CL_PLATFORM_EXTENSIONS");
	}
	std::cout &amp;lt;&amp;lt; "\nPress Enter to Continue";
	std::cin.ignore();
	return 0;
}
&lt;/I&gt;&lt;/I&gt;&lt;/I&gt;&lt;/I&gt;&lt;/I&gt;&lt;/PRE&gt;

&lt;P&gt;&lt;SPAN style="font-size: 1em; line-height: 1.5;"&gt;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&lt;/SPAN&gt;&lt;/P&gt;

&lt;P&gt;&amp;nbsp;&lt;/P&gt;</description>
      <pubDate>Thu, 01 Sep 2016 05:24:38 GMT</pubDate>
      <guid>https://community.intel.com/t5/OpenCL-for-CPU/clGetPlatformInfo-0xC0000005-Access-violation/m-p/1119088#M5454</guid>
      <dc:creator>Matthew_M_6</dc:creator>
      <dc:date>2016-09-01T05:24:38Z</dc:date>
    </item>
    <item>
      <title>I apologise for the double</title>
      <link>https://community.intel.com/t5/OpenCL-for-CPU/clGetPlatformInfo-0xC0000005-Access-violation/m-p/1119089#M5455</link>
      <description>&lt;P&gt;I apologise for the double post, I cant edit the OP cause im not authorized.&lt;/P&gt;

&lt;P&gt;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.&amp;nbsp;&lt;/P&gt;</description>
      <pubDate>Thu, 01 Sep 2016 05:36:37 GMT</pubDate>
      <guid>https://community.intel.com/t5/OpenCL-for-CPU/clGetPlatformInfo-0xC0000005-Access-violation/m-p/1119089#M5455</guid>
      <dc:creator>Matthew_M_6</dc:creator>
      <dc:date>2016-09-01T05:36:37Z</dc:date>
    </item>
    <item>
      <title>Found the solution.</title>
      <link>https://community.intel.com/t5/OpenCL-for-CPU/clGetPlatformInfo-0xC0000005-Access-violation/m-p/1119090#M5456</link>
      <description>&lt;P&gt;Found the solution.&lt;BR /&gt;
	Adding this to line 34:&lt;/P&gt;

&lt;PRE class="brush:cpp;"&gt;clGetPlatformIDs(numOfPlatforms, platforms, NULL);&lt;/PRE&gt;

&lt;P&gt;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.&lt;/P&gt;

&lt;P&gt;Anyone know if its correct in C without the extra line and if so why?&lt;/P&gt;</description>
      <pubDate>Thu, 01 Sep 2016 23:16:38 GMT</pubDate>
      <guid>https://community.intel.com/t5/OpenCL-for-CPU/clGetPlatformInfo-0xC0000005-Access-violation/m-p/1119090#M5456</guid>
      <dc:creator>Matthew_M_6</dc:creator>
      <dc:date>2016-09-01T23:16:38Z</dc:date>
    </item>
    <item>
      <title>Very glad you were able to</title>
      <link>https://community.intel.com/t5/OpenCL-for-CPU/clGetPlatformInfo-0xC0000005-Access-violation/m-p/1119091#M5457</link>
      <description>&lt;P&gt;Very glad you were able to find a way to get started.&amp;nbsp; As a "hello world" to double check that everything is installed correctly I usually start with the "platform/device capabilities viewer sample" from &lt;A href="https://software.intel.com/en-us/intel-opencl-support/code-samples"&gt;https://software.intel.com/en-us/intel-opencl-support/code-samples&lt;/A&gt;, which looks close to what you're trying here.&amp;nbsp; There are a lot of great starting points on that page known to work with Intel(R) SDK for OpenCL(TM) Applications.&lt;/P&gt;

&lt;P&gt;You've probably already explored this, but the basic pattern used by many of the OpenCL init functions is to call them twice.&amp;nbsp; 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.&amp;nbsp; If you are OK with always allocating a constant size bigger than you'll need&amp;nbsp;you can skip the "get the size" step and go directly to filling in the data.&lt;/P&gt;

&lt;P&gt;&amp;nbsp;&lt;/P&gt;</description>
      <pubDate>Sat, 10 Sep 2016 01:24:09 GMT</pubDate>
      <guid>https://community.intel.com/t5/OpenCL-for-CPU/clGetPlatformInfo-0xC0000005-Access-violation/m-p/1119091#M5457</guid>
      <dc:creator>Jeffrey_M_Intel1</dc:creator>
      <dc:date>2016-09-10T01:24:09Z</dc:date>
    </item>
  </channel>
</rss>

