Parallel
Ipaper.par_map
— Functionpar_map(f, A, args...; kw...)
Examples
function f(x)
sleep(0.1)
x
end
# get_clusters()
@time par_map(f, 1:10)
@time map(f, 1:10)
Ipaper.par_mapslices
— Functionpar_mapslices(f, A::AbstractArray{<:Real,N}, args...; dims=N, kw...)
Arguments
dims
: the dimension apply f
@seealso mapslices
Example
using Ipaper
using Distributions
A = rand(100, 100, 30, 4)
obj_size(A)
par_mapslices(mean, A)
# @time r = mapslices(slope_mk, A; dims=3);
# @time r_par = par_mapslices(slope_mk, A; dims=3); # 5X faster
TODO: par_mapslices is low efficiency
Ipaper.isCurrentWorker
— FunctionisCurrentWorker() -> Bool
isCurrentWorker(i) -> Any
Example
!isCurrentWorker(i) && continue