Using different decorators together on GPUs

8 views
Skip to first unread message

Jeffrey Layton

unread,
May 6, 2020, 3:43:41 PM5/6/20
to Numba...@continuum.io
Good afternoon,

Is it possible to use @cuda.jit on one function but have it call another function created with @vectorized? A quick and ugly example is below.

@cuda.jit
def Add(a, b, c, cv):
    max_length = len(a)
    for i in range(0, max_length):
        c[i] = a[i] + b[i]
    # end for
   
    cv = Addv(c, a)
# end def


@vectorize(['float32(float32, float32)'], target='cuda')
def Addv(a, b):
    return a + b
# end def

Thanks!

Jeff

Stanley Seibert

unread,
May 6, 2020, 6:01:49 PM5/6/20
to Numba Public Discussion - Public
We haven't enabled this because both the CUDA kernel and the vectorize decorator are implicitly running the function across many threads, and it isn't clear how the threads from one call should map onto the other call.  Should each thread in the kernel run the vectorize serially?  Should all the threads on the device cooperate to run the thread together?  (That in itself is tricky since CUDA generally discourages synchronization of an entire grid.)

You can call cuda device functions (cuda.jit(device=True)) from both CUDA kernels and vectorize functions, so that is a nice way to share common code.

--
You received this message because you are subscribed to the Google Groups "Numba Public Discussion - Public" group.
To unsubscribe from this group and stop receiving emails from it, send an email to numba-users...@continuum.io.
To view this discussion on the web visit https://groups.google.com/a/continuum.io/d/msgid/numba-users/CAJfzO5RXt7RMkNiiYLE6MbfUdHhz97UZOYCO%2Bt0M%2BpZGCTB6ow%40mail.gmail.com.
Reply all
Reply to author
Forward
0 new messages