### Author Topic: Why is a PC so fast compared to BeagleBoard?  (Read 775 times)

0 Members and 1 Guest are viewing this topic.

#### hamster_nz

• Super Contributor
• Posts: 1953
• Country:
##### Re: Why is a PC so fast compared to BeagleBoard?
« Reply #25 on: August 11, 2019, 09:15:43 am »
Revisit your code with the knowledge that sin() and cos() is very expensive on your platform, and are to be avoided as much as possible.

On a hobby DSP project using a lookup table made things 4x faster.
Gaze not into the abyss, lest you become recognized as an abyss domain expert, and they expect you keep gazing into the damn thing.

#### magic

• Frequent Contributor
• Posts: 615
• Country:
##### Re: Why is a PC so fast compared to BeagleBoard?
« Reply #26 on: August 11, 2019, 06:48:04 pm »
Another big weakness of most ARM boards in comparison with x86 PC is memory bus width, and perhaps frequency too, both limiting RAM bandwidth.
Not the limiting factor in this case, though.

#### rstofer

• Super Contributor
• Posts: 6076
• Country:
##### Re: Why is a PC so fast compared to BeagleBoard?
« Reply #27 on: August 12, 2019, 02:55:42 am »
Another possible speedup is in pulling loop invariant code outside the loop.

do i = 1, 100
ohmega(i) = 2.0 * Pi * f(i) // or some such  ** BAD **
end do

Here the 2.0 * Pi is loop invariant and should be pulled out of the loop.  Sometimes the compiler will do it, other times not.  Sometimes it is not obvious what is loop invariant because there is a bunch of code inside the loop.

twoPi = 2.0 * Pi  // ** BETTER **
do i = 1, 100
ohmega(i) = twoPi * f(i)
end do

Lookup tables for trig functions is a good idea.  You can even do a wee bit of interpolation between value if necessary.  You only need the table to cover 0..Pi/2 (90 degrees) so it doesn't necessarily have to take a lot of space.  You can also manipulate the argument for cos() such that it can also use the same table.  You can improve on the idea by not adding 3*Pi/4 but rather just start your index 3/4 the way through the table and deal with wrap-around.  Much faster...

#### ralphrmartin

• Frequent Contributor
• Posts: 275
• Country:
##### Re: Why is a PC so fast compared to BeagleBoard?
« Reply #28 on: August 15, 2019, 04:41:21 am »
Caches primarily, then effective branch prediction and speculative execution.

Shouldn't be any branch prediction in trig function calculation, or matrix multiplication.

#### coppice

• Super Contributor
• Posts: 4356
• Country:
##### Re: Why is a PC so fast compared to BeagleBoard?
« Reply #29 on: August 15, 2019, 04:55:35 am »
Another possible speedup is in pulling loop invariant code outside the loop.
Modern compilers are usually pretty good at doing that for themselves, as long as you have optimisation enabled.

Smf