Logo by Pauldelbrot - Contribute your own Logo!

END OF AN ERA, FRACTALFORUMS.COM IS CONTINUED ON FRACTALFORUMS.ORG

it was a great time but no longer maintainable by c.Kleinhuis contact him for any data retrieval,
thanks and see you perhaps in 10 years again

this forum will stay online for reference
News: Visit the official fractalforums.com Youtube Channel
 
*
Welcome, Guest. Please login or register. July 01, 2022, 05:08:08 AM


Login with username, password and session length


The All New FractalForums is now in Public Beta Testing! Visit FractalForums.org and check it out!


Pages: [1]   Go Down
  Print  
Share this topic on DiggShare this topic on FacebookShare this topic on GoogleShare this topic on RedditShare this topic on StumbleUponShare this topic on Twitter
Author Topic: Precalculate sin/cos tables?  (Read 2548 times)
0 Members and 1 Guest are viewing this topic.
twinbee
Fractal Fertilizer
*****
Posts: 383



WWW
« on: November 25, 2009, 03:01:57 PM »

I thought of iths idea a while back, and just remembered it recently. Would it be practical to precalculate massive sin/cos tables, rather than simply removing the trig? Granted, we may need several megabytes of RAM to allow for fine precision, but for the higher powers at least (where the non-trig math can still get quite long) it may be worth it.
« Last Edit: November 25, 2009, 03:08:35 PM by twinbee » Logged
David Makin
Global Moderator
Fractal Senior
******
Posts: 2286



Makin' Magic Fractals
WWW
« Reply #1 on: November 25, 2009, 03:15:19 PM »

I thought of iths idea a while back, and just remembered it recently. Would it be practical to precalculate massive sin/cos tables, rather than simply removing the trig? Granted, we may need several megabytes of RAM to allow for fine precision, but for the higher powers at least (where the non-trig math can still get quite long) it may be worth it.

I believe iq is using sincos tables in his GPU method.
Logged

The meaning and purpose of life is to give life purpose and meaning.

http://www.fractalgallery.co.uk/
"Makin' Magic Music" on Jango
twinbee
Fractal Fertilizer
*****
Posts: 383



WWW
« Reply #2 on: November 25, 2009, 03:55:35 PM »

It makes one wonder why CPU/GPU manufacturers don't implement tables on the hardware directly (in addition to accurate calculation of trig functions). With RAM being so cheap, it could enhance FPU capabilities...
Logged
cbuchner1
Fractal Phenom
******
Posts: 443


« Reply #3 on: November 25, 2009, 04:28:39 PM »


Precalculated sine/cosines would likely lead to very bad limitations of how far you can zoom in.

On the GPUs the sine/cosines are so fast that it's absolutely not worthwhile to replace them with polynomials or texture lookups. iq stated the polynomial version wasn't any faster on his GPU.
Logged
David Makin
Global Moderator
Fractal Senior
******
Posts: 2286



Makin' Magic Fractals
WWW
« Reply #4 on: November 25, 2009, 04:37:45 PM »


Precalculated sine/cosines would likely lead to very bad limitations of how far you can zoom in.

On the GPUs the sine/cosines are so fast that it's absolutely not worthwhile to replace them with polynomials or texture lookups. iq stated the polynomial version wasn't any faster on his GPU.


I was remembering this post:

http://www.fractalforums.com/3d-fractal-generation/true-3d-mandlebrot-type-fractal/msg8489/#msg8489

Including "This is disappointing, and might be related to the fact that probably the trig functions are partially implemented by little texture lookups which are fast".

I realise now that maybe he meant that's what the GPU does internally, rather than what he's doing in his own code smiley

As for using full sincos texture tables IMHO if you only have float on the GPU and not double then I think that's more of an accuracy restriction than using tables.

« Last Edit: November 25, 2009, 04:42:13 PM by David Makin » Logged

The meaning and purpose of life is to give life purpose and meaning.

http://www.fractalgallery.co.uk/
"Makin' Magic Music" on Jango
Buddhi
Fractal Iambus
***
Posts: 895



WWW
« Reply #5 on: November 25, 2009, 05:46:38 PM »

I have some bad experience with very big tables with precalculated values. Sometimes it works slower than direct calculations by CPU because direct memory access is really slow when table is bigger than CPU cache. As I know read data from memory can take up to 200 CPU cycles. Another problem is translation form floating point number to address in table, because it needs additional calculations and converting from floating point format (sin or cos argument) to integer (address in array). In my opinion this method is only usable when you want to precalculate some results of complicated formulas which needs many operations in one step and has limited range of arguments.
Logged

keldor314
Guest
« Reply #6 on: November 26, 2009, 10:40:32 PM »

On the GPU, lookup tables are a big no-no, since the actual cache is quite small (only a few KB).  In addition, there is dedicated hardware for computing sin and cos which computes with 1/4th to 1/8th the throughput of basic arithmetic.  In fact, sin and cos are faster than division on current hardware (specifically, division is implemented by a reciprocal, which is performed by the same transcendental unit as performs sin or cos, followed by a multiplication.)!  Also, the transcendental units are fully parallel to the standard ALUs, which means that so long as you don't compute more than 1 sin or cos for every 4 or 8 instructions, you essentially get them for free.
« Last Edit: November 26, 2009, 10:42:19 PM by keldor314 » Logged
David Makin
Global Moderator
Fractal Senior
******
Posts: 2286



Makin' Magic Fractals
WWW
« Reply #7 on: November 26, 2009, 11:28:06 PM »

On the GPU, lookup tables are a big no-no, since the actual cache is quite small (only a few KB).  In addition, there is dedicated hardware for computing sin and cos which computes with 1/4th to 1/8th the throughput of basic arithmetic.  In fact, sin and cos are faster than division on current hardware (specifically, division is implemented by a reciprocal, which is performed by the same transcendental unit as performs sin or cos, followed by a multiplication.)!  Also, the transcendental units are fully parallel to the standard ALUs, which means that so long as you don't compute more than 1 sin or cos for every 4 or 8 instructions, you essentially get them for free.

Thanks for that, I'm surprised that handling large areas of data isn't more optimised on GPUs given how much texture handling they normally do smiley
Logged

The meaning and purpose of life is to give life purpose and meaning.

http://www.fractalgallery.co.uk/
"Makin' Magic Music" on Jango
keldor314
Guest
« Reply #8 on: November 27, 2009, 10:37:30 AM »

Well, it is optimized.  GPUs have around 10x the memory bandwidth of CPUs.  It's just that they also have 100x the ALUs.  Thus, per ALU, GPUs only have around 1/10th the bandwidth of CPUs.
Logged
Pages: [1]   Go Down
  Print  
 
Jump to:  


Powered by MySQL Powered by PHP Powered by SMF 1.1.21 | SMF © 2015, Simple Machines

Valid XHTML 1.0! Valid CSS! Dilber MC Theme by HarzeM
Page created in 0.145 seconds with 25 queries. (Pretty URLs adds 0.006s, 2q)