Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- import os,sys
- import numpy as np
- import time
- #example for multithread numpy/scipy using Intel MKL:
- #acture it's amazingly easy by setting the following:
- #os.environ['MKL_NUM_THREADS']="8"
- def demo_eig(n):
- a=np.random.rand(n,n)
- a=a+a.transpose()-np.diag(np.diag(a))
- w,v=np.linalg.eigh(a)
- return
- def demo_num_thread():
- res=0.0
- for i in range(10):
- t=time.time()
- demo_eig(2000)
- res+=time.time()-t
- print("%s core: %f"%(os.environ['MKL_NUM_THREADS'],res))
- return
- os.environ['MKL_NUM_THREADS']=sys.argv[1]
- demo_num_thread()
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement