From b953979eff8471bbe72223671113f84398db0605 Mon Sep 17 00:00:00 2001
From: foreman
Date: Thu, 8 Nov 2018 15:20:47 -0500
Subject: [PATCH] P4 to Git Change 1704517 by gandryey@gera-w8 on 2018/11/08
15:15:03
SWDEV-165161 - Update OpenCL runtime to control RGP capture based on new RGP protocol.
- Added logic to control the dispatch capture frame.
Affected files ...
... //depot/stg/opencl/drivers/opencl/runtime/device/pal/palgpuopen.cpp#11 edit
... //depot/stg/opencl/drivers/opencl/runtime/device/pal/palgpuopen.hpp#8 edit
[ROCm/clr commit: c80c8964ff9ad1ee4c26d1d0cbc90073286633a2]
---
.../clr/rocclr/runtime/device/pal/palgpuopen.cpp | 11 +++++++++--
.../clr/rocclr/runtime/device/pal/palgpuopen.hpp | 13 ++++++++-----
2 files changed, 17 insertions(+), 7 deletions(-)
diff --git a/projects/clr/rocclr/runtime/device/pal/palgpuopen.cpp b/projects/clr/rocclr/runtime/device/pal/palgpuopen.cpp
index ec5b303c9b..95e84d4abd 100644
--- a/projects/clr/rocclr/runtime/device/pal/palgpuopen.cpp
+++ b/projects/clr/rocclr/runtime/device/pal/palgpuopen.cpp
@@ -40,6 +40,7 @@ RgpCaptureMgr::RgpCaptureMgr(Pal::IPlatform* platform, const Device& device)
device_(device),
dev_driver_server_(platform->GetDevDriverServer()),
num_prep_disp_(0),
+ max_sqtt_disp_(device_.settings().rgpSqttDispCount_),
trace_gpu_mem_limit_(0),
global_disp_count_(1), // Must start from 1 according to RGP spec
user_event_(nullptr),
@@ -252,7 +253,7 @@ void RgpCaptureMgr::PostDispatch(VirtualGPU* gpu)
if (trace_.status_ == TraceStatus::Running) {
amd::ScopedLock traceLock(&trace_mutex_);
trace_.sqtt_disp_count_++;
- if (trace_.sqtt_disp_count_ >= device_.settings().rgpSqttDispCount_) {
+ if (trace_.sqtt_disp_count_ >= max_sqtt_disp_) {
Pal::Result res = EndRGPHardwareTrace(gpu);
if (Pal::Result::ErrorIncompatibleQueue == res) {
// continue until we find the right queue...
@@ -440,7 +441,13 @@ Pal::Result RgpCaptureMgr::PrepareRGPTrace(VirtualGPU* gpu)
const auto traceParameters = rgp_server_->QueryTraceParameters();
- num_prep_disp_ = traceParameters.numPreparationFrames;
+ num_prep_disp_ = traceParameters.captureStartIndex;
+ uint32_t capture_disp = traceParameters.captureStopIndex - traceParameters.captureStartIndex;
+ // Validate if the captured dispatches are in the range
+ if ((capture_disp > 0) && (capture_disp < max_sqtt_disp_)) {
+ max_sqtt_disp_ = capture_disp;
+ }
+
trace_gpu_mem_limit_ = traceParameters.gpuMemoryLimitInMb * 1024 * 1024;
inst_tracing_enabled_ = traceParameters.flags.enableInstructionTokens;
diff --git a/projects/clr/rocclr/runtime/device/pal/palgpuopen.hpp b/projects/clr/rocclr/runtime/device/pal/palgpuopen.hpp
index 3bcb70679d..52789a581e 100644
--- a/projects/clr/rocclr/runtime/device/pal/palgpuopen.hpp
+++ b/projects/clr/rocclr/runtime/device/pal/palgpuopen.hpp
@@ -384,12 +384,15 @@ private:
DevDriver::RGPProtocol::RGPServer* rgp_server_;
mutable amd::Monitor trace_mutex_;
TraceState trace_;
- uint32_t num_prep_disp_;
- uint32_t trace_gpu_mem_limit_;
- uint32_t global_disp_count_;
RgpSqttMarkerUserEventWithString* user_event_;
- bool trace_enabled_; // True if tracing is currently enabled (master flag)
- bool inst_tracing_enabled_; // Enable instruction-level SQTT tokens
+
+ uint32_t num_prep_disp_;
+ uint32_t max_sqtt_disp_; // Maximum number of the dispatches allowed in the trace
+ uint32_t trace_gpu_mem_limit_;
+ uint32_t global_disp_count_;
+
+ bool trace_enabled_; // True if tracing is currently enabled (master flag)
+ bool inst_tracing_enabled_; // Enable instruction-level SQTT tokens
PAL_DISALLOW_DEFAULT_CTOR(RgpCaptureMgr);
PAL_DISALLOW_COPY_AND_ASSIGN(RgpCaptureMgr);