[racket-dev] speeding up 16-bit integer adds
On Sep 23, 2010, at 9:46 PM, John Clements wrote:
>
> On Sep 23, 2010, at 8:16 PM, Matthew Flatt wrote:
>
>> One more thought: Do you get to pick whether you use 16-bit integers or
>> 64-bit floating-point numbers? The `flvector-' and `f64vector-'
>> operations are inlined by the JIT and recognized for unboxing, so using
>> flonum vectors and operations could be much faster than using raw
>> pointers and 16-bit integers.
>
> Well, that's an option, albeit a somewhat unappetizing one; as the 44100 in my code no doubt signaled, I'm reading and writing sound data here, and both 16-bit ints and 32-bit floats are fairly common. 64-bit floats will be another factor of 2 in memory, for a total of 42 megabytes per minute.
>
> I ran some tests, using flvectors and unsafe operations everywhere. (Code below.)
Update before going to bed; re-running the C tests with doubles everywhere and the same setup (simply adding together two big buffers) took about half a second, so in fact in this instance Racket is less that 10x slower, which is as fast as I would expect it to be. So basically, it sounds like the flvectors are the way to go, if I can stomach the memory usage.
Thanks again,
John
-------------- next part --------------
A non-text attachment was scrubbed...
Name: smime.p7s
Type: application/pkcs7-signature
Size: 4669 bytes
Desc: not available
URL: <http://lists.racket-lang.org/dev/archive/attachments/20100923/3189b748/attachment.p7s>