Morpheus 1.0.0
Dynamic matrix type and algorithms for sparse matrices
Loading...
Searching...
No Matches
Morpheus_Utils_Impl.hpp
1
24#ifndef MORPHEUS_IMPL_DIA_UTILS_IMPL_HPP
25#define MORPHEUS_IMPL_DIA_UTILS_IMPL_HPP
26
27#include <Morpheus_Macros.hpp>
28
29namespace Morpheus {
30namespace Impl {
31
32// Calculates padding to align the data based on the current length
33template <typename T>
34MORPHEUS_INLINE_FUNCTION const T get_pad_size(T len, T alignment) {
35 return alignment * ((len + alignment - 1) / alignment);
36}
37
47template <typename T>
48bool exceeds_tolerance(const T num_rows, const T num_entries,
49 const T num_diagonals) {
50 const float max_fill = 10.0;
51 const float threshold = 100e6; // 10M entries
52 const float size = float(num_diagonals) * float(num_rows);
53 const float fill_ratio = size / std::max(1.0f, float(num_entries));
54
55 bool res = false;
56 if (fill_ratio > max_fill && size > threshold) {
57 res = true;
58 }
59
60 return res;
61}
62
63} // namespace Impl
64} // namespace Morpheus
65
66#endif // MORPHEUS_IMPL_DIA_UTILS_IMPL_HPP
Generic Morpheus interfaces.
Definition: dummy.cpp:24