[osg-users] SingleThreaded leading to whole application just running on one core

Christoph Weiss weiss at wsoptics.de
Fri Sep 23 00:42:08 PDT 2016


Thank you so much for pointing this out, Pete.  So in 
ViewerBase::setUpThreading() osg decides the whole application should be 
confined to a single core.

Judging by your comment, this has already been discussed and not deemed 
a fault that should be fixed?

Also, I suppose there is no way to it portably? 
Thread::setProcessorAffinity() only allows restricting to a single core 
and has tons of ifdefs, so I guess I need to handle every cross 
compilation target individually?

Thanks again, I really hope this behavior can be changed in a future 
release!

Christoph

Mit freundlichen Grüßen,

Christoph Weiß

WSoptics GmbH
weiss at WSoptics.de
+49 8868 181 997 3
Zugspitzstraße 9
86972 Altenstadt

HRB 204558  Gerichtsstand: München B  Ust.Id.Nr.: DE289079930
Geschäftsführer: Florian Sepp, Dr. Christoph Weiß

On 09/23/2016 06:25 AM, Pete Black wrote:
> This is, bizarrely, by design.
>
> In single-threaded mode, OpenSceneGraph silently sets CPU affinity to a single core by default. Personally I think this is incredibly obtrusive on the programmer, and the reasons for this being default behaviour are terrible, but it is what it is.
>
> This is what I do:
>
>
> Code:
> #ifdef LINUX
>     int numCPU = sysconf( _SC_NPROCESSORS_ONLN ); //glibc fails 'all ones' cpu masks so we need this sysconf call
>     cpu_set_t  mask;
>     CPU_ZERO(&mask);
>     for (int i = 0; i < numCPU ; i++)
>     {
>         CPU_SET(i, &mask);
>         //qDebug("SETTING CPU %d",i);
>     }
>     int ret = sched_setaffinity(0, sizeof(mask), &mask); //override OpenSceneGraphs shitty CPU affinity stuff
>     //qDebug("CPU COUNT: %d %d",CPU_COUNT(&mask),ret);
>
> #endif
>
>
>
> ------------------
> Read this topic online here:
> http://forum.openscenegraph.org/viewtopic.php?p=68702#68702
>
>
>
>
>
> _______________________________________________
> osg-users mailing list
> osg-users at lists.openscenegraph.org
> http://lists.openscenegraph.org/listinfo.cgi/osg-users-openscenegraph.org
>



More information about the osg-users mailing list