+ Reply to Thread
Results 1 to 2 of 2

Thread: Multi threading & Numpy

Threaded View

  1. #1

    Multi threading & Numpy

    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:
    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
    Could someone tell me how I could multithread the numpy module?

    Kind regards!

  2. #2
    I am also working on this.

    My problem revolves around the mtrand.dll which gives a corrupted memory error, when I run a parallel ForEach wich System.Tasks.Parallel.

    Cheers.

+ Reply to Thread

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts