From b04657c1678588d1dcea87617ccaf2bd045d09e3 Mon Sep 17 00:00:00 2001
From: foreman
Date: Thu, 30 May 2019 10:28:59 -0400
Subject: [PATCH] P4 to Git Change 1789549 by
vsytchen@vsytchen-remote-ocl-win10 on 2019/05/30 10:15:29
SWDEV-188631 - Allocating large buffers produce wrong kernel result on Windows
1. Set a limit for USWC allocations to 2GB on Windows.
2. Allocations larger than the specified limit will get placed into pinned memory instead.
ReviewBoardURL = http://ocltc.amd.com/reviews/r/17407/diff/
Affected files ...
... //depot/stg/opencl/drivers/opencl/runtime/device/pal/paldevice.cpp#138 edit
... //depot/stg/opencl/drivers/opencl/runtime/utils/flags.hpp#310 edit
[ROCm/clr commit: 66cda9d97a77c2234a52e9b9232a6b59fc8b4d6e]
---
projects/clr/rocclr/runtime/device/pal/paldevice.cpp | 3 ++-
projects/clr/rocclr/runtime/utils/flags.hpp | 3 +++
2 files changed, 5 insertions(+), 1 deletion(-)
diff --git a/projects/clr/rocclr/runtime/device/pal/paldevice.cpp b/projects/clr/rocclr/runtime/device/pal/paldevice.cpp
index 3011c60b74..59721a9923 100644
--- a/projects/clr/rocclr/runtime/device/pal/paldevice.cpp
+++ b/projects/clr/rocclr/runtime/device/pal/paldevice.cpp
@@ -1511,7 +1511,8 @@ pal::Memory* Device::createBuffer(amd::Memory& owner, bool directAccess) const {
(settings().remoteAlloc_)) {
// Allocate remote memory if AHP allocation and context has just 1 device
if ((owner.getMemFlags() & CL_MEM_ALLOC_HOST_PTR) &&
- (owner.getContext().devices().size() == 1)) {
+ (owner.getContext().devices().size() == 1) &&
+ (owner.getSize() < static_cast(GPU_MAX_USWC_ALLOC_SIZE) * Mi)) {
if (owner.getMemFlags() &
(CL_MEM_READ_ONLY | CL_MEM_HOST_WRITE_ONLY | CL_MEM_HOST_NO_ACCESS)) {
// GPU will be reading from this host memory buffer,
diff --git a/projects/clr/rocclr/runtime/utils/flags.hpp b/projects/clr/rocclr/runtime/utils/flags.hpp
index 14699238a5..339e31845f 100644
--- a/projects/clr/rocclr/runtime/utils/flags.hpp
+++ b/projects/clr/rocclr/runtime/utils/flags.hpp
@@ -183,6 +183,9 @@ release(bool, GPU_ENABLE_WGP_MODE, true, \
"Enables WGP Mode in HW if available") \
release(bool, OCL_DUMP_CODE_OBJECT, false, \
"Enable dump code object") \
+release(uint, GPU_MAX_USWC_ALLOC_SIZE, 2048, \
+ "Set a limit in Mb on the maximum USWC allocation size" \
+ "-1 = No limit")
namespace amd {