Hi,

I?m not new here, I just lost my old account, but I haven't wrote much anyway. Done some reading, though.
Here is a small class for bitfield handling, for the cases where memory usage is important.
Of couse it's slower than accessing field bytewise, but for larger ones it may be suitable.
I've wrapped it in a class to become familiar with OOP in Asm. Maybe I'll get lucky and get some responses
on style and other stuff.

Greetings and hello,
Godzilla3000
Attachments:
Posted on 2007-06-22 10:58:15 by Godzilla3000
Wouldn't it be better to use dwords instead of bytes as bit-containers?
Posted on 2007-06-22 21:23:29 by Ultrano

Wouldn't it be better to use dwords instead of bytes as bit-containers?

Definitely, and even better to use qwords if you've got a 64-bit machine, but I'm guessing that your question was rhetorical anyway.  ;)

Plus, if you align them to 16 bytes (128 bits), you can use SSE for completely clearing them faster or for doing operations between two sets of bits much faster.  You can get the extra cache line and pairing performance on those operations too if you align to 64 bytes and do 4 SSE instructions at a time.

Cheers!
Posted on 2007-06-23 04:13:20 by hackulous
Thanks for your responses, they were very helpful. I will put them in code as soon as I get
some grip on SSE-Instructions. The suggestion concerning the usage of dwords is easier to implement,
so I'll work on that earlier.

Greetz
Posted on 2007-06-23 09:17:04 by Godzilla3000

I will put them in code as soon as I get some grip on SSE-Instructions. The suggestion concerning the usage of dwords is easier to implement, so I'll work on that earlier.

Don't worry too much about the SSE stuff unless you really want to learn it, 'cause it is more complicated.  It took me a while to learn how to use it, and longer to learn how to use it well.

Best of luck to ya!  :)
Posted on 2007-06-24 03:36:32 by hackulous
Well, don't worry about SSE unless you have huge bitfields that you want to clear :)
Posted on 2007-06-24 08:21:47 by f0dder

Well, don't worry about SSE unless you have huge bitfields that you want to clear :)

That is quite a good point.  You probably wouldn't be using these bitfields for the kinds of applications that'd make it be a bottleneck anyway.  There are algorithms where SSE really speeds up the loads of intense bitfield operations they use, but you'd probably want custom inlined stuff in those cases anyway, and they're not the types of algorithms you'd see in most everyday applications.  NP-hard graph algorithms just aren't something you find everywhere.

It is nonetheless neat that you can pretty much operate on 512 bits in parallel if you organize the SSE code just right, but it's likely useless if you've got less than 512 bits to operate on. Even with 1024 bits, it may or may not be a useful improvement for algorithms that aren't really straining the CPU.
Posted on 2007-06-24 23:02:40 by hackulous