title: Is it safe to set the elements of an unitialised array to 0 with CUBLAS / CUSPARSE operations?
body: <p>When e.g. accumulating the results of different matrix-vector-multiplications (which is what you do in BLAS even when there's only one accumulating element), one formally starts with a zero vector. But there is no overhead-free way to directly allocate an array of zeroes on CUDA device memory (or is there?), so the solution that jumps to mind is to simply take an array with arbitrary numbers and, instead of initializing it to 0, pass a value <code>beta = 0.</code> to the first call of <code>cublas&lt;t&gt;gemv</code> or <code>cusparse&lt;t&gt;csrmv</code>. After all, if it has that parameter "why not use it".</p>
  
  <p>Is this</p>
  
  <ul>
  <li>a good idea? Or is the case <em>β</em> = 1 optimised in such a way that gives overall better performance to initialize an array to 0 and then use a call <code>cusparseDcsrmv(..., 1., zeroes_array)</code>?</li>
  <li>safe? Naïvely, floating-points as representations of ℝ elements should fulfill <em>x</em> ⋅ 0 = 0 ∀ <em>x</em>, but this naïve treatment is of course often rather deadly when dealing with floating points. I'm quite sure it <em>is</em> safe when the array was previously used for some other operations with the same data type where the result was well-behaved, but is it also safe for an unititialised block of freshly allocated device memory?</li>
  </ul>
  
  <p>I'm mainly interested in the sparse case, since for dense matrices the <em>O</em>( <em>n</em>² ) complexity of the multiplication makes it unnecessary to reason too much about performance of the <em>O</em>( <em>n</em> ) allocation of the vector.</p>