creation fix
Change-Id: I717d96555677664ce0a926cf1c3c3c48f55287d9
[ROCm/rocprofiler commit: 1ed97815f1]
Este commit está contenido en:
@@ -368,11 +368,11 @@ hsa_status_t hsa_amd_memory_async_copy_rect_interceptor(
|
||||
rocprofiler_properties_t rocprofiler_properties;
|
||||
uint32_t SqttProfile::output_buffer_size_ = 0x2000000; // 32M
|
||||
bool SqttProfile::output_buffer_local_ = true;
|
||||
Tracker* Tracker::instance_ = NULL;
|
||||
std::atomic<Tracker*> Tracker::instance_{};
|
||||
Tracker::mutex_t Tracker::glob_mutex_;
|
||||
Tracker::counter_t Tracker::counter_ = 0;
|
||||
util::Logger::mutex_t util::Logger::mutex_;
|
||||
util::Logger* util::Logger::instance_ = NULL;
|
||||
std::atomic<util::Logger*> util::Logger::instance_{};
|
||||
}
|
||||
|
||||
///////////////////////////////////////////////////////////////////////////////////////////////////
|
||||
|
||||
@@ -66,13 +66,19 @@ class Tracker {
|
||||
|
||||
static Tracker* Create() {
|
||||
std::lock_guard<mutex_t> lck(glob_mutex_);
|
||||
if (instance_ == NULL) instance_ = new Tracker;
|
||||
return instance_;
|
||||
Tracker* obj = instance_.load(std::memory_order_relaxed);
|
||||
if (obj == NULL) {
|
||||
obj = new Tracker;
|
||||
if (obj == NULL) EXC_ABORT(HSA_STATUS_ERROR, "Tracker creation failed");
|
||||
instance_.store(obj, std::memory_order_release);
|
||||
}
|
||||
return obj;
|
||||
}
|
||||
|
||||
static Tracker& Instance() {
|
||||
if (instance_ == NULL) instance_ = Create();
|
||||
return *instance_;
|
||||
Tracker* obj = instance_.load(std::memory_order_acquire);
|
||||
if (obj == NULL) obj = Create();
|
||||
return *obj;
|
||||
}
|
||||
|
||||
static void Destroy() {
|
||||
@@ -261,7 +267,7 @@ class Tracker {
|
||||
}
|
||||
|
||||
// instance
|
||||
static Tracker* instance_;
|
||||
static std::atomic<Tracker*> instance_;
|
||||
static mutex_t glob_mutex_;
|
||||
static counter_t counter_;
|
||||
|
||||
|
||||
@@ -76,8 +76,16 @@ class Logger {
|
||||
|
||||
static Logger* Create() {
|
||||
std::lock_guard<mutex_t> lck(mutex_);
|
||||
if (instance_ == NULL) instance_ = new Logger();
|
||||
return instance_;
|
||||
Logger* obj = instance_.load(std::memory_order_relaxed);
|
||||
if (obj == NULL) {
|
||||
obj = new Logger();
|
||||
if (obj == NULL) {
|
||||
std::cerr << "ROCProfiler: log object creation failed" << std::endl << std::flush;
|
||||
abort();
|
||||
}
|
||||
instance_.store(obj, std::memory_order_release);
|
||||
}
|
||||
return obj;
|
||||
}
|
||||
|
||||
static void Destroy() {
|
||||
@@ -87,8 +95,9 @@ class Logger {
|
||||
}
|
||||
|
||||
static Logger& Instance() {
|
||||
Create();
|
||||
return *instance_;
|
||||
Logger* obj = instance_.load(std::memory_order_acquire);
|
||||
if (obj == NULL) obj = Create();
|
||||
return *obj;
|
||||
}
|
||||
|
||||
private:
|
||||
@@ -179,10 +188,10 @@ class Logger {
|
||||
bool messaging_;
|
||||
bool error_;
|
||||
std::string session_dir_;
|
||||
std::map<uint32_t, std::string> message_;
|
||||
|
||||
static mutex_t mutex_;
|
||||
static Logger* instance_;
|
||||
std::map<uint32_t, std::string> message_;
|
||||
static std::atomic<Logger*> instance_;
|
||||
};
|
||||
|
||||
} // namespace util
|
||||
|
||||
Referencia en una nueva incidencia
Block a user