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


[ROCm/clr commit: 90c15d9f06]
This commit is contained in:
foreman
2014-09-29 17:38:55 -04:00
parent b64d62eedd
commit 6292b4d113
11 changed files with 78 additions and 158 deletions
@@ -3,7 +3,6 @@
//
#include "platform/runtime.hpp"
#include "thread/atomic.hpp"
#include "os/os.hpp"
#include "thread/thread.hpp"
#include "device/device.hpp"
@@ -24,14 +23,10 @@
#include <intrin.h>
#endif
#include <atomic>
#include <cstdlib>
#include <iostream>
#ifdef TIMEBOMB
# include <cstdio>
# include <time.h>
#endif // TIMEBOMB
namespace amd {
#ifdef __linux__
@@ -60,22 +55,19 @@ Runtime::init()
// from concurrently executing the init() routines. We can't use a
// Monitor since the system is not yet initialized.
static Atomic<int> lock = 0;
static std::atomic_flag lock = ATOMIC_FLAG_INIT;
struct CriticalRegion
{
Atomic<int>& lock_;
CriticalRegion(Atomic<int>& lock) : lock_(lock)
std::atomic_flag& lock_;
CriticalRegion(std::atomic_flag& lock) : lock_(lock)
{
while (true) {
if (lock == 0 && lock.swap(1) == 0) {
break;
}
while (lock.test_and_set(std::memory_order_acquire)) {
Os::yield();
}
}
~CriticalRegion()
{
lock_.storeRelease(0);
lock_.clear(std::memory_order_release);
}
} region(lock);
@@ -83,20 +75,6 @@ Runtime::init()
return true;
}
#ifdef TIMEBOMB
time_t current = time(NULL);
time_t expiration = TIMEBOMB;
if (current > expiration) {
fprintf(stderr, "Expired on %s", asctime(gmtime(&expiration)));
return false;
}
else {
fprintf(stderr, "For test only: Expires on %s",
asctime(gmtime(&expiration)));
}
#endif // TIMEBOMB
if ( !Flag::init()
|| !option::init()
|| !Device::init()