|
18 | 18 | #include <cassert>
|
19 | 19 | #include <vector>
|
20 | 20 |
|
| 21 | +/// Return a void* reference with a lifetime that is at least as long as this |
| 22 | +/// AsyncInfoTy object. The location can be used as intermediate buffer. |
| 23 | +void *&__tgt_async_info::getVoidPtrLocation() { |
| 24 | + BufferLocations.push_back(nullptr); |
| 25 | + return BufferLocations.back(); |
| 26 | +} |
| 27 | + |
21 | 28 | /* All begin addresses for partially mapped structs must be 8-aligned in order
|
22 | 29 | * to ensure proper alignment of members. E.g.
|
23 | 30 | *
|
@@ -415,7 +422,8 @@ int targetDataBegin(ident_t *loc, DeviceTy &Device, int32_t arg_num,
|
415 | 422 | DP("Update pointer (" DPxMOD ") -> [" DPxMOD "]\n",
|
416 | 423 | DPxPTR(PointerTgtPtrBegin), DPxPTR(TgtPtrBegin));
|
417 | 424 | uint64_t Delta = (uint64_t)HstPtrBegin - (uint64_t)HstPtrBase;
|
418 |
| - void *TgtPtrBase = (void *)((uint64_t)TgtPtrBegin - Delta); |
| 425 | + void *&TgtPtrBase = async_info_ptr->getVoidPtrLocation(); |
| 426 | + TgtPtrBase = (void *)((uint64_t)TgtPtrBegin - Delta); |
419 | 427 | int rt = Device.submitData(PointerTgtPtrBegin, &TgtPtrBase,
|
420 | 428 | sizeof(void *), async_info_ptr);
|
421 | 429 | if (rt != OFFLOAD_SUCCESS) {
|
@@ -1122,8 +1130,9 @@ static int processDataBefore(ident_t *loc, int64_t DeviceId, void *HostPtr,
|
1122 | 1130 | DP("Parent lambda base " DPxMOD "\n", DPxPTR(TgtPtrBase));
|
1123 | 1131 | uint64_t Delta = (uint64_t)HstPtrBegin - (uint64_t)HstPtrBase;
|
1124 | 1132 | void *TgtPtrBegin = (void *)((uintptr_t)TgtPtrBase + Delta);
|
1125 |
| - void *PointerTgtPtrBegin = Device.getTgtPtrBegin( |
1126 |
| - HstPtrVal, ArgSizes[I], IsLast, false, IsHostPtr); |
| 1133 | + void *&PointerTgtPtrBegin = AsyncInfo->getVoidPtrLocation(); |
| 1134 | + PointerTgtPtrBegin = Device.getTgtPtrBegin(HstPtrVal, ArgSizes[I], |
| 1135 | + IsLast, false, IsHostPtr); |
1127 | 1136 | if (!PointerTgtPtrBegin) {
|
1128 | 1137 | DP("No lambda captured variable mapped (" DPxMOD ") - ignored\n",
|
1129 | 1138 | DPxPTR(HstPtrVal));
|
|
0 commit comments