Hi,

I will try to be much more concise! :-) The problem appears to be that SetProcessorAffinityOfCurrentThread(unsigned int cpunum) is always being called with a cpunum value of zero. More information follows.

I am trying to use OpenMP with an application that uses OpenScenGraph. When OpenMP runs it says that there is only 1 CPU available on an 8 processor PC.

After numerous exchanges with jakub (thread may be found at http://gcc.gnu.org/bugzilla/show_bug.cgi?id=37586), it appears that a call to sched_setaffinity, or its "wrapper" pthread_setaffinity_np, is setting the number of processors available to 1 on my PC.

After a fair amount of looking around, I dug deep into OpenSceneGraph software and found 3 instances in OpenSceneGraph-2.4.0/src/OpenThreads/pthreads/ PThread.c++ where calls of this sort are being made. I put printouts in those places to check on what is going on. I found that only one call to pthread_setaffinity_np was being run in SetProcessorAffinityOfCurrentThread(unsigned int cpunum) -- see below. A short code fragment from SetProcessorAffinityOfCurrentThread follows which shows my printout.

#if defined(HAVE_PTHREAD_SETAFFINITY_NP)
std::cout << "SetProcessorAffinityOfCurrentThread cpunum=" << cpunum << " sizeof(cpumask)=" << sizeof(cpumask) << std::endl;
       pthread_setaffinity_np( pthread_self(), sizeof(cpumask), &cpumask);
#elif defined(HAVE_THREE_PARAM_SCHED_SETAFFINITY)
       sched_setaffinity( 0, sizeof(cpumask), &cpumask );
#elif defined(HAVE_TWO_PARAM_SCHED_SETAFFINITY)
       sched_setaffinity( 0, &cpumask );
#endif
#endif

If I use strace -f -e sched_setaffinity to watch what is happening with sched_setaffinity I see (partial output listing follows):

NOTE: usg::Scene using usg default data file path list
path = .:/usr/local/share/OpenSceneGraph/data:/usr/local/share/OpenSceneGraph/data/Env:/usr/local/share/OpenSceneGraph/data/fonts:/usr/local/share/OpenSceneGraph/data/Images:/usr/share/OpenSceneGraph/data:/usr/share/OpenSceneGraph/data/Env:/usr/share/OpenSceneGraph/data/fonts:/usr/share/OpenSceneGraph/data/Images
camera number: 0
SetProcessorAffinityOfCurrentThread cpunum=0 sizeof(cpumask)=128
sched_setaffinity(16718, 128, { 1, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0 }) = 0
INFO> navigation mode set to umbra

which seems to imply that the call pthread_setaffinity_np with zero processors is causing a problem.

I looked for calls to this function and found the following which explains why cpunum is zero! ../src/osgViewer/ViewerBase.cpp:137: OpenThreads::SetProcessorAffinityOfCurrentThread(0); ../src/osgViewer/ViewerBase.cpp:452: OpenThreads::SetProcessorAffinityOfCurrentThread(0);

What do you, particularly Robert, think? (More information concerning my PC is available.) How can we fix this? I am quite happy to run some experiments to figure this out.

Ralph



_______________________________________________
osg-users mailing list
osg-users@lists.openscenegraph.org
http://lists.openscenegraph.org/listinfo.cgi/osg-users-openscenegraph.org

Reply via email to