Skip to content

Instantly share code, notes, and snippets.

@andersonfreitas
Created November 11, 2016 17:48
Show Gist options
  • Save andersonfreitas/5ba03afa42c77b48209e94dee24c36cf to your computer and use it in GitHub Desktop.
Save andersonfreitas/5ba03afa42c77b48209e94dee24c36cf to your computer and use it in GitHub Desktop.
import numpy as np
import time
N = 6000
M = 10000
k_list = [64, 80, 96, 104, 112, 120, 128, 144, 160, 176, 192, 200, 208, 224, 240, 256, 384]
def get_gflops(M, N, K):
return M*N*(2.0*K-1.0) / 1000**3
np.show_config()
for K in k_list:
a = np.array(np.random.random((M, N)), dtype=np.double, order='C', copy=False)
b = np.array(np.random.random((N, K)), dtype=np.double, order='C', copy=False)
A = np.matrix(a, dtype=np.double, copy=False)
B = np.matrix(b, dtype=np.double, copy=False)
C = A*B
start = time.time()
C = A*B
C = A*B
C = A*B
C = A*B
C = A*B
end = time.time()
tm = (end-start) / 5.0
print ('{0:4}, {1:9.7}, {2:9.7}'.format(K, tm, get_gflops(M, N, K) / tm))
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment