Question about BITSET_WORD

2024-08-21 Thread Christophe JAILLET

Hi,

I'm new to this list, so sorry if it is not the correct place.

I've started to looked at the source code of mesa and I wonder why in 
src/util/bitset.h we have:


#define BITSET_WORD unsigned int

This is as-is since at least 2015, probably 2011.

Would it make sense to have it as a long, at least on 64 bits arch?
(the linux kernel uses bitmaps as unsigned long)

I don't think that it should be a noticeable speed-up, but at least on 
Linux it could save some cycles when doing some OR or AND and co on 
bitmaps on a 64 bits cpu.


Just my 2c.

Christophe JAILLET


Re: Question about BITSET_WORD

2024-08-21 Thread Faith Ekstrand
I've actually benchmarked this and 32bit is still faster on many modern
CPUs.

Also, I would be very surprised if we could change it without breaking the
universe. I'm sure there are hard-coded 32s various places.

~Faith

On Wed, Aug 21, 2024 at 8:13 AM Christophe JAILLET <
christophe.jail...@wanadoo.fr> wrote:

> Hi,
>
> I'm new to this list, so sorry if it is not the correct place.
>
> I've started to looked at the source code of mesa and I wonder why in
> src/util/bitset.h we have:
>
>  #define BITSET_WORD unsigned int
>
> This is as-is since at least 2015, probably 2011.
>
> Would it make sense to have it as a long, at least on 64 bits arch?
> (the linux kernel uses bitmaps as unsigned long)
>
> I don't think that it should be a noticeable speed-up, but at least on
> Linux it could save some cycles when doing some OR or AND and co on
> bitmaps on a 64 bits cpu.
>
> Just my 2c.
>
> Christophe JAILLET
>


Re: Question about BITSET_WORD

2024-08-21 Thread Brian Paul
Maybe there should be a comment regarding the performance and risk of 
change?


-Brian

On 8/21/24 07:54, Faith Ekstrand wrote:
I've actually benchmarked this and 32bit is still faster on many 
modern CPUs.


Also, I would be very surprised if we could change it without breaking 
the universe. I'm sure there are hard-coded 32s various places.


~Faith

On Wed, Aug 21, 2024 at 8:13 AM Christophe JAILLET 
 wrote:


Hi,

I'm new to this list, so sorry if it is not the correct place.

I've started to looked at the source code of mesa and I wonder why in
src/util/bitset.h we have:

     #define BITSET_WORD unsigned int

This is as-is since at least 2015, probably 2011.

Would it make sense to have it as a long, at least on 64 bits arch?
(the linux kernel uses bitmaps as unsigned long)

I don't think that it should be a noticeable speed-up, but at
least on
Linux it could save some cycles when doing some OR or AND and co on
bitmaps on a 64 bits cpu.

Just my 2c.

Christophe JAILLET



--
This electronic communication and the information and any files transmitted 
with it, or attached to it, are confidential and are intended solely for 
the use of the individual or entity to whom it is addressed and may contain 
information that is confidential, legally privileged, protected by privacy 
laws, or otherwise restricted from disclosure to anyone else. If you are 
not the intended recipient or the person responsible for delivering the 
e-mail to the intended recipient, you are hereby notified that any use, 
copying, distributing, dissemination, forwarding, printing, or copying of 
this e-mail is strictly prohibited. If you received this e-mail in error, 
please return the e-mail to the sender, delete it from your computer, and 
destroy any printed copy of it.


Re: Question about BITSET_WORD

2024-08-21 Thread Marek Olšák
All 32-bit operations are generally faster than 64-bit. If both happen
to have the same performance per clock (that would have to be a
deliberate hw design choice), 32-bit opcodes have likely lower power
consumption, which allows a higher core frequency.

That doesn't even scratch the surface. Explaining exactly why some
instructions are faster or slower would require detailed hw specs.

Marek

On Wed, Aug 21, 2024 at 10:05 AM Faith Ekstrand  wrote:
>
> I've actually benchmarked this and 32bit is still faster on many modern CPUs.
>
> Also, I would be very surprised if we could change it without breaking the 
> universe. I'm sure there are hard-coded 32s various places.
>
> ~Faith
>
> On Wed, Aug 21, 2024 at 8:13 AM Christophe JAILLET 
>  wrote:
>>
>> Hi,
>>
>> I'm new to this list, so sorry if it is not the correct place.
>>
>> I've started to looked at the source code of mesa and I wonder why in
>> src/util/bitset.h we have:
>>
>>  #define BITSET_WORD unsigned int
>>
>> This is as-is since at least 2015, probably 2011.
>>
>> Would it make sense to have it as a long, at least on 64 bits arch?
>> (the linux kernel uses bitmaps as unsigned long)
>>
>> I don't think that it should be a noticeable speed-up, but at least on
>> Linux it could save some cycles when doing some OR or AND and co on
>> bitmaps on a 64 bits cpu.
>>
>> Just my 2c.
>>
>> Christophe JAILLET