title: OpenCL - clCreateBuffer size error. Possible work arounds?
body: <p>After investigating the reason why my program was crashing, I found that I was hitting the maximum for a buffer size, which is 512Mb for me <code>(CL_DEVICE_MAX_MEM_ALLOC_SIZE)</code>.</p>
  
  <p>In my case, here are the parameters.</p>
  
  <pre><code>P = 146 (interpolation factor)
  num_items = 918144 (number of samples)
  sizeof(float) -&gt; 4
  </code></pre>
  
  <p>So my clCreateBuffer looks something like this:</p>
  
  <pre><code>output = clCreateBuffer(
          context,
          CL_MEM_READ_ONLY,
          num_items * P * sizeof(float),
          NULL,
          &amp;status);
  </code></pre>
  
  <p>When the above is multiplied together and divided by (1024x1024), you get around 511Mb which is under the threshold. Change any of the parameters to one higher now and it crashes because it will exceed that 512 value.</p>
  
  <p>My questions is, <strong>how can I implement the code in a way where I can use block sizes to do my calculations instead of storing everything in memory and passing that massive chunk of data to the kernel?</strong> In reality, the number of samples I have could easily vary to <strong>over 5 million</strong> and I <strong>definitely</strong> will not have enough memory to store all those values. </p>
  
  <p>I'm just not sure how to pass small sets of values into my kernel as I have three steps that the values go though before getting an output.</p>
  
  <p>First is an interpolation kernel, then the values go to a lowpass filter kernel and then to a kernel that does decimation. After that the values are written to an output array. If further details of the program are needed for the sake of the problem I can add more.</p>
  
  <p><strong>UPDATE</strong>
  Not sure what the expected answer is here, if anyone has a reason I would love to hear it and potentially accept it as the valid answer. I don't work with OpenCL anymore so i don't have the setup to verify.</p>