Last active
March 23, 2020 14:14
-
-
Save jacobkahn/487cdb58a007ef63c48a6c6869779b6a to your computer and use it in GitHub Desktop.
Updated changes for ArrayFire PR #2801
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
diff --git a/src/backend/common/DefaultMemoryManager.cpp b/src/backend/common/DefaultMemoryManager.cpp | |
index f3921a6b..0b1e44ca 100644 | |
--- a/src/backend/common/DefaultMemoryManager.cpp | |
+++ b/src/backend/common/DefaultMemoryManager.cpp | |
@@ -162,7 +162,8 @@ void* DefaultMemoryManager::alloc(bool user_lock, const unsigned ndims, | |
if (!this->debug_mode) { | |
// FIXME: Add better checks for garbage collection | |
// Perhaps look at total memory available as a metric | |
- if (getMemoryPressure() > getMemoryPressureThreshold()) { | |
+ if (current.lock_bytes >= current.max_bytes || | |
+ current.total_buffers >= this->max_buffers) { | |
this->signalMemoryCleanup(); | |
} | |
diff --git a/src/backend/cpu/queue.hpp b/src/backend/cpu/queue.hpp | |
index 92904268..1db27b24 100644 | |
--- a/src/backend/cpu/queue.hpp | |
+++ b/src/backend/cpu/queue.hpp | |
@@ -69,7 +69,7 @@ class queue { | |
#ifndef NDEBUG | |
sync(); | |
#else | |
- if (getMemoryPressure() > getMemoryPressureThreshold() || count >= 25) { | |
+ if (getMemoryPressure() >= getMemoryPressureThreshold() || count >= 25) { | |
sync(); | |
} | |
#endif | |
diff --git a/src/backend/cuda/Array.cpp b/src/backend/cuda/Array.cpp | |
index abd10435..ab1c4fe4 100644 | |
--- a/src/backend/cuda/Array.cpp | |
+++ b/src/backend/cuda/Array.cpp | |
@@ -236,7 +236,7 @@ kJITHeuristics passesJitHeuristics(Node *root_node) { | |
// A lightweight check based on the height of the node. This is an | |
// inexpensive operation and does not traverse the JIT tree. | |
if (root_node->getHeight() > 6 || | |
- getMemoryPressure() > getMemoryPressureThreshold()) { | |
+ getMemoryPressure() >= getMemoryPressureThreshold()) { | |
// The size of the parameters without any extra arguments from the | |
// JIT tree. This includes one output Param object and 4 integers. | |
constexpr size_t base_param_size = | |
diff --git a/src/backend/opencl/Array.cpp b/src/backend/opencl/Array.cpp | |
index 82f0c103..8926c95c 100644 | |
--- a/src/backend/opencl/Array.cpp | |
+++ b/src/backend/opencl/Array.cpp | |
@@ -256,7 +256,7 @@ kJITHeuristics passesJitHeuristics(Node *root_node) { | |
return kJITHeuristics::TreeHeight; | |
} | |
- bool isBufferLimit = getMemoryPressure() > getMemoryPressureThreshold(); | |
+ bool isBufferLimit = getMemoryPressure() >= getMemoryPressureThreshold(); | |
auto platform = getActivePlatform(); | |
// The Apple platform can have the nvidia card or the AMD card |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment