Author Topic: ArcSin timings  (Read 2437 times)

jj2007

  • Member
  • *****
  • Posts: 11434
  • Assembler is fun ;-)
    • MasmBasic
ArcSin timings
« on: December 21, 2020, 11:16:57 AM »
Two algos that calculate arcsin(x) in the range x=0 ... 0.5. The first one, Arcsinus(), uses Raymond's tutorial, the second algo uses FastMath with Arcsinus() values:

Code: [Select]
FastMath ArcSin ; define a math function
  For_ fct=0.0 To 1.0 Step 0.0001
fld fct
fstp REAL10 ptr [edi]
void Arcsinus(fct)
fstp REAL10 ptr [edi+REAL10]
add edi, 2*REAL10
  Next
FastMath

May I have some timings please?

Code: [Select]
Intel(R) Core(TM) i5-2450M CPU @ 2.50GHz (SSE4)

15296   cycles for 100 * Arcsinus
1907    cycles for 100 * ArcSin

15373   cycles for 100 * Arcsinus
1899    cycles for 100 * ArcSin

15238   cycles for 100 * Arcsinus
1912    cycles for 100 * ArcSin

15206   cycles for 100 * Arcsinus
1910    cycles for 100 * ArcSin

15219   cycles for 100 * Arcsinus
1905    cycles for 100 * ArcSin

58      bytes for Arcsinus
209     bytes for ArcSin

Real8   29.99999926061033761    Arcsinus
Real8   29.99999926061034117    ArcSin

Siekmanski

  • Member
  • *****
  • Posts: 2360
Re: ArcSin timings
« Reply #1 on: December 21, 2020, 11:24:33 AM »
Code: [Select]
Intel(R) Core(TM) i7-4930K CPU @ 3.40GHz (SSE4)

18643   cycles for 100 * Arcsinus
2256    cycles for 100 * ArcSin

18636   cycles for 100 * Arcsinus
2246    cycles for 100 * ArcSin

18650   cycles for 100 * Arcsinus
2261    cycles for 100 * ArcSin

18629   cycles for 100 * Arcsinus
2255    cycles for 100 * ArcSin

18640   cycles for 100 * Arcsinus
2261    cycles for 100 * ArcSin

58      bytes for Arcsinus
209     bytes for ArcSin

Real8   29.99999926061033761    Arcsinus
Real8   29.99999926061034117    ArcSin

--- ok ---
Creative coders use backward thinking techniques as a strategy.

jj2007

  • Member
  • *****
  • Posts: 11434
  • Assembler is fun ;-)
    • MasmBasic
Re: ArcSin timings
« Reply #2 on: December 21, 2020, 11:30:13 AM »
Thanks, Marinus :thup:

I wonder why my old i5 is a tick faster... doesn't make much sense :cool:

Core i5-2450M
Core i7-4930K

Siekmanski

  • Member
  • *****
  • Posts: 2360
Re: ArcSin timings
« Reply #3 on: December 21, 2020, 04:45:32 PM »
Hi Jochen,
My system is clocked down to prevent noise, for live audio recordings.
Creative coders use backward thinking techniques as a strategy.

daydreamer

  • Member
  • *****
  • Posts: 1586
  • building nextdoor
Re: ArcSin timings
« Reply #4 on: December 21, 2020, 06:37:33 PM »
Code: [Select]
Intel(R) Core(TM) i5-7200U CPU @ 2.50GHz (SSE4)

16580   cycles for 100 * Arcsinus
1378    cycles for 100 * ArcSin

16408   cycles for 100 * Arcsinus
1378    cycles for 100 * ArcSin

16397   cycles for 100 * Arcsinus
1358    cycles for 100 * ArcSin

16463   cycles for 100 * Arcsinus
1368    cycles for 100 * ArcSin

16674   cycles for 100 * Arcsinus
1358    cycles for 100 * ArcSin

58      bytes for Arcsinus
209     bytes for ArcSin

Real8   29.99999926061033761    Arcsinus
Real8   29.99999926061034117    ArcSin

-
also wonder how the oldschool raycasting optimization stand compared to this:an arccos LUT? :biggrin:

I have a general SSE trigo PROC thats untested,just input 4 floats and offset value that controls which set of constants it points to it,so it become different taylor series


@Marinus
I thought you underclock it because it would be a bigger challenge to optimize it to run on slower cpu :badgrin:
AMIGA clock speed today would really challenging :biggrin:
SIMD fan and macro fan
why assembly is fastest is because its switch has no (brakes) breaks
:P

Siekmanski

  • Member
  • *****
  • Posts: 2360
Re: ArcSin timings
« Reply #5 on: December 21, 2020, 10:47:47 PM »
@Magnus
Still miss the Amiga days, banging directly to the hardware was a lot of fun.
Creative coders use backward thinking techniques as a strategy.

HSE

  • Member
  • *****
  • Posts: 1650
  • <AMD>< 7-32>
Re: ArcSin timings
« Reply #6 on: December 22, 2020, 12:21:51 AM »
 :biggrin: What its ArcSinInit's timing?

jj2007

  • Member
  • *****
  • Posts: 11434
  • Assembler is fun ;-)
    • MasmBasic
