I am writing a macro in Julia that can split a certain function between many processors. I have the following:
macro parallel_calc(N::Int,proc::Int=4)
n=round(Int,N/proc);
proc_sum = @parallel (+) for i=1:proc
f(n)
end
return proc_sum / proc
end
The problem is I want to write the macro so that
@parallel_calc f(n)
And then it will be able to automatically split the job between my processors. Is there any way in Julia to write a macro that takes a function as its input? I've tried looking online, but I haven't found anything that could help. I've also tried using
@everywhere f(n)
After adding my processors, but it runs significantly slower than the macro defined above. I need to define a new macro that splits the computation load equally (or almost equally) between my different processors.