I`m working on a project where I want to do analysis,
but the analysis is quite intense and would like to exploit all my CPU`s.
I looked into multi threading, first option was (IMHO) the map function of python.
But that function seems not to exploit all my CPUs..![]()
So I found the following post: http://python.rhino3d.com/entries/60...hreaded-Python
Multi threading works great with that script UNTIL I use an numpy object.
Example:
Could someone tell me how I could multithread the numpy module?Code:##nessecary lines for Rhino&Scipy/Numpy import clr clr.AddReference("mtrand") #Import and set Rhino import numpy as np #Get the bridge to Rhino import rhinoscriptsyntax as rs import Rhino import System.Drawing import scriptcontext import System.Threading.Tasks as tasks import time big = 1000 A = np.array( [[1,1,1],[1,1,1],[1,1,1]] ) print "Test map function" def function(value): temp = value for i in range(big): temp = temp + value B = np.dot(A,A) start = time.time() for i in range(big): function(i) print time.time() - start start = time.time() map(function, range(big)) print time.time() - start start = time.time() tasks.Parallel.ForEach(range(big), function) print time.time() - start
Kind regards!


Reply With Quote