Coverage for /home/shudson/libensemble/rsync-to-clusters/nkag-fresh-checkout/libensemble_master/libensemble/libE.py : 70%

Hot-keys on this page
r m x p toggle line displays
j k next/prev highlighted chunk
0 (zero) top of page
1 (one) first highlighted chunk
""" Main libEnsemble routine ============================================
"""
# Set root logger # (Set above libe imports so errors in import are captured) # LEVEL: DEBUG/INFO/WARNING/ERROR #logging.basicConfig(level=logging.INFO, format='%(name)s (%(levelname)s): %(message)s')
#For debug messages in this module - uncomment (see libE.py to change root logging level) #logger.setLevel(logging.DEBUG)
"""Print to stderr."""
'''Abort all MPI ranks''' comm.Abort(1) # Exit code 1 to represent an abort
'''Worker signal manager to abort''' comm.send(obj=None, dest=0, tag=ABORT_ENSEMBLE)
alloc_specs={'alloc_f': give_sim_work_first, 'out':[('allocated', bool)]}, libE_specs={'comm': MPI.COMM_WORLD, 'color': 0}, H0=[]): """ libE(sim_specs, gen_specs, exit_criteria, persis_info={}, alloc_specs={'alloc_f': give_sim_work_first, 'out':[('allocated',bool)]}, libE_specs={'comm': MPI.COMM_WORLD, 'color': 0}, H0 =[])
This is the outer libEnsemble routine. If the rank in libE_specs['comm'] is 0, manager_main is run. Otherwise, worker_main is run.
If an exception is encountered by the manager or workers, the history array is dumped to file and MPI abort is called.
Parameters ----------
sim_specs: :obj:`dict`
Specifications for the simulation function :doc:`(example)<data_structures/sim_specs>`
gen_specs: :obj:`dict`
Specifications for the generator function :doc:`(example)<data_structures/gen_specs>`
exit_criteria: :obj:`dict`
Tell libEnsemble when to stop a run :doc:`(example)<data_structures/exit_criteria>`
persis_info: :obj:`dict`, optional
Persistent information to be passed between user functions :doc:`(example)<data_structures/persis_info>`
alloc_specs: :obj:`dict`, optional
Specifications for the allocation function :doc:`(example)<data_structures/alloc_specs>`
libE_specs: :obj:`dict`, optional
Specifications for libEnsemble :doc:`(example)<data_structures/libE_specs>`
H0: :obj:`dict`, optional
A previous libEnsemble history to be prepended to the history in the current libEnsemble run :doc:`(example)<data_structures/history_array>`
Returns -------
H: :obj:`dict`
History array storing rows for each point. :doc:`(example)<data_structures/history_array>` Dictionary containing persistent info
persis_info: :obj:`dict`
Final state of persistent information :doc:`(example)<data_structures/persis_info>`
exit_flag: :obj:`int`
Flag containing job status: 0 = No errors, 1 = Exception occured and MPI aborted, 2 = Manager timed out and ended simulation
""" #sys.excepthook = comms_abort(libE_specs['comm'])
# Manager exceptions are fatal
#sys.excepthook = comms_abort(libE_specs['comm']) #raise
else: logger.debug("Manager exiting") print(libE_specs['comm'].Get_size(), exit_criteria) sys.stdout.flush()
else: try: worker_main(libE_specs, sim_specs, gen_specs) except Exception as e: eprint("\nWorker exception raised on rank {} .. aborting ensemble:\n".format(libE_specs['comm'].Get_rank())) eprint(traceback.format_exc()) sys.stdout.flush() sys.stderr.flush()
#First try to signal manager to dump history comms_signal_abort_to_man(libE_specs['comm']) #comms_abort(libE_specs['comm']) else: logger.debug("Worker {} exiting".format(libE_specs['comm'].Get_rank()))
# Create calc summary file libE_specs['comm'].Barrier() if libE_specs['comm'].Get_rank() == 0: CalcInfo.merge_statfiles() H = hist.trim_H()
return H, persis_info, exit_flag
""" Check if the libEnsemble arguments are of the correct data type contain sufficient information to perform a run. """
libE_specs['comm'] = MPI.COMM_WORLD
assert exit_criteria['stop_val'][0] in [e[0] for e in sim_specs['out']] + [e[0] for e in gen_specs['out']],\ "Can't stop on " + exit_criteria['stop_val'][0] + " if it's not \ returned from sim_specs['out'] or gen_specs['out']"
if MPI.COMM_WORLD.Get_rank() == 0: print('\n' + 79*'*' + '\n' "User generator script will be creating sim_id.\n"\ "Take care to do this sequentially.\n"\ "Also, any information given back for existing sim_id values will be overwritten!\n"\ "So everything in gen_out should be in gen_in!"\ '\n' + 79*'*' + '\n\n') sys.stdout.flush() libE_fields = libE_fields[1:] # Must remove 'sim_id' from libE_fields because it's in gen_specs['out'] else:
|