Note that there are some explanatory texts on larger screens.

plurals
  1. POOpenCL. Weird bug with array addressing/pointers
    primarykey
    data
    text
    <p>I have this simple kernel for testing.</p> <pre><code>__kernel void nfa(__global const int *a, __global int *output) { output[0] = a[0]; } </code></pre> <p>Note: This is running on a cpu, and memory is probably on the host. It results in this error.</p> <p><strong>* glibc detected <em></strong> ./program: malloc(): smallbin double linked list corrupted: 0x0000000000a4a540 *</em>*</p> <p>I suspect somehow this is corrupting a part of the program, since it's accessing host memory. But as far I know all memory allocated correctly. It is on the stack, but stays in scope while running.</p> <p>However if I do this:</p> <pre><code> __kernel void nfa(__global const int *a, __global int *output) { a = a; output[0] = a[0]; } </code></pre> <p>It results in the answer 2, which is correct since a is an array with [2, 4, 8];</p> <p>An allocation to its self fixed the issue...</p> <p>This is also fine, resulting in 4.</p> <pre><code> __kernel void nfa(__global const int *a, __global int *output) { output[0] = a[1]; } </code></pre> <p>It seems as though just accessing a[0], without assigning to its self causes the problem.</p> <p>Does anyone know what's going on?</p> <p>I'm on linux with AMD OpenCL Drivers(With an intel CPU, but I have a AMD Card).</p> <p>Edit:</p> <p>The code the buffer is created with(Condensed down, there is other code between the array and buffer):</p> <pre><code>int a[3]; a[0] = 2; a[1] = 4; a[2] = 8; cl::Buffer bufferA = cl::Buffer(context, CL_MEM_READ_ONLY | CL_MEM_USE_HOST_PTR , sizeof(int) * 3, &amp;a); </code></pre>
    singulars
    1. This table or related slice is empty.
    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.
 

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