DCGPUBU-44: Added arbitrary envvars to file/dir names. Squashed some fixes.

- Added arbitrary env-vars
- Fixed some UBs with atomic variables
- Fixed loading of file plugin
- ATT vs. kernel-trace off by one

Change-Id: I69c75f66f722e4085b5279f41afd05813628846d
Este commit está contenido en:
Giovanni LB
2023-08-15 14:50:29 -03:00
padre 06cd40d7ab
commit 157eacd2bb
Se han modificado 11 ficheros con 94 adiciones y 140 borrados
+3 -3
Ver fichero
@@ -37,7 +37,7 @@ GenericBuffer::GenericBuffer(rocprofiler_session_id_t session_id, rocprofiler_bu
id_(id),
flush_function_(flush_function),
session_id_(session_id) {
if (!is_valid_.load(std::memory_order_release)) {
if (!is_valid_.load(std::memory_order_acquire)) {
// Pool definition: The memory pool is split in 2 buffers of equal size. When
// first initialized, the write pointer points to the first element of the
// first buffer. When a buffer is full, or when Flush() is called, the write
@@ -67,7 +67,7 @@ GenericBuffer::GenericBuffer(rocprofiler_session_id_t session_id, rocprofiler_bu
}
GenericBuffer::~GenericBuffer() {
if (is_valid_.load(std::memory_order_release)) {
if (is_valid_.load(std::memory_order_acquire)) {
std::lock_guard lock(buffer_lock_);
// if (rocprofiler::GetROCProfiler_Singleton()->GetSession(session_id_))
// rocprofiler::GetROCProfiler_Singleton()->GetSession(session_id_)->DisableTools(id_);
@@ -175,7 +175,7 @@ rocprofiler_session_id_t GenericBuffer::GetSessionId() {
return rocprofiler_session_id_t{0};
}
bool GenericBuffer::IsValid() { return is_valid_.load(std::memory_order_release); }
bool GenericBuffer::IsValid() { return is_valid_.load(std::memory_order_acquire); }
rocprofiler_buffer_id_t GenericBuffer::GetId() {
if (is_valid_) return id_;
+17 -17
Ver fichero
@@ -51,34 +51,34 @@ Session::~Session() {
{
std::lock_guard<std::mutex> lock(session_lock_);
if (FindFilterWithKind(ROCPROFILER_SPM_COLLECTION) && spmcounter_ &&
spm_started_.load(std::memory_order_release)) {
spm_started_.load(std::memory_order_acquire)) {
delete spmcounter_;
}
if (FindFilterWithKind(ROCPROFILER_API_TRACE) && tracer_ &&
tracer_started_.load(std::memory_order_release)) {
tracer_started_.load(std::memory_order_acquire)) {
delete tracer_;
tracer_started_.exchange(false, std::memory_order_release);
}
if (FindFilterWithKind(ROCPROFILER_PC_SAMPLING_COLLECTION) && pc_sampler_ &&
pc_sampler_started_.load(std::memory_order_release)) {
pc_sampler_started_.load(std::memory_order_acquire)) {
delete pc_sampler_;
pc_sampler_started_.exchange(false, std::memory_order_release);
}
if (FindFilterWithKind(ROCPROFILER_COUNTERS_SAMPLER) && counters_sampler_ &&
counters_sampler_started_.load(std::memory_order_release)) {
counters_sampler_started_.load(std::memory_order_acquire)) {
delete counters_sampler_;
counters_sampler_started_.exchange(false, std::memory_order_release);
}
if ((FindFilterWithKind(ROCPROFILER_DISPATCH_TIMESTAMPS_COLLECTION) ||
FindFilterWithKind(ROCPROFILER_COUNTERS_COLLECTION)) &&
profiler_ && profiler_started_.load(std::memory_order_release)) {
profiler_ && profiler_started_.load(std::memory_order_acquire)) {
rocprofiler::queue::ResetSessionID();
delete profiler_;
profiler_started_.exchange(false, std::memory_order_release);
}
if (FindFilterWithKind(ROCPROFILER_ATT_TRACE_COLLECTION) && att_tracer_ &&
att_tracer_started_.load(std::memory_order_release)) {
att_tracer_started_.load(std::memory_order_acquire)) {
delete att_tracer_;
att_tracer_started_.exchange(false, std::memory_order_release);
}
@@ -107,7 +107,7 @@ void Session::DisableTools(rocprofiler_buffer_id_t buffer_id) {
if (FindFilterWithKind(ROCPROFILER_API_TRACE) &&
GetFilter(GetFilterIdWithKind(ROCPROFILER_API_TRACE))->GetBufferId().value ==
buffer_id.value) {
if (tracer_started_.load(std::memory_order_release)) {
if (tracer_started_.load(std::memory_order_acquire)) {
tracer_->DisableRoctracer();
}
}
@@ -116,7 +116,7 @@ void Session::DisableTools(rocprofiler_buffer_id_t buffer_id) {
void Session::Start() {
std::lock_guard<std::mutex> lock(session_lock_);
if (!is_active_) {
if (!profiler_started_.load(std::memory_order_release)) {
if (!profiler_started_.load(std::memory_order_acquire)) {
if (FindFilterWithKind(ROCPROFILER_DISPATCH_TIMESTAMPS_COLLECTION)) {
profiler_ = new profiler::Profiler(
GetFilter(GetFilterIdWithKind(ROCPROFILER_DISPATCH_TIMESTAMPS_COLLECTION))
@@ -136,7 +136,7 @@ void Session::Start() {
rocprofiler::queue::ResetSessionID(session_id_);
}
if (FindFilterWithKind(ROCPROFILER_ATT_TRACE_COLLECTION)) {
if (!att_tracer_started_.load(std::memory_order_release)) {
if (!att_tracer_started_.load(std::memory_order_acquire)) {
att_tracer_ = new att::AttTracer(
GetFilter(GetFilterIdWithKind(ROCPROFILER_ATT_TRACE_COLLECTION))->GetBufferId(),
GetFilter(GetFilterIdWithKind(ROCPROFILER_ATT_TRACE_COLLECTION))->GetId(), session_id_);
@@ -145,7 +145,7 @@ void Session::Start() {
}
if (FindFilterWithKind(ROCPROFILER_SPM_COLLECTION)) {
if (!spm_started_.load(std::memory_order_release)) {
if (!spm_started_.load(std::memory_order_acquire)) {
rocprofiler_spm_parameter_t* spmparameter =
GetFilter(GetFilterIdWithKind(ROCPROFILER_SPM_COLLECTION))->GetSpmParameterData();
spmcounter_ = new spm::SpmCounters(
@@ -153,7 +153,7 @@ void Session::Start() {
GetFilter(GetFilterIdWithKind(ROCPROFILER_SPM_COLLECTION))->GetId(), spmparameter,
session_id_);
}
if (!profiler_started_.load(std::memory_order_release)) {
if (!profiler_started_.load(std::memory_order_acquire)) {
profiler_ = new profiler::Profiler(
GetFilter(GetFilterIdWithKind(ROCPROFILER_SPM_COLLECTION))->GetBufferId(),
GetFilter(GetFilterIdWithKind(ROCPROFILER_SPM_COLLECTION))->GetId(), session_id_);
@@ -165,7 +165,7 @@ void Session::Start() {
if (FindFilterWithKind(ROCPROFILER_API_TRACE)) {
std::vector<rocprofiler_tracer_activity_domain_t> domains =
GetFilter(GetFilterIdWithKind(ROCPROFILER_API_TRACE))->GetTraceData();
if (!tracer_started_.load(std::memory_order_release)) {
if (!tracer_started_.load(std::memory_order_acquire)) {
tracer_ = new tracer::Tracer(
session_id_,
(GetFilter(GetFilterIdWithKind(ROCPROFILER_API_TRACE))->HasCallback()
@@ -178,7 +178,7 @@ void Session::Start() {
}
if (FindFilterWithKind(ROCPROFILER_PC_SAMPLING_COLLECTION)) {
if (!pc_sampler_started_.load(std::memory_order_release)) {
if (!pc_sampler_started_.load(std::memory_order_acquire)) {
pc_sampler_ = new pc_sampler::PCSampler(
GetFilter(GetFilterIdWithKind(ROCPROFILER_PC_SAMPLING_COLLECTION))->GetBufferId(),
GetFilter(GetFilterIdWithKind(ROCPROFILER_PC_SAMPLING_COLLECTION))->GetId(),
@@ -189,7 +189,7 @@ void Session::Start() {
}
if (FindFilterWithKind(ROCPROFILER_COUNTERS_SAMPLER)) {
if (!counters_sampler_started_.load(std::memory_order_release)) {
if (!counters_sampler_started_.load(std::memory_order_acquire)) {
counters_sampler_ = new CountersSampler(
GetFilter(GetFilterIdWithKind(ROCPROFILER_COUNTERS_SAMPLER))->GetBufferId(),
GetFilter(GetFilterIdWithKind(ROCPROFILER_COUNTERS_SAMPLER))->GetId(), session_id_);
@@ -214,18 +214,18 @@ void Session::Terminate() {
if (FindFilterWithKind(ROCPROFILER_API_TRACE)) {
std::vector<rocprofiler_tracer_activity_domain_t> domains =
GetFilter(GetFilterIdWithKind(ROCPROFILER_API_TRACE))->GetTraceData();
if (tracer_started_.load(std::memory_order_release)) {
if (tracer_started_.load(std::memory_order_acquire)) {
tracer_->StopRoctracer();
}
}
if (FindFilterWithKind(ROCPROFILER_PC_SAMPLING_COLLECTION)) {
if (pc_sampler_started_.load(std::memory_order_release)) {
if (pc_sampler_started_.load(std::memory_order_acquire)) {
pc_sampler_->Stop();
}
}
if (FindFilterWithKind(ROCPROFILER_COUNTERS_SAMPLER)) {
if (counters_sampler_started_.load(std::memory_order_release)) {
if (counters_sampler_started_.load(std::memory_order_acquire)) {
counters_sampler_->Stop();
}
}
+4 -4
Ver fichero
@@ -67,7 +67,7 @@ std::mutex processQueueLock;
// rocprofiler_status_t SetDestBuffer(hsa_agent_t GPUNode, uint32_t size, uint32_t timeout) {
// rocprofiler_status_t ret;
// uint32_t idx = currIndex.load(std::memory_order_release);
// uint32_t idx = currIndex.load(std::memory_order_acquire);
// if (size) {
// // Check if user buffer in using
// if (spm_buffer_params[idx].addr != NULL) {
@@ -97,7 +97,7 @@ std::mutex processQueueLock;
// }
// if (spm_buffer_params[idx].data_loss) std::cout << "Data Loss" << std::endl;
// if (spm_buffer_params[idx].len) {
// uint32_t pidx = preIndex.load(std::memory_order_release);
// uint32_t pidx = preIndex.load(std::memory_order_acquire);
// if (spm_buffer_params[idx].len == spm_buffer_params[pidx].size) {
// std::cout << "Buffer completely filled with bytes" << spm_buffer_params[idx].len <<
// std::endl; fd = fopen("SPM_rocprofiler_data.txt", "wb"); size_t retele =
@@ -121,8 +121,8 @@ std::mutex processQueueLock;
// void spmBufferSetup(hsa_agent_t GPUNode) {
// rocprofiler_status_t ret;
// if (is_started.load(std::memory_order_release)) {
// uint32_t idx = currIndex.load(std::memory_order_release);
// if (is_started.load(std::memory_order_acquire)) {
// uint32_t idx = currIndex.load(std::memory_order_acquire);
// ret = SetDestBuffer(GPUNode, spm_buffer_params[idx].size, spm_buffer_params[idx].timeout);
// if (ret != ROCPROFILER_STATUS_SUCCESS) {
// std::cout << "Fail to set Dest Buf 2 "
+4 -4
Ver fichero
@@ -46,14 +46,14 @@ Tracer::Tracer(rocprofiler_session_id_t session_id, rocprofiler_sync_callback_t
rocprofiler_buffer_id_t buffer_id,
std::vector<rocprofiler_tracer_activity_domain_t> domains)
: domains_(domains), callback_(callback), buffer_id_(buffer_id), session_id_(session_id) {
assert(!is_active_.load(std::memory_order_release) && "Error: The tracer was initialized!");
assert(!is_active_.load(std::memory_order_acquire) && "Error: The tracer was initialized!");
std::lock_guard<std::mutex> lock(tracer_lock_);
callback_data_ = api_callback_data_t{callback, session_id};
is_active_.exchange(true, std::memory_order_release);
}
void Tracer::StartRoctracer() {
if (!roctracer_initiated_.load(std::memory_order_release)) {
if (!roctracer_initiated_.load(std::memory_order_acquire)) {
std::map<rocprofiler_tracer_activity_domain_t, is_filtered_domain_t> domains_filteration_map;
// TODO(aelwazir): get filter property and parse it here
for (auto& domain : domains_) {
@@ -68,7 +68,7 @@ void Tracer::StartRoctracer() {
}
void Tracer::StopRoctracer() {
if (roctracer_initiated_.load(std::memory_order_release)) roctracer_stop();
if (roctracer_initiated_.load(std::memory_order_acquire)) roctracer_stop();
}
void Tracer::DisableRoctracer() {
@@ -105,7 +105,7 @@ void Tracer::DisableRoctracer() {
}
Tracer::~Tracer() {
assert(is_active_.load(std::memory_order_release) && "Error: The tracer was not initialized!");
assert(is_active_.load(std::memory_order_acquire) && "Error: The tracer was not initialized!");
std::lock_guard<std::mutex> lock(tracer_lock_);
is_active_.exchange(false, std::memory_order_release);