# Looking for a real-time N-body simulation



## grecinos (Jun 21, 2015)

Hey guys,

I'm looking for a real-time n-body simulation that takes advantage of a discrete GPU.  I've seen YouTube videos of n-body simulations, but I'm looking for a program that I can download, change the parameters and run on my PC.  Anyone?

Cheers,

grecinos


----------



## scope54 (Jun 22, 2015)

Nvidia has some samples and one of them I believe is an n-body simulation using opencl. Check them out and if im wrong maybe something else you will find in there that is interesting. https://developer.nvidia.com/opencl

edit: just found it, it's at the bottom of the page.


----------



## grecinos (Jun 22, 2015)

Thanks for the link.  That looks very close to what I'm looking for.  I downloaded the "OpenCL N-Body Physics Simulation".  I tried to compile the sample code with MS Visual Studio 12 but am getting an error code. 

Their compiled sample crashes with some error message as well:

 !!! Error # -11 (CL_BUILD_PROGRAM_FAILURE) at line 297 , in file .\src\oclBodyS
ystemOpenclLaunch.cpp !!!

Exiting...

 It came with a  readme doc,  I'll have to do some investigating in their documentation.  If you have any suggestions, that'd be great.


----------



## scope54 (Jun 23, 2015)

There is an executable in   ...\NVIDIA GPU Computing SDK\OpenCL\bin\win64\Release where you can run it with these parameters:
Command line switches:
  --qatest        Check correctness of GPU execution and measure performance)
  --noprompt        Quit simulation automatically after a brief period
  --n=<numbodies>    Specify # of bodies to simulate (default = 7680)
  --double        Use double precision floating point values for simulation
  --p=<workgroup X dim>    Specify X dimension of workgroup (default = 256)
  --q=<workgroup Y dim>    Specify Y dimension of workgroup (default = 1)

I'm getting cl_device_not_found juist running ti though :x (it may be my use windows 10 drivers on 8.1)
I'll try compiling it also.


Edit: I just started typing graphics vendors (intel and amd) with n-body and also came up with this: https://software.intel.com/en-us/articles/opencl-cross-devices-nbody-simulation-sample check it out, that one may not give you as much trouble when compiling. AMD probably has an n-body sample too in one of there sdks. look around if the Nvidia one becomes a pain in the butt.


----------



## grecinos (Jun 23, 2015)

Excellent.  Thanks for the update.  I'll check it out tomorrow.  FYI, I'm on a Windows 7-64 bit PC.


----------



## grecinos (Jun 23, 2015)

I downloaded Intel's n-body simulation as per your link provided.  I think it's closer to successfully compiling than Nvidia's code.  But, it's giving me an error message.  It's complaining about a file called "cl_platform.h".  It wasn't included in the intel_ocl_nbody_multidevice_win.zip file.  Nvidia's simulation does have that file.  I tried copying it to the appropriate directory, but no dice, it couldn't find the file. It probably wouldn't have compiled, but I was surprised that it couldn't even find the include.


----------



## Shambles1980 (Jul 16, 2015)

remember to check windows hasnt blocked any files because they came from a nother computer.. 
that is annoying at times when it has you trouble shooting things that dont need trouble shooting.


----------



## CjStaal (Sep 15, 2015)

KSP with Principia 
http://forum.kerbalspaceprogram.com/threads/68502-WIP-1-0-4-Principia-Bourbaki-(2015-08-15)-N-Body-and-Extended-Body-Gravitation

It's pretty accurate and you can create your own solar systems. Take a look at the notes. 2 PhD's are developing it.


----------

