ATLAS Offline Software
Functions | Variables
python.algorithms.generators.multicore Namespace Reference

Functions

def multicore (process)
 Run multiple Powheg processes, each in its own thread. More...
 
def __multicore_v1 (generation_fn)
 Run Powheg V1 generation in multi-core mode. More...
 
def __multicore_multistage (process, generation_fn)
 Run Powheg V2/RES generation in multi-core mode. More...
 
def __multicore_multistage_stage_1 (generation_fn, n_xgrid_iterations)
 Run Powheg V2/RES (stage 1) generation in multi-core mode. More...
 
def __multicore_multistage_stage_2 (generation_fn)
 Run Powheg V2/RES (stage 2) generation in multi-core mode. More...
 
def __multicore_multistage_stage_3 (generation_fn)
 Run Powheg V2/RES (stage 3) generation in multi-core mode. More...
 
def __multicore_multistage_stage_4 (generation_fn)
 Run Powheg V2/RES (stage 4) generation in multi-core mode. More...
 
def multicore_untimed (process)
 Run multiple Powheg processes, each in its own thread. More...
 

Variables

 logger = Logging.logging.getLogger("PowhegControl")
 

Function Documentation

◆ __multicore_multistage()

def python.algorithms.generators.multicore.__multicore_multistage (   process,
  generation_fn 
)
private

Run Powheg V2/RES generation in multi-core mode.

Parameters
processPowhegBox process.
generation_fnFunction that can be called without argument to generate events.
Author
James Robinson james.nosp@m..rob.nosp@m.inson.nosp@m.@cer.nosp@m.n.ch

Definition at line 52 of file multicore.py.

52 def __multicore_multistage(process, generation_fn):
53  """! Run Powheg V2/RES generation in multi-core mode.
54 
55  @param process PowhegBox process.
56  @param generation_fn Function that can be called without argument to generate events.
57 
58  @author James Robinson <james.robinson@cern.ch>
59  """
60  shutil.rmtree("multistage_inputs", ignore_errors=True)
61  os.mkdir("multistage_inputs")
62  shutil.copy("pwgseeds.dat", "multistage_inputs/pwgseeds.dat")
63  # bb4l semileptonic events need to be run on top of dileptonic LHE files
64  if(process.executable != "pwhg_semileptonic" ):
65  if process.stage_is_completed(1):
66  logger.info("=> Skipping multi-core generation (V2/RES): stage 1 <=")
67  else:
68  process.modify_parameter(stage = 1)
69  __multicore_multistage_stage_1(generation_fn, process.itmx1)
70  if process.stage_is_completed(2):
71  logger.info("=> Skipping multi-core generation (V2/RES): stage 2 <=")
72  else:
73  process.modify_parameter(stage = 2)
74  __multicore_multistage_stage_2(generation_fn)
75  if process.stage_is_completed(3):
76  logger.info("=> Skipping multi-core generation (V2/RES): stage 3 <=")
77  else:
78  process.modify_parameter(stage = 3)
79  __multicore_multistage_stage_3(generation_fn)
80  else:
81  process.modify_parameter(stage = 3)
82  __multicore_multistage_stage_3(generation_fn)
83 
84  process.modify_parameter(stage = 4)
85  __multicore_multistage_stage_4(generation_fn)
86 
87 @timed("multi-core generation (V2/RES): stage 1)")

◆ __multicore_multistage_stage_1()

def python.algorithms.generators.multicore.__multicore_multistage_stage_1 (   generation_fn,
  n_xgrid_iterations 
)
private

Run Powheg V2/RES (stage 1) generation in multi-core mode.

Parameters
generation_fnFunction that can be called without argument to generate events.
n_xgrid_iterationsNumber of xgrid iterations to perform.
Author
James Robinson james.nosp@m..rob.nosp@m.inson.nosp@m.@cer.nosp@m.n.ch

Definition at line 88 of file multicore.py.

88 def __multicore_multistage_stage_1(generation_fn, n_xgrid_iterations):
89  """! Run Powheg V2/RES (stage 1) generation in multi-core mode.
90 
91  @param generation_fn Function that can be called without argument to generate events.
92  @param n_xgrid_iterations Number of xgrid iterations to perform.
93 
94  @author James Robinson <james.robinson@cern.ch>
95  """
96  FileParser("powheg.input").text_replace("parallelstage.*", "parallelstage 1")
97  # For stage 1, we need n_xgrid_iterations iterations
98  for xgrid_iteration in range(1, n_xgrid_iterations + 1):
99  FileParser("powheg.input").text_replace("xgriditeration.*", "xgriditeration {}".format(xgrid_iteration))
100  shutil.copy("powheg.input", "multistage_inputs/powheg.input.parallelstage{ps}.xgriditeration{xgi}".format(ps=1, xgi=xgrid_iteration))
101  generation_fn()
102 
103 @timed("multi-core generation (V2/RES): stage 2)")

