1. NodeBox 1
    1. Homepage
    2. NodeBox 3Node-based app for generative design and data visualization
    3. NodeBox OpenGLHardware-accelerated cross-platform graphics library
    4. NodeBox 1Generate 2D visuals using Python code (Mac OS X only)
  2. Gallery
  3. Documentation
  4. Forum
  5. Blog

GPU powered numeric functions?

Posted by toby_ on May 27, 2008

Is it possible to execute functions like sinus / cos or just
counting loops on the GPU?

Because right now all this is made by the CPU i guess.
So if i want to move a square - the cpu has to push up a
numeric parameter and the GPU just changes the picture?

Or is it possible to tell the GPU to do this by it self?



Posted by fdb on May 28, 2008

Short answer: no.

Longer answer: NodeBox uses the Cocoa drawing API (Quartz), which is hardware-accelerated. However, all mathematical functions happen on the CPU. Also, the main loop of your animation runs in Python.

Using the GPU for these calculations would require you to write custom vertex or fragment shaders, which would result in a totally different project.

With regards to your problem, don't focus to hard on these mini-optimizations; instead try to look at the big picture and see how you can optimize that. As an example, if you use sinus/cosinus a lot, you could use lookup tables to cache the computations. Profiling your code helps a lot to find the bottlenecks.

http://docs.python.org/lib/module-profile.html

Kind regards,

Frederik



Posted by giorgio o. on Jun 16, 2008

hello frederik,

could you post a dummy example on how to profile a NB script.? this could be very useful.
I've tried to use the profile module without real success.
thanks
giorgio