Last active
February 25, 2022 22:08
-
-
Save jaberg/6251351 to your computer and use it in GitHub Desktop.
Measure GEMM speed via numpy.dot
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#!/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