◆ __multicore_multistage_stage_2()

def python.algorithms.generators.multicore.__multicore_multistage_stage_2 (   generation_fn)
private

Run Powheg V2/RES (stage 2) generation in multi-core mode.

Parameters
generation_fnFunction that can be called without argument to generate events.
Author
James Robinson james.nosp@m..rob.nosp@m.inson.nosp@m.@cer.nosp@m.n.ch

Definition at line 104 of file multicore.py.

104 def __multicore_multistage_stage_2(generation_fn):
105  """! Run Powheg V2/RES (stage 2) generation in multi-core mode.
106 
107  @param generation_fn Function that can be called without argument to generate events.
108 
109  @author James Robinson <james.robinson@cern.ch>
110  """
111  FileParser("powheg.input").text_replace("parallelstage.*", "parallelstage 2")
112  shutil.copy("powheg.input", "multistage_inputs/powheg.input.parallelstage{ps}".format(ps=2))
113  generation_fn()
114 
115 @timed("multi-core generation (V2/RES): stage 3)")

◆ __multicore_multistage_stage_3()

def python.algorithms.generators.multicore.__multicore_multistage_stage_3 (   generation_fn)
private

Run Powheg V2/RES (stage 3) generation in multi-core mode.

Parameters
generation_fnFunction that can be called without argument to generate events.
Author
James Robinson james.nosp@m..rob.nosp@m.inson.nosp@m.@cer.nosp@m.n.ch

Definition at line 116 of file multicore.py.

116 def __multicore_multistage_stage_3(generation_fn):
117  """! Run Powheg V2/RES (stage 3) generation in multi-core mode.
118 
119  @param generation_fn Function that can be called without argument to generate events.
120 
121  @author James Robinson <james.robinson@cern.ch>
122  """
123  FileParser("powheg.input").text_replace("parallelstage.*", "parallelstage 3")
124  shutil.copy("powheg.input", "multistage_inputs/powheg.input.parallelstage{ps}".format(ps=3))
125  generation_fn()
126 
127 @timed("multi-core generation (V2/RES): stage 4)")

◆ __multicore_multistage_stage_4()

def python.algorithms.generators.multicore.__multicore_multistage_stage_4 (   generation_fn)
private

Run Powheg V2/RES (stage 4) generation in multi-core mode.

Parameters
generation_fnFunction that can be called without argument to generate events.
Author
James Robinson james.nosp@m..rob.nosp@m.inson.nosp@m.@cer.nosp@m.n.ch

Definition at line 128 of file multicore.py.

128 def __multicore_multistage_stage_4(generation_fn):
129  """! Run Powheg V2/RES (stage 4) generation in multi-core mode.
130 
131  @param generation_fn Function that can be called without argument to generate events.
132 
133  @author James Robinson <james.robinson@cern.ch>
134  """
135  FileParser("powheg.input").text_replace("parallelstage.*", "parallelstage 4")
136  shutil.copy("powheg.input", "multistage_inputs/powheg.input.parallelstage{ps}".format(ps=4))
137  generation_fn()
138 

◆ __multicore_v1()

def python.algorithms.generators.multicore.__multicore_v1 (   generation_fn)
private

Run Powheg V1 generation in multi-core mode.

Parameters
generation_fnFunction that can be called without argument to generate events.
Author
James Robinson james.nosp@m..rob.nosp@m.inson.nosp@m.@cer.nosp@m.n.ch

Definition at line 42 of file multicore.py.

42 def __multicore_v1(generation_fn):
43  """! Run Powheg V1 generation in multi-core mode.
44 
45  @param generation_fn Function that can be called without argument to generate events.
46 
47  @author James Robinson <james.robinson@cern.ch>
48  """
49  generation_fn()
50 
51 @timed("multi-core generation (V2/RES)")

◆ multicore()

def python.algorithms.generators.multicore.multicore (   process)

Run multiple Powheg processes, each in its own thread.

Parameters
processPowhegBox process.
Author
James Robinson james.nosp@m..rob.nosp@m.inson.nosp@m.@cer.nosp@m.n.ch

Definition at line 14 of file multicore.py.

14 def multicore(process):
15  """! Run multiple Powheg processes, each in its own thread.
16 
17  @param process PowhegBox process.
18 
19  @author James Robinson <james.robinson@cern.ch>
20  """
21  # Construct random seeds - increment by 1e6 each time
22  logger.info("Running in multicore mode with {} subjobs".format(process.cores))
23  with open("pwgseeds.dat", "w") as random_seed_list:
24  for idx in range(process.cores):
25  random_seed_list.write(str(process.random_seed + int(idx * 1e6)) + "\n")
26 
27  # Remove iseed when providing seeds from pwgseeds.dat
28  FileParser("powheg.input").text_remove("^iseed")
29  logger.debug("Disabling iseed variable when multiple seeds are used")
30 
31  # Construct generation function
32  generation_fn = partial(multicore_untimed, process)
33 
34  if process.powheg_version == "V1":
35  __multicore_v1(generation_fn)
36  elif process.powheg_version == "V2" or process.powheg_version == "RES":
37  __multicore_multistage(process, generation_fn)
38  else:
39  raise ValueError("Powheg version {} is not supported for multicore running!".format(process.powheg_version))
40 
41 @timed("multi-core generation (V1)")

◆ multicore_untimed()

def python.algorithms.generators.multicore.multicore_untimed (   process)

Run multiple Powheg processes, each in its own thread.

Parameters
processPowhegBox process.
Author
James Robinson james.nosp@m..rob.nosp@m.inson.nosp@m.@cer.nosp@m.n.ch

Definition at line 139 of file multicore.py.

139 def multicore_untimed(process):
140  """! Run multiple Powheg processes, each in its own thread.
141 
142  @param process PowhegBox process.
143 
144  @author James Robinson <james.robinson@cern.ch>
145  """
146  if not os.path.isfile(process.executable):
147  raise OSError("Powheg executable {} not found!".format(process.executable))
148  threads = [SingleProcessThread(process.executable, seed_index=idx,
149  warning_output=(process.warning_output if hasattr(process,"warning_output") else None),
150  info_output=(process.info_output if hasattr(process,"info_output") else None),
151  error_output=(process.error_output if hasattr(process,"error_output") else None)) for idx in range(1, process.cores + 1)]
152  manager = ProcessManager(threads)
153  while manager.monitor():
154  pass

Variable Documentation

◆ logger

python.algorithms.generators.multicore.logger = Logging.logging.getLogger("PowhegControl")

Definition at line 11 of file multicore.py.

python.decorators.timed.timed
def timed(name)
Decorator to output function execution time.
Definition: timed.py:12
python.algorithms.generators.multicore.__multicore_multistage_stage_4
def __multicore_multistage_stage_4(generation_fn)
Run Powheg V2/RES (stage 4) generation in multi-core mode.
Definition: multicore.py:128
vtune_athena.format
format
Definition: vtune_athena.py:14
CaloCellPos2Ntuple.int
int
Definition: CaloCellPos2Ntuple.py:24
python.algorithms.generators.multicore.multicore
def multicore(process)
Run multiple Powheg processes, each in its own thread.
Definition: multicore.py:14
python.algorithms.generators.multicore.__multicore_multistage_stage_1
def __multicore_multistage_stage_1(generation_fn, n_xgrid_iterations)
Run Powheg V2/RES (stage 1) generation in multi-core mode.
Definition: multicore.py:88
python.algorithms.generators.multicore.__multicore_multistage
def __multicore_multistage(process, generation_fn)
Run Powheg V2/RES generation in multi-core mode.
Definition: multicore.py:52
python.algorithms.generators.multicore.__multicore_multistage_stage_2
def __multicore_multistage_stage_2(generation_fn)
Run Powheg V2/RES (stage 2) generation in multi-core mode.
Definition: multicore.py:104
python.algorithms.generators.multicore.multicore_untimed
def multicore_untimed(process)
Run multiple Powheg processes, each in its own thread.
Definition: multicore.py:139
plotBeamSpotVxVal.range
range
Definition: plotBeamSpotVxVal.py:195
python.algorithms.generators.multicore.__multicore_v1
def __multicore_v1(generation_fn)
Run Powheg V1 generation in multi-core mode.
Definition: multicore.py:42
Trk::open
@ open
Definition: BinningType.h:40
if
if(febId1==febId2)
Definition: LArRodBlockPhysicsV0.cxx:569
str
Definition: BTagTrackIpAccessor.cxx:11
python.algorithms.generators.multicore.__multicore_multistage_stage_3
def __multicore_multistage_stage_3(generation_fn)
Run Powheg V2/RES (stage 3) generation in multi-core mode.
Definition: multicore.py:116