Integration with CUDA

Post Reply
kaistudio
Posts: 16
Joined: Mon Dec 06, 2010 1:31 pm

Integration with CUDA

Post by kaistudio » Tue Dec 07, 2010 3:04 am

Hello developers.
I've tried to integrate my CUDA SPH solver into the realflow as an custom particle solver plugin.
I've succeeded in complie and build a dll in Debug_DLL with x64 configuration.
After the dll successfully loaded, I've run 'Attach to process' to debug my plugin.
However the break-points were not working.
Those break-points are active(normal red dot) but I can't grab the process with them.
(I've linked a mov file that captures the reproduce process for the same situation)
http://taekwon.kaist.ac.kr/mov.zip

The 'surface tension' example worked fine which I copied and modified to build up my current solution.
It just stopped normally at the break-points in every virtual functions.
The 'cuda sph' also had worked fine as a standalone program in x64 windows.

I'm using
--------------------------
CUDA SDK: 3.2.16
Visual studio 2008 with SP1
Realflow 5.0.3
windows 7 Enterprise
gtx260
in MacPro
--------------------------

I'm not sure whether
1) there exists any potential conflict between RF_SDK with CUDA SDK3.2.16
2) there exists my mistake in coding custom ParticleSolverPlgSdk class

Could you let me know what would be the problem?

User avatar
Alex
Site Admin
Posts: 143
Joined: Mon Jun 14, 2010 9:35 am

Re: Integration with CUDA

Post by Alex » Tue Dec 07, 2010 11:05 am

Hi,

if we understand correctly, you have been able to compile and trace other RealFlow plugins, haven't you?

Make sure you don't have optimizations enabled for that compilation.
You can also try to set a breakpoint at some point before execution enters the section you are being unable to trace.
Finally, you could create some easily breakable function with no qualifiers (like virtual or inline), set the breakpoint inside and call it some time.

Let us know if it helps.
Alex Ribao
RealFlow Team
Next Limit Technologies

kaistudio
Posts: 16
Joined: Mon Dec 06, 2010 1:31 pm

Re: Integration with CUDA

Post by kaistudio » Tue Dec 07, 2010 12:03 pm

Alex wrote:if we understand correctly, you have been able to compile and trace other RealFlow plugins, haven't you?
Yes, other examples work correctly.
Alex wrote:Make sure you don't have optimizations enabled for that compilation.
I'm using same option to 'surface tension example' except, custom build rules for .cu files which seem have no relation with the current problem.
Alex wrote:You can also try to set a breakpoint at some point before execution enters the section you are being unable to trace.
As you can see in my movie file, I set those point at the beginning of every virtual functions.
Alex wrote:Finally, you could create some easily breakable function with no qualifiers (like virtual or inline), set the breakpoint inside and call it some time.
Thanks for the notice but there was no typo.

Okay, here's a more specific question.
I figured out that the call orders for 'surface tension example' from realflow.exe as follows:
--------------------------
preComputeInternalForces
computeInternalForces
getIntegrationTime
integrate
--------------------------
Q) Is there any other flag in the base code that prevents to call overriden virtual functions?

I've checked 'the PlgSdk_Status' while loading the realflow.exe
As 'initializing services' it's PlgSdk_Status::ST_ERROR, which seems to be a default value.
And when 'Loading Workspace..' it become PlgSdk_Status::ST_READY.
It seems reasonable that I can see my plugin loaded using 'Tool>User Plugins'.
Thus it's would not be related to the problem I have.
Any suggetions?

Code: Select all

             cudaflow() {}
	virtual ~cudaflow( void ) 
	{
		pNile->freeDevice();
		delete pNile; 
		pNile = NULL;
	};
	/// Class id.
	virtual NL_INT32  getClassId() const  { return ( 1503848364 );	};
	/// Get plugin name.
	virtual std::string getNameId() const  {  return ( "Cudaflow 1.0" ); };
	// getCopyRight()
	virtual std::string getCopyRight() const { return std::string( COPYRIGHT_TAEKWON ); }
	// getCopyRight()
	virtual std::string getLongDescription() const { return std::string( DESCRIPTION_LONG ); }
	// getCopyRight()
	virtual std::string getShortDescription() const { return std::string( DESCRIPTION_SHORT );}
	/// Initialize plugin, add properties, etc.
	virtual void initialize( PlgDescriptor* plgDesc )
	{
		particleVec.reserve(BN_PARTICLE_NUMBER);
		particleVec.clear();

		Ppty factor = Ppty::createPpty( "Default max cuda particle", BN_PARTICLE_NUMBER );
		plgDesc->addPpty( factor );

		//cuda system initialize
		BoundingBox bb;
		bb.minPt = NVector( 0,0,0 );
		float ratio = 1.0;
		bb.maxPt = bb.minPt + NVector( 1024, 1024, 1024 ) * ratio;

		pNile = new BlueNile;
		pNile->init( bb, BN_PARTICLE_NUMBER );
	}

	// get integration time
	virtual float getIntegrationTime( ParticleSolver* particleSolver ) const { return (0.02f); }

	virtual void preComputeInternalForces( ParticleSolver* particleSolver,
		PB_Emitter* emitter )
	{
		emitter->createVoxelization( true, 0.15f );
	}

	//virtual bool isMT() { return false; } 

	/// Integration
	virtual void integrate( ParticleSolver* particleSolver,
		PB_Emitter* emitter, 
		int nThread, 
		PB_Emitter::iterator iter,
		float dt )
	{
		particleVec.clear();
		emitter->getParticles( particleVec );

		int numParticles = (int)particleVec.size();
		if( numParticles > BN_PARTICLE_NUMBER )
		{
			//re-alloc memory
			dlg.show( GuiMessageDialog::ALERT_TYPE_INFORMATION, "Too many particles for CUDA");
			return;
		}
		else
		{
			//normal integration
			pNile->importParticles( particleVec );
			//pNile->run( dt );
			pNile->exportParticles( particleVec );
		}
	}
You do not have the required permissions to view the files attached to this post.

User avatar
Alex
Site Admin
Posts: 143
Joined: Mon Jun 14, 2010 9:35 am

Re: Integration with CUDA

Post by Alex » Tue Dec 07, 2010 12:21 pm

Hi again,

while we still troubleshoot the plugin, please remove the non debug version of the plugin from the plugins folder.

There should be no conflict since their IDs are different. However their share the same name, so there might be some interference.
Alex Ribao
RealFlow Team
Next Limit Technologies

kaistudio
Posts: 16
Joined: Mon Dec 06, 2010 1:31 pm

Re: Integration with CUDA

Post by kaistudio » Mon Apr 04, 2011 4:41 pm

The problem was solved when I've just added all the sdk header files to project directory.
Thanks.

Post Reply