Re: Bitwise OR on large memory regions
oswald.kluge@web.de wrote:
what efficient ways are there to OR two large memory regions?
I'm especially interested in applying this operation to two
large character arrays. I know memset and memcopy lets you
initialise or copy this arrays very fast, but are there
similar functions for bitwise OR?
The obvious solution is std::transform. For some strange
reason, there is no or operator in the objects in <functional>,
but it should be no problem to come up with one.
If for some reason this isn't fast enough, then you'll have to
look for special tricks. If the arrays are always word aligned,
and a multiple of bytes in word in length, reinterpret_cast'ing
the char* to word* (where word is unsigned or unsigned long),
and using transform on the words, could help. And if you really
need speed, a lot of machines have graphic cards with
specialized processors just for this sort of thing; *IF* you can
access the card (and that's a big if), offloading the work to it
could result in a big gain. (There's some sort of special DLL
for this under Windows, I think. I don't know much about it,
but I know that every time my son installs a game on his Windows
machine, it asks if he wants to update this DLL as well.)
--
James Kanze GABI Software
Conseils en informatique orient?e objet/
Beratung in objektorientierter Datenverarbeitung
9 place S?mard, 78210 St.-Cyr-l'?cole, France, +33 (0)1 30 23 00 34
[ See http://www.gotw.ca/resources/clcm.htm for info about ]
[ comp.lang.c++.moderated. First time posters: Do this! ]