Re: ArcSin timings
« Reply #7 on: December 22, 2020, 12:50:55 AM »
:biggrin: What its ArcSinInit's timing?

Test yourself - it might be enough for a coffee break, who knows? :biggrin:

ArcSinInit:
NanoTimer()
FastMath ArcSin        ; define a math function
  For_ fct=0.0 To 1.0 Step 0.0001
        fld fct
        fstp REAL10 ptr [edi]
        void Arcsinus(fct)
        fstp REAL10 ptr [edi+REAL10]
        add edi, 2*REAL10
  Next
FastMath
PrintLine NanoTimer$(), " for initialising the ArcSin macro"
retn

HSE

  • Member
  • *****
  • Posts: 1650
  • <AMD>< 7-32>
Re: ArcSin timings
« Reply #8 on: December 22, 2020, 01:05:42 AM »
Test yourself - it might be enough for a coffee break, who knows? :biggrin:

I tried previously but I have a little crash related with memory allocation  :biggrin:

jj2007

  • Member
  • *****
  • Posts: 11434
  • Assembler is fun ;-)
    • MasmBasic
Re: ArcSin timings
« Reply #9 on: December 22, 2020, 02:36:31 AM »
Post the exe, I am curious

TouEnMasm

  • Member
  • *****
  • Posts: 1647
    • EditMasm
Re: ArcSin timings
« Reply #10 on: December 22, 2020, 03:26:26 AM »
Code: [Select]
Intel(R) Core(TM) i3-4150 CPU @ 3.50GHz (SSE4)

18942   cycles for 100 * Arcsinus
2095    cycles for 100 * ArcSin

18950   cycles for 100 * Arcsinus
2100    cycles for 100 * ArcSin

19068   cycles for 100 * Arcsinus
2137    cycles for 100 * ArcSin

18970   cycles for 100 * Arcsinus
2596    cycles for 100 * ArcSin

18904   cycles for 100 * Arcsinus
2112    cycles for 100 * ArcSin

58      bytes for Arcsinus
209     bytes for ArcSin

Real8   29.99999926061033761    Arcsinus
Real8   29.99999926061034117    ArcSin

--- ok ---
Fa is a musical note to play with CL

TimoVJL

  • Member
  • ****
  • Posts: 698
Re: ArcSin timings
« Reply #11 on: December 22, 2020, 03:33:06 AM »
Code: [Select]
AMD Ryzen 5 3400G with Radeon Vega Graphics     (SSE4)

19735   cycles for 100 * Arcsinus
2530    cycles for 100 * ArcSin

19817   cycles for 100 * Arcsinus
2535    cycles for 100 * ArcSin

19796   cycles for 100 * Arcsinus
2309    cycles for 100 * ArcSin

19779   cycles for 100 * Arcsinus
2326    cycles for 100 * ArcSin

19822   cycles for 100 * Arcsinus
2321    cycles for 100 * ArcSin

58      bytes for Arcsinus
209     bytes for ArcSin

Real8   29.99999926061033761    Arcsinus
Real8   29.99999926061034117    ArcSin

-
May the source be with you

HSE

  • Member
  • *****
  • Posts: 1650
  • <AMD>< 7-32>
Re: ArcSin timings
« Reply #12 on: December 22, 2020, 04:12:07 AM »
Post the exe, I am curious

 :thumbsup: Was missing MbProHeap initialization:
Code: [Select]
  ifdef MbBufferInit
call MbBufferInit
  endif

quarantined

  • Regular Member
  • *
  • Posts: 22
Re: ArcSin timings
« Reply #13 on: December 22, 2020, 04:40:57 AM »
Code: [Select]
AMD A6-9220e RADEON R4, 5 COMPUTE CORES 2C+3G   (SSE4)
1.60 GHz

28377   cycles for 100 * Arcsinus
4369    cycles for 100 * ArcSin

28350   cycles for 100 * Arcsinus
4247    cycles for 100 * ArcSin

28358   cycles for 100 * Arcsinus
4414    cycles for 100 * ArcSin

28341   cycles for 100 * Arcsinus
4440    cycles for 100 * ArcSin

28374   cycles for 100 * Arcsinus
4300    cycles for 100 * ArcSin

58      bytes for Arcsinus
209     bytes for ArcSin

Real8   29.99999926061033761    Arcsinus
Real8   29.99999926061034117    ArcSin

Windows 7 Pro, 32 bit

coaster

  • Regular Member
  • *
  • Posts: 3
Re: ArcSin timings
« Reply #14 on: December 22, 2020, 05:13:35 AM »
Code: [Select]
Intel(R) Core(TM) i5-7300U CPU @ 2.60GHz (SSE4)

14448   cycles for 100 * Arcsinus
1225    cycles for 100 * ArcSin

14644   cycles for 100 * Arcsinus
1214    cycles for 100 * ArcSin

14663   cycles for 100 * Arcsinus
1237    cycles for 100 * ArcSin

14606   cycles for 100 * Arcsinus
1206    cycles for 100 * ArcSin

14518   cycles for 100 * Arcsinus
1272    cycles for 100 * ArcSin

58      bytes for Arcsinus
209     bytes for ArcSin

Real8   29.99999926061033761    Arcsinus
Real8   29.99999926061034117    ArcSin