Hello, 

On Thursday, December 19, 2013 4:50:00 PM UTC+1, Jiahao Chen wrote:
>
> Hi all,
>
> What is the recommended way to implement the equivalent of OpenMP sections 
> in Julia?
>
 

> Use case: I have code that calculates left and right vectors of a matrix. 
> They are computed completely independently until some point later in the 
> code where I take their mutual dot products:
>
> rl = A'*vl-b
> #do more stuff to rl and vl
> rr = A*vr-b
> #do more stuff to rr and vr
> w = dot(vl,vr)
>
>  In OpenMP, I would be able to wrap the code that computes the left and 
> right vectors in separate omp sections (up to and excluding the line that 
> computes w). What would be the equivalent construct in Julia? 
>
> Not at all familiar with OpenMP, I gather from the example that an omp 
section is an execution thread that is independent of the rest of the code. 
Assuming you have >2 procs (either with `julia -p 2` invocation or 
`addprocs(2)` within julia), I think the idea would be

ref1 = remotecall(2, rlstuff, rl)
ref2 = remotecall(3, rrstuff, rr)
dot(fetch(ref1), fetch(r2))

where you have the "#do more stuff" stuff in functions `rlstuff(x::Vector)` 
and `rrstuff(x::Vector)`.  The sub-processes must be aware of these 
functions, so if these functions are in a file "rstuff.jl" you need to 
issue a

require("rstuff.jl")


beforehand.  

I hope this is what you meant, however, I cannot tell if this is the 
recommended way. 

Cheers, 

---david 
 

Reply via email to