Disable worker thread creation for direct dispatch

Change-Id: I28f08ab9352310c9bf843fcb803a48f95ddf4676
이 커밋은 다음에 포함됨:
German Andryeyev
2020-11-30 17:49:25 -05:00
부모 4af8b53846
커밋 e4f51e063b
2개의 변경된 파일48개의 추가작업 그리고 30개의 파일을 삭제
+37 -28
파일 보기
@@ -38,43 +38,52 @@ HostQueue::HostQueue(Context& context, Device& device, cl_command_queue_properti
: CommandQueue(context, device, properties, device.info().queueProperties_, queueRTCUs,
priority, cuMask),
lastEnqueueCommand_(nullptr) {
if (thread_.state() >= Thread::INITIALIZED) {
ScopedLock sl(queueLock_);
thread_.start(this);
queueLock_.wait();
if (AMD_DIRECT_DISPATCH) {
// Initialize the queue
thread_.Init(this);
} else {
if (thread_.state() >= Thread::INITIALIZED) {
ScopedLock sl(queueLock_);
thread_.start(this);
queueLock_.wait();
}
}
}
bool HostQueue::terminate() {
if (Os::isThreadAlive(thread_)) {
Command* marker = nullptr;
if (AMD_DIRECT_DISPATCH) {
thread_.Release();
} else {
if (Os::isThreadAlive(thread_)) {
Command* marker = nullptr;
// Send a finish if the queue is still accepting commands.
{
ScopedLock sl(queueLock_);
if (thread_.acceptingCommands_) {
marker = new Marker(*this, false);
if (marker != nullptr) {
append(*marker);
queueLock_.notify();
// Send a finish if the queue is still accepting commands.
{
ScopedLock sl(queueLock_);
if (thread_.acceptingCommands_) {
marker = new Marker(*this, false);
if (marker != nullptr) {
append(*marker);
queueLock_.notify();
}
}
}
}
if (marker != nullptr) {
marker->awaitCompletion();
marker->release();
}
if (marker != nullptr) {
marker->awaitCompletion();
marker->release();
}
// Wake-up the command loop, so it can exit
{
ScopedLock sl(queueLock_);
thread_.acceptingCommands_ = false;
queueLock_.notify();
}
// Wake-up the command loop, so it can exit
{
ScopedLock sl(queueLock_);
thread_.acceptingCommands_ = false;
queueLock_.notify();
}
// FIXME_lmoriche: fix termination handshake
while (thread_.state() < Thread::FINISHED) {
Os::yield();
// FIXME_lmoriche: fix termination handshake
while (thread_.state() < Thread::FINISHED) {
Os::yield();
}
}
}