I’m here to share with you my idea of porting Nbody demo present in cuda sdk into .net.
The demo Nbody is written in c , opengl, my deal was porting in c#, directx managed, cuda managed for all people that don’t know Opengl and c … :)
I used Gass.Cuda managed. and directx managed febbrary2010, Cuda sdk 3.0
I had problems of setting shared mem size and i I was not able to find an algorithm for this but after many tests i find some values that works.
It’s not so clear the relation between GASS.Cuda method and C original method … in the source file i explained better…:) (Blockshape, shredsize an launch methhod)
The nbody_kernel.cu file is the original from the nvidia demo i’ve make no changes…
The demo show the difference of caculating nbody interaction by cpu and gpu.
The cpu uses multithreading and syncronization 1 thread per core… on my intel core i7920 @3.8Ghz i reach 3000-4000 particle at 25-20Fps via gpu i reached more than 20000 particles at 25 fps with 280gtx. (more than 7000 with a gt220)
I had problems about rendering, i was not able to make the same graphics of Nvidia Nbody demo that is better looking, they use opengl, a simple pixelshader and a simple vertex shader.
I used directx (i’m newbie of graphics) , i used an array of (CustomVertex.PositionColored) (non indexed) with alphablending and a texture… but for big point size artefact are visible… if you have some idea how to solve this let me know!!! :) (i’ll glad to make same graphics of Nbody demo with directx)
I tryed to make a grid of thread also in cpu mode (like cuda do) but i encounter big problems of syncronization…
For the demo i’ll thanks:
- Robydx for the graphics he’s demo written in c# was very helpfull,
- Nvidia Nbody demo for the idea and implementation of cuda code.
- My patience for rewrite all the code in c# and make Gass.Cuda works with many try!! (for my inexperience! :)
Software needed to run and compile:
C# Express 2008
Cuda sdk 3.0
Microsoft directx Sdk February 2010
The projects need to be compiled… the file cubin is alredy compiled x32
the bin attachment is the executable…
I’m waiting for your comment, considerations and Advice for better graphics… and grid on cpu…
I post the source code if you want to see…
Sorry for the bad english!!!