title: "Out of memory on device" with cumsum on gpuArray
body: <p>I am attempting to perform a cumulative sum using MATLAB's cumsum function on 22000x22000 gpuArray filled with -1s,0s and 1s. I am using an NVIDIA GeForce GTX 780 Ti which has 3GB of memory. A double-precision gpuArray is too large (3.9GB) but naturally the single precision fits. </p>
  
  <p>Attempting to do a cumsum on my single-precision gpuArray again resulted in reaching my memory limit, but I am not sure if this is due to memory types or the approach to calculating cumsum as it is a MATLAB p-file. This also means regardless I have little control over the datatypes used for calculation. Edit: Also cumsum does not support integer datatypes. Edit: On further inspection the result of performing this on a reduced array is a single, so highly likely function operates on array as input type.</p>
  
  <p>So my question is: is there an alternative to cumsum? (not loops - see note) Whether through MATLAB or CUDA that allows specification of datatype. Or can someone outline how to vectorise (matricise?) the cumsum operation so I can write it myself?</p>
  
  <p>EDIT: Alternative must be able to operate on integer types as just producing the CUM matrix will exceed memory limit. 2xsingle = double...</p>
  
  <p>NOTE: Given I will be performing this computation a significant number of times (no bound presented in paper) I would ideally have the >200x speed increase of cumsum(gpuArray) vs cumsum(double). And don't even mention loops, ridiculously slow.</p>
  
  <pre class="lang-MATLAB prettyprint-override"><code>tic;CUM = cumsum(W,2);toc
  Elapsed time is 0.002180 seconds.
  
  K = gather(W);
  tic;CUM = cumsum(K,2);toc
  Elapsed time is 0.125203 seconds.
  </code></pre>