[Openmp-commits] [PATCH] D104418: [OpenMP][Offloading] Fixed data race in libomptarget caused by async data movement
Shilei Tian via Phabricator via Openmp-commits
openmp-commits at lists.llvm.org
Tue Jan 4 16:44:11 PST 2022
tianshilei1992 added a comment.
In D104418#3220189 <https://reviews.llvm.org/D104418#3220189>, @ye-luo wrote:
> I still think the new/old event exchange should be removed.
> If T1 record an event for a D2H transfer and then T2 issues a H2D transfer and create an new event and then wait for the old event. the H2D or D2H may happen together when they are on two distinct streams.
> This violates `atomic` data transfer behavior.
> the solution is 1 persistent event per map and always check its status before issuing any transfer.
First, there is no event for D2H for now. This patch tries to make sure there is no race among H2D of the same memory from multiple target tasks, especially when they all read from that memory. D2H is out of the scope, and has nothing to do with the scenario mentioned in this patch. Without this patch, H2D and D2H can still happen at the same time on different streams.
Second, I think the case you describe is already data race caused by *user*. For two target tasks, if one task tries to move data in one direction while another task tries to move data in another direction, the two tasks should not run at the same time. That said, they should have dependency because one tries to read and another tries to write. Even with the "atomic" behavior you mentioned, which I didn't find it on the spec (maybe I missed it. could you pin point where it is?) it is still undetermined that which one comes first.
Third, using one event all the time sounds like a feasible solution. If an entry already has an event, we can reuse that one w/o the need to create a new one and destroy the old one, which can potentially save some overhead.
rG LLVM Github Monorepo
CHANGES SINCE LAST ACTION
More information about the Openmp-commits