Improve queueLock and lastCmdLock
Reduce the size of the queueLock and lastCmdLock critical sections
to improve lock contention performance. The smaller the critical
sections are the better.
lasCmdLock is still needed to guarantee that getLastEnqueueCommand_
can retain the command before it is swapped out and released.
Change-Id: Id35d4a77c035b2da0de4c15568b153d49e958bb7
[ROCm/clr commit: 080dcfe857]
이 커밋은 다음에 포함됨:
1 부모
5f5f1a3a84
커밋
d0b6c2b538
2 파일이 변경됨
+16
-8
검색과 일치하는 파일 없음
@@ -185,17 +185,26 @@ void HostQueue::append(Command& command) {
|
||||
}
|
||||
command.retain();
|
||||
command.setStatus(CL_QUEUED);
|
||||
ScopedLock l(lastCmdLock_);
|
||||
queue_.enqueue(&command);
|
||||
if (!IS_HIP) {
|
||||
return;
|
||||
}
|
||||
// Set last submitted command
|
||||
if (lastEnqueueCommand_ != nullptr) {
|
||||
lastEnqueueCommand_->release();
|
||||
Command* prevLastEnqueueCommand;
|
||||
command.retain();
|
||||
{
|
||||
// lastCmdLock_ ensures that lastEnqueueCommand() can retain the command before it is swapped
|
||||
// out. We want to keep this critical section as short as possible, so the command should be
|
||||
// released outside this section.
|
||||
ScopedLock l(lastCmdLock_);
|
||||
|
||||
prevLastEnqueueCommand = lastEnqueueCommand_;
|
||||
lastEnqueueCommand_ = &command;
|
||||
}
|
||||
|
||||
if (prevLastEnqueueCommand != nullptr) {
|
||||
prevLastEnqueueCommand->release();
|
||||
}
|
||||
lastEnqueueCommand_ = &command;
|
||||
lastEnqueueCommand_->retain();
|
||||
}
|
||||
|
||||
bool HostQueue::isEmpty() {
|
||||
@@ -207,6 +216,8 @@ Command* HostQueue::getLastQueuedCommand(bool retain) {
|
||||
// Get last submitted command
|
||||
ScopedLock l(lastCmdLock_);
|
||||
|
||||
// Since the lastCmdLock_ is acquired, it is safe to read and retain the lastEnqueueCommand. It is
|
||||
// guaranteed that the pointer will not change.
|
||||
if (retain && lastEnqueueCommand_ != nullptr) {
|
||||
lastEnqueueCommand_->retain();
|
||||
}
|
||||
|
||||
새 이슈에서 참조
사용자 차단