title: Numbapro: No speed-up for Matrix Multiplication
body: <p>For last couple of days I've been trying to understand why Numbapro (Accelerate from Continuum Analytics, Inc.; I'm running a 30day trial version) does not accelerate on my MacBook Pro (Intel Core i7, 2.6GHz, 16GB RAM with NVIDIA GeForce GT 650M, 1GB on PCI bus). </p>
  
  <p>I took one of the examples from the codes for (NxM)x(MxN) matrix multiplication where Continuum Analytics, Inc. claims acceleration of computation via CUDA and I compared the times between CUDA.JIT and numpy. My idea is to run e.g 1e4 <em>iterations</em> and matrix B is randomised every iteration. Below the following code I used, I quote times I obtained. Is there any solution for that? Thanks!</p>
  
  <pre><code>from numbapro import *
  from numba import *
  import numpy as np
  import math
  from timeit import default_timer as timer
  
  m=1000
  n=1000
  A = np.array(np.random.random((n,m)), dtype=np.float32)
  C = np.empty([n,n])
  
  iterations = 10000
  
  start = timer()
  for i in range(iterations):
      B = np.array(np.random.random((m,n)), dtype=np.float32)
      X=np.dot(A,B)
  numpy_time=(timer() - start)
  
  @cuda.jit(void(float32[:,:],float32[:,:],float32[:,:]))
  def cu_square_matrix_mul(A, B, C):
  
      tx = cuda.threadIdx.x
      ty = cuda.threadIdx.y
      bx = cuda.blockIdx.x
      by = cuda.blockIdx.y
      bw = cuda.blockDim.x
      bh = cuda.blockDim.y
      x = tx + bx * bw
      y = ty + by * bh
      n = C.shape[0]
  
      if x &gt;= n or y &gt;= n:
          return
  
      cs = 0
      for i in range(n):
          cs += A[y,i]*B[i,x]
      C[y,x]= cs
  
      cuda.syncthreads()
  
  blockdim = 256,3
  griddim = 10,3
  
  stream = cuda.stream()
  dA = cuda.to_device(A, stream)
  dC = cuda.to_device(C, stream)
  
  start = timer()    
  for i in range(iterations):
      B = np.array(np.random.random((m,n)), dtype=np.float32)
      dB = cuda.to_device(B, stream)
      cu_square_matrix_mul[griddim,blockdim,stream](dA, dB, dC) 
      dC.to_host()
      stream.synchronize()
  cuda_time = (timer() - start)    
  
  print
  print("Numpy took    %f seconds" % numpy_time)
  print("CUDA JIT took %f seconds, %.5fx speedup" % (cuda_time, numpy_time / cuda_time))
  </code></pre>
  
  <p>results in:</p>
  
  <pre><code>Vendor:  Continuum Analytics, Inc.
  Package: mkl
  Message: trial mode expires in 30 days
  Vendor:  Continuum Analytics, Inc.
  Package: mkl
  Message: trial mode expires in 30 days
  Vendor:  Continuum Analytics, Inc.
  Package: numbapro
  Message: trial mode expires in 30 days
  
  Numpy took    378.328881 seconds
  CUDA JIT took 342.723757 seconds, 1.10389x speedup
  </code></pre>