llvm-project icon indicating copy to clipboard operation
llvm-project copied to clipboard

[OpenMP][offload] Fix map-type order

Open ro-i opened this issue 6 months ago • 6 comments

Reorder mappers such that

  • on target entry: "from" mappers are handled at the end, where they only act as decayed alloc/storage mappers.
  • on target exit: "to" mappers are handled first so that they can act as decayed release/storage mappers and decrement the reference count.

This avoids that map to+from or from+to result in different outcomes than mapping with a tofrom mapper. The previous behavior:

  • target map(to: ptr[0:size]) map(from: ptr[0:size]): the from-mapper was hindered from copying the data back to the host because it was handled first on target exit which means that the to-mapper hadn't been able to decrement the reference count first.
  • target map(from: ptr[0:size]) map(to: ptr[0:size]): the to-mapper was hindered from copying the data to the device because it was handled second on target entry which means that the reference count had already been incremented by the decayed alloc/storage operation of the from-mapper.

ro-i avatar Oct 24 '25 19:10 ro-i