SMAUG
Simulating Machine Learning Applications on gem5-Aladdin
Macros
Common math functions in Aladdin

Macros for computing the min/max of a group of elements. More...

Macros

#define max2(A, B)   (((A) > (B)) ? (A) : (B))
 
#define max3(e0, e1, e2)   max2(max2(e0, e1), e2)
 
#define max4(e0, e1, e2, e3)   max2(max2(e0, e1), max2(e2, e3))
 
#define max8(e0, e1, e2, e3, e4, e5, e6, e7)   max2(max4(e0, e1, e2, e3), max4(e4, e5, e6, e7))
 
#define max9(e0, e1, e2, e3, e4, e5, e6, e7, e8)   max2(max8(e0, e1, e2, e3, e4, e5, e6, e7), e8)
 
#define min2(A, B)   (((A) < (B)) ? (A) : (B))
 
#define FRAC_CEIL(A, B)   ((A) / (B) + ((A) % (B) != 0))
 Implements the ceiling function of A/B.
 

Detailed Description

Macros for computing the min/max of a group of elements.

Why macros and not functions (or a loop)? A loop takes O(n) cycles to compute the maximum, when it could be done in O(log n) time with a tree based implementation. But Aladdin regards function calls as a hard dependency that it does not optimize across, so we would not get the parallelism we expect from the tree. Thus, these are best expressed as macros.