Hello,

I am trying to use OpenMP inside an application that uses OpenSceneGraph. I can get OpenMP to use multiple threads inside my examples, but NOT inside my my OpenSceneGraph app. I think that I may have tracked the problem down to the use of sched_setaffinity inside files in .../OpenThreads/pthreads. It seems that inside CMakelists.txt in that directory, pthread_setaffinity_np is not being found and sched_setaffinity calls are being made that kill multi-processor availability. From CMakeLists.txt:

CHECK_FUNCTION_EXISTS(pthread_setaffinity_np HAVE_PTHREAD_SETAFFINITY_NP)
IF(HAVE_PTHREAD_SETAFFINITY_NP)
 ADD_DEFINITIONS(-DHAVE_PTHREAD_SETAFFINITY_NP)
ELSE(HAVE_PTHREAD_SETAFFINITY_NP)
 CHECK_CXX_SOURCE_COMPILES("
#include <sched.h>
int main() {
 cpu_set_t cpumask;
 sched_setaffinity( 0, sizeof(cpumask), &cpumask );
 return 0;
}" HAVE_THREE_PARAM_SCHED_SETAFFINITY)
 IF(HAVE_THREE_PARAM_SCHED_SETAFFINITY)
   ADD_DEFINITIONS(-DHAVE_THREE_PARAM_SCHED_SETAFFINITY)
 ELSE(HAVE_THREE_PARAM_SCHED_SETAFFINITY)
   CHECK_CXX_SOURCE_COMPILES("
#include <sched.h>
int main() {
 cpu_set_t cpumask;
 sched_setaffinity( 0, &cpumask );
 return 0;
}" HAVE_TWO_PARAM_SCHED_SETAFFINITY)
   IF(HAVE_TWO_PARAM_SCHED_SETAFFINITY)
     ADD_DEFINITIONS(-DHAVE_TWO_PARAM_SCHED_SETAFFINITY)
   ENDIF(HAVE_TWO_PARAM_SCHED_SETAFFINITY)
 ENDIF(HAVE_THREE_PARAM_SCHED_SETAFFINITY)
ENDIF(HAVE_PTHREAD_SETAFFINITY_NP)

so I see:
[EMAIL PROTECTED] src]$ find . -exec grep -n -H sched_setaffinity {} \;
./OpenThreads/pthreads/CMakeLists.txt:73: sched_setaffinity( 0, sizeof(cpumask), &cpumask );
./OpenThreads/pthreads/CMakeLists.txt:83:  sched_setaffinity( 0, &cpumask );
./OpenThreads/pthreads/PThread.c++:135: sched_setaffinity( 0, sizeof(cpumask), &cpumask ); ./OpenThreads/pthreads/PThread.c++:137: sched_setaffinity( 0, &cpumask ); ./OpenThreads/pthreads/PThread.c++:549: sched_setaffinity( 0, sizeof(cpumask), &cpumask ); ./OpenThreads/pthreads/PThread.c++:551: sched_setaffinity( 0, &cpumask ); ./OpenThreads/pthreads/PThread.c++:984: sched_setaffinity( 0, sizeof(cpumask), &cpumask ); ./OpenThreads/pthreads/PThread.c++:986: sched_setaffinity( 0, &cpumask ); ./OpenThreads/pthreads/GNUmakefile:43:ifeq ($(COMPILE_USING_TWO_PARAM_sched_setaffinity),yes) ./OpenThreads/pthreads/GNUmakefile:44:DEF += -DCOMPILE_USING_TWO_PARAM_sched_setaffinity

I am compiling this myself with GCC 4.3.2 (that I also compile myself), so I am not out-of-date with my compiler.

What do I need to do to get this working? Must I run on only a single processor? I have an 8 processor PC and huge jobs to run on it. My app also must run in windows (sigh). Will the MS Visual Studio 2005 compiler be a problem?


Ralph



_______________________________________________
osg-users mailing list
[email protected]
http://lists.openscenegraph.org/listinfo.cgi/osg-users-openscenegraph.org

Reply via email to