Speed hack dirty?

Tim Rowledge rowledge at interval.com
Tue Jan 20 20:00:41 UTC 1998


On Tue 20 Jan, John-Reed Maffeo wrote:

> > Just another thought though - if you have a large number of
values to do the same ro
> tate to, it might work to use bitblt!
> 
> Tim,
> 
> For thoses of us who don't have a clue what you are talking about,
would you
> please elaborate?
Assuming you refer mainly to the BitBLt comment:-
the code presented previously to do the rotate was something like
(hyper simplified)
a := word bitShift: x1.
b:=  word bitShift: 31 -x1.
word := a bitOr: b.
Now if you have many words that you want to do this same thing to you
can put them all in a wordArray, fudge together a form to hold this
array and pretend it is a Form. If you then do a bitblt to copy from
the source to a temp form 'a', shifting by x1, then another to create
the 'b' equivalent shifting by (31-x1), then bitblt them together,
you will have done the whole array in one big chunk.

Pugh & LaLonde used this sort of trickery to do fast flaot array
operations in an old JOOP issue. It's a bit like having some APL
available. Maybe somebody has a fuller reference to offer? Chances
are good that the code is out there on a webpage somewhere.

Probably you would only really win for largeish arrays, if you had
the words in an array already, and if you really do have to do the
same rotate for every word. The setup costs of the blit could
overwhelm small numbers of otherwise inefficient looking prim calls.

-- 
Useful random insult:- Evidence for the theory of a missing link.
Tim Rowledge:  rowledge at interval.com (w)  +1 (650) 856-7230 (w)
 tim at sumeru.stanford.edu (h)  <http://sumeru.stanford.edu/tim>





More information about the Squeak-dev mailing list