Skip to content

Commit 73e5f3c

Browse files
authored
Merge pull request #2461 from yingcong-wu/yc/1213-omp-global-fix
[DeviceASAN] Register globals for the program
2 parents f6337ce + f10473a commit 73e5f3c

File tree

2 files changed

+11
-0
lines changed

2 files changed

+11
-0
lines changed

source/loader/layers/sanitizer/asan/asan_interceptor.cpp

+10
Original file line numberDiff line numberDiff line change
@@ -431,6 +431,12 @@ ur_result_t AsanInterceptor::unregisterProgram(ur_program_handle_t Program) {
431431
auto ProgramInfo = getProgramInfo(Program);
432432
assert(ProgramInfo != nullptr && "unregistered program!");
433433

434+
std::scoped_lock<ur_shared_mutex> Guard(m_AllocationMapMutex);
435+
for (auto AI : ProgramInfo->AllocInfoForGlobals) {
436+
m_AllocationMap.erase(AI->AllocBegin);
437+
}
438+
ProgramInfo->AllocInfoForGlobals.clear();
439+
434440
ProgramInfo->InstrumentedKernels.clear();
435441

436442
return UR_RESULT_SUCCESS;
@@ -549,6 +555,10 @@ AsanInterceptor::registerDeviceGlobals(ur_program_handle_t Program) {
549555
{}});
550556

551557
ContextInfo->insertAllocInfo({Device}, AI);
558+
ProgramInfo->AllocInfoForGlobals.emplace(AI);
559+
560+
std::scoped_lock<ur_shared_mutex> Guard(m_AllocationMapMutex);
561+
m_AllocationMap.emplace(AI->AllocBegin, std::move(AI));
552562
}
553563
}
554564

source/loader/layers/sanitizer/asan/asan_interceptor.hpp

+1
Original file line numberDiff line numberDiff line change
@@ -112,6 +112,7 @@ struct ProgramInfo {
112112
std::atomic<int32_t> RefCount = 1;
113113

114114
// Program is built only once, so we don't need to lock it
115+
std::unordered_set<std::shared_ptr<AllocInfo>> AllocInfoForGlobals;
115116
std::unordered_set<std::string> InstrumentedKernels;
116117

117118
explicit ProgramInfo(ur_program_handle_t Program) : Handle(Program) {

0 commit comments

Comments
 (0)