From 9dade23425db89385f57e77e3b535b6848e5bddb 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/hip commit: b12c53ccebb6c13fcc89426428ef85bfe4929a0c] --- projects/hip/tests/src/runtimeApi/memory/hipMemcpy.cpp | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/projects/hip/tests/src/runtimeApi/memory/hipMemcpy.cpp b/projects/hip/tests/src/runtimeApi/memory/hipMemcpy.cpp index 208f263ab5..5c21be4acf 100644 --- a/projects/hip/tests/src/runtimeApi/memory/hipMemcpy.cpp +++ b/projects/hip/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 29ca9f7d537a7de57a491cfe52620be87f67b1e1 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/hip commit: 12634879e24b61751f22f84727f04bff35b17d26] --- projects/hip/tests/src/runtimeApi/memory/hipMemcpy.cpp | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/projects/hip/tests/src/runtimeApi/memory/hipMemcpy.cpp b/projects/hip/tests/src/runtimeApi/memory/hipMemcpy.cpp index 5c21be4acf..411aec3645 100644 --- a/projects/hip/tests/src/runtimeApi/memory/hipMemcpy.cpp +++ b/projects/hip/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 6015efe6f5caf8169ecd779f91cae5f0dd23c496 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/hip commit: bf3df9d7c06428f474b9a97aa519e4bbf681c044] --- projects/hip/tests/src/runtimeApi/memory/hipMemcpy.cpp | 4 ++++ 1 file changed, 4 insertions(+) diff --git a/projects/hip/tests/src/runtimeApi/memory/hipMemcpy.cpp b/projects/hip/tests/src/runtimeApi/memory/hipMemcpy.cpp index 411aec3645..2d03b95e0f 100644 --- a/projects/hip/tests/src/runtimeApi/memory/hipMemcpy.cpp +++ b/projects/hip/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); }