From aaf533287b08ea04077b9a999e1e28a394b32778 Mon Sep 17 00:00:00 2001 From: foreman Date: Tue, 30 Sep 2014 17:21:19 -0400 Subject: [PATCH] P4 to Git Change 1082950 by lmoriche@lmoriche_opencl_dev on 2014/09/30 16:50:37 ECR #304775 - Implement the changes recommended in review#5943 Pre-checkin: http://ocltc.amd.com:8111/viewModification.html?modId=40717&personal=true&buildTypeId=&tab=vcsModificationBuilds&show_all_builds=true Affected files ... ... //depot/stg/opencl/drivers/opencl/runtime/platform/command.cpp#65 edit ... //depot/stg/opencl/drivers/opencl/runtime/platform/memory.cpp#109 edit ... //depot/stg/opencl/drivers/opencl/runtime/thread/semaphore.cpp#7 edit ... //depot/stg/opencl/drivers/opencl/runtime/utils/concurrent.hpp#6 edit --- rocclr/runtime/platform/command.cpp | 6 ++---- rocclr/runtime/platform/memory.cpp | 6 ++---- rocclr/runtime/thread/semaphore.cpp | 5 ++--- rocclr/runtime/utils/concurrent.hpp | 8 ++++---- 4 files changed, 10 insertions(+), 15 deletions(-) diff --git a/rocclr/runtime/platform/command.cpp b/rocclr/runtime/platform/command.cpp index 97ac07c7a0..98f13d014b 100644 --- a/rocclr/runtime/platform/command.cpp +++ b/rocclr/runtime/platform/command.cpp @@ -129,10 +129,8 @@ Event::setCallback(cl_int status, Event::CallBackFunction callback, void* data) } entry->next_ = callbacks_; - while (!callbacks_.compare_exchange_weak(entry->next_, entry)) { - // Someone else is also updating the head of the linked list! reload. - entry->next_ = callbacks_; - } + while (!callbacks_.compare_exchange_weak(entry->next_, entry)) + ; // Someone else is also updating the head of the linked list! reload. // Check if the event has already reached 'status' if (status_ <= status && entry->callback_ != CallBackFunction(0)) { diff --git a/rocclr/runtime/platform/memory.cpp b/rocclr/runtime/platform/memory.cpp index 18d742ae07..05ac64ec7c 100644 --- a/rocclr/runtime/platform/memory.cpp +++ b/rocclr/runtime/platform/memory.cpp @@ -439,10 +439,8 @@ Memory::setDestructorCallback(DestructorCallBackFunction callback, void* data) } entry->next_ = destructorCallbacks_; - while (!destructorCallbacks_.compare_exchange_weak(entry->next_, entry)) { - // Someone else is also updating the head of the linked list! reload. - entry->next_ = destructorCallbacks_; - } + while (!destructorCallbacks_.compare_exchange_weak(entry->next_, entry)) + ; // Someone else is also updating the head of the linked list! reload. return true; } diff --git a/rocclr/runtime/thread/semaphore.cpp b/rocclr/runtime/thread/semaphore.cpp index d1ff87d596..a9e22e011d 100644 --- a/rocclr/runtime/thread/semaphore.cpp +++ b/rocclr/runtime/thread/semaphore.cpp @@ -43,9 +43,8 @@ Semaphore::~Semaphore() void Semaphore::post() { - int state; - while (true) { - state = state_; + int state = state_; + for (;;) { if (state > 0) { if (state == state_.load(std::memory_order_acquire)) { return; diff --git a/rocclr/runtime/utils/concurrent.hpp b/rocclr/runtime/utils/concurrent.hpp index 970e43d6bf..a52c8701ef 100644 --- a/rocclr/runtime/utils/concurrent.hpp +++ b/rocclr/runtime/utils/concurrent.hpp @@ -151,11 +151,11 @@ ConcurrentLinkedQueue::enqueue(T elem) node->value_ = elem; node->next_ = NULL; - while (true) { + for (;;) { typename Node::Ptr tail = tail_.load(std::memory_order_acquire); typename Node::Ptr next = tail->ptr()->next_.load(std::memory_order_acquire); - if (tail == tail_.load(std::memory_order_acquire)) { + if (likely(tail == tail_.load(std::memory_order_acquire))) { if (next->ptr() == NULL) { if (tail->ptr()->next_.compare_exchange_weak( next, Node::ptr(node, next->tag()+1), @@ -179,12 +179,12 @@ template inline T ConcurrentLinkedQueue::dequeue() { - while (true) { + for (;;) { typename Node::Ptr head = head_.load(std::memory_order_acquire); typename Node::Ptr tail = tail_.load(std::memory_order_acquire); typename Node::Ptr next = head->ptr()->next_.load(std::memory_order_acquire); - if (head == head_.load(std::memory_order_acquire)) { + if (likely(head == head_.load(std::memory_order_acquire))) { if (head->ptr() == tail->ptr()) { if (next->ptr() == NULL) { return NULL;