[Openmp-commits] [PATCH] D132532: [libomptarget] Avoid deleting the same entry multiple times

Ye Luo via Phabricator via Openmp-commits openmp-commits at lists.llvm.org
Wed Aug 24 08:20:47 PDT 2022


ye-luo added a comment.

In D132532#3745747 <https://reviews.llvm.org/D132532#3745747>, @jdoerfert wrote:

> In D132532#3745645 <https://reviews.llvm.org/D132532#3745645>, @ye-luo wrote:
>
>> In D132532#3745640 <https://reviews.llvm.org/D132532#3745640>, @jdoerfert wrote:
>>
>>> I thought about this but IIRC, this doesn't work either. Now you have no way to prevent races between the copy back and copy to since the entry is gone while the copy back runs.
>>
>> I thought about the racing. If race to write the same data, there is no harm. If race to write different data, the source of race is user program which needs to protect the race anyway.
>
> I still believe there is a problem.
>
> T1: copy back old device memory into HostMem after entry has been deleted
> T2: copy from HostMem into some new device region as the entry is new
>
> We cannot use events or anything to prevent this race on the host memory and since maps should be atomic we break the program.
>
> Where am I wrong?

You are right. There is potential data corruption. The H2D to a new device memory location may start before D2H completes.


Repository:
  rG LLVM Github Monorepo

CHANGES SINCE LAST ACTION
  https://reviews.llvm.org/D132532/new/

https://reviews.llvm.org/D132532



More information about the Openmp-commits mailing list