Hello, sorry I keep forgetting how to do this :
function main()
n = UInt128(10^7)
input ::Vector{UInt128} = collect(0:n-1)
result = OncePerTask() do
Ref(UInt128(0))
end
Threads.@threads for i in input
result()[] += i*i
end
return result
end
how to collect after that ? I know, people should use OhMyThreads.jl, but this should work right ? and be somewhat equivalent to
function main()
n = UInt128(10^7)
input ::Vector{UInt128} = collect(0:n-1)
result = Vector{UInt128}(undef,16)
it = Iterators.partition(1:n,cld(n,16))
@sync for (id,I) in enumerate(it)
Threads.@spawn begin
s ::UInt128 = 0
for i in I
ini = input[i]
s += ini*ini
end
result[id] = s
end
end
return sum(result)
end