Skip to content

Instantly share code, notes, and snippets.

@jaberg
Last active February 25, 2022 22:08
Show Gist options
  • Save jaberg/6251351 to your computer and use it in GitHub Desktop.
Save jaberg/6251351 to your computer and use it in GitHub Desktop.
Measure GEMM speed via numpy.dot
#!/bin/python
import sys
import time
import numpy as np
N = int(sys.argv[1])
dtype = sys.argv[2]
A = np.random.rand(N, N).astype(dtype)
B = np.random.rand(N, N).astype(dtype)
t0 = time.time()
reps = 5
for ii in range(reps):
C = np.dot(A, B)
t1 = time.time()
FLOPS = reps * 2 * N ** 3
print 'GFLOP/s', FLOPS / (1000 ** 3) / (t1 - t0)
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment