Skip to content

Commit acf4219

Browse files
committed
Repair the rebase
1 parent 5accf42 commit acf4219

File tree

6 files changed

+35
-59
lines changed

6 files changed

+35
-59
lines changed

offload/plugins-nextgen/amdgpu/src/rtl.cpp

Lines changed: 3 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1601,7 +1601,6 @@ struct AMDGPUStreamManagerTy final
16011601
using ResourceRef = AMDGPUResourceRef<AMDGPUStreamTy>;
16021602
using ResourcePoolTy = GenericDeviceResourceManagerTy<ResourceRef>;
16031603

1604-
GenericDeviceTy &Device;
16051604
AMDGPUStreamManagerTy(GenericDeviceTy &Device, hsa_agent_t HSAAgent)
16061605
: GenericDeviceResourceManagerTy(Device), Device(Device),
16071606
OMPX_QueueTracking("LIBOMPTARGET_AMDGPU_HSA_QUEUE_BUSY_TRACKING", true),
@@ -3528,6 +3527,9 @@ void AMDGPUQueueTy::callbackError(hsa_status_t Status, hsa_queue_t *Source,
35283527
void *Data) {
35293528
auto &AMDGPUDevice = *reinterpret_cast<AMDGPUDeviceTy *>(Data);
35303529

3530+
auto *Device = reinterpret_cast<AMDGPUDeviceTy *>(Data);
3531+
Device->reportSanitizerError();
3532+
35313533
if (Status == HSA_STATUS_ERROR_EXCEPTION) {
35323534
auto KernelTraceInfoRecord =
35333535
AMDGPUDevice.KernelLaunchTraces.getExclusiveAccessor();
@@ -3542,9 +3544,6 @@ void AMDGPUQueueTy::callbackError(hsa_status_t Status, hsa_queue_t *Source,
35423544
AsyncInfoWrapperMatcher);
35433545
}
35443546

3545-
auto *Device = reinterpret_cast<AMDGPUDeviceTy *>(Data);
3546-
Device->reportSanitizerError();
3547-
35483547
auto Err = Plugin::check(Status, "Received error in queue %p: %s", Source);
35493548
FATAL_MESSAGE(1, "%s", toString(std::move(Err)).data());
35503549
}

offload/plugins-nextgen/common/include/PluginInterface.h

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -987,7 +987,7 @@ struct GenericDeviceTy : public DeviceAllocatorTy {
987987
auto AllocationTraceMap = AllocationTraces.getExclusiveAccessor();
988988
for (auto &It : *AllocationTraceMap) {
989989
if (It.first <= DevicePtr &&
990-
advanceVoidPtr(It.first, It.second->Size) > DevicePtr)
990+
utils::advancePtr(It.first, It.second->Size) > DevicePtr)
991991
return It.second;
992992
}
993993
return nullptr;

offload/plugins-nextgen/common/src/PluginInterface.cpp

Lines changed: 29 additions & 44 deletions
Original file line numberDiff line numberDiff line change
@@ -17,6 +17,7 @@
1717
#include "ErrorReporting.h"
1818
#include "GlobalHandler.h"
1919
#include "JIT.h"
20+
#include "Shared/EnvironmentVar.h"
2021
#include "Shared/Sanitizer.h"
2122
#include "Shared/Utils.h"
2223
#include "Utils/ELF.h"
@@ -939,24 +940,33 @@ GenericDeviceTy::loadBinary(GenericPluginTy &Plugin,
939940
if (auto Err = callGlobalConstructors(Plugin, *Image))
940941
return std::move(Err);
941942

942-
auto GetKernel = [&](StringRef Name) -> GenericKernelTy * {
943-
auto KernelOrErr = constructKernel(Name.data());
944-
if (Error Err = KernelOrErr.takeError()) {
945-
REPORT("Failure to look up kernel: %s\n",
946-
toString(std::move(Err)).data());
947-
return nullptr;
943+
auto *&SanitizerTrapInfo = SanitizerTrapInfos[Image];
944+
GlobalTy TrapId("__sanitizer_trap_info_ptr", sizeof(SanitizerTrapInfo),
945+
&SanitizerTrapInfo);
946+
GenericGlobalHandlerTy &GHandler = Plugin.getGlobalHandler();
947+
if (GHandler.isSymbolInImage(*this, *Image, TrapId.getName())) {
948+
949+
SanitizerTrapInfo = reinterpret_cast<SanitizerTrapInfoTy *>(allocate(
950+
sizeof(*SanitizerTrapInfo), &SanitizerTrapInfo, TARGET_ALLOC_HOST));
951+
memset(SanitizerTrapInfo, '\0', sizeof(SanitizerTrapInfoTy));
952+
953+
if (auto Err = GHandler.writeGlobalToDevice(*this, *Image, TrapId))
954+
return Err;
955+
{
956+
auto KernelOrErr = getKernel("__sanitizer_register", Image);
957+
if (auto Err = KernelOrErr.takeError())
958+
consumeError(std::move(Err));
959+
else
960+
addGPUSanNewFn(*KernelOrErr);
948961
}
949-
GenericKernelTy &Kernel = *KernelOrErr;
950-
if (auto Err = Kernel.init(*this, *Image)) {
951-
REPORT("Failure to init kernel: %s\n", toString(std::move(Err)).data());
952-
return nullptr;
962+
{
963+
auto KernelOrErr = getKernel("__sanitizer_unregister", Image);
964+
if (auto Err = KernelOrErr.takeError())
965+
consumeError(std::move(Err));
966+
else
967+
addGPUSanFreeFn(*KernelOrErr);
953968
}
954-
return &Kernel;
955-
};
956-
if (GenericKernelTy *Kernel = GetKernel("__sanitizer_register"))
957-
addGPUSanNewFn(*Kernel);
958-
if (GenericKernelTy *Kernel = GetKernel("__sanitizer_unregister"))
959-
addGPUSanFreeFn(*Kernel);
969+
}
960970

961971
// Return the pointer to the table of entries.
962972
return Image;
@@ -1036,16 +1046,6 @@ Error GenericDeviceTy::setupDeviceMemoryPool(GenericPluginTy &Plugin,
10361046
if (auto Err = GHandler.writeGlobalToDevice(*this, Image, TrackerGlobal))
10371047
return Err;
10381048

1039-
auto *&SanitizerTrapInfo = SanitizerTrapInfos[&Image];
1040-
SanitizerTrapInfo = reinterpret_cast<SanitizerTrapInfoTy *>(allocate(
1041-
sizeof(*SanitizerTrapInfo), &SanitizerTrapInfo, TARGET_ALLOC_HOST));
1042-
memset(SanitizerTrapInfo, '\0', sizeof(SanitizerTrapInfoTy));
1043-
1044-
GlobalTy TrapId("__sanitizer_trap_info_ptr", sizeof(SanitizerTrapInfo),
1045-
&SanitizerTrapInfo);
1046-
if (auto Err = GHandler.writeGlobalToDevice(*this, Image, TrapId))
1047-
return Err;
1048-
10491049
// Create the metainfo of the device environment global.
10501050
GlobalTy DevEnvGlobal("__omp_rtl_device_memory_pool",
10511051
sizeof(DeviceMemoryPoolTy), &DeviceMemoryPool);
@@ -2404,32 +2404,17 @@ void GPUSanTy::checkAndReportError() {
24042404
Green(), STI->PtrSlot, STI->PtrTag, STI->PtrKind, STI->AllocationId,
24052405
STI->AllocationTag, STI->AllocationKind, Default());
24062406

2407-
AllocationInfoTy *AllocationInfo = nullptr;
2408-
if (STI->AllocationStart) {
2409-
auto AllocationTraceMap = Device.AllocationTraces.getExclusiveAccessor();
2410-
AllocationInfo = (*AllocationTraceMap)[STI->AllocationStart];
2411-
}
2412-
if (AllocationInfo) {
2413-
fprintf(stderr, "\nAllocated at\n");
2414-
fprintf(stderr, "%s", AllocationInfo->AllocationTrace.c_str());
2415-
2416-
if (!AllocationInfo->DeallocationTrace.empty()) {
2417-
fprintf(stderr, "\nDeallocated at\n");
2418-
fprintf(stderr, "%s", AllocationInfo->DeallocationTrace.c_str());
2419-
}
2420-
}
2421-
24222407
};
24232408

24242409
switch (STI->ErrorCode) {
24252410
case SanitizerTrapInfoTy::None:
24262411
llvm_unreachable("Unexpected exception");
24272412
case SanitizerTrapInfoTy::ExceedsLength:
2428-
fprintf(stderr, "%sERROR: OffloadSanitizer %s %d\n%s", Red(),
2413+
fprintf(stderr, "%sERROR: OffloadSanitizer %s %lu\n%s", Red(),
24292414
"exceeds length", STI->PtrSlot, Default());
24302415
break;
24312416
case SanitizerTrapInfoTy::ExceedsSlots:
2432-
fprintf(stderr, "%sERROR: OffloadSanitizer %s %d\n%s", Red(),
2417+
fprintf(stderr, "%sERROR: OffloadSanitizer %s %lu\n%s", Red(),
24332418
"exceeds slots", STI->PtrSlot, Default());
24342419
break;
24352420
case SanitizerTrapInfoTy::PointerOutsideAllocation:
@@ -2449,7 +2434,7 @@ void GPUSanTy::checkAndReportError() {
24492434
DiagnoseAccess("use-after-free");
24502435
break;
24512436
case SanitizerTrapInfoTy::MemoryLeak:
2452-
fprintf(stderr, "%sERROR: OffloadSanitizer memory leak at slot %d\n%s",
2437+
fprintf(stderr, "%sERROR: OffloadSanitizer memory leak at slot %lu\n%s",
24532438
Red(), STI->PtrSlot, Default());
24542439
break;
24552440
case SanitizerTrapInfoTy::GarbagePointer:

offload/src/Kernels/Sanitizer.cpp

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -15,12 +15,12 @@ __device__ void __sanitizer_register_host(void *P, uint64_t Bytes,
1515
uint64_t Slot);
1616
__device__ void __sanitizer_unregister_host(void *P);
1717

18-
[[clang::disable_sanitizer_instrumentation]] __global__ void
18+
[[gnu::weak, clang::disable_sanitizer_instrumentation]] __global__ void
1919
__sanitizer_register(void *P, uint64_t Bytes, uint64_t Slot) {
2020
__sanitizer_register_host(P, Bytes, Slot);
2121
}
2222

23-
[[clang::disable_sanitizer_instrumentation]] __global__ void
23+
[[gnu::weak, clang::disable_sanitizer_instrumentation]] __global__ void
2424
__sanitizer_unregister(void *P) {
2525
__sanitizer_unregister_host(P);
2626
}

offload/src/exports

Lines changed: 0 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -75,9 +75,6 @@ VERS1.0 {
7575
__llvmPushCallConfiguration;
7676
__llvmPopCallConfiguration;
7777
llvmLaunchKernel;
78-
ompx_new_allocation_host;
79-
ompx_free_allocation_host;
80-
ompx_register_image_functions;
8178
local:
8279
*;
8380
};

offload/src/omptarget.cpp

Lines changed: 0 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -215,11 +215,6 @@ void *targetAllocExplicit(size_t Size, int64_t DeviceNum, int Kind,
215215
return Rc;
216216
}
217217

218-
if (checkDeviceAndCtors(DeviceNum, nullptr)) {
219-
DP("Not offloading to device %" PRId64 "\n", DeviceNum);
220-
return Rc;
221-
}
222-
223218
auto DeviceOrErr = PM->getDevice(DeviceNum);
224219
if (!DeviceOrErr)
225220
FATAL_MESSAGE(DeviceNum, "%s", toString(DeviceOrErr.takeError()).c_str());

0 commit comments

Comments
 (0)