RISC OS Open
Safeguarding the past, present and future of RISC OS for everyone
ROOL
Home | News | Downloads | Bugs | Bounties | Forum | Documents | Photos | Contact us
Account

Latest news


edit

Going round in circles, quickly

Posted by Steve Revill Sat, 10 Jul 2021 11:15:00 GMT

There are a few areas where the potential for speed-ups are huge yet to date RISC OS has been unable to harness them. One such area is where the more complicated floating point mathematical operations are used, like sine and cosine, rather than simple add/subtract/multiply/divide – but that has all changed in our nightly RISC OS 5 ROMs from July 2021 onwards.

Origins

The Arm instruction set design includes a chunk of spare space to communicate with coprocessors. Coprocessors are add-on areas of the silicon chip which handle whatever specialism those spare instructions are defined to do. One such add-on is a maths accelerator.

The original math accelerator was unimaginatively called the Floating Point Accelerator, or FPA for short. Even though the last time an FPA was available on chip was the 7500FE used in the A7000+ back in 1997, RISC OS still faithfully supports those instructions through emulation with the FPEmulator module. By modern standards, this can be quite slow, particularly for the more complex mathematical operations.

In steps the Vector Floating Point unit, or VFP for short. Introduced in 1998 the VFP replaced FPA entirely, bringing with is a larger bank of working registers, but VFP wasn’t instruction compatible with FPA. For those platforms sporting Vector Floating Point units, which is now a vast majority, the potential for high speed computations using the VFP unit is great.

Support in a roundabout way

RISC OS now supports a set of 11 hardware-accelerated functions:

  • sine and arcsine
  • cosine and arcsine
  • tangent, arctangent and atan2 (a variant of artangent)
  • logarithm base e and base 10
  • exponent
  • power
Bezier in Draw

A bezier curve uses several of these complex mathematical functions

The VFPSupport module in RISC OS 5 is responsible for looking after the VFP coprocessor, so was the natural home for these new functions. By having them available centrally it’s possible to use any of them from any language that might offer them, or even directly from an application. For example, BASIC provides the keywords SIN and COS which map directly to sine and cosine:

10 start%=TIME
20 FOR rad = 0 TO 2*PI STEP 0.000001
30   x = COS(rad) : y = SIN(rad)
40 NEXT
50 PRINT TIME-start%;" centiseconds"

This works out over 6 million coordinates of a unit circle, so it should be possible to see the difference in speed when run on integer BASIC V and floating point BASIC VI. Try it!

And to round off, a word about making it happen

We’d like to make a special mention of RISC OS FR who were a key sponsor and tester for this development work. There’s a big resource of BASIC-related material on their site, and of course there’s still time to bag a copy of the BASIC-only DDE if you’d like to explore programming in BASIC at no cost.

Posted in New component, Community | 8 comments

Comments

Comment on this article

  1. nukeedit
    Martin Avison (27) said about 23 hours later:

    Wow! That is impressive.
    I did a few quick tests with the program above, on my Titanium…
    Test#1 RO5.29 (22 Apr 2021), BASIC v1.81 (26 Sep 2020), VFPSupport v0.13 (20 Feb 2018)
    Test#2 RO5.29 (11 Jul 2021), BASIC v1.84 (23 Jun 2021), VFPSupport v0.16 (28 Jun 2021)

    
    BASIC     Test1     Test2
    V           650       770
    VI FPA    11300     11160
    VI VFP    10300       345
    

    The results are in cs, and do vary slightly from run to run.
    Obviously whether this speed increase is noticeable depends on how much the accelerated functions are used in a particular program.

  2. nukeedit
    Andrew Rawnsley (492) said 2 days later:

    The posting references this being applicatable to other high level languages beyond BASIC, but it isn’t clear to me if that is now working, or requires further changes to be implemented (eg. sharedclib or something)?

  3. nukeedit
    Andrew Rawnsley (492) said 2 days later:

    PS either way, excellent progress!

  4. nukeedit
    Chris Hall (132) said 2 days later:

    Interesting. One thing I take away from this is how good the floating point routines in BASIC V are.

  5. nukeedit
    Chris Hall (132) said 2 days later:

    I thought it was possible to plot a Bezier curve parametrically without using any trig functions.

  6. nukeedit
    David Feugey (2125) said 3 days later:

    Good question Andrew. Technically, with the VFP opcodes and the additional functions now provided by VFPSupport, you can completely support IEEE-754 calls. But a direct support in DDE would be needed at some point in the future. Aswell as an accelerated FPEmulator module (for old software).

  7. nukeedit
    Kuemmel (439) said 18 days later:

    Very nice ! But proof me wrong, I think like Chris said, an implementation of cubic or quadric Bezier lines is ‘normally’ done just using multiply/add and none of the listed functions…

  8. nukeedit
    Bernard Boase (169) said 12 months later:

    I used the given BASIC program to test speeds on ARMX6 and Pi 400, but my results do not show the improvement that Martin reported in his Test#2 (above). So I started thread ‘BASIC VFP speed’ in forum ‘Community Support’. It would be good to understand the caveats that seem to apply when expecting the speed-up described in your news article.

RSS feed for this post

Spinner-blue

Social

Follow us on and

ROOL Store

Buy RISC OS Open merchandise here, including SD cards for Raspberry Pi and more.

Donate! Why?

Help ROOL make things happen – please consider donating!

RISC OS IPR

RISC OS is an Open Source operating system owned by RISC OS Developments Ltd and licensed primarily under the Apache 2.0 license.

Categories

  • Miscellaneous (38)
  • New component (33)
  • New documentation (13)
  • New product (47)
  • Press coverage (7)
  • Web site (42)
  • Press release (65)
  • Community (120)

Recent Comments

  • by Rebecca (1663) on Looking to spark your imagination?
  • by Colin (9958) on RISC OS in Spaaaaace!
  • by Steve Revill (20) on RISC OS in Spaaaaace!
  • by Paolo Fabio Zaino (28) on RISC OS in Spaaaaace!
  • by Detlef Froehlich (9715) on RISC OS in Spaaaaace!

RSS Feeds

  • Articles
  • Comments
  • Trackbacks

Archives

  • October 2023 (1)
  • May 2023 (1)
  • April 2023 (2)
  • February 2023 (2)
  • September 2022 (1)
  • July 2022 (2)
  • June 2022 (1)
  • May 2022 (2)
  • February 2022 (1)
  • October 2021 (2)
  • September 2021 (1)
  • August 2021 (1)
Site design © RISC OS Open Limited 2018 except where indicated
The RISC OS Open Typo theme is distantly based on Typo's 'Azure'

Valid XHTML 1.0  |  Valid CSS

Powered
This site runs on Rails

Hosted by Arachsys