Bitband performance?

Status
Not open for further replies.

potatotron

Well-known member
Has anyone ever tested twiddling bits in the RAM via the bitband addresses? Instead of doing things like ORing and ANDing masks like

Code:
	for (mask = (1<<23) ; mask ; mask >>= 1) {
		if (color & mask) {
			*p++ |= bit;
		} else {
			*p++ &= ~bit;
		}

would it be faster to do something like

Code:
	for (mask = (1<<23) ; mask ; mask >>= 1) {
                *p++ = (color & mask) ? 1 : 0;
		}

If nobody's looked into this I will test it this weekend and report back. Thanks in advance.
 
Just in case anybody's wondering I'm abandoning this test…I didn't read the spec sheet very well…

DMA memory has to be in lower memory (SRAM_L) but only the upper memory (SRAM_U) is mapped via bitband.

Back to the drawing board…
 
DMA can access either half of the memory. The lower half is usually more efficient (less likely to conflict and add a wait state), because the ARM core frequently accesses the upper half where the stack is located.

I'm curious if the bitband feature is more efficient, and if so by how much. I'm guessing it should be, but the truth is I've never tried really measuring.

The huge advantage of the bitband is that it's guaranteed atomic. Even DMA isn't supposed to be able to catch the intermediate value, since the hardware is supposed to do the read-modify-write all as a single indivisible bus operation. Of course, I haven't really tested that either, it's merely my understanding from reading ARM's documentation.
 
Status
Not open for further replies.
Back
Top