Author Topic: SIMD Real4 to ASCII string routine  (Read 4519 times)

Siekmanski

  • Member
  • *****
  • Posts: 2274
SIMD Real4 to ASCII string routine
« on: September 28, 2018, 07:58:04 AM »
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:

Code: [Select]
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):
« Last Edit: October 12, 2018, 08:04:10 AM by Siekmanski »
Creative coders use backward thinking techniques as a strategy.

LiaoMi

  • Member
  • ****
  • Posts: 697
Re: SIMD Real4 to ASCII string routine
« Reply #1 on: September 28, 2018, 08:27:46 AM »
Hi Siekmanski,

cool implementation, thanks!

Code: [Select]
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

  • Member
  • *****
  • Posts: 10446
  • Assembler is fun ;-)
    • MasmBasic
Re: SIMD Real4 to ASCII string routine
« Reply #2 on: September 28, 2018, 08:35:24 AM »
Timings for the i7's little brother:
Code: [Select]
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

  • Member
  • *****
  • Posts: 2274
Re: SIMD Real4 to ASCII string routine
« Reply #3 on: September 28, 2018, 09:09:42 AM »
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

  • Member
  • *****
  • Posts: 1345
  • <AMD>< 7-32>
Re: SIMD Real4 to ASCII string routine
« Reply #4 on: September 28, 2018, 09:38:31 AM »
Very nice  :t

Code: [Select]
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...

Mikl__

  • Member
  • ****
  • Posts: 980
Re: SIMD Real4 to ASCII string routine
« Reply #5 on: September 28, 2018, 05:40:38 PM »
Hi, Siekmanski!
Code: [Select]
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

  • Member
  • *****
  • Posts: 1345
  • <AMD>< 7-32>
Re: SIMD Real4 to ASCII string routine
« Reply #6 on: September 28, 2018, 10:19:54 PM »
Almost thinking :biggrin:

How much difference result because the algorithm and how much because the function is inside a system dll?

FORTRANS

  • Member
  • *****
  • Posts: 1076
Re: SIMD Real4 to ASCII string routine
« Reply #7 on: September 28, 2018, 11:25:12 PM »
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

  • Member
  • ****
  • Posts: 819
Re: SIMD Real4 to ASCII string routine
« Reply #8 on: September 28, 2018, 11:33:59 PM »
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

  • Member
  • *****
  • Posts: 2274
Re: SIMD Real4 to ASCII string routine
« Reply #9 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
Creative coders use backward thinking techniques as a strategy.

RuiLoureiro

  • Member
  • ****
  • Posts: 819
Re: SIMD Real4 to ASCII string routine
« Reply #10 on: September 29, 2018, 01:22:35 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

  • Member
  • *****
  • Posts: 2274
Re: SIMD Real4 to ASCII string routine
« Reply #11 on: September 29, 2018, 02:51:13 AM »
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

  • Member
  • *****
  • Posts: 1345
  • <AMD>< 7-32>
Re: SIMD Real4 to ASCII string routine
« Reply #12 on: September 29, 2018, 03:25:43 AM »
Only 41 times!
Code: [Select]
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...

LiaoMi

  • Member
  • ****
  • Posts: 697
Re: SIMD Real4 to ASCII string routine
« Reply #13 on: September 29, 2018, 04:07:20 AM »
Code: [Select]
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

  • Member
  • ****
  • Posts: 819
Re: SIMD Real4 to ASCII string routine
« Reply #14 on: September 29, 2018, 04:58:01 AM »
 :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.
« Last Edit: September 29, 2018, 06:50:48 AM by RuiLoureiro »