Classes | Functions | Variables
run_unfold_ppfx_multiprocess Namespace Reference

Classes

class  Consumer
 
class  Task
 

Functions

def make_cmd (nnodes, ranks_per_node, procid, nuniv_per_rank, nfiles_per_rank, ppfx_batch_idx, totuniv, totfiles)
 
def RunMultiProcess (nCMD, lCMD, num_consumers=0)
 

Variables

 parser
 
 default
 
 type
 
 help
 
 args = parser.parse_args()
 
 nranks_per_node = multiprocessing.cpu_count()
 
 jsub_id = os.environ['JOBSUBJOBID']
 
 jid = jsub_id.split('@')[0].split('.')[0]
 
 procid = jsub_id.split('@')[0].split('.')[1]
 
 ncmd
 
 cmd
 

Function Documentation

def run_unfold_ppfx_multiprocess.make_cmd (   nnodes,
  ranks_per_node,
  procid,
  nuniv_per_rank,
  nfiles_per_rank,
  ppfx_batch_idx,
  totuniv,
  totfiles 
)

Definition at line 7 of file run_unfold_ppfx_multiprocess.py.

References novadaq::HexUtils.format(), makeTrainCVSamples.int, and PandAna.Demos.demo1.range.

7 def make_cmd(nnodes, ranks_per_node, procid, nuniv_per_rank, nfiles_per_rank, ppfx_batch_idx, totuniv, totfiles):
8 
9  cmd = []
10  name_cmd = []
11  covered = False
12  # ncmd = nuniv*nfiles
13  nfiles_last_batch = totfiles%nfiles_per_rank
14 
15  if nnodes > 1 and int(procid) == nnodes - 1:
16  ifilefirst = totfiles - nfiles_last_batch
17  ifilelast = ifilefirst + nfiles_last_batch -1
18  else:
19  ifilefirst = int(procid) * nfiles_per_rank
20  ifilelast = ifilefirst + nfiles_per_rank - 1
21 
22  for irank in range(ranks_per_node):
23  iunivfirst = ppfx_batch_idx * totuniv + irank * nuniv_per_rank
24  iunivlast = iunivfirst + nuniv_per_rank - 1
25 
26  icmd = "cafe -bq -nr --numuccinc /development/NDAna/numucc_inc/specprod_numuccinc.C ppfx -1 -1 {} {} 0 {} {}".format(
27  iunivfirst, iunivlast, ifilefirst, ifilelast)
28  iname_cmd = "ProcID: {} , Ppfx batch index: {}, cafe -bq -nr --numuccinc /development/NDAna/numucc_inc/specprod_numuccinc.C ppfx -1 -1 {} {} 0 {} {}".format(
29  procid, ppfx_batch_idx, iunivfirst, iunivlast, ifilefirst, ifilelast)
30  cmd.append(icmd)
31  name_cmd.append(iname_cmd)
32 
33  return (name_cmd, cmd)
34 
std::string format(const int32_t &value, const int &ndigits=8)
Definition: HexUtils.cpp:14
def make_cmd(nnodes, ranks_per_node, procid, nuniv_per_rank, nfiles_per_rank, ppfx_batch_idx, totuniv, totfiles)
def run_unfold_ppfx_multiprocess.RunMultiProcess (   nCMD,
  lCMD,
  num_consumers = 0 
)

Definition at line 69 of file run_unfold_ppfx_multiprocess.py.

References novadaq::HexUtils.format(), print, and PandAna.Demos.demo1.range.

69 def RunMultiProcess(nCMD, lCMD, num_consumers=0):
70  # Establish communication queues
71  tasks = multiprocessing.Queue()
72  results = multiprocessing.Queue()
73 
74  # Start consumers
75  if num_consumers == 0:
76  num_consumers = multiprocessing.cpu_count()
77  print('Creating {} consumers'.format(num_consumers))
78  consumers = [Consumer(tasks, results) for i in range(num_consumers)]
79  for w in consumers:
80  w.start()
81 
82  num_jobs = len(lCMD)
83  for i in range(num_jobs):
84  tasks.put(Task(nCMD[i], lCMD[i]))
85 
86  # Add a poison pill for each consumer
87  for i in range(num_consumers):
88  tasks.put(None)
89  # Start printing results
90  while num_jobs:
91  result = results.get()
92  print('Result: {}'.format(result))
93  num_jobs -= 1
94  return
95 
96 
bool print
std::string format(const int32_t &value, const int &ndigits=8)
Definition: HexUtils.cpp:14
def RunMultiProcess(nCMD, lCMD, num_consumers=0)

Variable Documentation

run_unfold_ppfx_multiprocess.args = parser.parse_args()

Definition at line 121 of file run_unfold_ppfx_multiprocess.py.

run_unfold_ppfx_multiprocess.cmd

Definition at line 136 of file run_unfold_ppfx_multiprocess.py.

run_unfold_ppfx_multiprocess.default

Definition at line 104 of file run_unfold_ppfx_multiprocess.py.

run_unfold_ppfx_multiprocess.help

Definition at line 105 of file run_unfold_ppfx_multiprocess.py.

run_unfold_ppfx_multiprocess.jid = jsub_id.split('@')[0].split('.')[0]

Definition at line 130 of file run_unfold_ppfx_multiprocess.py.

run_unfold_ppfx_multiprocess.jsub_id = os.environ['JOBSUBJOBID']

Definition at line 129 of file run_unfold_ppfx_multiprocess.py.

run_unfold_ppfx_multiprocess.ncmd

Definition at line 136 of file run_unfold_ppfx_multiprocess.py.

run_unfold_ppfx_multiprocess.nranks_per_node = multiprocessing.cpu_count()

Definition at line 124 of file run_unfold_ppfx_multiprocess.py.

run_unfold_ppfx_multiprocess.parser
Initial value:
1 = argparse.ArgumentParser(
2  prog='make_cafe_cmd',
3  description=,
4  epilog="Questions and Comments to dingpf@fnal.gov")

Definition at line 98 of file run_unfold_ppfx_multiprocess.py.

run_unfold_ppfx_multiprocess.procid = jsub_id.split('@')[0].split('.')[1]

Definition at line 131 of file run_unfold_ppfx_multiprocess.py.

run_unfold_ppfx_multiprocess.type

Definition at line 104 of file run_unfold_ppfx_multiprocess.py.