Removing ATT buffer size limitation (#534)

* Removing SQTT buffer size limitation

* Update source/lib/rocprofiler-sdk/thread_trace/core.cpp

* Added testing for buffer size. Formatting.

* Add test as unstable

* Increase default buffer size

* Apply suggestions from code review

Co-authored-by: Indic, Vladimir <Vladimir.Indic@amd.com>

* Fix typo from code review

* Update tests/thread-trace/agent.cpp

---------

Co-authored-by: Giovanni <gbaraldi@amd.com>
Co-authored-by: Indic, Vladimir <Vladimir.Indic@amd.com>

[ROCm/rocprofiler-sdk commit: 1ba08cd4df]
This commit is contained in:
Baraldi, Giovanni
2025-07-29 22:47:40 +02:00
committed by GitHub
parent fe6cfc9cc8
commit b30a084da2
8 changed files with 53 additions and 23 deletions
@@ -47,19 +47,16 @@ dispatch_tracing_callback(rocprofiler_callback_tracing_record_t record,
assert(record.payload);
auto* rdata = static_cast<rocprofiler_callback_tracing_kernel_dispatch_data_t*>(record.payload);
int dispatch_id = (int) rdata->dispatch_info.dispatch_id;
auto dispatch_id = rdata->dispatch_info.dispatch_id;
auto get_int_var = [](const char* var_name, int def) {
const char* var = getenv(var_name);
if(var) return atoi(var);
return def;
};
static int begin_dispatch = get_int_var("ROCPROFILER_THREAD_TRACE_BEGIN", 1);
static int end_dispatch = get_int_var("ROCPROFILER_THREAD_TRACE_END", 4);
// Choose two dispatches to begin(6) and end(10) the trace
constexpr uint64_t begin_dispatch = 6;
constexpr uint64_t end_dispatch = 10;
static std::atomic<bool> isprofiling{false};
static std::atomic<bool> stop_profiling{false};
static std::mutex mut;
static std::set<int> captured_ids;
static std::mutex mut{};
static std::set<int> captured_ids{};
if(record.phase == ROCPROFILER_CALLBACK_PHASE_ENTER)
{
@@ -73,6 +70,7 @@ dispatch_tracing_callback(rocprofiler_callback_tracing_record_t record,
std::unique_lock<std::mutex> lk(mut);
captured_ids.insert(dispatch_id);
}
if(dispatch_id > end_dispatch) stop_profiling.store(true);
return;
}
@@ -82,7 +80,7 @@ dispatch_tracing_callback(rocprofiler_callback_tracing_record_t record,
std::unique_lock<std::mutex> lk(mut);
captured_ids.erase(dispatch_id);
if(!captured_ids.empty()) return;
if(!captured_ids.empty() || stop_profiling == false) return;
bool _exp = true;
if(!isprofiling.compare_exchange_strong(_exp, false, std::memory_order_relaxed)) return;
@@ -104,11 +102,15 @@ query_available_agents(rocprofiler_agent_version_t /* version */,
const auto* agent = static_cast<const rocprofiler_agent_v0_t*>(agents[idx]);
if(agent->type != ROCPROFILER_AGENT_TYPE_GPU) continue;
// Check if we are testing for large buffers
static const char* var = getenv("ATT_BUFFER_SIZE_MB");
static uint64_t buffer_size_mb = (var ? atoi(var) : 96) * 1024ul * 1024ul;
std::vector<rocprofiler_thread_trace_parameter_t> parameters;
parameters.push_back({ROCPROFILER_THREAD_TRACE_PARAMETER_TARGET_CU, 1});
parameters.push_back({ROCPROFILER_THREAD_TRACE_PARAMETER_SIMD_SELECT, 0xF});
parameters.push_back({ROCPROFILER_THREAD_TRACE_PARAMETER_BUFFER_SIZE, 0x6000000});
parameters.push_back({ROCPROFILER_THREAD_TRACE_PARAMETER_SHADER_ENGINE_MASK, 0x11});
parameters.push_back({ROCPROFILER_THREAD_TRACE_PARAMETER_BUFFER_SIZE, buffer_size_mb});
parameters.push_back({ROCPROFILER_THREAD_TRACE_PARAMETER_SHADER_ENGINE_MASK, 0x1});
parameters.push_back({ROCPROFILER_THREAD_TRACE_PARAMETER_SERIALIZE_ALL, 0});
ROCPROFILER_CALL(