From 0a7709ae9eba69a9736631a186a20881b375a47a Mon Sep 17 00:00:00 2001
From: foreman
Date: Thu, 5 Apr 2018 12:17:12 -0400
Subject: [PATCH] P4 to Git Change 1537141 by gandryey@gera-w8 on 2018/04/05
11:56:20
SWDEV-149190 - [CQE OCL][DTB-BLOCKER][WIN][LNX][QR]observed soft hang while running oclruntime sub-test of ocltst due to faulty CL#1529531
- Pal::PerfExperiment can't works with extra offsets for allocations. Thus disable suballocation for the thread trace.
- Minor clean-ups: make sure the profiling end is called for threadtrace commands; call buf release on mem copy in the program loader; add comments to the scratch buffer alignment.
Affected files ...
... //depot/stg/opencl/drivers/opencl/runtime/device/pal/paldevice.cpp#80 edit
... //depot/stg/opencl/drivers/opencl/runtime/device/pal/palprogram.cpp#60 edit
... //depot/stg/opencl/drivers/opencl/runtime/device/pal/palthreadtrace.cpp#5 edit
... //depot/stg/opencl/drivers/opencl/runtime/device/pal/palvirtual.cpp#85 edit
[ROCm/clr commit: 1d972ed59a3b5c1ba2aaa9ed1e6942ea3b95d8c6]
---
projects/clr/rocclr/runtime/device/pal/paldevice.cpp | 3 ++-
projects/clr/rocclr/runtime/device/pal/palprogram.cpp | 1 +
projects/clr/rocclr/runtime/device/pal/palthreadtrace.cpp | 7 +++++--
projects/clr/rocclr/runtime/device/pal/palvirtual.cpp | 4 ++++
4 files changed, 12 insertions(+), 3 deletions(-)
diff --git a/projects/clr/rocclr/runtime/device/pal/paldevice.cpp b/projects/clr/rocclr/runtime/device/pal/paldevice.cpp
index 57a1a2131a..d4cad620ad 100644
--- a/projects/clr/rocclr/runtime/device/pal/paldevice.cpp
+++ b/projects/clr/rocclr/runtime/device/pal/paldevice.cpp
@@ -1814,7 +1814,8 @@ bool Device::allocScratch(uint regNum, const VirtualGPU* vgpu) {
scratchBuf->regNum_ * numMaxWaves * sizeof(uint32_t);
scratchBuf->size_ = std::min(scratchBuf->size_, info().maxMemAllocSize_);
scratchBuf->size_ = std::min(scratchBuf->size_, uint64_t(3 * Gi));
- scratchBuf->size_ = amd::alignUp(scratchBuf->size_, 0xFFFF);
+ // Note: Generic address space setup in HW requires 64KB alignment for scratch
+ scratchBuf->size_ = amd::alignUp(scratchBuf->size_, 64 * Ki);
scratchBuf->offset_ = offset;
size += scratchBuf->size_;
offset += scratchBuf->size_;
diff --git a/projects/clr/rocclr/runtime/device/pal/palprogram.cpp b/projects/clr/rocclr/runtime/device/pal/palprogram.cpp
index c00aa3bf14..9a841319b8 100644
--- a/projects/clr/rocclr/runtime/device/pal/palprogram.cpp
+++ b/projects/clr/rocclr/runtime/device/pal/palprogram.cpp
@@ -98,6 +98,7 @@ void Segment::copy(size_t offset, const void* src, size_t size) {
srcOffs += tmpSize;
tmpSize = std::min(static_cast(xferBuf.size()), size);
}
+ gpuAccess_->dev().xferWrite().release(gpu, xferBuf);
gpu.waitAllEngines();
}
}
diff --git a/projects/clr/rocclr/runtime/device/pal/palthreadtrace.cpp b/projects/clr/rocclr/runtime/device/pal/palthreadtrace.cpp
index 6075f689e2..b7da255341 100644
--- a/projects/clr/rocclr/runtime/device/pal/palthreadtrace.cpp
+++ b/projects/clr/rocclr/runtime/device/pal/palthreadtrace.cpp
@@ -58,8 +58,11 @@ bool PalThreadTraceReference::finalize() {
// Acquire GPU memory for the query from the pool and bind it.
Pal::GpuMemoryRequirements gpuMemReqs = {};
iPerf()->GetGpuMemoryRequirements(&gpuMemReqs);
-
- memory_ = new Memory(gpu().dev(), amd::alignUp(gpuMemReqs.size, gpuMemReqs.alignment));
+ // Note: Pal:::PerfExperiments can't apply the runtime offsets for suballocaiotns,
+ // thus disable suballocation.
+ Pal::gpusize bufSize = std::max(gpuMemReqs.size,
+ gpu_.dev().settings().subAllocationMaxSize_ + gpuMemReqs.alignment);
+ memory_ = new Memory(gpu().dev(), amd::alignUp(bufSize, gpuMemReqs.alignment));
if (nullptr == memory_) {
return false;
diff --git a/projects/clr/rocclr/runtime/device/pal/palvirtual.cpp b/projects/clr/rocclr/runtime/device/pal/palvirtual.cpp
index ea7adc98d3..31358c6aed 100644
--- a/projects/clr/rocclr/runtime/device/pal/palvirtual.cpp
+++ b/projects/clr/rocclr/runtime/device/pal/palvirtual.cpp
@@ -2427,6 +2427,8 @@ void VirtualGPU::submitThreadTraceMemObjects(amd::ThreadTraceMemObjectsCommand&
LogError("Unsupported command type for ThreadTraceMemObjects!");
break;
}
+
+ profilingEnd(cmd);
}
void VirtualGPU::submitThreadTrace(amd::ThreadTraceCommand& cmd) {
@@ -2469,6 +2471,8 @@ void VirtualGPU::submitThreadTrace(amd::ThreadTraceCommand& cmd) {
LogError("Unsupported command type for ThreadTrace!");
break;
}
+
+ profilingEnd(cmd);
}
void VirtualGPU::submitAcquireExtObjects(amd::AcquireExtObjectsCommand& vcmd) {