Skip to content

Commit

Permalink
Merge pull request #2461 from yingcong-wu/yc/1213-omp-global-fix
Browse files Browse the repository at this point in the history
[DeviceASAN] Register globals for the program
  • Loading branch information
martygrant authored Dec 13, 2024
2 parents f6337ce + f10473a commit 73e5f3c
Show file tree
Hide file tree
Showing 2 changed files with 11 additions and 0 deletions.
10 changes: 10 additions & 0 deletions source/loader/layers/sanitizer/asan/asan_interceptor.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -431,6 +431,12 @@ ur_result_t AsanInterceptor::unregisterProgram(ur_program_handle_t Program) {
auto ProgramInfo = getProgramInfo(Program);
assert(ProgramInfo != nullptr && "unregistered program!");

std::scoped_lock<ur_shared_mutex> Guard(m_AllocationMapMutex);
for (auto AI : ProgramInfo->AllocInfoForGlobals) {
m_AllocationMap.erase(AI->AllocBegin);
}
ProgramInfo->AllocInfoForGlobals.clear();

ProgramInfo->InstrumentedKernels.clear();

return UR_RESULT_SUCCESS;
Expand Down Expand Up @@ -549,6 +555,10 @@ AsanInterceptor::registerDeviceGlobals(ur_program_handle_t Program) {
{}});

ContextInfo->insertAllocInfo({Device}, AI);
ProgramInfo->AllocInfoForGlobals.emplace(AI);

std::scoped_lock<ur_shared_mutex> Guard(m_AllocationMapMutex);
m_AllocationMap.emplace(AI->AllocBegin, std::move(AI));
}
}

Expand Down
1 change: 1 addition & 0 deletions source/loader/layers/sanitizer/asan/asan_interceptor.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -112,6 +112,7 @@ struct ProgramInfo {
std::atomic<int32_t> RefCount = 1;

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

explicit ProgramInfo(ur_program_handle_t Program) : Handle(Program) {
Expand Down

0 comments on commit 73e5f3c

Please sign in to comment.