From 37d6bf11f4ca5c71123c80c733f4bb856701a6df Mon Sep 17 00:00:00 2001
From: foreman
Date: Fri, 8 Sep 2017 18:03:23 -0400
Subject: [PATCH] P4 to Git Change 1456988 by gandryey@gera-w8 on 2017/09/08
17:48:25
SWDEV-129129 - [[CQE OCL][Vega vs Fiji] Upto 12% Performance drop observed on VEGA10 compared to FIJI while running BlackMagic Davinci Resolve
- Force tiny read_only buffers into USWC memory. That will avoid expensive tiny data uploads, which occur every frame.
Affected files ...
... //depot/stg/opencl/drivers/opencl/runtime/device/pal/paldevice.cpp#59 edit
... //depot/stg/opencl/drivers/opencl/runtime/utils/flags.hpp#278 edit
[ROCm/clr commit: caa25fc792817a7180c25be51a2f0c287254d08c]
---
projects/clr/rocclr/runtime/device/pal/paldevice.cpp | 6 ++++++
projects/clr/rocclr/runtime/utils/flags.hpp | 2 ++
2 files changed, 8 insertions(+)
diff --git a/projects/clr/rocclr/runtime/device/pal/paldevice.cpp b/projects/clr/rocclr/runtime/device/pal/paldevice.cpp
index 03750a6254..1d4a24d4b2 100644
--- a/projects/clr/rocclr/runtime/device/pal/paldevice.cpp
+++ b/projects/clr/rocclr/runtime/device/pal/paldevice.cpp
@@ -1228,6 +1228,12 @@ pal::Memory* Device::createBuffer(amd::Memory& owner, bool directAccess) const {
? Resource::Remote
: Resource::Local;
+ // Check if runtime can force a tiny buffer into USWC memory
+ if ((size <= (GPU_MAX_REMOTE_MEM_SIZE * Ki)) && (type == Resource::Local) &&
+ (owner.getMemFlags() & CL_MEM_READ_ONLY)) {
+ type = Resource::RemoteUSWC;
+ }
+
if (owner.getMemFlags() & CL_MEM_BUS_ADDRESSABLE_AMD) {
type = Resource::BusAddressable;
} else if (owner.getMemFlags() & CL_MEM_EXTERNAL_PHYSICAL_AMD) {
diff --git a/projects/clr/rocclr/runtime/utils/flags.hpp b/projects/clr/rocclr/runtime/utils/flags.hpp
index 88ba4b50aa..9d0858ecdb 100644
--- a/projects/clr/rocclr/runtime/utils/flags.hpp
+++ b/projects/clr/rocclr/runtime/utils/flags.hpp
@@ -187,6 +187,8 @@ release(bool, OCL_STUB_PROGRAMS, false, \
"1 = Enables OCL programs stubing") \
release(bool, GPU_ANALYZE_HANG, false, \
"1 = Enables GPU hang analysis") \
+release(uint, GPU_MAX_REMOTE_MEM_SIZE, 2, \
+ "Maximum size (in Ki) that allows device memory substitution with system") \
release_on_stg(uint, GPU_WAVE_LIMIT_CU_PER_SH, 0, \
"Assume the number of CU per SH for wave limiter") \
release_on_stg(uint, GPU_WAVE_LIMIT_MAX_WAVE, 10, \