Commit fb8d158f authored by Martin Reinecke's avatar Martin Reinecke

add mkl_fft benchmark; use 'nice' array dimensions by default

parent 33fc9ec3
......@@ -88,11 +88,27 @@ def measure_numpy_fft(a, nrepeat, nthr):
return tmin, b
def bench_nd(ndim, nmax, nthr, ntry, tp, funcs, nrepeat, ttl="", filename=""):
def measure_mkl_fft(a, nrepeat, nthr):
import os
os.environ['OMP_NUM_THREADS'] = str(nthr)
import mkl_fft
tmin = 1e38
for i in range(nrepeat):
t0 = time()
b = mkl_fft.fftn(a)
t1 = time()
tmin = min(tmin, t1-t0)
return tmin, b
def bench_nd(ndim, nmax, nthr, ntry, tp, funcs, nrepeat, ttl="", filename="",
nice_sizes=True):
print("{}D, type {}, max extent is {}:".format(ndim, tp, nmax))
results = [[] for i in range(len(funcs))]
for n in range(ntry):
shp = np.random.randint(nmax//3, nmax+1, ndim)
if nice_sizes:
shp = np.array([pypocketfft.good_size(sz) for sz in shp])
print(" {0:4d}/{1}: shape={2} ...".format(n, ntry, shp), end=" ", flush=True)
a = (np.random.rand(*shp)-0.5 + 1j*(np.random.rand(*shp)-0.5)).astype(tp)
output=[]
......@@ -115,9 +131,10 @@ def bench_nd(ndim, nmax, nthr, ntry, tp, funcs, nrepeat, ttl="", filename=""):
funcs = (measure_pypocketfft, measure_fftw)
ttl = "pypocketfft/FFTW()"
nthr = 1
bench_nd(1, 8192, nthr, 100, "c16", funcs, 10, ttl, "1d.png")
bench_nd(2, 2048, nthr, 100, "c16", funcs, 2, ttl, "2d.png")
bench_nd(3, 256, nthr, 100, "c16", funcs, 2, ttl, "3d.png")
bench_nd(1, 8192, nthr, 100, "c8", funcs, 10, ttl, "1d_single.png")
bench_nd(2, 2048, nthr, 100, "c8", funcs, 2, ttl, "2d_single.png")
bench_nd(3, 256, nthr, 100, "c8", funcs, 2, ttl, "3d_single.png")
nice_sizes = True
bench_nd(1, 8192, nthr, 100, "c16", funcs, 10, ttl, "1d.png", nice_sizes)
bench_nd(2, 2048, nthr, 100, "c16", funcs, 2, ttl, "2d.png", nice_sizes)
bench_nd(3, 256, nthr, 100, "c16", funcs, 2, ttl, "3d.png", nice_sizes)
bench_nd(1, 8192, nthr, 100, "c8", funcs, 10, ttl, "1d_single.png", nice_sizes)
bench_nd(2, 2048, nthr, 100, "c8", funcs, 2, ttl, "2d_single.png", nice_sizes)
bench_nd(3, 256, nthr, 100, "c8", funcs, 2, ttl, "3d_single.png", nice_sizes)
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment