View Single Post
Old 2009-03-13, 12:19   #1
fivemack
(loop (#_fork))
 
fivemack's Avatar
 
Feb 2006
Cambridge, England

638210 Posts
Default SIMD string->int

I'm sure there are people here who like useless exercises in SIMD assembly language.

The exercise: how fast can you perform atoi?

Specifically, let char* A point to a list of a million 0x0a-separated positive integers written out in decimal, each of 15 or fewer digits. Output the result of XORing the numbers together. libc is about 650 cycles per number on K8; this must be beatable!

For an easier case, let XMM0 contain something of the form

'3' '1' '4' '1' '5' '9' ':' '2' '7' '1' '8' '2' '8' '1' '8' ',' '8'

and return 314159.

For an even easier case, let XMM0 contain something of the form above, and do the right-justification to return

'0' '0' '0' '0' '0' '0' '0' '0' '0' '0' '3' '1' '4' '1' '5' '9'

in as few cycles as you can.
fivemack is offline   Reply With Quote