Author Topic: Speed-Tests with Neural Network Calculations  (Read 67 times)

0 Members and 1 Guest are viewing this topic.

Offline Theo Gottwald

  • Administrator
  • Hero Member
  • *****
  • Posts: 1116
  • Gender: Male
    • it-berater
Speed-Tests with Neural Network Calculations
« on: February 07, 2018, 08:08:09 AM »
The First Test is done with SINGLE Precision, it compares the
MAT - Statement with conventional Loops. The result is surprising.

Code: [Select]

REGISTER R01 as Long, R02 as Long
tix Q1
#if 0
MAT Hidi()=wi()*InpN()
For R01=1 to %hidA
  For R02=1 to %Input
next r02
 tix END Q1
 ? STR$(int(Q1/100000))

I get 68057 for the FOR-Loop.
And 79259 for the MAT Statement.

With smaller Numbers the effect is even stronger.
Code: [Select]

I need 66 Tix for MAT and 24 Tix with the FOR-Loop. MAT is slower anyway.
Code: [Select]
 ? STR$(int(Q1/1000))
I need again 66 Tix for MAT and 24 Tix with the FOR-Loop. MAT is generally slower here.

Now switching to Extended-Datatype. Does it change?

MAT uses 73 Tix, the For-Loop just 36 Tix. So what we see is that Extended is 50 slower then SINGLE using a FOR-Loop, but still faster then MAT using SINGLE.

Let's try Double. It comes with 67 Tix for MAT and 22 with the FOR-Loop. So no big difference to SINGLE anymore.
And with higher numbers?

Code: [Select]
 ? STR$(int(Q1/100000))

We get 26 with the FOR-Loop and we get 72 with MAT.
With SINGLE it was 24/66.
With EXTENDED it was 46/83

It shows that modern CPU's do not have substancial advantages using SINGLE anymore.
Just use DOUBLE. While EXTENDED ist still a bit more costly.
Unless you use MAT then its not such a large difference.

Conclusion: For simple MATRIX-Multiplication with 1-dimensional Vectors, MAT is slower then a conventional FOR-Loop by amazing 50%.