How to implement @parallel_map macro?
results = @parallel_map for i in 1:10
i^2
end
So that it won't use Any like code below (I assume it slow down code)?
results = Vector{Any}(undef, 10) # possible slow?
Threads.@threads for i in 1:10
results[i] = i^2
end
Vector{Int}(undef, 10)instead. I will grab any memory area so it will contain some random bytes. Since you overwrite them this is fine. This is fastest (with some caveats for complex multiprocesing scenarios).