I think it would be useful to give the user access to the task id (i.e. 1:ntasks:). My motivation for this is code that have this pattern (which is pretty common):
for i in 1:N
@tasks for j in 1:N
@local cache = computation_with_heavy_allocs()
end
end
where there currently isn't a great way to hoist the task local cache allocation out of the outer loop. If I can observe the task id I can do something like
caches = [computation_with_heavy_allocs() for _ in 1:ntasks]
for i in 1:N
@tasks for j in 1:N
@local cache = caches[OhMyThreads.taskid()] # or @taskid
end
end
Is there a better way to achieve this?
I think it would be useful to give the user access to the task id (i.e.
1:ntasks:). My motivation for this is code that have this pattern (which is pretty common):where there currently isn't a great way to hoist the task local cache allocation out of the outer loop. If I can observe the task id I can do something like
Is there a better way to achieve this?