[PATCH] D135462: [SelectionDAG] Do not second-guess alignment for alloca

Andrew Savonichev via Phabricator via llvm-commits llvm-commits at lists.llvm.org
Tue Dec 20 12:26:24 PST 2022


asavonic added subscribers: grokos, Hahnfeld.
asavonic added a comment.

It appears that the issue is caused by libomptarget mapping code that adds padding if the begin address does not have alignment of 8 (search for "alignment" in  `omptarget.cpp`). The problem is that the padding is not applied consistently, so we may have a mapping without the padding (size == 8), and then get a request for a mapping with the padding (size == 12). Notice that we don't have `Using a padding of 4 bytes for begin address` for the first mapping, and we have it for the same exact pointer for the second mapping.

  check: parent DynRefCount=1 is not sufficient for transfer
  Libomptarget --> Entering data begin region for device -1 with 1 mappings
  [...]
  Libomptarget --> Entry  0: Base=0x00007ffc9b2581e4, Begin=0x00007ffc9b2581e4, Size=8, Type=0x2003, Name=unknown
  Libomptarget --> Looking up mapping(HstPtrBegin=0x00007ffc9b2581e4, Size=8)...
  Libomptarget --> Creating new map entry with HstPtrBase=0x00007ffc9b2581e4, HstPtrBegin=0x00007ffc9b2581e4, TgtPtrBegin=0x0000561d0739b390, Size=8, DynRefCount=0, HoldRefCount=1, Name=unknown
  Libomptarget --> Moving 8 bytes (hst:0x00007ffc9b2581e4) -> (tgt:0x0000561d0739b390)
  [...]
  Libomptarget --> Entering target region for device -1 with entry point 0x0000561d059ca298
  [...]
  Libomptarget --> Entry  0: Base=0x00007ffc9b2581e4, Begin=0x00007ffc9b2581e4, Size=8, Type=0x20, Name=unknown
  Libomptarget --> Entry  1: Base=0x00007ffc9b2581e4, Begin=0x00007ffc9b2581e4, Size=4, Type=0x1000000000002, Name=unknown
  Libomptarget --> Entry  2: Base=0x00007ffc9b2581e4, Begin=0x00007ffc9b2581e8, Size=4, Type=0x1000000000002, Name=unknown
  Libomptarget --> loop trip count is 0.
  Libomptarget --> Using a padding of 4 bytes for begin address 0x00007ffc9b2581e4
  Libomptarget --> Looking up mapping(HstPtrBegin=0x00007ffc9b2581e0, Size=12)...
  Libomptarget --> WARNING: Pointer is not mapped but section extends into already mapped data
  Libomptarget message: explicit extension not allowed: host address specified is 0x00007ffc9b2581e0 (12 bytes), but device allocation maps to host at 0x00007ffc9b2581e4 (8 bytes)

I'm not sure how to fix this issue. The obvious solution is to pass the padding value to DeviceTy::getTargetPointer, and ignore it if we already have a mapping without it (since alignment requirements are already satisfied, right?). Another option is to apply padding more consistently, but I don't know enough about OpenMP to figure out what exactly is wrong with the current implementation.

@grokos, @Hahnfeld, do you have any suggestions how to fix this issue? The handling of alignment was added in D44186 <https://reviews.llvm.org/D44186>.


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D135462



More information about the llvm-commits mailing list