Re: [Mesa-dev] [PATCH] faster util_next_power_of_two() function

2011-06-08 Thread Benjamin
2011/6/8 Chris Bandy cba...@jbandy.com On 06/08/2011 06:38 AM, Benjamin Bellec wrote: Here is the v4 patch. Benjamin As an uninformed bystander, I have some nitpicks that may just be coding style. From the patch: + if (x = 1) + return 1; I think it would make more sense

Re: [Mesa-dev] [PATCH] faster util_next_power_of_two() function

2011-06-08 Thread Chris Bandy
On 06/08/2011 06:38 AM, Benjamin Bellec wrote: Here is the v4 patch. Benjamin As an uninformed bystander, I have some nitpicks that may just be coding style. From the patch: + if (x = 1) + return 1; I think it would make more sense to move this above the #ifdef and not duplicate it

Re: [Mesa-dev] [PATCH] faster util_next_power_of_two() function

2011-06-08 Thread Roland Scheidegger
Looks ok to me. I think it might actually be ok to omit the version check, we use __builtin_popcount without it too (and that seems to be gcc 3.4 too, so presumably gcc 3.4 is a requirement). So what about __builtin_clz optimized logbase2 :-) I think that should just be 31 - __builtin_clz(n | 1)

Re: [Mesa-dev] [PATCH] faster util_next_power_of_two() function

2011-06-06 Thread Benjamin Bellec
Le 06/06/2011 17:34, Roland Scheidegger a écrit : Am 05.06.2011 03:55, schrieb Benjamin Bellec: Le 05/06/2011 03:05, Matt Turner a écrit : On Sat, Jun 4, 2011 at 7:14 PM, Benjamin Bellec b.bel...@gmail.com wrote: Le 03/06/2011 06:09, Matt Turner a écrit : Also, if you want to check if the

Re: [Mesa-dev] [PATCH] faster util_next_power_of_two() function

2011-06-06 Thread Brian Paul
On Mon, Jun 6, 2011 at 11:57 AM, Benjamin Bellec b.bel...@gmail.com wrote: Le 06/06/2011 17:34, Roland Scheidegger a écrit : Am 05.06.2011 03:55, schrieb Benjamin Bellec: Le 05/06/2011 03:05, Matt Turner a écrit : On Sat, Jun 4, 2011 at 7:14 PM, Benjamin Bellec b.bel...@gmail.com wrote: Le

Re: [Mesa-dev] [PATCH] faster util_next_power_of_two() function

2011-06-06 Thread Tormod Volden
On Sun, Jun 5, 2011 at 1:14 AM, Benjamin Bellec wrote: So here is a v2 patch with a builtin GCC optimization which is the fastest (thx Matt to point me to this solution). From patch: + return (1 (32 - __builtin_clz(x - 1))); I don't know if the use of gcc guarantees that int will

Re: [Mesa-dev] [PATCH] faster util_next_power_of_two() function

2011-06-06 Thread Roland Scheidegger
Am 06.06.2011 23:18, schrieb Tormod Volden: On Sun, Jun 5, 2011 at 1:14 AM, Benjamin Bellec wrote: So here is a v2 patch with a builtin GCC optimization which is the fastest (thx Matt to point me to this solution). From patch: + return (1 (32 - __builtin_clz(x - 1))); I don't

Re: [Mesa-dev] [PATCH] faster util_next_power_of_two() function

2011-06-05 Thread Brian Paul
On Sun, Jun 5, 2011 at 11:34 AM, Ian Romanick i...@freedesktop.org wrote: -BEGIN PGP SIGNED MESSAGE- Hash: SHA1 On 06/02/2011 04:40 PM, Brian Paul wrote: On 06/02/2011 03:18 PM, Benjamin Bellec wrote: It's me again, with a new minor optimization for the util_next_power_of_two()

Re: [Mesa-dev] [PATCH] faster util_next_power_of_two() function

2011-06-04 Thread Benjamin Bellec
Le 03/06/2011 01:40, Brian Paul a écrit : I'd like to avoid the warning if at all possible. If you replace (val 32) with (val (sizeof(unsigned) * 4)) does that silence it? Yes it fix, but as Matt Turner said, it's not necessary to check this. Btw we don't check that in the other functions.

Re: [Mesa-dev] [PATCH] faster util_next_power_of_two() function

2011-06-04 Thread Matt Turner
On Sat, Jun 4, 2011 at 7:14 PM, Benjamin Bellec b.bel...@gmail.com wrote: Le 03/06/2011 06:09, Matt Turner a écrit : Also, if you want to check if the value is already a power-of-two, instead of a case statement for every POT (including 0), just do the standard is-power-of-two check: (x (x

Re: [Mesa-dev] [PATCH] faster util_next_power_of_two() function

2011-06-04 Thread Benjamin Bellec
Le 05/06/2011 03:05, Matt Turner a écrit : On Sat, Jun 4, 2011 at 7:14 PM, Benjamin Bellec b.bel...@gmail.com wrote: Le 03/06/2011 06:09, Matt Turner a écrit : Also, if you want to check if the value is already a power-of-two, instead of a case statement for every POT (including 0), just do

[Mesa-dev] [PATCH] faster util_next_power_of_two() function

2011-06-02 Thread Benjamin Bellec
It's me again, with a new minor optimization for the util_next_power_of_two() function. This patch implements a faster algorithm, still taken from Wikipedia ( http://en.wikipedia.org/wiki/Power_of_two#Algorithm_to_round_up_to_power_of_two ). But especially, I added the most common values used by

Re: [Mesa-dev] [PATCH] faster util_next_power_of_two() function

2011-06-02 Thread Brian Paul
On 06/02/2011 03:18 PM, Benjamin Bellec wrote: It's me again, with a new minor optimization for the util_next_power_of_two() function. This patch implements a faster algorithm, still taken from Wikipedia ( http://en.wikipedia.org/wiki/Power_of_two#Algorithm_to_round_up_to_power_of_two ). But

Re: [Mesa-dev] [PATCH] faster util_next_power_of_two() function

2011-06-02 Thread Matt Turner
On Thu, Jun 2, 2011 at 5:18 PM, Benjamin Bellec b.bel...@gmail.com wrote: But there is an issue, during compilation there is an error (-Wall) warning: right shift count = width of type [enabled by default]. This doesn't make any sense since I don't think the unsigned int type is ever 8 bytes: