title: Sum arrays with Numba and CUDA
body: <p>I have just started learning how to program with Numba and CUDA, so this code may be very wrong, but I don't understand why it's not working. I am trying to sum N different arrays, whose content depends on another array. Showing the code is maybe better than this explanation:</p>
  <pre class="lang-py prettyprint-override"><code>import numba as nb
  from numba import cuda
  import numpy as np
  from math import exp, ceil
  
  t0s = np.array([2.5,6.7,8.1,9.6,10.5])
  threadsperblock = 32
  blockspergrid = ceil(t0s.shape[0] / threadsperblock)
  
  time = np.linspace(0,10,2000)
  waveform = np.zeros_like(time)
  total_waveform = np.zeros_like(waveform)
  
  @cuda.jit(device=True)
  def current(waveform, time, t0):
      for i in range(waveform.shape[0]):
          if time[i] &gt; t0:
              waveform[i] = 0
          else:
              waveform[i] = exp(time[i]-t0)
  
  @cuda.jit
  def total(time, waveform, total_waveform, t0s):
      i = cuda.grid(1)
      if i &lt; t0s.shape[0]:
          current(waveform, time, t0s[i]) 
          for j in range(total_waveform.shape[0]):
              total_waveform[j] += waveform[j]
  
  total[blockspergrid, threadsperblock](time, waveform, total_waveform, t0s)
  </code></pre>
  <p>Unfortunately, <code>total_waveform</code> contains just the first waveform (it's like it stops after the first element of <code>t0s</code>) and I really don't understand why. Help! :)</p>