Version: 2.0

Posted: 2009-10-09

Build Requirements: Mac OS X v10.6 or later

Runtime Requirements: Mac OS X v10.6 or later

View Source Code:

Download Sample Code (“OpenCL_NBody_Simulation_Example.zip”, 5.44M)



Description

This example performs an NBody simulation which calculates a gravity field and corresponding velocity and acceleration contributions accumulated by each body in the system from every other body. This example also shows how to mitigate computation between all available devices including CPU and GPU devices, as well as a hybrid combination of both, using separate threads for each simulator.

Click on the corresponding buttons to select the active simulation and render devices, and/or press the following keyboard shortcuts:

1-6: Select an N-Body System Configuration

g: Select the next Graphics Device

s: Select the next Simulation Device

r: Enable/Disable Auto Rotation

d: Show/Hide Dock UI

h: Show/Hide HUD UI

u: Show/Hide Simulation Updates Meter

f: Show/Hide FPS Meter

space: Pause/Unpause Simulation

Note that the .cl compute kernel file(s) are loaded and compiled at runtime. The example source assumes that these files are in the same path as the built executable.

Document Revision History

Date Notes
2009-10-09This is major change. We have modified the WWDC NBODY example from this year. 1) Removed scalar single core version 2) float4 vector operations in kernel, which really were operations on float3s (forth component was not being used) are now broken into three scalar operations. 3) CPU-GPU hybrid shown at WWDC, is removed for now since it requires careful load balancing. 4) Number of particles is now user provided parameter at command line with 32k being default.
2009-09-24Updated for bug fixes and to adapt to API changes.
2009-05-13Updated to new API.
2009-04-02OpenCL NBody Simulation Example