diff options
author | Anthony Barbier <anthony.barbier@arm.com> | 2018-02-22 15:45:35 +0000 |
---|---|---|
committer | Anthony Barbier <anthony.barbier@arm.com> | 2018-02-23 11:49:54 +0000 |
commit | 06ea048f062a50404b1b3998a61a45449c2d1f0f (patch) | |
tree | aa0dea3b0c49422538df9a5a02578b2c29e6fa67 /utils/Utils.cpp | |
parent | 292227986edb37b01061afcad6df18ba9d6ccbeb (diff) | |
download | armcl-06ea048f062a50404b1b3998a61a45449c2d1f0f.tar.gz armcl-06ea048f062a50404b1b3998a61a45449c2d1f0f.tar.bz2 armcl-06ea048f062a50404b1b3998a61a45449c2d1f0f.zip |
arm_compute v18.02
Change-Id: I7207aa488e5470f235f39b6c188b4678dc38d1a6
Diffstat (limited to 'utils/Utils.cpp')
-rw-r--r-- | utils/Utils.cpp | 36 |
1 files changed, 35 insertions, 1 deletions
diff --git a/utils/Utils.cpp b/utils/Utils.cpp index 32d5e3a6c..8a2d11814 100644 --- a/utils/Utils.cpp +++ b/utils/Utils.cpp @@ -1,5 +1,5 @@ /* - * Copyright (c) 2017, 2018 ARM Limited. + * Copyright (c) 2017-2018 ARM Limited. * * SPDX-License-Identifier: MIT * @@ -191,5 +191,39 @@ std::tuple<std::vector<unsigned long>, bool, std::string> parse_npy_header(std:: return std::make_tuple(shape, fortran_order, typestr); } + +/** This function returns the amount of memory free reading from /proc/meminfo + * + * @return The free memory in kB + */ +uint64_t get_mem_free_from_meminfo() +{ + std::string line_attribute; + std::ifstream file_meminfo("/proc/meminfo"); + + if(file_meminfo.is_open()) + { + while(!(file_meminfo >> line_attribute).fail()) + { + //Test if is the line containing MemFree + if(line_attribute == "MemFree:") + { + uint64_t mem_available; + if(!(file_meminfo >> mem_available).fail()) + { + return mem_available; + } + else + { + return 0; + } + } + // if it's not MemFree ignore rest of the line + file_meminfo.ignore(std::numeric_limits<std::streamsize>::max(), '\n'); + } + } + // Nothing found or an error during opening the file + return 0; +} } // namespace utils } // namespace arm_compute |