Changeset 1337 for trunk/examples/extended/parallel/MPI
- Timestamp:
- Sep 30, 2010, 2:47:17 PM (14 years ago)
- Location:
- trunk/examples/extended/parallel/MPI
- Files:
-
- 61 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/examples/extended/parallel/MPI/History
r807 r1337 1 $Id: History,v 1. 1 2007/11/16 04:02:10 kmuraExp $1 $Id: History,v 1.3 2010/06/06 05:07:23 perl Exp $ 2 2 ------------------------------------------------------------------- 3 3 … … 13 13 ---------------------------------------------------------- 14 14 15 4 June 2010 J.Perl (MPI-V09-03-01) 16 - Updated vis usage. 17 18 18 May 2010 K.Murakami (MPI-V09-03-00) 19 == code review was performed. == 20 << mpi_ineterface >> 21 - OpenMPI as default MPI library instead of LAM/MPI 22 - improve /mpi/status command. (waste of CPU, time measurement) 23 - /mpi/wait command is introduced for waiting until beamOn ends. 24 - improve macro file parser 25 * same parser as G4UIbatch 26 * fixed unexpected behavior at the end of batch mode 27 - changed "beamOn" behavior for better performance 28 * thread-out for interactive, on-thread for batch 29 << exMPI01 >> 30 - use G4UIcsh instead of G4UItcsh because OpenMPI is now default. 31 - use G4eMultipleScattering instead of obsolete G4MultipleScattering. 32 << exMPI02 >> 33 - use G4UIcsh instead of G4UItcsh because OpenMPI is now default. 34 35 15 36 16 Nov. 2007 K.Murakami 16 37 - commited to G4 CVS. -
trunk/examples/extended/parallel/MPI/README
r807 r1337 1 $Id: README,v 1. 2 2007/11/16 14:04:05kmura Exp $1 $Id: README,v 1.3 2010/05/18 06:09:09 kmura Exp $ 2 2 ========================================================================== 3 3 Geant4 MPI Interface … … 12 12 a Geant4 UI library and a couple of parallelized examples. 13 13 Using this interface, users applications can be parllelized with 14 different MPI compliant libraries, such as LAM/MPI, MPICH2, OpenMPI,14 different MPI compliant libraries, such as OpenMPI, LAM/MPI, MPICH2, 15 15 and so on. 16 16 … … 25 25 * MPI implementation 26 26 27 - LAM/MPI (7.1.3) 27 - Open MPI (1.4.2) 28 http://www.open-mpi.org/ 29 30 - LAM/MPI (7.1.3) (development is terminated. maintenance only) 28 31 http://www.lam-mpi.org/ 29 32 30 - MPICH2 (1. 0.6p1)33 - MPICH2 (1.2.1p1) 31 34 http://www.mcs.anl.gov/research/projects/mpich2/ 32 33 - Open MPI (1.2.4)34 http://www.open-mpi.org/35 36 35 37 36 * Optional … … 42 41 ---------------- 43 42 G4MPI UI library is provided in the "mpi_interface" directory. 44 Start with building the G4MPI UI library according to the instruction 43 Start with building the G4MPI UI library according to the instruction 45 44 in the directory. 46 45 … … 60 59 // MPI session (G4MPIsession) instead of G4UIterminal 61 60 G4MPIsession* session= g4MPI-> GetMPIsession(); 62 63 // LAM users can use G4tcsh.64 G4String prompt= "G4MPI";65 G4UItcsh* tcsh= new G4UItcsh(prompt);66 session-> SetShell(tcsh);67 61 68 62 // user application setting … … 86 80 For other users (Open MPI/MPICH2), plese use G4csh (default). 87 81 82 In case of OpenMPI, LD_LIBRARY_PATH for OpenMPI runtime libraries 83 should be set at run time. Alternatively, you can add this path 84 to the dynamic linker configuration using `ldconfig`. 85 (needs sys-admin authorization) 86 88 87 89 88 How to use: … … 93 92 1. Make hosts/cluster configuration of your MPI environment. 94 93 95 2. Launch MPI runtime environment, typically executing 94 2. Launch MPI runtime environment, typically executing 96 95 lamboot (LAM) / mpdboot (MPICH2). 97 96 … … 119 118 execute * Execute a macro file. (=/control/execute) 120 119 beamOn * Start a parallel run w/ thread. 121 .beamOn * Start a parallel run w/o thread. (=/run/beamOn)120 .beamOn * Start a parallel run w/o thread. 122 121 masterWeight * Set weight for master node. 122 wait * Wait until beamOn-s on all nodes are done. (batch mode only) 123 123 showSeeds * Show seeds of MPI nodes. 124 124 setMasterSeed * Set a master seed for the seed generator. … … 126 126 127 127 * Notes: 128 While "/run/beamOn" is executed in foreground, the "/mpi/beamOn" 129 command invokes beam-on in background, so you can input UI commands 130 even while event processing. 128 While "/run/beamOn" and "/mpi/beamOn" commands invoke beam-on in background, 129 so you can input UI commands even while event processing. 131 130 132 The original "/control/execute" and "/run/beamOn" are overwritten 133 with "/mpi/execute" and "/mpi/ .beamOn" commands, customized for134 the MPI interface.131 The original "/control/execute" and "/run/beamOn" are overwritten 132 with "/mpi/execute" and "/mpi/beamOn" commands respectively, 133 customized for the MPI interface. 135 134 136 135 … … 142 141 for running examples: 143 142 144 - G4LEVELGAMMADATA : directory path for the data of 143 - G4LEVELGAMMADATA : directory path for the data of 145 144 "low energy electromagnetic processes". 146 145 147 For running ROOT applications, 146 For running ROOT applications, 148 147 149 148 - ROOTSYS : root path of the ROOT package … … 174 173 * treat multiple outputs properly: 175 174 each slave node generate a ROOT file, whose file name should 176 be different from each other. 175 be different from each other. 177 176 -
trunk/examples/extended/parallel/MPI/exMPI01/GNUmakefile
r1230 r1337 1 # $Id: GNUmakefile,v 1. 1 2007/11/16 14:16:46 kmuraExp $2 # $Name: geant4-09-0 3-cand-01 $1 # $Id: GNUmakefile,v 1.2 2010/01/11 16:53:51 gcosmo Exp $ 2 # $Name: geant4-09-04-beta-01 $ 3 3 # =========================================================== 4 4 # Makefile for building G4 MPI aplication 5 5 # =========================================================== 6 name := exMPI01# 6 7 name := exMPI01 7 8 G4TARGET := $(name) 8 9 G4EXLIB := true 9 10 10 G4WORKDIR := . 11 ifndef G4INSTALL 12 G4INSTALL = ../../../../.. 13 endif 11 14 12 15 .PHONY: all -
trunk/examples/extended/parallel/MPI/exMPI01/History
r807 r1337 1 $Id: History,v 1. 1 2007/11/16 14:16:46 kmuraExp $1 $Id: History,v 1.3 2010/06/06 05:07:23 perl Exp $ 2 2 ------------------------------------------------------------------- 3 3 … … 9 9 --------------- 10 10 11 4 June 2010 J.Perl 12 - Updated vis usage. 13 14 18 May 2010 K.Murakami 15 - use G4UIcsh instead of G4UItcsh because OpenMPI is now default. 16 - use G4eMultipleScattering instead of obsolete G4MultipleScattering. 17 11 18 16 Nov. 2007 K.Murakami 12 19 - commited to G4 CVS. 13 20 14 -
trunk/examples/extended/parallel/MPI/exMPI01/exMPI01.cc
r1230 r1337 24 24 // ******************************************************************** 25 25 // 26 // $Id: exMPI01.cc,v 1. 1 2007/11/16 14:16:46kmura Exp $27 // $Name: geant4-09-0 3-cand-01 $26 // $Id: exMPI01.cc,v 1.2 2010/05/18 06:07:43 kmura Exp $ 27 // $Name: geant4-09-04-beta-01 $ 28 28 // 29 29 // ==================================================================== … … 43 43 #include "G4MPImanager.hh" 44 44 #include "G4MPIsession.hh" 45 #include "G4UItcsh.hh"46 45 47 46 #ifdef G4VIS_USE … … 70 69 prompt+= "G4MPI"; 71 70 prompt+= "[40;31m(%s)[40;36m[%/][00;30m:"; 72 73 G4UItcsh* tcsh= new G4UItcsh(prompt); 74 tcsh-> SetLsColor(BLUE,RED); 75 session-> SetShell(tcsh); 71 session-> SetPrompt(prompt); 76 72 77 73 // -------------------------------------------------------------------- -
trunk/examples/extended/parallel/MPI/exMPI01/include/DetectorConstruction.hh
r807 r1337 25 25 // 26 26 // $Id: DetectorConstruction.hh,v 1.1 2007/11/16 14:16:46 kmura Exp $ 27 // $Name: $27 // $Name: geant4-09-04-beta-01 $ 28 28 // 29 29 // ==================================================================== -
trunk/examples/extended/parallel/MPI/exMPI01/include/Materials.hh
r807 r1337 25 25 // 26 26 // $Id: Materials.hh,v 1.1 2007/11/16 14:16:46 kmura Exp $ 27 // $Name: $27 // $Name: geant4-09-04-beta-01 $ 28 28 // 29 29 // ==================================================================== -
trunk/examples/extended/parallel/MPI/exMPI01/include/Particles.hh
r807 r1337 25 25 // 26 26 // $Id: Particles.hh,v 1.1 2007/11/16 14:16:46 kmura Exp $ 27 // $Name: $27 // $Name: geant4-09-04-beta-01 $ 28 28 // 29 29 // ==================================================================== -
trunk/examples/extended/parallel/MPI/exMPI01/include/PhysicsList.hh
r807 r1337 25 25 // 26 26 // $Id: PhysicsList.hh,v 1.1 2007/11/16 14:16:46 kmura Exp $ 27 // $Name: $27 // $Name: geant4-09-04-beta-01 $ 28 28 // 29 29 // ==================================================================== -
trunk/examples/extended/parallel/MPI/exMPI01/include/PhysicsListEMstd.hh
r807 r1337 25 25 // 26 26 // $Id: PhysicsListEMstd.hh,v 1.1 2007/11/16 14:16:46 kmura Exp $ 27 // $Name: $27 // $Name: geant4-09-04-beta-01 $ 28 28 // 29 29 // ==================================================================== -
trunk/examples/extended/parallel/MPI/exMPI01/include/PrimaryGeneratorAction.hh
r807 r1337 25 25 // 26 26 // $Id: PrimaryGeneratorAction.hh,v 1.1 2007/11/16 14:16:46 kmura Exp $ 27 // $Name: $27 // $Name: geant4-09-04-beta-01 $ 28 28 // 29 29 // ==================================================================== -
trunk/examples/extended/parallel/MPI/exMPI01/src/DetectorConstruction.cc
r807 r1337 25 25 // 26 26 // $Id: DetectorConstruction.cc,v 1.1 2007/11/16 14:16:46 kmura Exp $ 27 // $Name: $27 // $Name: geant4-09-04-beta-01 $ 28 28 // 29 29 // ==================================================================== -
trunk/examples/extended/parallel/MPI/exMPI01/src/Materials.cc
r807 r1337 25 25 // 26 26 // $Id: Materials.cc,v 1.1 2007/11/16 14:16:46 kmura Exp $ 27 // $Name: $27 // $Name: geant4-09-04-beta-01 $ 28 28 // 29 29 // ==================================================================== -
trunk/examples/extended/parallel/MPI/exMPI01/src/Particles.cc
r807 r1337 25 25 // 26 26 // $Id: Particles.cc,v 1.1 2007/11/16 14:16:46 kmura Exp $ 27 // $Name: $27 // $Name: geant4-09-04-beta-01 $ 28 28 // 29 29 // ==================================================================== -
trunk/examples/extended/parallel/MPI/exMPI01/src/PhysicsList.cc
r807 r1337 25 25 // 26 26 // $Id: PhysicsList.cc,v 1.1 2007/11/16 14:16:46 kmura Exp $ 27 // $Name: $27 // $Name: geant4-09-04-beta-01 $ 28 28 // 29 29 // ==================================================================== -
trunk/examples/extended/parallel/MPI/exMPI01/src/PhysicsListEMstd.cc
r807 r1337 24 24 // ******************************************************************** 25 25 // 26 // $Id: PhysicsListEMstd.cc,v 1. 1 2007/11/16 14:16:46kmura Exp $27 // $Name: $26 // $Id: PhysicsListEMstd.cc,v 1.2 2010/05/13 03:12:00 kmura Exp $ 27 // $Name: geant4-09-04-beta-01 $ 28 28 // 29 29 // ==================================================================== … … 48 48 #include "G4GammaConversion.hh" 49 49 #include "G4PhotoElectricEffect.hh" 50 #include "G4 MultipleScattering.hh"50 #include "G4eMultipleScattering.hh" 51 51 #include "G4eIonisation.hh" 52 52 #include "G4eBremsstrahlung.hh" … … 87 87 G4ProcessManager* pm; 88 88 89 // ---------------------------------------------------------- 89 // ---------------------------------------------------------- 90 90 // gamma physics 91 91 // ---------------------------------------------------------- … … 98 98 // electron physics 99 99 // ---------------------------------------------------------- 100 G4 MultipleScattering* msc= new G4MultipleScattering;100 G4eMultipleScattering* msc= new G4eMultipleScattering; 101 101 G4eIonisation* eion= new G4eIonisation; 102 102 G4eBremsstrahlung* ebrems= new G4eBremsstrahlung; … … 110 110 // positron physics 111 111 // ---------------------------------------------------------- 112 msc= new G4 MultipleScattering;112 msc= new G4eMultipleScattering; 113 113 eion= new G4eIonisation; 114 114 ebrems= new G4eBremsstrahlung; … … 123 123 } 124 124 125 -
trunk/examples/extended/parallel/MPI/exMPI01/src/PrimaryGeneratorAction.cc
r807 r1337 25 25 // 26 26 // $Id: PrimaryGeneratorAction.cc,v 1.1 2007/11/16 14:16:46 kmura Exp $ 27 // $Name: $27 // $Name: geant4-09-04-beta-01 $ 28 28 // 29 29 // ==================================================================== -
trunk/examples/extended/parallel/MPI/exMPI01/v.mac
r807 r1337 1 /vis/open OGLIX 2 3 /vis/scene/create 4 /vis/scene/add/volume 5 6 /vis/sceneHandler/attach 7 1 # Use this open statement to create an OpenGL view: 2 /vis/open OGL 600x600-0+0 3 # 4 # Use this open statement to create a .prim file suitable for 5 # viewing in DAWN: 6 #/vis/open DAWNFILE 7 # 8 # Use this open statement to create a .heprep file suitable for 9 # viewing in HepRApp: 10 #/vis/open HepRepFile 11 # 12 # Use this open statement to create a .wrl file suitable for 13 # viewing in a VRML viewer: 14 #/vis/open VRML2FILE 15 # 16 # Disable auto refresh and quieten vis messages whilst scene and 17 # trajectories are established: 18 /vis/viewer/set/autoRefresh false 19 /vis/verbose errors 20 # 21 # Draw geometry: 22 /vis/drawVolume 23 # 24 # Specify view angle: 8 25 /vis/viewer/set/viewpointThetaPhi 90. 270. 9 10 /tracking/storeTrajectory 1 11 /vis/scene/add/trajectories 26 # 27 # Specify zoom value: 28 #/vis/viewer/zoom 2. 29 # 30 # Specify style (surface or wireframe): 31 #/vis/viewer/set/style wireframe 32 # 33 # Draw coordinate axes: 34 #/vis/scene/add/axes 0 0 0 1 m 35 # 36 # Draw smooth trajectories at end of event, showing trajectory points 37 # as markers 2 pixels wide: 38 /vis/scene/add/trajectories smooth 39 /vis/modeling/trajectories/create/drawByCharge 40 /vis/modeling/trajectories/drawByCharge-0/default/setDrawStepPts true 41 /vis/modeling/trajectories/drawByCharge-0/default/setStepPtsSize 2 42 # (if too many tracks cause core dump => /tracking/storeTrajectory 0) 43 # 44 # Draw hits at end of event: 45 #/vis/scene/add/hits 46 # 47 # To draw only gammas: 48 #/vis/filtering/trajectories/create/particleFilter 49 #/vis/filtering/trajectories/particleFilter-0/add gamma 50 # 51 # To invert the above, drawing all particles except gammas, 52 # keep the above two lines but also add: 53 #/vis/filtering/trajectories/particleFilter-0/invert true 54 # 55 # Many other options are available with /vis/modeling and /vis/filtering. 56 # For example, to select colour by particle ID: 57 #/vis/modeling/trajectories/create/drawByParticleID 58 #/vis/modeling/trajectories/drawByParticleID-0/set e- blue 59 # 60 # To superimpose all of the events from a given run: 12 61 /vis/scene/endOfEventAction accumulate 13 #/vis/scene/endOfEventAction refresh 14 15 62 # 63 # Re-establish auto refreshing and verbosity: 64 /vis/viewer/set/autoRefresh true 65 /vis/verbose warnings 66 # 67 # For file-based drivers, use this to create an empty detector view: 68 #/vis/viewer/flush -
trunk/examples/extended/parallel/MPI/exMPI02/GNUmakefile
r1230 r1337 1 # $Id: GNUmakefile,v 1. 1 2007/11/16 14:28:34 kmuraExp $2 # $Name: geant4-09-0 3-cand-01 $1 # $Id: GNUmakefile,v 1.2 2010/01/11 16:55:08 gcosmo Exp $ 2 # $Name: geant4-09-04-beta-01 $ 3 3 # =========================================================== 4 4 # Makefile for building G4 MPI aplication 5 5 # =========================================================== 6 name := exMPI02# 6 7 name := exMPI02 7 8 G4TARGET := $(name) 8 9 G4EXLIB := true 9 10 10 G4WORKDIR := . 11 ifndef G4INSTALL 12 G4INSTALL = ../../../../.. 13 endif 11 14 12 15 .PHONY: all -
trunk/examples/extended/parallel/MPI/exMPI02/History
r807 r1337 1 $Id: History,v 1. 1 2007/11/16 14:28:34 kmuraExp $1 $Id: History,v 1.3 2010/06/06 05:07:23 perl Exp $ 2 2 ------------------------------------------------------------------- 3 3 … … 9 9 --------------- 10 10 11 4 June 2010 J.Perl 12 - Updated vis usage. 13 14 18 May 2010 K.Murakami 15 - use G4UIcsh instead of G4UItcsh because OpenMPI is now default. 16 11 17 16 Nov. 2007 K.Murakami 12 18 - commited to G4 CVS. 13 19 14 -
trunk/examples/extended/parallel/MPI/exMPI02/exMPI02.cc
r1230 r1337 24 24 // ******************************************************************** 25 25 // 26 // $Id: exMPI02.cc,v 1. 1 2007/11/16 14:28:34kmura Exp $27 // $Name: geant4-09-0 3-cand-01 $26 // $Id: exMPI02.cc,v 1.2 2010/05/18 06:08:30 kmura Exp $ 27 // $Name: geant4-09-04-beta-01 $ 28 28 // 29 29 // ==================================================================== … … 45 45 #include "G4MPImanager.hh" 46 46 #include "G4MPIsession.hh" 47 #include "G4UItcsh.hh"48 47 49 48 #ifdef G4VIS_USE … … 71 70 prompt+= "G4MPI"; 72 71 prompt+= "[40;31m(%s)[40;36m[%/][00;30m:"; 73 74 G4UItcsh* tcsh= new G4UItcsh(prompt); 75 tcsh-> SetLsColor(BLUE,RED); 76 session-> SetShell(tcsh); 72 session-> SetPrompt(prompt); 77 73 78 74 // -------------------------------------------------------------------- -
trunk/examples/extended/parallel/MPI/exMPI02/include/Analysis.hh
r807 r1337 25 25 // 26 26 // $Id: Analysis.hh,v 1.1 2007/11/16 14:29:32 kmura Exp $ 27 // $Name: $27 // $Name: geant4-09-04-beta-01 $ 28 28 // 29 29 // ==================================================================== -
trunk/examples/extended/parallel/MPI/exMPI02/include/DetectorConstruction.hh
r807 r1337 25 25 // 26 26 // $Id: DetectorConstruction.hh,v 1.1 2007/11/16 14:29:32 kmura Exp $ 27 // $Name: $27 // $Name: geant4-09-04-beta-01 $ 28 28 // 29 29 // ==================================================================== -
trunk/examples/extended/parallel/MPI/exMPI02/include/EventAction.hh
r807 r1337 25 25 // 26 26 // $Id: EventAction.hh,v 1.2 2007/12/10 16:28:34 gunter Exp $ 27 // $Name: $27 // $Name: geant4-09-04-beta-01 $ 28 28 // ==================================================================== 29 29 // EventAction.hh -
trunk/examples/extended/parallel/MPI/exMPI02/include/MedicalBeam.hh
r807 r1337 25 25 // 26 26 // $Id: MedicalBeam.hh,v 1.1 2007/11/16 14:29:33 kmura Exp $ 27 // $Name: $27 // $Name: geant4-09-04-beta-01 $ 28 28 // ==================================================================== 29 29 // MedicalBeam.hh -
trunk/examples/extended/parallel/MPI/exMPI02/include/RunAction.hh
r807 r1337 25 25 // 26 26 // $Id: RunAction.hh,v 1.2 2007/12/10 16:28:39 gunter Exp $ 27 // $Name: $27 // $Name: geant4-09-04-beta-01 $ 28 28 // ==================================================================== 29 29 // RunAction.hh -
trunk/examples/extended/parallel/MPI/exMPI02/include/VoxelParam.hh
r807 r1337 25 25 // 26 26 // $Id: VoxelParam.hh,v 1.1 2007/11/16 14:29:33 kmura Exp $ 27 // $Name: $27 // $Name: geant4-09-04-beta-01 $ 28 28 // 29 29 // ==================================================================== -
trunk/examples/extended/parallel/MPI/exMPI02/include/VoxelSD.hh
r807 r1337 25 25 // 26 26 // $Id: VoxelSD.hh,v 1.1 2007/11/16 14:29:33 kmura Exp $ 27 // $Name: $27 // $Name: geant4-09-04-beta-01 $ 28 28 // 29 29 // ==================================================================== -
trunk/examples/extended/parallel/MPI/exMPI02/src/Analysis.cc
r807 r1337 25 25 // 26 26 // $Id: Analysis.cc,v 1.1 2007/11/16 14:29:33 kmura Exp $ 27 // $Name: $27 // $Name: geant4-09-04-beta-01 $ 28 28 // 29 29 // ==================================================================== -
trunk/examples/extended/parallel/MPI/exMPI02/src/DetectorConstruction.cc
r807 r1337 25 25 // 26 26 // $Id: DetectorConstruction.cc,v 1.1 2007/11/16 14:29:33 kmura Exp $ 27 // $Name: $27 // $Name: geant4-09-04-beta-01 $ 28 28 // 29 29 // ==================================================================== -
trunk/examples/extended/parallel/MPI/exMPI02/src/EventAction.cc
r807 r1337 25 25 // 26 26 // $Id: EventAction.cc,v 1.2 2007/12/10 16:28:52 gunter Exp $ 27 // $Name: $27 // $Name: geant4-09-04-beta-01 $ 28 28 // ==================================================================== 29 29 // EventAction.cc -
trunk/examples/extended/parallel/MPI/exMPI02/src/MedicalBeam.cc
r807 r1337 25 25 // 26 26 // $Id: MedicalBeam.cc,v 1.1 2007/11/16 14:29:33 kmura Exp $ 27 // $Name: $27 // $Name: geant4-09-04-beta-01 $ 28 28 // ==================================================================== 29 29 // MedicalBeam.cc -
trunk/examples/extended/parallel/MPI/exMPI02/src/RunAction.cc
r807 r1337 25 25 // 26 26 // $Id: RunAction.cc,v 1.2 2007/12/10 16:28:54 gunter Exp $ 27 // $Name: $27 // $Name: geant4-09-04-beta-01 $ 28 28 // ==================================================================== 29 29 // RunAction.cc -
trunk/examples/extended/parallel/MPI/exMPI02/src/VoxelParam.cc
r807 r1337 25 25 // 26 26 // $Id: VoxelParam.cc,v 1.1 2007/11/16 14:29:33 kmura Exp $ 27 // $Name: $27 // $Name: geant4-09-04-beta-01 $ 28 28 // 29 29 // ==================================================================== -
trunk/examples/extended/parallel/MPI/exMPI02/src/VoxelSD.cc
r807 r1337 25 25 // 26 26 // $Id: VoxelSD.cc,v 1.1 2007/11/16 14:29:33 kmura Exp $ 27 // $Name: $27 // $Name: geant4-09-04-beta-01 $ 28 28 // 29 29 // ==================================================================== -
trunk/examples/extended/parallel/MPI/exMPI02/v.mac
r807 r1337 1 /vis/verbose 0 2 3 /vis/open OGLIX 4 5 /vis/scene/create 6 /vis/scene/add/volume 7 8 /vis/sceneHandler/attach 9 1 # Use this open statement to create an OpenGL view: 2 /vis/open OGL 600x600-0+0 3 # 4 # Use this open statement to create a .prim file suitable for 5 # viewing in DAWN: 6 #/vis/open DAWNFILE 7 # 8 # Use this open statement to create a .heprep file suitable for 9 # viewing in HepRApp: 10 #/vis/open HepRepFile 11 # 12 # Use this open statement to create a .wrl file suitable for 13 # viewing in a VRML viewer: 14 #/vis/open VRML2FILE 15 # 16 # Disable auto refresh and quieten vis messages whilst scene and 17 # trajectories are established: 18 /vis/viewer/set/autoRefresh false 19 /vis/verbose errors 20 # 21 # Draw geometry: 22 /vis/drawVolume 23 # 24 # Specify view angle: 10 25 /vis/viewer/set/viewpointThetaPhi 90. 270. 11 12 /tracking/storeTrajectory 1 13 /vis/scene/add/trajectories 26 # 27 # Specify zoom value: 28 #/vis/viewer/zoom 2. 29 # 30 # Specify style (surface or wireframe): 31 #/vis/viewer/set/style wireframe 32 # 33 # Draw coordinate axes: 34 #/vis/scene/add/axes 0 0 0 1 m 35 # 36 # Draw smooth trajectories at end of event, showing trajectory points 37 # as markers 2 pixels wide: 38 /vis/scene/add/trajectories smooth 39 /vis/modeling/trajectories/create/drawByCharge 40 /vis/modeling/trajectories/drawByCharge-0/default/setDrawStepPts true 41 /vis/modeling/trajectories/drawByCharge-0/default/setStepPtsSize 2 42 # (if too many tracks cause core dump => /tracking/storeTrajectory 0) 43 # 44 # Draw hits at end of event: 45 #/vis/scene/add/hits 46 # 47 # To draw only gammas: 48 #/vis/filtering/trajectories/create/particleFilter 49 #/vis/filtering/trajectories/particleFilter-0/add gamma 50 # 51 # To invert the above, drawing all particles except gammas, 52 # keep the above two lines but also add: 53 #/vis/filtering/trajectories/particleFilter-0/invert true 54 # 55 # Many other options are available with /vis/modeling and /vis/filtering. 56 # For example, to select colour by particle ID: 57 #/vis/modeling/trajectories/create/drawByParticleID 58 #/vis/modeling/trajectories/drawByParticleID-0/set e- blue 59 # 60 # To superimpose all of the events from a given run: 14 61 /vis/scene/endOfEventAction accumulate 15 #/vis/scene/endOfEventAction refresh 16 17 62 # 63 # Re-establish auto refreshing and verbosity: 64 /vis/viewer/set/autoRefresh true 65 /vis/verbose warnings 66 # 67 # For file-based drivers, use this to create an empty detector view: 68 #/vis/viewer/flush -
trunk/examples/extended/parallel/MPI/mpi_interface/G4MPI-lam.gmk
r807 r1337 1 1 # $Id: G4MPI-lam.gmk,v 1.1 2007/11/16 13:32:56 kmura Exp $ 2 # $Name: $2 # $Name: geant4-09-04-beta-01 $ 3 3 # =========================================================== 4 4 # Makefile for building G4MPI (LAM) -
trunk/examples/extended/parallel/MPI/mpi_interface/G4MPI-mpich2.gmk
r807 r1337 1 1 # $Id: G4MPI-mpich2.gmk,v 1.1 2007/11/16 13:32:56 kmura Exp $ 2 # $Name: $2 # $Name: geant4-09-04-beta-01 $ 3 3 # =========================================================== 4 4 # Makefile for building G4MPI (MPICH2) -
trunk/examples/extended/parallel/MPI/mpi_interface/G4MPI-openmpi.gmk
r807 r1337 1 # $Id: G4MPI-openmpi.gmk,v 1. 1 2007/11/16 13:32:56kmura Exp $2 # $Name: $1 # $Id: G4MPI-openmpi.gmk,v 1.3 2010/05/18 06:02:01 kmura Exp $ 2 # $Name: geant4-09-04-beta-01 $ 3 3 # =========================================================== 4 # Makefile for building G4MPI ( LAM)4 # Makefile for building G4MPI (OpenMPI) 5 5 # =========================================================== 6 6 … … 13 13 CPPFLAGS += -I$(G4MPIROOT)/include -I$(G4MPIROOT)/include/openmpi 14 14 15 # to suppress compiler warnings for OpenMPI headers 16 CXXFLAGS := $(subst -Wall, , $(CXXFLAGS)) -
trunk/examples/extended/parallel/MPI/mpi_interface/G4MPI.gmk
r807 r1337 1 # $Id: G4MPI.gmk,v 1. 1 2007/11/16 13:32:56kmura Exp $2 # $Name: $1 # $Id: G4MPI.gmk,v 1.3 2010/05/18 06:01:09 kmura Exp $ 2 # $Name: geant4-09-04-beta-01 $ 3 3 # =========================================================== 4 # Makefile for building G4MPI ( LAM)4 # Makefile for building G4MPI (OpenMPI) 5 5 # =========================================================== 6 6 7 7 ifndef G4MPIROOT 8 G4MPIROOT = /opt/ lam8 G4MPIROOT = /opt/ompi 9 9 endif 10 10 11 11 # additional flags 12 12 CXX := mpic++ 13 CPPFLAGS += -I$(G4MPIROOT)/include 13 CPPFLAGS += -I$(G4MPIROOT)/include -I$(G4MPIROOT)/include/openmpi 14 14 15 # to suppress compiler warnings for OpenMPI headers 16 CXXFLAGS := $(subst -Wall, , $(CXXFLAGS)) -
trunk/examples/extended/parallel/MPI/mpi_interface/GNUmakefile
r1230 r1337 1 1 # $Id: GNUmakefile,v 1.1 2007/11/16 13:32:56 kmura Exp $ 2 # $Name: geant4-09-0 3-cand-01 $2 # $Name: geant4-09-04-beta-01 $ 3 3 # =========================================================== 4 4 # Makefile for building MPI interface -
trunk/examples/extended/parallel/MPI/mpi_interface/History
r807 r1337 1 $Id: History,v 1. 1 2007/11/16 13:32:56kmura Exp $1 $Id: History,v 1.2 2010/05/18 06:00:40 kmura Exp $ 2 2 ------------------------------------------------------------------- 3 3 … … 9 9 ------------------ 10 10 11 18 May 2010 K.Murakami 12 == Code reviewed == 13 - OpenMPI as default MPI library instead of LAM/MPI 14 - improve /mpi/status command. (waste of CPU, time measurement) 15 - /mpi/wait command is introduced for waiting until beamOn ends. 16 - improve macro file parser 17 * same parser as G4UIbatch 18 * fixed unexpected behavior at the end of batch mode 19 - changed "beamOn" behavior for better performance 20 * thread-out for interactive, on-thread for batch 21 11 22 16 Nov. 2007 K.Murakami 12 23 - commited to G4 CVS. 13 24 14 15 16 -
trunk/examples/extended/parallel/MPI/mpi_interface/README
r807 r1337 1 $Id: README,v 1. 1 2007/11/16 13:32:56kmura Exp $1 $Id: README,v 1.2 2010/05/18 06:00:18 kmura Exp $ 2 2 ========================================================================== 3 3 Geant4 MPI Interface … … 16 16 * Specify additional include paths and compiler flags to "CPPFLAGS". 17 17 18 Sample makefiles for ( LAM, MPICH2, OpenMPI) are also presented.18 Sample makefiles for (OpnMPI, LAM, MPICH2) are also presented. 19 19 An example of "G4MPI.gmk": 20 20 21 22 # Makefile for building G4MPI (LAM)23 21 # =========================================================== 22 # Makefile for building G4MPI (OpenMPI) 23 # =========================================================== 24 24 25 26 G4MPIROOT = /opt/lam27 25 ifndef G4MPIROOT 26 G4MPIROOT = /opt/ompi 27 endif 28 28 29 # additional flags 30 CXX := mpic++ 31 CPPFLAGS += -I$(G4MPIROOT)/include 29 # additional flags 30 CXX := mpic++ 31 CXXFLAGS := $(subst -Wall, , $(CXXFLAGS)) 32 CPPFLAGS += -I$(G4MPIROOT)/include -I$(G4MPIROOT)/include/openmpi 32 33 33 34 -
trunk/examples/extended/parallel/MPI/mpi_interface/include/G4MPIbatch.hh
r807 r1337 25 25 // 26 26 // $Id: G4MPIbatch.hh,v 1.1 2007/11/16 14:05:39 kmura Exp $ 27 // $Name: $27 // $Name: geant4-09-04-beta-01 $ 28 28 // 29 29 // ==================================================================== -
trunk/examples/extended/parallel/MPI/mpi_interface/include/G4MPImanager.hh
r807 r1337 24 24 // ******************************************************************** 25 25 // 26 // $Id: G4MPImanager.hh,v 1. 1 2007/11/16 14:05:40kmura Exp $27 // $Name: $26 // $Id: G4MPImanager.hh,v 1.2 2010/05/18 06:03:27 kmura Exp $ 27 // $Name: geant4-09-04-beta-01 $ 28 28 // 29 29 // ==================================================================== … … 55 55 G4MPImessenger* messenger; 56 56 G4MPIsession* session; 57 57 58 58 G4int verbose; 59 59 G4MPIstatus* status; // status for each node … … 140 140 void ShowSeeds(); 141 141 void SetSeed(G4int inode, G4long seed); 142 void WaitBeamOn(); 142 143 143 144 // methods for MPI environment … … 226 227 { 227 228 masterWeight= aweight; 228 229 229 230 if(aweight<0.) masterWeight= 0.; 230 231 if(aweight>1.) masterWeight= 1.; -
trunk/examples/extended/parallel/MPI/mpi_interface/include/G4MPImessenger.hh
r807 r1337 24 24 // ******************************************************************** 25 25 // 26 // $Id: G4MPImessenger.hh,v 1. 1 2007/11/16 14:05:40kmura Exp $27 // $Name: $26 // $Id: G4MPImessenger.hh,v 1.2 2010/05/18 06:03:54 kmura Exp $ 27 // $Name: geant4-09-04-beta-01 $ 28 28 // 29 29 // ==================================================================== … … 63 63 64 64 G4UIcommand* beamOn; 65 G4UIc mdWithAnInteger* dotbeamOn;65 G4UIcommand* dotbeamOn; 66 66 G4UIcmdWithADouble* masterWeight; 67 G4UIcmdWithoutParameter* waitall; 67 68 68 69 G4UIcmdWithoutParameter* showSeeds; … … 73 74 G4MPImessenger(G4MPImanager* manager); 74 75 ~G4MPImessenger(); 75 76 76 77 virtual void SetNewValue(G4UIcommand* command, G4String newValue); 77 78 virtual G4String GetCurrentValue(G4UIcommand* command); 78 79 79 80 }; 80 81 -
trunk/examples/extended/parallel/MPI/mpi_interface/include/G4MPIrandomSeedGenerator.hh
r807 r1337 25 25 // 26 26 // $Id: G4MPIrandomSeedGenerator.hh,v 1.1 2007/11/16 14:05:40 kmura Exp $ 27 // $Name: $27 // $Name: geant4-09-04-beta-01 $ 28 28 // 29 29 // ==================================================================== -
trunk/examples/extended/parallel/MPI/mpi_interface/include/G4MPIsession.hh
r807 r1337 25 25 // 26 26 // $Id: G4MPIsession.hh,v 1.1 2007/11/16 14:05:41 kmura Exp $ 27 // $Name: $27 // $Name: geant4-09-04-beta-01 $ 28 28 // 29 29 // ==================================================================== -
trunk/examples/extended/parallel/MPI/mpi_interface/include/G4MPIstatus.hh
r807 r1337 25 25 // 26 26 // $Id: G4MPIstatus.hh,v 1.1 2007/11/16 14:05:41 kmura Exp $ 27 // $Name: $27 // $Name: geant4-09-04-beta-01 $ 28 28 // 29 29 // ==================================================================== -
trunk/examples/extended/parallel/MPI/mpi_interface/include/G4UImpish.hh
r807 r1337 25 25 // 26 26 // $Id: G4UImpish.hh,v 1.1 2007/11/16 14:05:41 kmura Exp $ 27 // $Name: $27 // $Name: geant4-09-04-beta-01 $ 28 28 // 29 29 // ==================================================================== -
trunk/examples/extended/parallel/MPI/mpi_interface/include/G4VMPIseedGenerator.hh
r807 r1337 25 25 // 26 26 // $Id: G4VMPIseedGenerator.hh,v 1.1 2007/11/16 14:05:41 kmura Exp $ 27 // $Name: $27 // $Name: geant4-09-04-beta-01 $ 28 28 // 29 29 // ==================================================================== -
trunk/examples/extended/parallel/MPI/mpi_interface/include/G4VMPIsession.hh
r807 r1337 24 24 // ******************************************************************** 25 25 // 26 // $Id: G4VMPIsession.hh,v 1. 1 2007/11/16 14:05:41kmura Exp $27 // $Name: $26 // $Id: G4VMPIsession.hh,v 1.2 2010/05/18 06:05:05 kmura Exp $ 27 // $Name: geant4-09-04-beta-01 $ 28 28 // 29 29 // ==================================================================== … … 58 58 G4int rank; 59 59 60 G4int ExecCommand(G4String a Command);60 G4int ExecCommand(G4String acommand); 61 61 G4String TruncateCommand(const G4String& command) const; 62 62 G4String BypassCommand(const G4String& command) const; -
trunk/examples/extended/parallel/MPI/mpi_interface/src/G4MPIbatch.cc
r807 r1337 24 24 // ******************************************************************** 25 25 // 26 // $Id: G4MPIbatch.cc,v 1. 1 2007/11/16 14:05:41 kmura Exp $27 // $Name: $26 // $Id: G4MPIbatch.cc,v 1.2 2010/05/18 06:06:21 kmura Exp $ 27 // $Name: geant4-09-04-beta-01 $ 28 28 // 29 29 // ==================================================================== … … 34 34 #include "G4MPIbatch.hh" 35 35 #include "G4MPImanager.hh" 36 #include "G4UImanager.hh" 36 37 #include "G4UIcommandStatus.hh" 38 #include <vector> 39 40 //////////////////////////////////////////////////////////////////////// 41 static void Tokenize(const G4String& str, std::vector<G4String>& tokens) 42 //////////////////////////////////////////////////////////////////////// 43 { 44 const char* delimiter= " "; 45 46 str_size pos0= str.find_first_not_of(delimiter); 47 str_size pos = str.find_first_of(delimiter, pos0); 48 49 while (pos != G4String::npos || pos0 != G4String::npos) { 50 if (str[pos0] == '\"') { 51 pos = str.find_first_of("\"", pos0+1); 52 if(pos != G4String::npos) pos++; 53 } 54 if (str[pos0] == '\'') { 55 pos = str.find_first_of("\'", pos0+1); 56 if(pos != G4String::npos) pos++; 57 } 58 59 tokens.push_back(str.substr(pos0, pos-pos0)); 60 pos0 = str.find_first_not_of(delimiter, pos); 61 pos = str.find_first_of(delimiter, pos0); 62 } 63 } 37 64 38 65 // ==================================================================== … … 72 99 ////////////////////////////////// 73 100 { 74 enum { BUFSIZE= 256 }; 75 char linebuf[BUFSIZE]; 76 101 enum { BUFSIZE= 4096 }; 102 static char linebuf[BUFSIZE]; 103 104 G4String cmdtotal= ""; 105 G4bool qcontinued= false; 77 106 while(batchStream.good()) { 78 107 batchStream.getline(linebuf, BUFSIZE); 79 108 80 109 G4String cmdline(linebuf); 81 cmdline= cmdline.strip(G4String::both); 82 cmdline= cmdline.strip(G4String::both, '\011'); // remove TAB 83 cmdline= TruncateCommand(cmdline); 84 85 str_size ic= cmdline.find_first_of('#'); 86 if(ic != G4String::npos) { 87 cmdline= cmdline(0, ic); 88 } 89 90 if(batchStream.eof()) { 91 if(cmdline.size()==0) { 92 return "exit"; 93 } else { 94 return cmdline; 95 } 110 111 // TAB-> ' ' conversion 112 str_size nb=0; 113 while ((nb= cmdline.find('\t',nb)) != G4String::npos) { 114 cmdline.replace(nb, 1, " "); 96 115 } 97 116 98 if(cmdline.size()==0) continue; // skip null line 99 return cmdline; 100 } 117 // strip 118 cmdline= cmdline.strip(G4String::both); 101 119 102 return "exit"; // dummy 120 // skip null line if single line 121 if(!qcontinued && cmdline.size()==0) continue; 122 123 // '#' is treated as echoing something 124 if(cmdline[(size_t)0]=='#') return cmdline; 125 126 // tokenize... 127 std::vector<G4String> tokens; 128 Tokenize(cmdline, tokens); 129 qcontinued= false; 130 for (G4int i=0; i< G4int(tokens.size()); i++) { 131 // string after '#" is ignored 132 if(tokens[i][(size_t)0] == '#' ) break; 133 // '\' or '_' is treated as continued line. 134 if(tokens[i] == '\\' || tokens[i] == '_' ) { 135 qcontinued= true; 136 // check nothing after line continuation character 137 if( i != G4int(tokens.size())-1) { 138 G4Exception("unexpected character after " 139 "line continuation character"); 140 } 141 break; // stop parsing 142 } 143 cmdtotal+= tokens[i]; 144 cmdtotal+= " "; 145 } 146 147 if(qcontinued) continue; // read the next line 148 149 if(cmdtotal.size() != 0) break; 150 if(batchStream.eof()) break; 151 } 152 153 // strip again 154 cmdtotal= cmdtotal.strip(G4String::both); 155 156 // bypass some commands 157 cmdtotal= BypassCommand(cmdtotal); 158 159 // finally, 160 if(batchStream.eof() && cmdtotal.size()==0) { 161 return "exit"; 162 } 163 164 return cmdtotal; 103 165 } 104 166 … … 110 172 G4String newCommand="", scommand; // newCommand is always "" in slaves 111 173 112 if(isMaster) newCommand= ReadCommand(); 113 // broadcast a new G4 command 114 scommand= g4MPI-> BcastCommand(newCommand); 115 if(scommand == "exit" ) return 0; 116 117 while(1){ 118 G4int rc= ExecCommand(scommand); 119 if(rc != fCommandSucceeded) break; 120 121 if(isMaster) newCommand= ReadCommand(); 122 scommand= g4MPI-> BcastCommand(newCommand); 123 if(scommand == "exit" ) { 124 if(isBatchMode) { 125 if(g4MPI-> CheckThreadStatus()) { 126 g4MPI-> JoinBeamOnThread(); 127 break; 128 } 129 } else { 130 break; 174 while(1) { 175 if (isMaster) newCommand = ReadCommand(); 176 // broadcast a new G4 command 177 scommand = g4MPI-> BcastCommand(newCommand); 178 if(scommand == "exit") return 0; 179 180 // just echo something 181 if( scommand[(size_t)0] == '#') { 182 if(G4UImanager::GetUIpointer()-> GetVerboseLevel()==2) { 183 G4cout << scommand << G4endl; 131 184 } 185 continue; 186 } 187 188 G4int rc = ExecCommand(scommand); 189 if (rc != fCommandSucceeded) { 190 G4cerr << G4endl << "***** Batch is interupted!! *****" << G4endl; 191 break; 132 192 } 133 193 } 134 194 135 195 return 0; 136 196 } -
trunk/examples/extended/parallel/MPI/mpi_interface/src/G4MPImanager.cc
r807 r1337 24 24 // ******************************************************************** 25 25 // 26 // $Id: G4MPImanager.cc,v 1. 1 2007/11/16 14:05:41 kmura Exp $27 // $Name: $26 // $Id: G4MPImanager.cc,v 1.2 2010/05/18 06:06:21 kmura Exp $ 27 // $Name: geant4-09-04-beta-01 $ 28 28 // 29 29 // ==================================================================== … … 68 68 //////////////////////////// 69 69 G4MPImanager::G4MPImanager() 70 : verbose(0), 70 : verbose(0), 71 71 qfcout(false), 72 72 qinitmacro(false), … … 75 75 masterWeight(1.) 76 76 //////////////////////////// 77 { 77 { 78 78 //MPI::Init(); 79 79 MPI::Init_thread(MPI::THREAD_SERIALIZED); … … 86 86 : verbose(0), qfcout(false), 87 87 qinitmacro(false), qbatchmode(false), 88 threadID(0), 88 threadID(0), 89 89 masterWeight(1.) 90 90 ///////////////////////////////////////////////// … … 140 140 isMaster= (rank == RANK_MASTER); 141 141 isSlave= (rank != RANK_MASTER); 142 142 143 143 // initialize MPI communicator 144 144 COMM_G4COMMAND= MPI::COMM_WORLD.Dup(); … … 231 231 char str[1024]; 232 232 sprintf(str, prefix.c_str(), rank); 233 G4String fname(str); 233 G4String fname(str); 234 234 fscout.open(fname.c_str(), std::ios::out); 235 235 } … … 265 265 G4int runid, eventid, neventTBP; 266 266 267 if (run) { // running... 267 G4StateManager* stateManager= G4StateManager::GetStateManager(); 268 G4ApplicationState g4state= stateManager-> GetCurrentState(); 269 270 if (run) { 268 271 runid= run-> GetRunID(); 269 272 neventTBP= run -> GetNumberOfEventToBeProcessed(); 270 273 eventid= run-> GetNumberOfEvent(); 274 if(g4state == G4State_GeomClosed || g4state == G4State_EventProc) { 275 status-> StopTimer(); 276 } 271 277 } else { 272 278 runid= 0; … … 274 280 neventTBP= 0; 275 281 } 276 277 G4StateManager* stateManager= G4StateManager::GetStateManager();278 G4ApplicationState g4state= stateManager-> GetCurrentState();279 282 280 283 status-> SetStatus(rank, runid, neventTBP, eventid, g4state); … … 308 311 nev+= status-> GetEventID(); 309 312 nevtp+= status-> GetNEventToBeProcessed(); 310 //mpistate= status-> GetG4State();311 313 cputime+= status-> GetCPUTime(); 312 314 } … … 322 324 << G4endl 323 325 << "* #ranks= " << size 324 << " event= " << nev << "/" << nevtp 325 << " state= " << strStatus 326 << " event= " << nev << "/" << nevtp 327 << " state= " << strStatus 326 328 << " time= " << cputime << "s" 327 329 << G4endl; 328 330 } else { 329 331 status-> Pack(buff); 330 COMM_G4COMMAND.Send(buff, G4MPIstatus::NSIZE, MPI::INT, 332 COMM_G4COMMAND.Send(buff, G4MPIstatus::NSIZE, MPI::INT, 331 333 RANK_MASTER, TAG_G4STATUS); 332 334 } … … 352 354 if(isMaster) { 353 355 // print master 354 G4cout << "* rank= " << rank 355 << " seed= " << CLHEP::HepRandom::getTheSeed() 356 G4cout << "* rank= " << rank 357 << " seed= " << CLHEP::HepRandom::getTheSeed() 356 358 << G4endl; 357 359 // receive from each slave 358 360 for (G4int islave=1; islave< size; islave++) { 359 361 COMM_G4COMMAND.Recv(&buff, 1, MPI::LONG, islave, TAG_G4SEED); 360 G4cout << "* rank= " << islave 362 G4cout << "* rank= " << islave 361 363 << " seed= " << buff 362 364 << G4endl; … … 391 393 // get slave status 392 394 for (G4int islave=1; islave< size; islave++) { 393 COMM_G4COMMAND.Recv(&buff, 1, MPI::UNSIGNED, islave, TAG_G4STATUS); 395 MPI::Request request= COMM_G4COMMAND.Irecv(&buff, 1, MPI::UNSIGNED, 396 islave, TAG_G4STATUS); 397 MPI::Status status; 398 while(! request.Test(status)) { 399 Wait(100); 400 } 394 401 qstatus |= buff; 395 402 } … … 452 459 static G4String cmdstr; 453 460 cmdstr= command; 454 G4int rc= pthread_create(&threadID, 0, 461 G4int rc= pthread_create(&threadID, 0, 455 462 (Func_t)thread_ExecuteThreadCommand, 456 463 (void*)&cmdstr); … … 487 494 488 495 // waiting message exhausts CPU in LAM! 489 //COMM_G4COMMAND.Bcast(sbuff, BUFF_SIZE, MPI::CHAR, RANK_MASTER);496 //COMM_G4COMMAND.Bcast(sbuff, ssize, MPI::CHAR, RANK_MASTER); 490 497 491 498 // another implementation … … 514 521 ///////////////////////////////////////////////////////////////////////// 515 522 { 523 G4bool currentmode= qbatchmode; 524 qbatchmode= true; 516 525 G4MPIbatch* batchSession= new G4MPIbatch(fname, qbatch); 517 526 batchSession-> SessionStart(); 518 527 delete batchSession; 528 qbatchmode= currentmode; 519 529 } 520 530 … … 552 562 } 553 563 564 /////////////////////////////// 565 void G4MPImanager::WaitBeamOn() 566 /////////////////////////////// 567 { 568 G4int buff= 0; 569 if (qbatchmode) { // valid only in batch mode 570 if(isMaster) { 571 // receive from each slave 572 for (G4int islave=1; islave< size; islave++) { 573 MPI::Request request= COMM_G4COMMAND.Irecv(&buff, 1, MPI::INT, 574 islave, TAG_G4STATUS); 575 MPI::Status status; 576 while(! request.Test(status)) { 577 Wait(1000); 578 } 579 } 580 } else { 581 buff= 1; 582 COMM_G4COMMAND.Send(&buff, 1, MPI::INT, RANK_MASTER, TAG_G4STATUS); 583 } 584 } 585 } 554 586 555 587 ///////////////////////////////////////////////// -
trunk/examples/extended/parallel/MPI/mpi_interface/src/G4MPImessenger.cc
r807 r1337 24 24 // ******************************************************************** 25 25 // 26 // $Id: G4MPImessenger.cc,v 1. 1 2007/11/16 14:05:41 kmura Exp $27 // $Name: $26 // $Id: G4MPImessenger.cc,v 1.2 2010/05/18 06:06:21 kmura Exp $ 27 // $Name: geant4-09-04-beta-01 $ 28 28 // 29 29 // ==================================================================== … … 72 72 execute= new G4UIcmdWithAString("/mpi/execute", this); 73 73 execute-> SetGuidance("Execute a macro file. (=/control/execute)"); 74 execute-> SetParameterName("fileName", false, false); 74 execute-> SetParameterName("fileName", false, false); 75 75 76 76 // /mpi/beamOn … … 88 88 89 89 // /mpi/.beamOn 90 dotbeamOn= new G4UIcmdWithAnInteger("/mpi/.beamOn", this); 91 dotbeamOn-> SetGuidance("Start a parallel run w/o thread. (=/run/beamOn)"); 92 dotbeamOn-> SetParameterName("numberOfEvent", true, false); 93 dotbeamOn-> SetDefaultValue(1); 94 dotbeamOn-> SetRange("numberOfEvent>=0"); 90 dotbeamOn= new G4UIcommand("/mpi/.beamOn", this); 91 dotbeamOn-> SetGuidance("Start a parallel run w/o thread."); 92 93 p1= new G4UIparameter("numberOfEvent", 'i', true); 94 p1-> SetDefaultValue(1); 95 p1-> SetParameterRange("numberOfEvent>=0"); 96 dotbeamOn-> SetParameter(p1); 97 98 p2= new G4UIparameter("divide", 'b', true); 99 p2-> SetDefaultValue(true); 100 dotbeamOn-> SetParameter(p2); 95 101 96 102 // /mpi/weightForMaster … … 99 105 masterWeight-> SetParameterName("weight", false, false); 100 106 masterWeight-> SetRange("weight>=0. && weight<=1."); 107 108 // /mpi/wait 109 waitall= new G4UIcmdWithoutParameter("/mpi/wait", this); 110 waitall-> SetGuidance( "Wait until beamOn-s on all nodes are done. " 111 "(batch mode only)"); 101 112 102 113 // /mpi/showSeeds … … 132 143 delete dotbeamOn; 133 144 delete masterWeight; 145 delete waitall; 134 146 delete showSeeds; 135 147 delete setMasterSeed; 136 148 delete setSeed; 137 149 138 150 delete dir; 139 151 } … … 162 174 163 175 } else if (command == dotbeamOn){ // /mpi/.beamOn 164 G4int nevent= dotbeamOn-> GetNewIntValue(newValue); 165 g4MPI-> BeamOn(nevent); 176 std::istringstream is(newValue); 177 G4int nevent; 178 G4bool qdivide; 179 is >> nevent >> qdivide; 180 g4MPI-> BeamOn(nevent, qdivide); 166 181 167 182 } else if (command == masterWeight){ // /mpi/masterWeight 168 183 G4double weight= masterWeight-> GetNewDoubleValue(newValue); 169 184 g4MPI-> SetMasterWeight(weight); 170 185 186 } else if (command == waitall) { 187 g4MPI-> WaitBeamOn(); 188 171 189 } else if (command == showSeeds){ // /mpi/showSeeds 172 190 g4MPI-> ShowSeeds(); 173 191 174 192 } else if (command == setMasterSeed){ // /mpi/setMasterSeed 175 193 std::istringstream is(newValue); … … 178 196 g4MPI-> GetSeedGenerator()-> SetMasterSeed(seed); 179 197 g4MPI-> DistributeSeeds(); 180 198 181 199 } else if (command == setSeed){ // /mpi/setSeed 182 200 std::istringstream is(newValue); -
trunk/examples/extended/parallel/MPI/mpi_interface/src/G4MPIrandomSeedGenerator.cc
r807 r1337 25 25 // 26 26 // $Id: G4MPIrandomSeedGenerator.cc,v 1.1 2007/11/16 14:05:41 kmura Exp $ 27 // $Name: $27 // $Name: geant4-09-04-beta-01 $ 28 28 // 29 29 // ==================================================================== -
trunk/examples/extended/parallel/MPI/mpi_interface/src/G4MPIsession.cc
r807 r1337 24 24 // ******************************************************************** 25 25 // 26 // $Id: G4MPIsession.cc,v 1. 1 2007/11/16 14:05:41 kmura Exp $27 // $Name: $26 // $Id: G4MPIsession.cc,v 1.2 2010/05/18 06:06:21 kmura Exp $ 27 // $Name: geant4-09-04-beta-01 $ 28 28 // 29 29 // ==================================================================== … … 125 125 } else if(nC == "pwd") { // show current directory 126 126 G4cout << "Current Command Directory : " 127 127 << GetCurrentWorkingDirectory() << G4endl; 128 128 newCommand= nullString; 129 129 … … 195 195 g4MPI-> ExecuteMacroFile(g4MPI->GetMacroFileName(), true); 196 196 return 0; 197 } 198 197 } 198 199 199 // interactive session 200 200 G4String newCommand="", scommand; // newCommand is always "" in slaves 201 202 if(isMaster) newCommand= GetCommand(); 203 // broadcast a new G4 command 204 scommand= g4MPI-> BcastCommand(newCommand); 205 if(scommand == "exit" ) return 0; 206 207 while(1){ 201 202 while(1) { 203 if(isMaster) newCommand = GetCommand(); 204 // broadcast a new G4 command 205 scommand = g4MPI-> BcastCommand(newCommand); 206 if(scommand == "exit") { 207 G4bool qexit = TryForcedTerminate(); 208 if(qexit) break; 209 else scommand = ""; 210 } 208 211 ExecCommand(scommand); 209 210 // get next ...211 if(isMaster) newCommand= GetCommand();212 scommand= g4MPI-> BcastCommand(newCommand);213 if(scommand == "exit" ) {214 G4bool qexit= TryForcedTerminate();215 if(qexit) break;216 else scommand="";217 }218 212 } 219 213 … … 254 248 xmessage= g4MPI->BcastCommand(""); 255 249 } 256 250 257 251 if(xmessage == "kill me") { 258 252 G4RunManager* runManager= G4RunManager::GetRunManager(); -
trunk/examples/extended/parallel/MPI/mpi_interface/src/G4MPIstatus.cc
r807 r1337 24 24 // ******************************************************************** 25 25 // 26 // $Id: G4MPIstatus.cc,v 1. 1 2007/11/16 14:05:41 kmura Exp $27 // $Name: $26 // $Id: G4MPIstatus.cc,v 1.2 2010/05/18 06:06:21 kmura Exp $ 27 // $Name: geant4-09-04-beta-01 $ 28 28 // 29 29 // ==================================================================== … … 43 43 ////////////////////////// 44 44 G4MPIstatus::G4MPIstatus() 45 : rank(0), runID(0), 45 : rank(0), runID(0), 46 46 nEventToBeProcessed(0), 47 47 eventID(0), … … 51 51 { 52 52 timer= new G4Timer; 53 timer-> Start();54 53 } 55 54 … … 64 63 65 64 ///////////////////////////////////////////////////// 66 void G4MPIstatus::SetStatus(G4int arank, G4int runid, 65 void G4MPIstatus::SetStatus(G4int arank, G4int runid, 67 66 G4int noe, G4int evtid, 68 67 G4ApplicationState state) … … 74 73 eventID= evtid; 75 74 g4state= state; 76 77 timer-> Stop(); 78 cputime= timer-> GetUserElapsed(); 75 if (timer-> IsValid()) cputime= timer-> GetUserElapsed(); 76 else cputime = 0.; 79 77 } 80 78 … … 83 81 void G4MPIstatus::Pack(G4int* data) const 84 82 ///////////////////////////////////////// 85 { 83 { 86 84 data[0]= rank; 87 85 data[1]= runID; … … 115 113 { 116 114 // * rank= 001 run= 10002 event= 00001 / 100000 state= Idle" 117 G4cout << "* rank= " << rank 118 << " run= " << runID 115 G4cout << "* rank= " << rank 116 << " run= " << runID 119 117 << " event= " << eventID << " / " << nEventToBeProcessed 120 118 << " state= " << GetStateString(g4state) -
trunk/examples/extended/parallel/MPI/mpi_interface/src/G4UImpish.cc
r807 r1337 25 25 // 26 26 // $Id: G4UImpish.cc,v 1.1 2007/11/16 14:05:41 kmura Exp $ 27 // $Name: $27 // $Name: geant4-09-04-beta-01 $ 28 28 // 29 29 // ==================================================================== -
trunk/examples/extended/parallel/MPI/mpi_interface/src/G4VMPIseedGenerator.cc
r807 r1337 25 25 // 26 26 // $Id: G4VMPIseedGenerator.cc,v 1.1 2007/11/16 14:05:41 kmura Exp $ 27 // $Name: $27 // $Name: geant4-09-04-beta-01 $ 28 28 // ==================================================================== 29 29 // G4VMPIseedGenerator.cc -
trunk/examples/extended/parallel/MPI/mpi_interface/src/G4VMPIsession.cc
r807 r1337 24 24 // ******************************************************************** 25 25 // 26 // $Id: G4VMPIsession.cc,v 1. 1 2007/11/16 14:05:41 kmura Exp $27 // $Name: $26 // $Id: G4VMPIsession.cc,v 1.2 2010/05/18 06:06:21 kmura Exp $ 27 // $Name: geant4-09-04-beta-01 $ 28 28 // 29 29 // ==================================================================== … … 94 94 95 95 /////////////////////////////////////////////////// 96 G4int G4VMPIsession::ExecCommand(G4String a Command)96 G4int G4VMPIsession::ExecCommand(G4String acommand) 97 97 /////////////////////////////////////////////////// 98 98 { 99 if(a Command.length()<2) return fCommandSucceeded;99 if(acommand.length()<2) return fCommandSucceeded; 100 100 101 101 G4UImanager* UI= G4UImanager::GetUIpointer(); 102 102 G4int returnVal= 0; 103 103 104 G4String command= BypassCommand(a Command);105 104 G4String command= BypassCommand(acommand); 105 106 106 // "/mpi/beamOn is threaded out. 107 107 if(command(0,11) == "/mpi/beamOn") { 108 g4MPI-> ExecuteBeamOnThread( aCommand);108 g4MPI-> ExecuteBeamOnThread(command); 109 109 returnVal= fCommandSucceeded; 110 110 } else if(command(0,12) == "/mpi/.beamOn") { // care for beamOn … … 183 183 str_size idx; 184 184 while( (idx= acommand.find("//")) != G4String::npos) { 185 G4String command1= acommand(0,idx+1); 185 G4String command1= acommand(0,idx+1); 186 186 G4String command2= acommand(idx+2, acommand.size()-idx-2); 187 187 acommand= command1 + command2; … … 199 199 { 200 200 // bypass some commands 201 // /run/beamon -> /mpi/.beamOn 202 // /control/execute -> /mpi/execute 201 // * /mpi/beamOn 202 // -> /mpi/.beamOn (batch session) 203 // 204 // * /run/beamOn 205 // -> /mpi/.beamOn (batch session) 206 // -> /mpi/beamOn (interactive session) 207 // 208 // * /control/execute -> /mpi/execute 203 209 204 210 G4String acommand= command; 205 211 212 // /mpi/beamOn 213 if(acommand(0,11) == "/mpi/beamOn") { 214 if(g4MPI-> IsBatchMode()) { 215 acommand= "/mpi/.beamOn"; 216 if(command.length() > 11) { 217 acommand +=command.substr(11); 218 } 219 } 220 } 221 222 // /run/beamOn 206 223 if(acommand(0,11) == "/run/beamOn") { 207 if(g4MPI-> GetVerbose()>0 && isMaster) {208 G4cout << "/run/beamOn is overridden by /mpi/.beamOn"209 << G4endl;210 }211 212 acommand= "/mpi/.beamOn ";213 214 224 G4String strarg= ""; 215 225 G4bool qget= false; … … 222 232 continue; 223 233 } 224 225 234 if(qget) { 226 235 strarg+= command[idx]; … … 228 237 } 229 238 } 230 acommand += strarg; 231 } 232 239 240 if(g4MPI-> IsBatchMode()) { // batch session 241 acommand= "/mpi/.beamOn "; 242 if(command.length() > 11) acommand += strarg; 243 } else { // interactive session 244 if(g4MPI-> GetVerbose()>0 && isMaster) { 245 G4cout << "/run/beamOn is overridden by /mpi/.beamOn" << G4endl; 246 } 247 acommand= "/mpi/beamOn "; 248 if(command.length() > 11) acommand += strarg; 249 } 250 } 251 252 // /control/execute 233 253 if(acommand(0,16) == "/control/execute") { 234 254 if(g4MPI-> GetVerbose()>0 && isMaster) { 235 G4cout << "/control/execute is overridden by /mpi/execute" 255 G4cout << "/control/execute is overridden by /mpi/execute" 236 256 << G4endl; 237 257 } 238 239 258 acommand.replace(0, 16, "/mpi/execute "); 240 259 }
Note: See TracChangeset
for help on using the changeset viewer.