Thank you, this is helpful.

On Wednesday, June 17, 2015 at 8:01:56 AM UTC-4, Lyndon White wrote:
>
> As a convention, one should not normally call `map` with a function that 
> mutates it's inputs,
> Map comes from the world of functional programming, so assumes to run on 
> pure functions  (ie those without side-effects -- such as changing the 
> inputs).
> Now in the julia implementation of map, it is basically a forloop so 
> nonput functions work fine.
>
> The implementation of pmap on the other hand is not a forloop.
> copys chunks of the input vector to other processes,
> and then asks each section to call the function on these copies, and 
> return a vector of the functions return results.
>
> So the copies are modified and then discared on each process.
> The function will return `a,a+b*c`
>
> ---
>
> On Tuesday, 16 June 2015 22:49:10 UTC+8, Chris wrote:
>>
>> Hello,
>>
>> I am having some issues using pmap(). I constructed a basic example that 
>> illustrates the problem I'm seeing:
>>
>> *in "partest.jl":*
>> module MyMod
>>     type mytype
>>         a::Float64
>>         b::Int64
>>         c::Float64
>>     end
>>
>>     function myfun!(a,b,c)
>>         a.a += b*c
>>     end
>>
>>     function mywrapper!(s)
>>         pmap( x->myfun!(x,1.,1.), s )
>>     end
>> end
>>
>> *In the Julia REPL:*
>> include("partest.jl")
>> addprocs(4)
>> @everywhere using MyMod
>> v = [MyMod.mytype(randn(i)[1],i,0.) for i = 1:1000];
>> MyMod.mywrapper!(v);
>>
>> I expect the elements of v to be changed according to the operation in 
>> myfun!, but they are not. What am I doing wrong here?
>>
>> Thanks,
>> Chris
>>
>

Reply via email to