SWDEV-290371 - Add lock protection for signal

Add lock protection for signal processing
If signal is reused, then disable reference to it from HIP
Increase the pool signal size to 32

Change-Id: I7d529b35910f83ce577c9eca6d3386759611ccc0
This commit is contained in:
German Andryeyev
2021-06-10 14:49:14 -04:00
committed by Maneesh Gupta
parent 0af6ba9428
commit a1629cad26
2 changed files with 16 additions and 5 deletions
+11 -3
View File
@@ -109,12 +109,14 @@ static unsigned extractAqlBits(unsigned v, unsigned pos, unsigned width) {
};
// ================================================================================================
void Timestamp::checkGpuTime() {
void Timestamp::checkGpuTime(bool event_recycle) {
if (HwProfiling()) {
uint64_t start = std::numeric_limits<uint64_t>::max();
uint64_t end = 0;
for (auto it : signals_) {
amd::ScopedLock lock(it->LockSignalOps());
// Ignore the wait if runtime processes API callback, because the signal value is bigger
// than expected and the value reset will occur after API callback is done
if (GetCallbackSignal().handle == 0) {
@@ -138,6 +140,10 @@ void Timestamp::checkGpuTime() {
ClPrint(amd::LOG_INFO, amd::LOG_SIG, "Signal = (0x%lx), start = %ld, "
"end = %ld", it->signal_.handle, start, end);
}
// The signal is reused and the upper layer can't rely on it.
if (event_recycle) {
const_cast<amd::Command&>(it->ts_->command_).SetHwEvent(nullptr);
}
it->ts_ = nullptr;
it->done_ = true;
}
@@ -325,7 +331,7 @@ VirtualGPU::HwQueueTracker::~HwQueueTracker() {
// ================================================================================================
bool VirtualGPU::HwQueueTracker::Create() {
constexpr size_t kSignalListSize = 16;
constexpr size_t kSignalListSize = 32;
signal_list_.resize(kSignalListSize);
hsa_agent_t agent = gpu_.gpu_device();
@@ -475,11 +481,13 @@ std::vector<hsa_signal_t>& VirtualGPU::HwQueueTracker::WaitingSignal(HwQueueEngi
// ================================================================================================
bool VirtualGPU::HwQueueTracker::CpuWaitForSignal(ProfilingSignal* signal) {
amd::ScopedLock lock(signal->LockSignalOps());
// Wait for the current signal
if (!signal->done_) {
// Update timestamp values if requested
if (signal->ts_ != nullptr) {
signal->ts_->checkGpuTime();
static constexpr bool kEventRecycle = true;
signal->ts_->checkGpuTime(kEventRecycle);
} else {
ClPrint(amd::LOG_DEBUG, amd::LOG_COPY, "[%zx]!\t Host wait on completion_signal=0x%zx",
std::this_thread::get_id(), signal->signal_.handle);