Geant4 Cross Reference |
1 // 1 // 2 // ******************************************* 2 // ******************************************************************** 3 // * License and Disclaimer 3 // * License and Disclaimer * 4 // * 4 // * * 5 // * The Geant4 software is copyright of th 5 // * The Geant4 software is copyright of the Copyright Holders of * 6 // * the Geant4 Collaboration. It is provided 6 // * the Geant4 Collaboration. It is provided under the terms and * 7 // * conditions of the Geant4 Software License 7 // * conditions of the Geant4 Software License, included in the file * 8 // * LICENSE and available at http://cern.ch/ 8 // * LICENSE and available at http://cern.ch/geant4/license . These * 9 // * include a list of copyright holders. 9 // * include a list of copyright holders. * 10 // * 10 // * * 11 // * Neither the authors of this software syst 11 // * Neither the authors of this software system, nor their employing * 12 // * institutes,nor the agencies providing fin 12 // * institutes,nor the agencies providing financial support for this * 13 // * work make any representation or warran 13 // * work make any representation or warranty, express or implied, * 14 // * regarding this software system or assum 14 // * regarding this software system or assume any liability for its * 15 // * use. Please see the license in the file 15 // * use. Please see the license in the file LICENSE and URL above * 16 // * for the full disclaimer and the limitatio 16 // * for the full disclaimer and the limitation of liability. * 17 // * 17 // * * 18 // * This code implementation is the result 18 // * This code implementation is the result of the scientific and * 19 // * technical work of the GEANT4 collaboratio 19 // * technical work of the GEANT4 collaboration. * 20 // * By using, copying, modifying or distri 20 // * By using, copying, modifying or distributing the software (or * 21 // * any work based on the software) you ag 21 // * any work based on the software) you agree to acknowledge its * 22 // * use in resulting scientific publicati 22 // * use in resulting scientific publications, and indicate your * 23 // * acceptance of all terms of the Geant4 Sof 23 // * acceptance of all terms of the Geant4 Software license. * 24 // ******************************************* 24 // ******************************************************************** 25 // 25 // 26 // 26 // 27 27 28 // /vis/multithreading commands - John Allison 28 // /vis/multithreading commands - John Allison 29th September 2015 29 29 >> 30 #include "G4Types.hh" >> 31 #ifdef G4MULTITHREADED >> 32 30 #include "G4VisCommandsMultithreading.hh" 33 #include "G4VisCommandsMultithreading.hh" 31 34 32 #include "G4Threading.hh" << 33 #include "G4UIcmdWithAnInteger.hh" 35 #include "G4UIcmdWithAnInteger.hh" 34 #include "G4UIcmdWithAString.hh" 36 #include "G4UIcmdWithAString.hh" 35 #include "G4VisManager.hh" 37 #include "G4VisManager.hh" 36 38 37 // For future use with additional G4ios loggin << 38 #define G4warn G4cout << 39 << 40 ////////////// /vis/multithreading/actionOnEve 39 ////////////// /vis/multithreading/actionOnEventQueueFull /////////////////////////////////////// 41 40 42 G4VisCommandMultithreadingActionOnEventQueueFu 41 G4VisCommandMultithreadingActionOnEventQueueFull::G4VisCommandMultithreadingActionOnEventQueueFull() 43 { 42 { 44 G4bool omitable; 43 G4bool omitable; 45 fpCommand = new G4UIcmdWithAString("/vis/mul 44 fpCommand = new G4UIcmdWithAString("/vis/multithreading/actionOnEventQueueFull", this); 46 fpCommand->SetGuidance("When event queue for 45 fpCommand->SetGuidance("When event queue for drawing gets full:"); 47 fpCommand->SetGuidance("wait: event processi 46 fpCommand->SetGuidance("wait: event processing waits for vis manager to catch up."); 48 fpCommand->SetGuidance("discard: events are 47 fpCommand->SetGuidance("discard: events are discarded for drawing."); 49 fpCommand->SetCandidates("wait discard"); 48 fpCommand->SetCandidates("wait discard"); 50 fpCommand->SetParameterName ("wait", omitabl 49 fpCommand->SetParameterName ("wait", omitable = true); 51 fpCommand->SetDefaultValue ("wait"); 50 fpCommand->SetDefaultValue ("wait"); 52 } 51 } 53 52 54 G4VisCommandMultithreadingActionOnEventQueueFu 53 G4VisCommandMultithreadingActionOnEventQueueFull::~G4VisCommandMultithreadingActionOnEventQueueFull() 55 { 54 { 56 delete fpCommand; 55 delete fpCommand; 57 } 56 } 58 57 59 G4String G4VisCommandMultithreadingActionOnEve 58 G4String G4VisCommandMultithreadingActionOnEventQueueFull::GetCurrentValue(G4UIcommand*) 60 { 59 { 61 return ""; 60 return ""; 62 } 61 } 63 62 64 void G4VisCommandMultithreadingActionOnEventQu 63 void G4VisCommandMultithreadingActionOnEventQueueFull::SetNewValue(G4UIcommand*, G4String newValue) 65 { 64 { 66 G4VisManager::Verbosity verbosity = fpVisMan 65 G4VisManager::Verbosity verbosity = fpVisManager->GetVerbosity(); 67 66 68 // Only relevant in a MT application << 69 if(!G4Threading::IsMultithreadedApplication( << 70 if (verbosity >= G4VisManager::warnings) { << 71 G4warn << "command /vis/multithreading/a << 72 } << 73 return; << 74 } << 75 << 76 if (newValue == "wait") { 67 if (newValue == "wait") { 77 fpVisManager->SetWaitOnEventQueueFull(true 68 fpVisManager->SetWaitOnEventQueueFull(true); 78 } else { 69 } else { 79 fpVisManager->SetWaitOnEventQueueFull(fals 70 fpVisManager->SetWaitOnEventQueueFull(false); 80 } 71 } 81 72 82 if (verbosity >= G4VisManager::confirmations 73 if (verbosity >= G4VisManager::confirmations) { 83 G4cout << 74 G4cout << 84 "When event queue for drawing is full,"; 75 "When event queue for drawing is full,"; 85 if (fpVisManager->GetWaitOnEventQueueFull( 76 if (fpVisManager->GetWaitOnEventQueueFull()) { 86 G4cout << " event processing will wait"; 77 G4cout << " event processing will wait"; 87 } else { 78 } else { 88 G4cout << " events will be discarded for 79 G4cout << " events will be discarded for drawing"; 89 } 80 } 90 G4cout << G4endl; 81 G4cout << G4endl; 91 } 82 } 92 } 83 } 93 84 94 ////////////// /vis/multithreading/maxEventQue 85 ////////////// /vis/multithreading/maxEventQueueSize /////////////////////////////////////// 95 86 96 G4VisCommandMultithreadingMaxEventQueueSize::G 87 G4VisCommandMultithreadingMaxEventQueueSize::G4VisCommandMultithreadingMaxEventQueueSize() 97 { 88 { 98 G4bool omitable; 89 G4bool omitable; 99 fpCommand = new G4UIcmdWithAnInteger("/vis/m 90 fpCommand = new G4UIcmdWithAnInteger("/vis/multithreading/maxEventQueueSize", this); 100 fpCommand->SetGuidance 91 fpCommand->SetGuidance 101 ("Defines maximum event queue size. N <=0 me 92 ("Defines maximum event queue size. N <=0 means \"unlimited\"."); 102 fpCommand->SetGuidance 93 fpCommand->SetGuidance 103 ("If adding an event to the visualisation ev 94 ("If adding an event to the visualisation event queue would cause the" 104 " queue size to exceed this value:"); 95 " queue size to exceed this value:"); 105 fpCommand->SetGuidance 96 fpCommand->SetGuidance 106 (" if actionOnEventQueueFull==wait the worke 97 (" if actionOnEventQueueFull==wait the worker threads are paused for a short" 107 " time to give the visualisation manager a 98 " time to give the visualisation manager a chance to catch up."); 108 fpCommand->SetGuidance 99 fpCommand->SetGuidance 109 (" if actionOnEventQueueFull==discard the ev 100 (" if actionOnEventQueueFull==discard the event is discarded for drawing."); 110 fpCommand->SetParameterName ("maxSize", omit 101 fpCommand->SetParameterName ("maxSize", omitable = true); 111 fpCommand->SetDefaultValue (100); 102 fpCommand->SetDefaultValue (100); 112 } 103 } 113 104 114 G4VisCommandMultithreadingMaxEventQueueSize::~ 105 G4VisCommandMultithreadingMaxEventQueueSize::~G4VisCommandMultithreadingMaxEventQueueSize() 115 { 106 { 116 delete fpCommand; 107 delete fpCommand; 117 } 108 } 118 109 119 G4String G4VisCommandMultithreadingMaxEventQue 110 G4String G4VisCommandMultithreadingMaxEventQueueSize::GetCurrentValue(G4UIcommand*) 120 { 111 { 121 return ""; 112 return ""; 122 } 113 } 123 114 124 void G4VisCommandMultithreadingMaxEventQueueSi 115 void G4VisCommandMultithreadingMaxEventQueueSize::SetNewValue(G4UIcommand*, G4String newValue) 125 { 116 { 126 G4VisManager::Verbosity verbosity = fpVisMan 117 G4VisManager::Verbosity verbosity = fpVisManager->GetVerbosity(); 127 118 128 // Only relevant in a MT application << 129 if(!G4Threading::IsMultithreadedApplication( << 130 if (verbosity >= G4VisManager::warnings) { << 131 G4warn << "command /vis/multithreading/m << 132 } << 133 return; << 134 } << 135 << 136 G4int maxEventQueueSize = fpCommand->GetNewI 119 G4int maxEventQueueSize = fpCommand->GetNewIntValue(newValue); 137 fpVisManager->SetMaxEventQueueSize(maxEventQ 120 fpVisManager->SetMaxEventQueueSize(maxEventQueueSize); 138 121 139 if (verbosity >= G4VisManager::confirmations 122 if (verbosity >= G4VisManager::confirmations) { 140 G4cout << 123 G4cout << 141 "Maximum event queue size has been set to 124 "Maximum event queue size has been set to " 142 << fpVisManager->GetMaxEventQueueSize() 125 << fpVisManager->GetMaxEventQueueSize() 143 << G4endl; 126 << G4endl; 144 } 127 } 145 } 128 } >> 129 >> 130 #endif 146 131