1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26#ifndef __DML_INLINE_DEFS_H__
27#define __DML_INLINE_DEFS_H__
28
29#include "dml_common_defs.h"
30#include "../calcs/dcn_calc_math.h"
31#include "dml_logger.h"
32
33static inline double dml_min(double a, double b)
34{
35 return (double) dcn_bw_min2(a, b);
36}
37
38static inline double dml_min3(double a, double b, double c)
39{
40 return dml_min(dml_min(a, b), c);
41}
42
43static inline double dml_min4(double a, double b, double c, double d)
44{
45 return dml_min(dml_min(a, b), dml_min(c, d));
46}
47
48static inline double dml_max(double a, double b)
49{
50 return (double) dcn_bw_max2(a, b);
51}
52
53static inline double dml_max3(double a, double b, double c)
54{
55 return dml_max(dml_max(a, b), c);
56}
57
58static inline double dml_max4(double a, double b, double c, double d)
59{
60 return dml_max(dml_max(a, b), dml_max(c, d));
61}
62
63static inline double dml_max5(double a, double b, double c, double d, double e)
64{
65 return dml_max(dml_max4(a, b, c, d), e);
66}
67
68static inline double dml_ceil(double a, double granularity)
69{
70 return (double) dcn_bw_ceil2(a, granularity);
71}
72
73static inline double dml_floor(double a, double granularity)
74{
75 return (double) dcn_bw_floor2(a, granularity);
76}
77
78static inline int dml_log2(double x)
79{
80 return dml_round((double)dcn_bw_log(x, 2));
81}
82
83static inline double dml_pow(double a, int exp)
84{
85 return (double) dcn_bw_pow(a, exp);
86}
87
88static inline double dml_fmod(double f, int val)
89{
90 return (double) dcn_bw_mod(f, val);
91}
92
93static inline double dml_ceil_2(double f)
94{
95 return (double) dcn_bw_ceil2(f, 2);
96}
97
98static inline double dml_ceil_ex(double x, double granularity)
99{
100 return (double) dcn_bw_ceil2(x, granularity);
101}
102
103static inline double dml_floor_ex(double x, double granularity)
104{
105 return (double) dcn_bw_floor2(x, granularity);
106}
107
108static inline double dml_log(double x, double base)
109{
110 return (double) dcn_bw_log(x, base);
111}
112
113static inline unsigned int dml_round_to_multiple(unsigned int num,
114 unsigned int multiple,
115 bool up)
116{
117 unsigned int remainder;
118
119 if (multiple == 0)
120 return num;
121
122 remainder = num % multiple;
123
124 if (remainder == 0)
125 return num;
126
127 if (up)
128 return (num + multiple - remainder);
129 else
130 return (num - remainder);
131}
132#endif
133