Classes | Functions | Variables
run_unfold_genie_multiprocess Namespace Reference

Classes

class  Consumer
 
class  Task
 

Functions

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

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
 
 False
 
 action
 

Function Documentation

def run_unfold_genie_multiprocess.make_cmd (   nnodes,
  ranks_per_node,
  procid,
  nuniv_per_rank,
  nfiles_per_rank,
  genie_batch_idx,
  totuniv,
  totfiles 
)

Definition at line 7 of file run_unfold_genie_multiprocess.py.

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

Referenced by make_cmd().

7 def make_cmd(nnodes, ranks_per_node, procid, nuniv_per_rank, nfiles_per_rank, genie_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  # if int(procid) == ranks_per_node:
22  # ifilefirst = int(procid) * nfiles_per_rank * ranks_per_node + irank * nfiles_per_rank
23  # ifilelast = ifilefirst + nfiles_per_rank - 1
24  # else:
25  # ifilefirst = totfiles - nfiles_last_batch
26  # ifilelast = totfiles - 1
27 
28  for irank in range(ranks_per_node):
29  iunivfirst = genie_batch_idx * totuniv + irank * nuniv_per_rank
30  iunivlast = iunivfirst + nuniv_per_rank - 1
31 
32  icmd = "cafe -bq -nr --numuccinc /development/NDAna/numucc_inc/specprod_numuccinc.C genie {} {} -1 -1 0 {} {}".format(
33  iunivfirst, iunivlast, ifilefirst, ifilelast)
34  iname_cmd = "ProcID: {} , Genie batch index: {}, cafe -bq -nr --numuccinc /development/NDAna/numucc_inc/specprod_numuccinc.C genie {} {} -1 -1 0 {} {}".format(
35  procid, genie_batch_idx, iunivfirst, iunivlast, ifilefirst, ifilelast)
36  cmd.append(icmd)
37  name_cmd.append(iname_cmd)
38 
39  return (name_cmd, cmd)
40 
def make_cmd(nnodes, ranks_per_node, procid, nuniv_per_rank, nfiles_per_rank, genie_batch_idx, totuniv, totfiles)
std::string format(const int32_t &value, const int &ndigits=8)
Definition: HexUtils.cpp:14
def run_unfold_genie_multiprocess.make_cmd (   nnodes,
  ranks_per_node,
  procid,
  nuniv_per_rank,
  nfiles_per_rank,
  genie_batch_idx,
  totuniv,
  totfiles,
  mode 
)

Definition at line 7 of file run_unfold_genie_multiprocess.py.

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

7 def make_cmd(nnodes, ranks_per_node, procid, nuniv_per_rank, nfiles_per_rank, genie_batch_idx, totuniv, totfiles, mode):
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  if ifilefirst > totfiles-1:
22  print('First file index exceeds total number of files in the dataset')
23  sys.exit(-1)
24  if ifilelast > totfiles-1:
25  print('Reached the end of the dataset. Setting last file index to the last file')
26  ifilelast = totfiles-1
27  # if int(procid) == ranks_per_node:
28  # ifilefirst = int(procid) * nfiles_per_rank * ranks_per_node + irank * nfiles_per_rank
29  # ifilelast = ifilefirst + nfiles_per_rank - 1
30  # else:
31  # ifilefirst = totfiles - nfiles_last_batch
32  # ifilelast = totfiles - 1
33 
34  for irank in range(ranks_per_node):
35  iunivfirst = genie_batch_idx * totuniv + irank * nuniv_per_rank
36  iunivlast = iunivfirst + nuniv_per_rank - 1
37  cmd_base='/usr/bin/time -v cafe -bq -nr --numuccinc /development/NDAna/numucc_inc/nersc/unfolding_macros/genie_ppfx/specprod_numuccinc.C {0}'.format(mode)
38 # cmd_base='cafe -bq --numuccinc /development/NDAna/numucc_inc/nersc/unfolding_macros/genie_ppfx/specprod_numuccinc.C {0}'.format(mode)
39  if 'genie' in mode:
40  icmd = cmd_base + " {0} {1} -1 -1 {2} {3}".format(iunivfirst, iunivlast, ifilefirst, ifilelast)
41  elif 'ppfx' in mode:
42  icmd = cmd_base + " -1 -1 {0} {1} {2} {3}".format(iunivfirst, iunivlast, ifilefirst, ifilelast)
43  else:
44  print('Mode {} not recognized. Must run in mode genie or ppfx'.format(mode))
45  sys.exit(-1)
46 
47  iname_cmd = "ProcID: {0} , Genie batch index: {1}, {2}".format(procid, genie_batch_idx, icmd)
48  cmd.append(icmd)
49  name_cmd.append(iname_cmd)
50 
51  return (name_cmd, cmd)
52 
def make_cmd(nnodes, ranks_per_node, procid, nuniv_per_rank, nfiles_per_rank, genie_batch_idx, totuniv, totfiles)
bool print
std::string format(const int32_t &value, const int &ndigits=8)
Definition: HexUtils.cpp:14
def run_unfold_genie_multiprocess.RunMultiProcess (   nCMD,
  lCMD,
  num_consumers = 0 
)

Definition at line 75 of file run_unfold_genie_multiprocess.py.

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

Referenced by run_unfold_genie_multiprocess.Task.__str__().

75 def RunMultiProcess(nCMD, lCMD, num_consumers=0):
76  # Establish communication queues
77  tasks = multiprocessing.Queue()
78  results = multiprocessing.Queue()
79 
80  # Start consumers
81  if num_consumers == 0:
82  num_consumers = multiprocessing.cpu_count()
83  print('Creating {} consumers'.format(num_consumers))
84  consumers = [Consumer(tasks, results) for i in range(num_consumers)]
85  for w in consumers:
86  w.start()
87 
88  num_jobs = len(lCMD)
89  for i in range(num_jobs):
90  tasks.put(Task(nCMD[i], lCMD[i]))
91 
92  # Add a poison pill for each consumer
93  for i in range(num_consumers):
94  tasks.put(None)
95  # Start printing results
96  while num_jobs:
97  result = results.get()
98  print('Result: {}'.format(result))
99  num_jobs -= 1
100  return
101 
102 
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_genie_multiprocess.action

Definition at line 140 of file run_unfold_genie_multiprocess.py.

run_unfold_genie_multiprocess.args = parser.parse_args()

Definition at line 127 of file run_unfold_genie_multiprocess.py.

run_unfold_genie_multiprocess.cmd

Definition at line 142 of file run_unfold_genie_multiprocess.py.

run_unfold_genie_multiprocess.default

Definition at line 110 of file run_unfold_genie_multiprocess.py.

run_unfold_genie_multiprocess.False

Definition at line 140 of file run_unfold_genie_multiprocess.py.

run_unfold_genie_multiprocess.help

Definition at line 111 of file run_unfold_genie_multiprocess.py.

run_unfold_genie_multiprocess.jid = jsub_id.split('@')[0].split('.')[0]
run_unfold_genie_multiprocess.jsub_id = os.environ['JOBSUBJOBID']

Definition at line 135 of file run_unfold_genie_multiprocess.py.

run_unfold_genie_multiprocess.ncmd
run_unfold_genie_multiprocess.nranks_per_node = multiprocessing.cpu_count()

Definition at line 130 of file run_unfold_genie_multiprocess.py.

run_unfold_genie_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 104 of file run_unfold_genie_multiprocess.py.

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

Definition at line 137 of file run_unfold_genie_multiprocess.py.

Referenced by FCTutorial2020().

run_unfold_genie_multiprocess.type

Definition at line 110 of file run_unfold_genie_multiprocess.py.