task_local_storage
isn’t going anywhere. It’s just not particularly useful or nice for implementing reductions.
For an example of something that task_local_storage
does well in the context of @threads
, here’s some code @GunnarFarneback shared on Zulip:
Threads.@threads for j in axes(x, 2)
temp = get!(() -> Vector{Int}(undef, N), task_local_storage(), :temp)::Vector{Int}
# fill in temp with j-dependent data
for i in axes(x, 1)
y[i, j] = # some computation with x, i, j, temp
end
end