On Feb 8, 2008 10:38 PM, Michael van der Gulik <mikevdg@gmail.com> wrote:




go
    | anArray numProcesses step |
    anArray := Array new: 60000. "Assume an even larger number for realistic examples"
    numProcesses := 32.   
    step := anArray size // numProcesses.
    1 to: anArray size by: step do: [ :i |
        [   
            i to: (i+numProcesses-1) do: [ :j |
                anArray at: j put: j ]
        ] fixTemps fork.
    ].
    ^ anArray.

However, it doesn't work except for small numbers. I'd be happy if somebody would be able to provide a fixed version; I can't work it out.



That was a really obvious, stupid bug. Try again:

    anArray := Array new: 3200000.
    numProcesses := 64.  
    step := anArray size // numProcesses.
    1 to: anArray size by: step do: [ :i |
        [  
            i to: i+step-1 do: [ :j |
                anArray at: j put: j ]
        ] fixTemps fork.
    ].


Gulik.

--
http://people.squeakfoundation.org/person/mikevdg
http://gulik.pbwiki.com/