Skip to content
This repository has been archived by the owner on Jan 26, 2024. It is now read-only.

Commit

Permalink
SWDEV-301667 - Optimize lock for graph global capture mode
Browse files Browse the repository at this point in the history
Remove unneeded lock and add smaller scope

Change-Id: I03a437057d54ce2d72c07a080bb872693b7f3f6c
  • Loading branch information
chrispaquot committed Mar 21, 2023
1 parent 0e37910 commit 4209792
Show file tree
Hide file tree
Showing 2 changed files with 6 additions and 5 deletions.
1 change: 0 additions & 1 deletion src/hip_internal.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -166,7 +166,6 @@ static amd::Monitor g_hipInitlock{"hipInit lock"};
if (hip::tls.capture_streams_.size() != 0) { \
HIP_RETURN(hipErrorStreamCaptureUnsupported); \
} \
amd::ScopedLock lock(g_captureStreamsLock); \
if (g_captureStreams.size() != 0) { \
HIP_RETURN(hipErrorStreamCaptureUnsupported); \
} \
Expand Down
10 changes: 6 additions & 4 deletions src/hip_stream.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -470,10 +470,12 @@ hipError_t hipStreamDestroy(hipStream_t stream) {
}
s->GetDevice()->RemoveStreamFromPools(s);

amd::ScopedLock lock(g_captureStreamsLock);
const auto& g_it = std::find(g_captureStreams.begin(), g_captureStreams.end(), s);
if (g_it != g_captureStreams.end()) {
g_captureStreams.erase(g_it);
{
amd::ScopedLock lock(g_captureStreamsLock);
const auto& g_it = std::find(g_captureStreams.begin(), g_captureStreams.end(), s);
if (g_it != g_captureStreams.end()) {
g_captureStreams.erase(g_it);
}
}
const auto& l_it = std::find(hip::tls.capture_streams_.begin(),
hip::tls.capture_streams_.end(), s);
Expand Down

0 comments on commit 4209792

Please sign in to comment.