P4 to Git Change 1082378 by lmoriche@lmoriche_opencl_dev on 2014/09/29 17:08:11
ECR #304775 - Replace amd::Atomic with std::atomic Pre-checkin: http://ocltc.amd.com:8111/viewModification.html?modId=40639&personal=true&buildTypeId=&tab=vcsModificationBuilds&show_all_builds=true Affected files ... ... //depot/stg/opencl/drivers/opencl/runtime/os/os_posix.cpp#38 edit ... //depot/stg/opencl/drivers/opencl/runtime/os/os_win32.cpp#40 edit ... //depot/stg/opencl/drivers/opencl/runtime/platform/command.cpp#64 edit ... //depot/stg/opencl/drivers/opencl/runtime/platform/command.hpp#73 edit ... //depot/stg/opencl/drivers/opencl/runtime/platform/memory.cpp#108 edit ... //depot/stg/opencl/drivers/opencl/runtime/platform/memory.hpp#86 edit ... //depot/stg/opencl/drivers/opencl/runtime/platform/runtime.cpp#33 edit ... //depot/stg/opencl/drivers/opencl/runtime/thread/monitor.hpp#6 edit ... //depot/stg/opencl/drivers/opencl/runtime/thread/semaphore.cpp#6 edit ... //depot/stg/opencl/drivers/opencl/runtime/thread/semaphore.hpp#6 edit ... //depot/stg/opencl/drivers/opencl/runtime/utils/util.hpp#10 edit
This commit is contained in:
@@ -3,7 +3,6 @@
|
||||
//
|
||||
|
||||
#include "thread/semaphore.hpp"
|
||||
#include "thread/atomic.hpp"
|
||||
#include "thread/thread.hpp"
|
||||
|
||||
#if defined(_WIN32) || defined(__CYGWIN__)
|
||||
@@ -16,8 +15,8 @@
|
||||
namespace amd {
|
||||
|
||||
Semaphore::Semaphore()
|
||||
: state_(0)
|
||||
{
|
||||
std::atomic_init(&state_, 0);
|
||||
#ifdef _WIN32
|
||||
handle_ = static_cast<void*>(CreateSemaphore(NULL, 0, LONG_MAX, NULL));
|
||||
assert(handle_ != NULL && "CreateSemaphore failed");
|
||||
@@ -48,14 +47,13 @@ Semaphore::post()
|
||||
while (true) {
|
||||
state = state_;
|
||||
if (state > 0) {
|
||||
// Do a load acquire.
|
||||
MemoryOrder::fence();
|
||||
if (state == state_) {
|
||||
if (state == state_.load(std::memory_order_acquire)) {
|
||||
return;
|
||||
}
|
||||
continue;
|
||||
}
|
||||
if (state_.compareAndSet(state, state+1)) {
|
||||
if (state_.compare_exchange_weak(state, state+1,
|
||||
std::memory_order_acq_rel, std::memory_order_acquire)) {
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user