Multithreading PhysX with NxOgre

OgreMage

04-05-2008 20:22:20

Hello NxOgre,

Performance is criticial for my application of NxOgre 0.9 and PhysX.

Is it safe to assume that NX_SF_SIMULATE_SEPARATE_THREAD is the default, and how can I disable this for profiling comparissons of 1 CPU?

How do I enable NX_SF_ENABLE_MULTITHREAD and set the "internalThreadCount"? Is there a way to guarantee I am maximizing "internalThreadCount"?

Thank you dearly. I hope this thread helps many people, especially if it is answered in detail! The main idea is to master the ability to maximize the performance of PhysX with NxOgre on single, dual, and quad core CPUs.

If you have any experiences in which quad core computing is different on Vista than with XP, please post!

Respectfully,
OM

betajaen

04-05-2008 20:24:16

Sadly. I've had no experience in threading, nor do I have a multi-core processor to work with. So I've never really implemented anything special in NxOgre to work with threading. So anything you do; will have to be with the PhysX interface directly.

So this thread won't be big as you hoped. But keep us posted.

OgreMage

04-05-2008 20:47:12

Just fyi, I am considering using Visual Studio 2005's native OpenMP for multi-parallel processing (more info at http://msdn.microsoft.com/en-us/library/tt15eb9t(VS.80).aspx)

So here is a more specific question, how could I implement below with NxOgre? (it has to be done before "createScene")

void InitNx()
{
...
// Create the scene
NxSceneDesc sceneDesc;
...
sceneDesc.flags |= NX_SF_ENABLE_MULTITHREAD;
sceneDesc.internalThreadCount = 2;
...
gScene = gPhysicsSDK->createScene(sceneDesc);
...
}

betajaen

04-05-2008 20:51:05

I don't see why not.

SceneParams sp;
sp.mFloor = true;
sp.mGravity = true;

#if defined(THREAD_POLLING)
sp.mSceneFlags.mEnableMultithread = true;
#endif

mScene = mWorld->createScene("Eddie", sp);

OgreMage

04-05-2008 21:19:02

Thank you, I did this:

SceneParams sp;
sp.setToDefault();
sp.floor = true;
sp.gravity = NxVec3( 0, -9.80665, 0 ); // 0,0,0 appears to be the default
sp.flags |= NX_SF_ENABLE_MULTITHREAD;
sp.internal_thread_count = omp_get_num_procs(); // OpenMP 2.0
mPhysicsScene = mWorld->createScene("Main", DefaultSceneManager(), sp); // DefaultSceneManager(), is my own func