3D rotation with CUDA

0 views
Skip to first unread message

Bushra Nazir

unread,
Mar 13, 2018, 9:29:01 AM3/13/18
to Numba Public Discussion - Public
I am implementing protein docking. Since it takes quite a long time, I want to switch to CUDA. For a particular set of euler angles(psi,theta,phi), the code runs independently. Earlier I used multiprocessing modules of python to run the code parallel for every set of angles.
1.How to implement the same using CUDA?
2.Can I distribute my calculations among threads so that each thread gives me an independent result?

I have 1024 threads per block.
Being new to cuda, I need some guidance with the approach.

    1. for psi in range(0,360,15):
      for theta in range(0,180,15):
      for phi in range(0,360,15):
      dataset.append([psi, theta, phi])



      main_program
      ( ith element of dataset i.e [psi,theta,phi] ) {
      run program
      give output
      }



    Thanks in advance.

    Chris Uchytil

    unread,
    Mar 13, 2018, 2:11:32 PM3/13/18
    to numba...@continuum.io
    Something along these lines. I am using the thread indices as the angle values. I didn't actually run this code so there might be bugs in it.

    #Change the return statement to the function you want computed
    @cuda.jit(device = True)
    def func(psi, thetam, phi):
    return psi*thetam*phi

    @cuda.jit
    def kernel(d_out):
    i,j,k = cuda.grid(3)
    x,y,z = d_out.shape
    if i < x and j < y and k < z:
    psi = i*15
    theta = j*15
    phi = k*15
    d_out[i,j,k] = func(psi, theta, phi)
    360//15 = psi_incitements
    180//15 = theta_incitements
    360//15 = phi_incitements

    d_out = cuda.device_array((psi_incitements,
       theta_incitements,
       phi_incitements),dtype = np.float32)

    TPB = 32
    gridDim = ((psi_incitements + TPB - 1)//TPB,
       (theta_incitements + TPB - 1)//TPB,
       (phi_incitements + TPB - 1)//TPB)
    blockDim = (TPB,
    TPB,
    TPB)

    kernel[gridDim, blockDim](d_out)
    out = d_out.copy_to_host()

    --
    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+unsubscribe@continuum.io.
    To post to this group, send email to numba...@continuum.io.
    To view this discussion on the web visit https://groups.google.com/a/continuum.io/d/msgid/numba-users/20bac9dd-3771-401e-a6c1-51871616dd50%40continuum.io.
    For more options, visit https://groups.google.com/a/continuum.io/d/optout.

    Reply all
    Reply to author
    Forward
    0 new messages