Note that there are some explanatory texts on larger screens.

plurals
  1. POclGetProgramInfo CL_PROGRAM_BINARY_SIZES Incorrect Results?
    primarykey
    data
    text
    <p>I am trying to cache a program in a file so that it does not need to compile to assembly. Consequently, I am trying to dump the binaries. I am getting an issue where the binary program returned alternately has garbage data at the end.</p> <p>Error checking omitted for clarity (no errors occur, though):</p> <pre><code>clGetProgramInfo(kernel-&gt;program, CL_PROGRAM_BINARY_SIZES, 0,NULL, &amp;n); n /= sizeof(size_t); size_t* sizes = new size_t[n]; clGetProgramInfo(kernel-&gt;program, CL_PROGRAM_BINARY_SIZES, n*sizeof(size_t),sizes, NULL); </code></pre> <p>I have confirmed that kernel->program is identical between times. In the above code, "n" is invariably 1, but sizes[0] varies between 2296 and 2312 alternate runs. </p> <p>The problem is that the 2296 number appears to be more accurate--after the final closing brace in the output, there are three newlines and then three spaces.</p> <p>For the 2312 number, after the final closing brace in the output, there are the three newlines, a line of garbage data, and then the three spaces.</p> <p>Naturally, the line of garbage data is problematic. I'm not sure how to get rid of it, and I'm pretty sure it's not an error on my part.</p> <p>NVIDIA GeForce GTX 580M, with driver 305.60 on Windows 7.</p> <p><strong>Update:</strong> I have changed the code to the following:</p> <pre><code>//Get how many devices there are size_t n; clGetProgramInfo(kernel-&gt;program, CL_PROGRAM_NUM_DEVICES, 0,NULL, &amp;n); //Get the list of binary sizes size_t* sizes = new size_t[n]; clGetProgramInfo(kernel-&gt;program, CL_PROGRAM_BINARY_SIZES, n*sizeof(size_t),sizes, NULL); //Get the binaries unsigned char** binaries = new unsigned char*[n]; for (int i=0;i&lt;(int)n;++i) { binaries[i] = new unsigned char[sizes[i]]; } clGetProgramInfo(kernel-&gt;program, CL_PROGRAM_BINARIES, n*sizeof(unsigned char*),binaries, NULL); </code></pre> <p>Now, the code has n = 4, but only sizes[0] contains meaningful information (so the alloc of sizes[1] fails in the loop). Thoughts?</p>
    singulars
    1. This table or related slice is empty.
    plurals
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. This table or related slice is empty.
 

Querying!

 
Guidance

SQuiL has stopped working due to an internal error.

If you are curious you may find further information in the browser console, which is accessible through the devtools (F12).

Reload