News:

Masm32 SDK description, downloads and other helpful links
Message to All Guests
NB: Posting URL's See here: Posted URL Change

Main Menu

SIMD Real4 to ASCII string routine

Started by Siekmanski, September 28, 2018, 07:58:04 AM

Previous topic - Next topic

Siekmanski

Wrote a Real4 to ASCII string routine.
It checks floating-point exceptions and sends messages if they occur

edit: See Reply #23 for comments http://masm32.com/board/index.php?topic=7441.msg81609#msg81609

If you spot something stupid or find optimizations please tell me.  :idea:

SIMD Real4 to ASCII conversion by Siekmanski 2018.

1000000 calls per Run for the Cycle counter and the Routine timer.

Intel(R) Core(TM) i7-4930K CPU @ 3.40GHz

Routine timers starting now....

Real4_2_ASCII Cycles: 69 RoutineTime: 0.022400193 seconds
sprintf       Cycles: 1955 RoutineTime: 0.600757429 seconds

Result Real4_2_ASCII:  1.234567e+14
Result sprintf      : 1.234567e+014




EDIT: Latest source code (october 11 2018):
Creative coders use backward thinking techniques as a strategy.

LiaoMi

Hi Siekmanski,

cool implementation, thanks!


SIMD Real4 to ASCII conversion by Siekmanski 2018.

1000000 calls per Run for the Cycle counter and the Routine timer.

Intel(R) Core(TM) i7-4810MQ CPU @ 2.80GHz

Routine timers starting now....

Real4_2_ASCII Cycles: 263 RoutineTime: 0.094416496 seconds
sprintf       Cycles: 1052 RoutineTime: 0.376839394 seconds

Result Real4_2_ASCII: -0.12345670
Result sprintf      : -0.123457

Press any key to continue...

jj2007

Timings for the i7's little brother:
Intel(R) Core(TM) i5-2450M CPU @ 2.50GHz

Routine timers starting now....

Real4_2_ASCII Cycles: 302 RoutineTime: 0.128082656 seconds
sprintf       Cycles: 1328 RoutineTime: 0.513514157 seconds

Siekmanski

Minor correction in the source code, wrong character was send to the string when correcting the rounding.  :lol: :lol:
New source code posted in original post.
Creative coders use backward thinking techniques as a strategy.

HSE

Very nice  :t


SIMD Real4 to ASCII conversion by Siekmanski 2018.

1000000 calls per Run for the Cycle counter and the Routine timer.

AMD A6-3500 APU with Radeon(tm) HD Graphics

Routine timers starting now....

Real4_2_ASCII Cycles: 802 RoutineTime: 0.391841977 seconds
sprintf       Cycles: 1602 RoutineTime: 0.771314581 seconds

Result Real4_2_ASCII: -0.12345675
Result sprintf      : -0.123457

Press any key to continue...
Equations in Assembly: SmplMath

Mikl__

Hi, Siekmanski!
SIMD Real4 to ASCII conversion by Siekmanski 2018.

1000000 calls per Run for the Cycle counter and the Routine timer.

Intel(R) Core(TM) i3-4330 CPU @ 3.50GHz

Routine timers starting now....

Real4_2_ASCII Cycles: 327 RoutineTime: 0.094714404 seconds
sprintf       Cycles: 1308 RoutineTime: 0.374306773 seconds

Result Real4_2_ASCII: -0.12345675
Result sprintf      : -0.123457

Press any key to continue...

HSE

Almost thinking :biggrin:

How much difference result because the algorithm and how much because the function is inside a system dll?
Equations in Assembly: SmplMath

FORTRANS

Hi,

   A mixed set of results.

{P-III}
= = =
SIMD Real4 to ASCII conversion by Siekmanski 2018.

1000000 calls per Run for the Cycle counter and the Routine timer.

????

Routine timers starting now....

{Illegal Instruction Occured.}
= = =
SIMD Real4 to ASCII conversion by Siekmanski 2018.

1000000 calls per Run for the Cycle counter and the Routine timer.

Intel(R) Pentium(R) M processor 1.70GHz

Routine timers starting now....

Real4_2_ASCII Cycles: 1249 RoutineTime: 0.741747624 seconds
sprintf       Cycles: 3200 RoutineTime: 1.885160265 seconds

Result Real4_2_ASCII: -0.12345675
Result sprintf      : -0.123457

Press any key to continue...
= = =
SIMD Real4 to ASCII conversion by Siekmanski 2018.

1000000 calls per Run for the Cycle counter and the Routine timer.

Intel(R) Core(TM) i3-4005U CPU @ 1.70GHz

Routine timers starting now....

Real4_2_ASCII Cycles: 338 RoutineTime: 0.196068641 seconds
sprintf       Cycles: 1449 RoutineTime: 0.906805013 seconds

Result Real4_2_ASCII: -0.12345675
Result sprintf      : -0.123457

Press any key to continue...


   Except not a cursor key apparently.

HTH,

Steve N.

RuiLoureiro

Hi Siekmanski,
                     Good job! Seems to work fine  :t
                     But rounding seems to be always 5: 0 is 0.00000005
                     It should be 0 or 0.0000000 ?
                     Dont post my results P4 is too old! :biggrin:

Siekmanski

Thanks guys,   :biggrin:

The rounding problem is solved, I will post the new sources in about a few hours and maybe it is now 32 times faster then sprintf, stay tuned.  :t
Creative coders use backward thinking techniques as a strategy.

RuiLoureiro

Quote from: Siekmanski on September 29, 2018, 01:02:40 AM
Thanks guys,   :biggrin:

The rounding problem is solved, I will post the new sources in about a few hours and maybe it is now 32 times faster then sprintf, stay tuned.  :t
Well, you may call it Real4_3_ASCII, Real4_4_ASCII... to say version3, version4,... we may follow it easily. Is only one idea :t

LATER: if the result is 0 the routine should print 0.0000000 ? If it is 0.1 should print 0.1000000 ?

Siekmanski

Massive improvement in speed and precision.
Got new logic insight in the algorithm, when reading the routine notes again, which I wrote on paper first.  :idea:
Now it is +/- 50 times faster than sprintf.  :eusa_dance:

New source code uploaded in the first post.
Creative coders use backward thinking techniques as a strategy.

HSE

Only 41 times!

SIMD Real4 to ASCII conversion by Siekmanski 2018.

1000000 calls per Run for the Cycle counter and the Routine timer.

AMD A6-3500 APU with Radeon(tm) HD Graphics

Routine timers starting now....

Real4_2_ASCII Cycles: 49 RoutineTime: 0.026793207 seconds
sprintf       Cycles: 2017 RoutineTime: 1.048435206 seconds

Result Real4_2_ASCII:  1.6777216
Result sprintf      : 1.677722

Press any key to continue...
Equations in Assembly: SmplMath

LiaoMi


SIMD Real4 to ASCII conversion by Siekmanski 2018.

1000000 calls per Run for the Cycle counter and the Routine timer.

Intel(R) Core(TM) i7-4810MQ CPU @ 2.80GHz

Routine timers starting now....

Real4_2_ASCII Cycles: 24 RoutineTime: 0.010178617 seconds
sprintf       Cycles: 1239 RoutineTime: 0.439053661 seconds

Result Real4_2_ASCII:  1.6777216
Result sprintf      : 1.677722

Press any key to continue...

RuiLoureiro

#14
 :biggrin:
Hi Siekmanski,
                      The rounding problem is not solved yet: all strings end in 5 starting with 0 that gives 0.00000005 which is not zero. -333.3 gives -333.20995 (only 3 digits are correct) i dont know why. -99999999.9 gives -0000000/5.
0.00000001  gives  0.00000005
0.000000001 gives 0.0000000<<< the same and the same for 2,3,4,5,6,7,8,9.