[Openmp-commits] [PATCH] D121057: [OpenMP][FIX] Ensure exclusive access to the HDTT map

Johannes Doerfert via Phabricator via Openmp-commits openmp-commits at lists.llvm.org
Sat Mar 5 13:50:16 PST 2022


jdoerfert created this revision.
jdoerfert added reviewers: JonChesterfield, jhuber6, tianshilei1992.
Herald added subscribers: guansong, bollu, yaxunl.
Herald added a project: All.
jdoerfert requested review of this revision.
Herald added a subscriber: sstefan1.
Herald added a project: OpenMP.

This patch solves two problems with the `HostDataToTargetMap` (HDTT
map) which caused races and crashes before:

1. Any access to the HDTT map needs to be exclusive access. This was not the case for the "dump table" traversals that could collide with updates by other threads. The new `Accessor` and `ProtectedObject` wrappers will ensure we have a hard time introducing similar races in the future. Note that we could allow multiple concurrent read-accesses but that feature can be added to the `Accessor` API later.
2. The elements of the HDTT map were `HostDataToTargetTy` objects which meant that they could be copied/moved/deleted as the map was changed. However, we sometimes kept pointers to these elements around after we gave up the map lock which caused potential races again. The new indirection through `HostDataToTargetMapKeyTy` will allows us to modify the map while keeping the (interesting part of the) entries valid. To offset potential cost we duplicate the ordering key of the entry which avoids an additional indirect lookup.

We should replace more objects with "protected objects" as we go.


Repository:
  rG LLVM Github Monorepo

https://reviews.llvm.org/D121057

Files:
  openmp/libomptarget/include/ExclusiveAccess.h
  openmp/libomptarget/include/device.h
  openmp/libomptarget/src/device.cpp
  openmp/libomptarget/src/omptarget.cpp
  openmp/libomptarget/src/private.h

-------------- next part --------------
A non-text attachment was scrubbed...
Name: D121057.413248.patch
Type: text/x-patch
Size: 25322 bytes
Desc: not available
URL: <http://lists.llvm.org/pipermail/openmp-commits/attachments/20220305/5eaf56b9/attachment-0001.bin>


More information about the Openmp-commits mailing list