[Mesa-dev] [PATCH 022/140] amdgpu/addrlib: add explicit Log2NonPow2 function
Marek Olšák
maraeo at gmail.com
Mon Mar 20 22:42:32 UTC 2017
From: Roy Zhan <roy.zhan at amd.com>
---
src/amd/addrlib/core/addrcommon.h | 28 ++++++++++++++++++++--------
1 file changed, 20 insertions(+), 8 deletions(-)
diff --git a/src/amd/addrlib/core/addrcommon.h b/src/amd/addrlib/core/addrcommon.h
index 019ebd0..0dff0b8 100644
--- a/src/amd/addrlib/core/addrcommon.h
+++ b/src/amd/addrlib/core/addrcommon.h
@@ -438,48 +438,60 @@ static inline UINT_32 NextPow2(
{
newDim <<= 1;
}
}
return newDim;
}
/**
***************************************************************************************************
-* Log2
+* Log2NonPow2
*
* @brief
-* Compute log of base 2
+* Compute log of base 2 no matter the target is power of 2 or not
***************************************************************************************************
*/
-static inline UINT_32 Log2(
+static inline UINT_32 Log2NonPow2(
UINT_32 x) ///< [in] the value should calculate log based 2
{
UINT_32 y;
- //
- // Assert that x is a power of two.
- //
- ADDR_ASSERT(IsPow2(x));
-
y = 0;
while (x > 1)
{
x >>= 1;
y++;
}
return y;
}
/**
***************************************************************************************************
+* Log2
+*
+* @brief
+* Compute log of base 2
+***************************************************************************************************
+*/
+static inline UINT_32 Log2(
+ UINT_32 x) ///< [in] the value should calculate log based 2
+{
+ // Assert that x is a power of two.
+ ADDR_ASSERT(IsPow2(x));
+
+ return Log2NonPow2(x);
+}
+
+/**
+***************************************************************************************************
* QLog2
*
* @brief
* Compute log of base 2 quickly (<= 16)
***************************************************************************************************
*/
static inline UINT_32 QLog2(
UINT_32 x) ///< [in] the value should calculate log based 2
{
ADDR_ASSERT(x <= 16);
--
2.7.4
More information about the mesa-dev
mailing list