From d2be30f0e0114f1e62fca47595404ffad434c423 Mon Sep 17 00:00:00 2001 From: Vladislav Sytchenko Date: Wed, 11 Dec 2019 20:21:12 -0500 Subject: [PATCH 1/3] Reduce the amount of free host memory to 40% of what is reported on Windows, otherwise we can run into OOM situations. [ROCm/clr commit: 282367ed6db79eaedbe3389ffd17a255750d8a74] --- projects/clr/hipamd/tests/src/runtimeApi/memory/hipMemcpy.cpp | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/projects/clr/hipamd/tests/src/runtimeApi/memory/hipMemcpy.cpp b/projects/clr/hipamd/tests/src/runtimeApi/memory/hipMemcpy.cpp index 208f263ab5..5c21be4acf 100644 --- a/projects/clr/hipamd/tests/src/runtimeApi/memory/hipMemcpy.cpp +++ b/projects/clr/hipamd/tests/src/runtimeApi/memory/hipMemcpy.cpp @@ -292,8 +292,8 @@ void memcpytest2_get_host_memory(size_t& free, size_t& total) { MEMORYSTATUSEX status; status.dwLength = sizeof(status); GlobalMemoryStatusEx(&status); - free = status.ullAvailPhys; - total = status.ullTotalPhys; + free = (0.4 * status.ullAvailPhys); + total = (0.4 * status.ullTotalPhys); } #else struct sysinfo memInfo; From 014f068e2fef01a91abbb7d37d50180bd0014a14 Mon Sep 17 00:00:00 2001 From: Vladislav Sytchenko Date: Fri, 13 Dec 2019 21:37:30 -0500 Subject: [PATCH 2/3] Add explicit cast when computing the available amount of system memory. [ROCm/clr commit: 4c21eed68b9e6ec9afb5e741418fae91d3cbcd9d] --- projects/clr/hipamd/tests/src/runtimeApi/memory/hipMemcpy.cpp | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/projects/clr/hipamd/tests/src/runtimeApi/memory/hipMemcpy.cpp b/projects/clr/hipamd/tests/src/runtimeApi/memory/hipMemcpy.cpp index 5c21be4acf..411aec3645 100644 --- a/projects/clr/hipamd/tests/src/runtimeApi/memory/hipMemcpy.cpp +++ b/projects/clr/hipamd/tests/src/runtimeApi/memory/hipMemcpy.cpp @@ -292,8 +292,8 @@ void memcpytest2_get_host_memory(size_t& free, size_t& total) { MEMORYSTATUSEX status; status.dwLength = sizeof(status); GlobalMemoryStatusEx(&status); - free = (0.4 * status.ullAvailPhys); - total = (0.4 * status.ullTotalPhys); + free = static_cast(0.4 * status.ullAvailPhys); + total = static_cast(0.4 * status.ullTotalPhys); } #else struct sysinfo memInfo; From dc12f8017e3b8841ace5182f1140490761179a12 Mon Sep 17 00:00:00 2001 From: Vladislav Sytchenko Date: Fri, 13 Dec 2019 21:38:27 -0500 Subject: [PATCH 3/3] Add comments explaining choice on the cap for system memory on Windows. [ROCm/clr commit: a91bafca40fad853045ed96b980a751f1222a1b0] --- projects/clr/hipamd/tests/src/runtimeApi/memory/hipMemcpy.cpp | 4 ++++ 1 file changed, 4 insertions(+) diff --git a/projects/clr/hipamd/tests/src/runtimeApi/memory/hipMemcpy.cpp b/projects/clr/hipamd/tests/src/runtimeApi/memory/hipMemcpy.cpp index 411aec3645..2d03b95e0f 100644 --- a/projects/clr/hipamd/tests/src/runtimeApi/memory/hipMemcpy.cpp +++ b/projects/clr/hipamd/tests/src/runtimeApi/memory/hipMemcpy.cpp @@ -292,6 +292,10 @@ void memcpytest2_get_host_memory(size_t& free, size_t& total) { MEMORYSTATUSEX status; status.dwLength = sizeof(status); GlobalMemoryStatusEx(&status); + // Windows doesn't allow allocating more than half of system memory to the gpu. + // Since the runtime also needs space for its internal allocations, + // we should not try to allocate more than 40% of reported system memory, + // otherwise we can run into OOM issues. free = static_cast(0.4 * status.ullAvailPhys); total = static_cast(0.4 * status.ullTotalPhys); }