diff options
author | Georgios Pinitas <georgios.pinitas@arm.com> | 2018-06-18 18:13:51 +0100 |
---|---|---|
committer | Anthony Barbier <anthony.barbier@arm.com> | 2018-11-02 16:53:20 +0000 |
commit | 17b12307edeaf488cfdf0cc3fa00b8f08293c93e (patch) | |
tree | d7025d84a03d9897b4811ade16a2a1952bdb09c4 /arm_compute/core | |
parent | 09b19129b65c5b8d1ca1c3851bab919bb9b7e1a1 (diff) | |
download | ComputeLibrary-17b12307edeaf488cfdf0cc3fa00b8f08293c93e.tar.gz |
COMPMID-1293: Handle aligned allocations
Change-Id: I6e642c8cd968240f883c327464519e57e5d0c3e3
Reviewed-on: https://eu-gerrit-1.euhpc.arm.com/136088
Tested-by: Jenkins <bsgcomp@arm.com>
Reviewed-by: Anthony Barbier <anthony.barbier@arm.com>
Diffstat (limited to 'arm_compute/core')
-rw-r--r-- | arm_compute/core/utils/misc/Utility.h | 24 |
1 files changed, 21 insertions, 3 deletions
diff --git a/arm_compute/core/utils/misc/Utility.h b/arm_compute/core/utils/misc/Utility.h index f30a417a09..a2784a2fc0 100644 --- a/arm_compute/core/utils/misc/Utility.h +++ b/arm_compute/core/utils/misc/Utility.h @@ -165,15 +165,33 @@ std::vector<size_t> sort_indices(const std::vector<T> &v) return idx; } -inline bool endswith(const std::string &filename, const std::string &suffix) +/** Checks if a string contains a given suffix + * + * @param[in] str Input string + * @param[in] suffix Suffix to check for + * + * @return True if the string ends with the given suffix else false + */ +inline bool endswith(const std::string &str, const std::string &suffix) { - if(filename.size() < suffix.size()) + if(str.size() < suffix.size()) { return false; } - return std::equal(suffix.rbegin(), suffix.rend(), filename.rbegin()); + return std::equal(suffix.rbegin(), suffix.rend(), str.rbegin()); } +/** Checks if a pointer complies with a given alignment + * + * @param[in] ptr Pointer to check + * @param[in] alignment Alignment value + * + * @return True if the pointer is aligned else false + */ +inline bool check_aligned(void *ptr, const size_t alignment) +{ + return (reinterpret_cast<std::uintptr_t>(ptr) % alignment) == 0; +} } // namespace utility } // namespace arm_compute #endif /* __ARM_COMPUTE_MISC_UTILITY_H__ */ |