Changeset 20824
- Timestamp:
- 09/19/07 14:11:56 (1 year ago)
- Files:
-
- juggler/trunk/modules/vrjuggler/ChangeLog (modified) (1 diff)
- juggler/trunk/modules/vrjuggler/VERSION (modified) (1 diff)
- juggler/trunk/modules/vrjuggler/vrj/Draw/CpuAffinityFromEnv.cpp (added)
- juggler/trunk/modules/vrjuggler/vrj/Draw/CpuAffinityFromEnv.h (added)
- juggler/trunk/modules/vrjuggler/vrj/Draw/OpenGL/DrawManager.cpp (modified) (4 diffs)
- juggler/trunk/modules/vrjuggler/vrj/Draw/OpenGL/DrawManager.h (modified) (3 diffs)
- juggler/trunk/modules/vrjuggler/vrj/Draw/OpenGL/Pipe.cpp (modified) (3 diffs)
- juggler/trunk/modules/vrjuggler/vrj/Draw/OpenGL/Pipe.h (modified) (1 diff)
Legend:
- Unmodified
- Added
- Removed
- Modified
- Copied
- Moved
juggler/trunk/modules/vrjuggler/ChangeLog
r20811 r20824 1 1 DATE AUTHOR CHANGE 2 2 ----------- ----------- ------------------------------------------------------- 3 Sep-19-2007 patrick Added draw thread CPU affinity capabilities through the 4 new environment variable VJ_DRAW_THREAD_AFFINITY. This 5 is currently used only by the OpenGL Draw Manager. 6 NEW VERSION: 2.3.14 3 7 Sep-09-2007 patrick Added vrjuggler-direct3d fpc file. 4 8 Sep-07-2007 dshipton Added vrjuggler-opengl and vrjuggler-performer fpc juggler/trunk/modules/vrjuggler/VERSION
r20757 r20824 1 2.3.14-0 @09/19/2007 19:10:00 UTC@ 1 2 2.3.13-0 @09/05/2007 02:05:00 UTC@ 2 3 2.3.12-0 @08/25/2007 13:15:00 UTC@ juggler/trunk/modules/vrjuggler/vrj/Draw/OpenGL/DrawManager.cpp
r20629 r20824 43 43 #include <vrj/Display/SimViewport.h> 44 44 #include <vrj/Display/SurfaceViewport.h> 45 #include <vrj/Draw/CpuAffinityFromEnv.h> 45 46 46 47 #include <vrj/Draw/OpenGL/App.h> … … 74 75 , mControlThread(NULL) 75 76 { 76 /* Do nothing. */;77 setCpuAffinityStrategy(vrj::CpuAffinityFromEnv()); 77 78 } 78 79 … … 90 91 mControlThread = NULL; 91 92 } 93 } 94 95 void 96 DrawManager::setCpuAffinityStrategy(const cpu_affinity_strategy_t& strategy) 97 { 98 getDrawThreadAffinity = strategy; 92 99 } 93 100 … … 310 317 new vrj::opengl::Pipe(pipes.size(), this, &mCreateWindowMutex); // Create a new pipe to use 311 318 pipes.push_back(new_pipe); // Add the pipe 312 new_pipe->start( );// Start the pipe running319 new_pipe->start(getDrawThreadAffinity(pipe_num)); // Start the pipe running 313 320 // NOTE: Run pipe even if no windows. Then it waits for windows. 314 321 } juggler/trunk/modules/vrjuggler/vrj/Draw/OpenGL/DrawManager.h
r20495 r20824 32 32 #include <vector> 33 33 #include <boost/noncopyable.hpp> 34 #include <boost/function.hpp> 34 35 35 36 #include <vpr/vpr.h> … … 90 91 friend class ContextDataBase; 91 92 93 typedef boost::function<int (const unsigned int)> cpu_affinity_strategy_t; 94 95 /** 96 * Changes the callable object used for determining the draw thread CPU 97 * affinity to use the given value. In order for this to have the 98 * desired effect, it must be called before any render threads have been 99 * started. 100 * 101 * @post \c getDrawThreadAffinity is assigned the value of \p strategy. 102 * 103 * @param strategy A callable (either a C function pointer, a value 104 * returned by boost::bind(), or an object whose class 105 * overloads operator()) that serves to map zero-based 106 * thread identifiers to zero-based CPU values in order 107 * to assign affinity. 108 * 109 * @see vpr::Thead::setRunOn() 110 * @see addDisplay() 111 * 112 * @since 2.3.14 113 */ 114 void setCpuAffinityStrategy(const cpu_affinity_strategy_t& strategy); 115 92 116 /** Starts the control loop. */ 93 117 virtual void start(); … … 241 265 DrawManager(); 242 266 267 cpu_affinity_strategy_t getDrawThreadAffinity; 268 243 269 vprSingletonHeader(DrawManager); 244 270 }; juggler/trunk/modules/vrjuggler/vrj/Draw/OpenGL/Pipe.cpp
r20657 r20824 84 84 85 85 // Starts the pipe running. 86 int Pipe::start( )86 int Pipe::start(const int cpuAffinity) 87 87 { 88 88 vprASSERT(mThreadRunning == false); // We should not be running yet … … 93 93 try 94 94 { 95 mActiveThread = new vpr::Thread(boost::bind(&Pipe::controlLoop, this)); 95 // mActiveThread is assigned at the start of controlLoop(). 96 vpr::Thread* thread = 97 new vpr::Thread(boost::bind(&Pipe::controlLoop, this, cpuAffinity)); 96 98 vprDEBUG(vrjDBG_DRAW_MGR, vprDBG_CONFIG_LVL) 97 99 << "[vrj::opengl::Pipe::start()] Started control loop. " 98 << mActiveThread<< std::endl << vprDEBUG_FLUSH;100 << thread<< std::endl << vprDEBUG_FLUSH; 99 101 started = 1; 100 102 } … … 182 184 // - Signal swap completed <br> 183 185 // 184 void Pipe::controlLoop() 185 { 186 void Pipe::controlLoop(const int cpuAffinity) 187 { 188 vprASSERT(NULL != vpr::Thread::self()); 189 mActiveThread = vpr::Thread::self(); 190 191 if ( cpuAffinity >= 0 ) 192 { 193 vprDEBUG(vrjDBG_DRAW_MGR, vprDBG_CRITICAL_LVL) 194 << "[vrj::opengl::Pipe::controlLoop()] Setting CPU affinity for " 195 << "pipe " << mPipeNum << " to " << cpuAffinity << std::endl 196 << vprDEBUG_FLUSH; 197 198 try 199 { 200 mActiveThread->setRunOn(cpuAffinity); 201 } 202 catch (vpr::Exception& ex) 203 { 204 vprDEBUG(vrjDBG_DRAW_MGR, vprDBG_WARNING_LVL) 205 << clrOutBOLD(clrYELLOW, "WARNING") 206 << ": Failed to set draw thread affinity in vrj::opengl::Pipe:\n" 207 << ex.what() << std::endl << vprDEBUG_FLUSH; 208 } 209 } 210 186 211 mThreadRunning = true; // We are running so set flag 187 212 // Loop until flag set juggler/trunk/modules/vrjuggler/vrj/Draw/OpenGL/Pipe.h
r20657 r20824 82 82 * 83 83 * @pre The pipe should not have a thread of control yet. 84 * @post The pipe has it 's own thread of control and is ready to operate84 * @post The pipe has its own thread of control and is ready to operate 85 85 * The Thread of control is running controlLoop. 86 * 87 * @param cpuAffinity The CPU affinity to assign for the rendering thread 88 * spawned by this method. A value less than 0 89 * indicates that no CPU affinity will be assigned to 90 * the rendering thread. 91 * 86 92 * @note The pipe does NOT have to have any windows in order to run 87 93 * that way we can add windows to pipes at run-time. 88 */ 89 int start(); 94 * @note The signature of this method changed in version 2.3.14 to take the 95 * CPU affinity value. 96 */ 97 int start(const int cpuAffinity); 90 98 91 99 /** 92 100 * The main loop routine. 93 * -Checks for new windows <br> 94 * -renders all windows when triggered <br> 95 */ 96 void controlLoop(); 101 * - Checks for new windows. 102 * - Renders all windows when triggered. 103 * 104 * @param cpuAffinity The CPU affinity to assign for the rendering thread 105 * spawned by this method. A value less than 0 106 * indicates that no CPU affinity will be assigned to 107 * the rendering thread. 108 * 109 * @note The signature of this method changed in version 2.3.14 to take the 110 * CPU affinity value. 111 * 112 * @see vpr::Thead::setRunOn() 113 */ 114 void controlLoop(const int cpuAffinity); 97 115 98 116 /**
