Changeset 20836
- Timestamp:
- 09/19/07 21:14:50 (1 year ago)
- Files:
-
- juggler/branches/2.2/modules/vrjuggler/ChangeLog (modified) (1 diff)
- juggler/branches/2.2/modules/vrjuggler/vrj/Draw/OGL/CpuAffinityFromEnv.cpp (copied) (copied from juggler/trunk/modules/vrjuggler/vrj/Draw/CpuAffinityFromEnv.cpp) (2 diffs)
- juggler/branches/2.2/modules/vrjuggler/vrj/Draw/OGL/CpuAffinityFromEnv.h (copied) (copied from juggler/trunk/modules/vrjuggler/vrj/Draw/CpuAffinityFromEnv.h) (3 diffs)
- juggler/branches/2.2/modules/vrjuggler/vrj/Draw/OGL/GlDrawManager.cpp (modified) (5 diffs)
- juggler/branches/2.2/modules/vrjuggler/vrj/Draw/OGL/GlDrawManager.h (modified) (3 diffs)
- juggler/branches/2.2/modules/vrjuggler/vrj/Draw/OGL/GlPipe.cpp (modified) (3 diffs)
- juggler/branches/2.2/modules/vrjuggler/vrj/Draw/OGL/GlPipe.h (modified) (1 diff)
- juggler/branches/2.2/modules/vrjuggler/vrj/Draw/OGL/Makefile.in (modified) (1 diff)
- juggler/branches/2.2/vc7/VRJuggler/VRJuggler.vcproj (modified) (2 diffs)
- juggler/branches/2.2/vc8/VRJuggler/VRJuggler.vcproj (modified) (2 diffs)
Legend:
- Unmodified
- Added
- Removed
- Modified
- Copied
- Moved
juggler/branches/2.2/modules/vrjuggler/ChangeLog
r20812 r20836 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. 3 6 Sep-09-2007 patrick Added vrjuggler-direct3d fpc file. 4 7 Sep-07-2007 dshipton Added vrjuggler-opengl and vrjuggler-performer fpc juggler/branches/2.2/modules/vrjuggler/vrj/Draw/OGL/CpuAffinityFromEnv.cpp
r20824 r20836 25 25 *************** <auto-copyright.pl END do not edit this line> ***************/ 26 26 27 #include <vrj/ vrjConfig.h>27 #include <vrj/Draw/OGL/Config.h> 28 28 29 29 #include <algorithm> … … 36 36 37 37 #include <vrj/Util/Debug.h> 38 #include <vrj/Draw/ CpuAffinityFromEnv.h>38 #include <vrj/Draw/OGL/CpuAffinityFromEnv.h> 39 39 40 40 juggler/branches/2.2/modules/vrjuggler/vrj/Draw/OGL/CpuAffinityFromEnv.h
r20824 r20836 25 25 *************** <auto-copyright.pl END do not edit this line> ***************/ 26 26 27 #ifndef _VRJ_ DRAW_CPU_AFFINITY_FROM_ENV_H_28 #define _VRJ_ DRAW_CPU_AFFINITY_FROM_ENV_H_27 #ifndef _VRJ_OGL_CPU_AFFINITY_FROM_ENV_H_ 28 #define _VRJ_OGL_CPU_AFFINITY_FROM_ENV_H_ 29 29 30 #include <vrj/ vrjConfig.h>30 #include <vrj/Draw/OGL/Config.h> 31 31 32 32 #include <string> … … 48 48 * of the list. 49 49 * 50 * @since 2. 3.1450 * @since 2.2.1 51 51 */ 52 class VJ_ CLASS_API CpuAffinityFromEnv52 class VJ_OGL_CLASS_API CpuAffinityFromEnv 53 53 { 54 54 public: … … 82 82 }; 83 83 84 } // end of openglnamespace84 } // end of vrj namespace 85 85 86 86 87 #endif /* _VRJ_ DRAW_CPU_AFFINITY_FROM_ENV_H_ */87 #endif /* _VRJ_OGL_CPU_AFFINITY_FROM_ENV_H_ */ juggler/branches/2.2/modules/vrjuggler/vrj/Draw/OGL/GlDrawManager.cpp
r20098 r20836 50 50 #include <vrj/Draw/OGL/GlWindow.h> 51 51 #include <vrj/Draw/OGL/GlSimInterfaceFactory.h> 52 #include <vrj/Draw/OGL/CpuAffinityFromEnv.h> 52 53 53 54 #include <gmtl/Vec.h> … … 72 73 , mControlThread(NULL) 73 74 { 75 setCpuAffinityStrategy(vrj::CpuAffinityFromEnv()); 74 76 } 75 77 … … 89 91 } 90 92 91 / ** Sets the app the draw should interact with. */93 // Sets the app the draw should interact with. 92 94 void GlDrawManager::setApp(App* _app) 93 95 { … … 317 319 GlPipe* new_pipe = new GlPipe(pipes.size(), this, 318 320 &mCreateWindowMutex); // Create a new pipe to use 321 // The size of pipes right now tells us the newly created pipe's 322 // identifier. 323 const unsigned int pipe_id = pipes.size(); 319 324 pipes.push_back(new_pipe); // Add the pipe 320 new_pipe->start( );// Start the pipe running325 new_pipe->start(getDrawThreadAffinity(pipe_id)); // Start the pipe running 321 326 // NOTE: Run pipe even if no windows. Then it waits for windows. 322 327 } … … 429 434 boost::ignore_unused_variable_warning(element); 430 435 return false; 436 } 437 438 void 439 GlDrawManager::setCpuAffinityStrategy(const cpu_affinity_strategy_t& strategy) 440 { 441 getDrawThreadAffinity = strategy; 431 442 } 432 443 juggler/branches/2.2/modules/vrjuggler/vrj/Draw/OGL/GlDrawManager.h
r19873 r20836 30 30 #include <vrj/Draw/OGL/Config.h> 31 31 #include <vector> 32 #include <boost/function.hpp> 32 33 33 34 #include <vpr/vpr.h> … … 157 158 158 159 public: 160 typedef boost::function<int (const unsigned int)> cpu_affinity_strategy_t; 161 162 /** 163 * Changes the callable object used for determining the draw thread CPU 164 * affinity to use the given value. In order for this to have the 165 * desired effect, it must be called before any render threads have been 166 * started. 167 * 168 * @post \c getDrawThreadAffinity is assigned the value of \p strategy. 169 * 170 * @param strategy A callable (either a C function pointer, a value 171 * returned by boost::bind(), or an object whose class 172 * overloads operator()) that serves to map zero-based 173 * thread identifiers to zero-based CPU values in order 174 * to assign affinity. 175 * 176 * @see vpr::Thead::setRunOn() 177 * @see addDisplay() 178 * 179 * @since 2.2.1 180 */ 181 void setCpuAffinityStrategy(const cpu_affinity_strategy_t& strategy); 182 159 183 /** 160 184 * Gets pointer to the current user data. Should be used in the draw … … 236 260 void operator=(const GlDrawManager&) {;} 237 261 262 cpu_affinity_strategy_t getDrawThreadAffinity; 263 238 264 vprSingletonHeader(GlDrawManager); 239 265 }; juggler/branches/2.2/modules/vrjuggler/vrj/Draw/OGL/GlPipe.cpp
r20661 r20836 77 77 } 78 78 79 /** 80 * Starts the pipe running. 81 * @post The pipe has it's own thread of control and is ready to operate. 82 */ 83 int GlPipe::start() 79 // Starts the pipe running. 80 int GlPipe::start(const int cpuAffinity) 84 81 { 85 82 vprASSERT(mThreadRunning == false); // We should not be running yet … … 90 87 try 91 88 { 92 mActiveThread = new vpr::Thread(boost::bind(&GlPipe::controlLoop, this)); 89 // mActiveThread is assigned at the start of controlLoop(). 90 vpr::Thread* thread = 91 new vpr::Thread(boost::bind(&GlPipe::controlLoop, this, cpuAffinity)); 93 92 vprDEBUG(vrjDBG_DRAW_MGR, vprDBG_CONFIG_LVL) 94 << "[vrj::GlPipe::start()] Started control loop. " << mActiveThread93 << "[vrj::GlPipe::start()] Started control loop. " << thread 95 94 << std::endl << vprDEBUG_FLUSH; 96 95 started = 1; … … 190 189 // - Signal swap completed <br> 191 190 // 192 void GlPipe::controlLoop() 193 { 191 void GlPipe::controlLoop(const int cpuAffinity) 192 { 193 vprASSERT(NULL != vpr::Thread::self()); 194 mActiveThread = vpr::Thread::self(); 195 196 if ( cpuAffinity >= 0 ) 197 { 198 // On this branch, vpr::Thread::setRunOn() is only available with 199 // POSIX threads. 200 #if VPR_THREAD_DOMAIN_INCLUDE == VPR_DOMAIN_POSIX 201 vprDEBUG(vrjDBG_DRAW_MGR, vprDBG_STATE_LVL) 202 << "[vrj::GlPipe::controlLoop()] Setting CPU affinity for pipe " 203 << mPipeNum << " to " << cpuAffinity << std::endl << vprDEBUG_FLUSH; 204 205 try 206 { 207 mActiveThread->setRunOn(cpuAffinity); 208 } 209 catch (vpr::Exception& ex) 210 { 211 vprDEBUG(vrjDBG_DRAW_MGR, vprDBG_WARNING_LVL) 212 << clrOutBOLD(clrYELLOW, "WARNING") 213 << ": Failed to set draw thread affinity in vrj::GlPipe:\n" 214 << ex.what() << std::endl << vprDEBUG_FLUSH; 215 } 216 #else 217 vprDEBUG(vrjDBG_DRAW_MGR, vprDBG_WARNING_LVL) 218 << "Setting CPU affinity for vrj::GlPipe is not supported on this " 219 << "platform." << std::endl << vprDEBUG_FLUSH; 220 #endif 221 } 222 194 223 mThreadRunning = true; // We are running so set flag 195 224 // Loop until flag set juggler/branches/2.2/modules/vrjuggler/vrj/Draw/OGL/GlPipe.h
r20661 r20836 73 73 * 74 74 * @pre The pipe should not have a thread of control yet. 75 * @post The pipe has it 's own thread of control and is ready to operate75 * @post The pipe has its own thread of control and is ready to operate 76 76 * The Thread of control is running controlLoop. 77 * 78 * @param cpuAffinity The CPU affinity to assign for the rendering thread 79 * spawned by this method. A value less than 0 80 * indicates that no CPU affinity will be assigned to 81 * the rendering thread. 82 * 77 83 * @note The pipe does NOT have to have any windows in order to run 78 84 * that way we can add windows to pipes at run-time. 79 */ 80 int start(); 85 * @note The signature of this method changed in version 2.3.14 to take the 86 * CPU affinity value. 87 */ 88 int start(const int cpuAffinity); 81 89 82 90 /** 83 91 * The main loop routine. 84 * -Checks for new windows <br> 85 * -renders all windows when triggered <br> 86 */ 87 void controlLoop(); 92 * - Checks for new windows. 93 * - Renders all windows when triggered. 94 * 95 * @param cpuAffinity The CPU affinity to assign for the rendering thread 96 * spawned by this method. A value less than 0 97 * indicates that no CPU affinity will be assigned to 98 * the rendering thread. 99 * 100 * @note The signature of this method changed in version 2.3.14 to take the 101 * CPU affinity value. 102 * 103 * @see vpr::Thead::setRunOn() 104 */ 105 void controlLoop(const int cpuAffinity); 88 106 89 107 /** juggler/branches/2.2/modules/vrjuggler/vrj/Draw/OGL/Makefile.in
r20092 r20836 42 42 SUBOBJDIR= $(GL_LIBRARY) 43 43 44 SRCS= GlApp.cpp \ 44 SRCS= CpuAffinityFromEnv.cpp \ 45 GlApp.cpp \ 45 46 GlBasicSimulator.cpp \ 46 47 GlDrawManager.cpp \ juggler/branches/2.2/vc7/VRJuggler/VRJuggler.vcproj
r20500 r20836 198 198 </File> 199 199 <File 200 RelativePath="..\..\modules\vrjuggler\vrj\Draw\CpuAffinityFromEnv.cpp"> 201 </File> 202 <File 200 203 RelativePath="..\..\modules\vrjuggler\vrj\Display\Display.cpp"> 201 204 </File> … … 272 275 <File 273 276 RelativePath="..\..\modules\vrjuggler\vrj\Display\CameraProjection.h"> 277 </File> 278 <File 279 RelativePath="..\..\modules\vrjuggler\vrj\Draw\CpuAffinityFromEnv.h"> 274 280 </File> 275 281 <File juggler/branches/2.2/vc8/VRJuggler/VRJuggler.vcproj
r20548 r20836 565 565 </File> 566 566 <File 567 RelativePath="..\..\modules\vrjuggler\vrj\Draw\CpuAffinityFromEnv.cpp" 568 > 569 </File> 570 <File 567 571 RelativePath="..\..\modules\vrjuggler\vrj\Display\Display.cpp" 568 572 > … … 666 670 </File> 667 671 <File 672 RelativePath="..\..\modules\vrjuggler\vrj\Draw\CpuAffinityFromEnv.h" 673 > 674 </File> 675 <File 668 676 RelativePath="..\..\modules\vrjuggler\vrj\Util\Debug.h" 669 677 >
