fix instance creation

This commit is contained in:
Evgeny
2019-03-07 23:57:04 -06:00
والد b15861dcc9
کامیت 5dd9f0d9b2
2فایلهای تغییر یافته به همراه19 افزوده شده و 11 حذف شده
+17 -9
مشاهده پرونده
@@ -43,9 +43,13 @@ class HipLoader : protected Loader {
typedef decltype(hipKernelNameRef) KernelNameRef_t;
static HipLoader& Instance() {
std::lock_guard<mutex_t> lck(mutex_);
if (instance_ == NULL) {
instance_ = new HipLoader();
HipLoader* obj = instance_.load(std::memory_order_acquire);
if (obj == NULL) {
std::lock_guard<mutex_t> lck(mutex_);
if (instance_.load(std::memory_order_relaxed) == NULL) {
obj = new HipLoader();
instance_.store(obj, std::memory_order_release);
}
}
return *instance_;
}
@@ -65,7 +69,7 @@ class HipLoader : protected Loader {
KernelNameRef_t* KernelNameRef;
private:
static HipLoader* instance_;
static std::atomic<HipLoader*> instance_;
};
// HCC runtime library loader class
@@ -80,11 +84,15 @@ class HccLoader : protected Loader {
static HccLoader* GetRef() { return instance_; }
static HccLoader& Instance() {
std::lock_guard<mutex_t> lck(mutex_);
if (instance_ == NULL) {
instance_ = new HccLoader();
HccLoader* obj = instance_.load(std::memory_order_acquire);
if (obj == NULL) {
std::lock_guard<mutex_t> lck(mutex_);
if (instance_.load(std::memory_order_relaxed) == NULL) {
obj = new HccLoader();
instance_.store(obj, std::memory_order_release);
}
}
return *instance_;
return *obj;
}
HccLoader() : Loader("libmcwamp.so") {
@@ -101,7 +109,7 @@ class HccLoader : protected Loader {
GetCmdName_t* GetCmdName;
private:
static HccLoader* instance_;
static std::atomic<HccLoader*> instance_;
};
} // namespace roctracer
+2 -2
مشاهده پرونده
@@ -441,8 +441,8 @@ typedef std::recursive_mutex memory_pool_mutex_t;
memory_pool_mutex_t memory_pool_mutex;
Loader::mutex_t Loader::mutex_;
HipLoader* HipLoader::instance_;
HccLoader* HccLoader::instance_;
std::atomic<HipLoader*> HipLoader::instance_{};
std::atomic<HccLoader*> HccLoader::instance_{};
}
proxy::Tracker* proxy::Tracker::instance_ = NULL;