aboutsummaryrefslogtreecommitdiff
path: root/arm_compute/core/CPP
diff options
context:
space:
mode:
authorPablo Tello <pablo.tello@arm.com>2018-10-24 15:32:39 +0100
committerGeorgios Pinitas <georgios.pinitas@arm.com>2018-11-09 17:04:04 +0000
commit0cf77981fadb883b97efec112e115450873e64c3 (patch)
tree42592f5dd8721ab8337059df3861e1e2b849399d /arm_compute/core/CPP
parent283fc606dbd9058f636b91350a1c47b97aba1a87 (diff)
downloadComputeLibrary-0cf77981fadb883b97efec112e115450873e64c3.tar.gz
COMPMID-1626: Fixed VGG 16/19 bad_alloc failure.
Some systems don't have enough memory to run the VGG networks, for example on systems with only 2GB memory the VGG example fails throwing a bad_alloc exception. This patch introduces the concept of global memory policy in ACL, the policy is a mechanism which could be used by the library's functions to try to reduce memory consumption on systems with limited memory. In this specific case the VGG examples set the policy to MINIMIZE. The GEMM function checks if the policy is MINIMIZE and in this case does not use the pretransposed weights path as this requires considerable more memory. Change-Id: I53abc3c9c64d045d8306793ffc9d24b28e228b7b
Diffstat (limited to 'arm_compute/core/CPP')
-rw-r--r--arm_compute/core/CPP/CPPTypes.h41
1 files changed, 41 insertions, 0 deletions
diff --git a/arm_compute/core/CPP/CPPTypes.h b/arm_compute/core/CPP/CPPTypes.h
index 9ffb4840a3..0ac8bf6e52 100644
--- a/arm_compute/core/CPP/CPPTypes.h
+++ b/arm_compute/core/CPP/CPPTypes.h
@@ -26,6 +26,7 @@
#include "arm_compute/core/Error.h"
+#include <array>
#include <string>
#include <vector>
@@ -46,6 +47,19 @@ enum class CPUModel
A55r1
};
+/** Global memory policy.
+ * The functions in the runtime will use different strategies based on the policy currently set.
+ *
+ * MINIMIZE will try to reduce the amount allocated by the functions at the expense of performance normally.
+ * NORMAL won't try to save any memory and will favor speed over memory consumption
+ *
+ */
+enum class MemoryPolicy
+{
+ MINIMIZE,
+ NORMAL
+};
+
/** Convert a cpumodel value to a string
*
* @param val CPUModel value to be converted
@@ -180,6 +194,33 @@ private:
unsigned int _L2_cache_size = 262144;
};
+class MEMInfo final
+{
+public:
+ MEMInfo();
+
+ /** Return the total amount of RAM memory in the system expressed in KB.
+ *
+ * @return Total memory
+ */
+ size_t get_total_in_kb() const;
+
+ static void set_policy(MemoryPolicy policy);
+ static MemoryPolicy get_policy();
+
+ /** Common memory sizes expressed in Kb to avoid having them
+ * duplicated throughout the code.
+ */
+ static const size_t ONE_GB_IN_KB = { 1035842 };
+ static const size_t TWO_GB_IN_KB = { ONE_GB_IN_KB * 2 };
+
+private:
+ size_t _total;
+ size_t _free;
+ size_t _buffer;
+ static MemoryPolicy _policy;
+};
+
/** Information about executing thread and CPU. */
struct ThreadInfo
{