3 ms·
Would have been nice to see CPU and GPU benchmark scores alongside. I get 1.5mil iterations in numpy on CPU which is on par with typed arrays and much slower t
by visarga 5y ago
Would have been nice to see CPU and GPU benchmark scores alongside.
I get 1.5mil iterations in numpy on CPU which is on par with typed arrays and much slower than wasmblr.
- brrrrrm 5y agoI believe numpy is bounded by Python's interpreter (which runs at about ~1us per dispatch to C function from what I recall while working on PyTorch). The number you get is definitely what I'd expect. If you use larger arrays (and use the "out" variant: `numpy.add(a, b, out=c)`), you might get similar total throughput at least. import numpy as np N = 1024 * 128 A = np.random.randn(N) B = np.random.randn(N) C = np.random.randn(N) import time for _ in range(1000): np.add(A, B, out=C) iters = 1000 t = time.time() for _ in range(iters): np.add(A, B, out=C) d = time.time() - t print(f"{iters * N * 3 * 4 / d / 1e9:.2f} GB/s")