Hi Julio,

I believe this is a very common type of workload, especially in scientific 
computing.
In C++ one can use OpenMP for this type of computation, in Matlab there is 
parfor.  From the users perspective both "just work".

In Julia, I have not found an easy and convenient way to do such 
computation.
The difficulties I have experienced, trying to do this with distributed 
arrays and the Julia parallel operations:

1. Having to prepend @parallel before every import/require so that all 
parallel processes have all definitions.
2. Working with the distributed arrays API has given me plenty of 
headaches; it is more like programming with local/global contexts in OpenCL.
3. (I believe this is fixed now.) There were garbage collection issues and 
crashes on Windows when using distributed arrays.

What would be very convenient is a type of OpenMP like parallelism, really 
anything that can enable us to write simply

function compute(X::Vector{Float64}, theta)
    n = length(X)
    A = zeros(Float64, n)
    @smp for i=1:n
        A[i] = embarassing_parallel(X[i], theta);
    end
    A
end

Where @smp would correspond to "#pragma omp parallel for".
I know this may be difficult to implement for a language as dynamic as 
Julia, but it is hard to argue against this simplicity from the users' 
point of view.

As Clang/LLVM now support OpenMP (https://clang-omp.github.io/), one 
perhaps can recycle the same OpenMP runtime for such lightweight 
parallelism?

Thanks,
Sebastian


On Wednesday, 19 August 2015 19:03:59 UTC+1, Júlio Hoffimann wrote:
>
> Hi Kristoffer, sorry for the delay and thanks for the code.
>
> What I want to do is very simple: I have an expensive loop for i=1:N such 
> that each iteration is independent and produces a large array of size M. 
> The result of this loop is a matrix of size MxN. I have many CPU cores at 
> my disposal and want to distribute this work.
>
> In the past I accomplished that with MPI in Python: 
> https://github.com/juliohm/HUM/blob/master/pyhum/utils.py Whenever a 
> process in the pool is free it "consumes" an iteration of the loop. What 
> exactly the @parallel macro in Julia is doing? How can I modify the code I 
> previously posted in this thread to achieve such effect?
>
> -Júlio
>

Reply via email to