Bullet + OpenCL + Tesla?

aws357
Posts: 9
Joined: Tue Jul 03, 2007 8:20 am

Bullet + OpenCL + Tesla?

Post by aws357 »

At my lab, we might soon have access to Tesla equiped supercomputers.

Knowing that Bullet is moving toward OpenCL, I wanted to know if OpenCL code could run on Tesla machines, or if anyone tried?

I think it would a really good reason for me to move from python+ODE and plunge into c++ and Bullet.

I already started because I now have a 4 GT120 machine that I would like to take advantage of. But having Teslas would make the move even more interesting.
User avatar
Erwin Coumans
Site Admin
Posts: 4221
Joined: Sun Jun 26, 2005 6:43 pm
Location: California, USA

Re: Bullet + OpenCL + Tesla?

Post by Erwin Coumans »

Our OpenCL efforts are work-in-progress, and we haven't tried it on Tesla machines yet, but as long as they support OpenCL it should be fine. Also note that we have only been working on single-GPU for OpenCL so far, we might look into multiple-GPU later.

Thanks,
Erwin
aws357
Posts: 9
Joined: Tue Jul 03, 2007 8:20 am

Re: Bullet + OpenCL + Tesla?

Post by aws357 »

I've searched a bit and indeed Teslas are built upon Quadros or G80s, so (in theory) the Tesla should run smoothly.

For the moment I am busy making code that work with Bullet-non-OpenCL.

But when I manage to make something that run, I will provide feedback.

Are there any OpenCL/CUDA/GPU features that I can already take a look at?
I've seen broadphase collision for CUDA & OpenCL in the OpenCL branch of Bullet.

What lines should I add if I want to try the OpenCL broadphase instead of btAxisSweep3 for example (maybe it's not that simple?).
RBD
Posts: 141
Joined: Tue Sep 16, 2008 11:31 am

Re: Bullet + OpenCL + Tesla?

Post by RBD »

Erwin Coumans wrote:[...]Also note that we have only been working on single-GPU for OpenCL so far, we might look into multiple-GPU later.[...]
Hey Erwin, I came across these little OpenCL demo path tracing renderers called SmallptGPU and SmallLuxGPU by David Bucciarelli (see David's OpenCL Toys and/or LuxRender forums [long]). They're fun little OpenCL demos and they're an interesting example of making use of multiple / all OpenCL devices.

Btw, I did a little test with them here: OpenCL path tracing renderer testing, animation (and Bullet Physics) (YouTube)

Speaking of which, I downloaded the OpenCL branch. I'm using the AMD Stream SDK v2.0 with OpenCL 1.0 support so I had to modify the clCreateContextFromType() calls as per the AMD KB71 - Updating your OpenCL™ code to work with the OpenCL™ ICD. I was able to get the demos working, but the Gpu3dDemo is a little unstable; BasicDemoOpenCL (using btBatchConstraintSolverOCL) was easy to get going with, but currently when I tried it with my GPU OpenCL device [CL_DEVICE_TYPE_GPU], it's slow (works ok with CPU OpenCL device [CL_DEVICE_TYPE_CPU]). Also I get an OCL error -30 when (I think) there are too many simultaneous collisions. Oh well, I'm not complaining, or asking for help, I realize this is all still in development / test / experimental at this point, just thought I'd mention these things in case. I did manage to adapt BasicDemoOpenCL to make a little sim for my little test just for the principle of the thing. :D
User avatar
Erwin Coumans
Site Admin
Posts: 4221
Joined: Sun Jun 26, 2005 6:43 pm
Location: California, USA

Re: Bullet + OpenCL + Tesla?

Post by Erwin Coumans »

The SmallLuxGPU work is very cool, we will look into it further.

Thanks for testing the OpenCL work-in-progress. We are now focussing on releasing Bullet 2.76 and fixing some Maya Dynamica issues, in particular improving the constraints.
As you already noticed, the current OpenCL branch is not well optimized yet, we just tried to port various algorithms. We plan to improve this and integrate OpenCL in the core of Bullet 3.x.

Can you provide a patch for the OpenCL ICD? Also, can we include your scripts under the ZLib license with Dynamica?
Thanks!
Erwin
RBD
Posts: 141
Joined: Tue Sep 16, 2008 11:31 am

Re: Bullet + OpenCL + Tesla?

Post by RBD »

Honestly I don't know how OpenCL platform selection should be handled for the library? (perhaps centralized, along with device selection?) Seems like it might require some thought.

Based on AMD's KB71, I simply adapted to take whatever first platform is returned... doesn't seem so right.

For the recurring calls to clCreateContextFromType() replaced this line:

Code: Select all

m_cxMainContext = clCreateContextFromType(0, CL_DEVICE_TYPE_ALL, NULL, NULL, &ciErrNum);
With this block:

Code: Select all

cl_uint numPlatforms = 0;
cl_platform_id platform = NULL;
ciErrNum = clGetPlatformIDs(0, NULL, &numPlatforms);
oclCHECKERROR(ciErrNum, CL_SUCCESS); // may change, i.e. BCSOCL_CHECKERROR() for btBatchConstraintSolverOCL.cpp
if (numPlatforms > 0)
{
	// Just use first platform?
	cl_platform_id* platforms = new cl_platform_id[numPlatforms];
	ciErrNum = clGetPlatformIDs(numPlatforms, platforms, NULL);
	oclCHECKERROR(ciErrNum, CL_SUCCESS);
	platform = platforms[0];
}
cl_context_properties cps[3] = 
{
	CL_CONTEXT_PLATFORM, 
	(cl_context_properties)platform, 
	0
};
cl_context_properties* cprops = (NULL == platform) ? NULL : cps;
m_cxMainContext = clCreateContextFromType(cprops, CL_DEVICE_TYPE_ALL, NULL, NULL, &ciErrNum);
Yes, of course, you can use the scripts (RBD Tools) any way you want.

Thanks.
User avatar
Erwin Coumans
Site Admin
Posts: 4221
Joined: Sun Jun 26, 2005 6:43 pm
Location: California, USA

Re: Bullet + OpenCL + Tesla?

Post by Erwin Coumans »

RBD wrote:Honestly I don't know how OpenCL platform selection should be handled for the library? (perhaps centralized, along with device selection?) Seems like it might require some thought.
We leave this up to the developer to provide a OpenCL context. We do provide a basic multi-threaded C implementation in case no OpenCL implementation is available (we call this MiniCL), so we can share and debug the kernel code easier.
RBD wrote: Yes, of course, you can use the scripts (RBD Tools) any way you want.
Thanks a lot, I appreciate that. We'll look if the latest Dynamica plugin is compatible with the RBD tools and include them in the next binary release. Roman improved the constraints recently, and we will add support for binary serialization of the new .bullet format, to make it easier to get physics models from Maya Dynamica into standalone Bullet.

Thanks,
Erwin