What numpy workload would yield the highest speed up when having MKL, OPENBLAS installed? MMM? QR? SVD? I have tried with MMM but I don't see a speed up, to the contrary it gets worse. My test code is as follows:
import numpy as np
import time
import gc
sizes = [2000, 20000]
samples = np.zeros(5)
for n in sizes:
# allocate outside the benchmark
X = np.random.normal(size=(n, n))
Y = X
for i in range(2):
Z = X @ Y
# run 5 times
for r in range(5):
start_time = time.process_time()
Z = X @ Y
samples[r] = time.process_time() - start_time
X = Y = Z = None
# remove unnecessary memory consumption
gc.collect()
print(np.mean(samples))
print(np.std(samples))
As I re-run this increasing the number of available threads (max cores in this box are 8) I see the response time increasing instead of decreasing.
Not taking any chances and so I change all these env variables each time (here to 1 but I change to 2, 4, 8):
export MKL_NUM_THREADS=1
export OMP_NUM_THREADS=1
export OPENBLAS_NUM_THREADS=1
export NUMEXPR_MAX_THREADS=1
export VECLIB_MAXIMUM_THREADS=1