def load_transition(element, project, net): id = utils.xml_int(element, "id") name = element.get("name") guard = project.parse_expression(element.get("guard"), get_source(element, "guard"), allow_empty=True) transition = Transition(net, id, name, guard) transition.collective = utils.xml_bool(element, "collective", False) transition.edges_in = map( lambda e: load_edge_in(e, project, net, transition), element.findall("edge-in")) transition.edges_out = map( lambda e: load_edge_out(e, project, net, transition), element.findall("edge-out")) if element.find("code") is not None: transition.code = element.find("code").text transition.trace_fire = element.find("trace") is not None transition.clock = utils.xml_bool(element, "clock", False) if transition.collective: transition.root = project.parse_expression(element.get("root"), get_source(element, "root"), allow_empty=True) if element.find("time-substitution") is not None: transition.time_substitution = element.find("time-substitution").text if element.find("clock-substitution") is not None: transition.clock_substitution = element.find("clock-substitution").text if element.find("verif-quit_flag") is not None: transition.calls_quit = True e = element.find("verif-occurrence") if e is not None: transition.occurrence_analysis = True transition.occurrence_analysis_compare_process = utils.xml_bool( e, "process") transition.occurrence_analysis_compare_binding = utils.xml_bool( e, "binding") priority = element.get("priority").strip() if priority == "": transition.priority = 0 elif utils.is_integer(priority): transition.priority = int(priority) else: raise utils.PtpException("Priority has to be integer or empty", get_source(element, "priority")) return transition
def load_transition(element, project, net): id = utils.xml_int(element, "id") name = element.get("name") guard = project.parse_expression(element.get("guard"), get_source(element, "guard"), allow_empty=True) transition = Transition(net, id, name, guard) transition.collective = utils.xml_bool(element, "collective", False) transition.edges_in = map(lambda e: load_edge_in(e, project, net, transition), element.findall("edge-in")) transition.edges_out = map(lambda e: load_edge_out(e, project, net, transition), element.findall("edge-out")) if element.find("code") is not None: transition.code = element.find("code").text transition.trace_fire = element.find("trace") is not None transition.clock = utils.xml_bool(element, "clock", False) if transition.collective: transition.root = project.parse_expression(element.get("root"), get_source(element, "root"), allow_empty=True) if element.find("time-substitution") is not None: transition.time_substitution = element.find("time-substitution").text if element.find("clock-substitution") is not None: transition.clock_substitution = element.find("clock-substitution").text if element.find("verif-quit_flag") is not None: transition.calls_quit = True e = element.find("verif-occurrence") if e is not None: transition.occurrence_analysis = True transition.occurrence_analysis_compare_process = utils.xml_bool(e, "process") transition.occurrence_analysis_compare_binding = utils.xml_bool(e, "binding") priority = element.get("priority").strip() if priority == "": transition.priority = 0 elif utils.is_integer(priority): transition.priority = int(priority) else: raise utils.PtpException("Priority has to be integer or empty", get_source(element, "priority")) return transition
def parse_args(): parser = argparse.ArgumentParser(description= "Aislinn -- Statespace analytical tool for MPI applications") parser.add_argument("program", metavar="PROGRAM", type=str, help="Path to your program") parser.add_argument("args", type=str, nargs=argparse.REMAINDER, help="Arguments for your program") parser.add_argument("-p", metavar="N", type=int, default=1, help="Number of processes") parser.add_argument("--verbose", metavar="N", type=int, default=1, help="Verbosity level (default: 1)") parser.add_argument("--vgv", metavar="N", type=int, default=0, help="Verbosity of valgrind tool") parser.add_argument("--heap-size", metavar="SIZE", type=str, help="Maximal size of heap") parser.add_argument("--redzone-size", metavar="SIZE", type=int, help="Allocation red zones") parser.add_argument("-S", "--send-protocol", metavar="VALUE", type=str, help="Standard send protocol.", default="full") parser.add_argument("--report-type", metavar="TYPE", choices=["html", "xml", "none", "html+xml"], help="Output type: xml, html, none", default="html") parser.add_argument("--max-states", metavar="N", type=int, default=9999999) parser.add_argument('--stdout', metavar="MODE", choices=["capture", "capture", "print", "drop"], default="capture", help="") parser.add_argument('--stdout-write', metavar="N", type=str, default="0", help="") parser.add_argument('--stderr', metavar="MODE", choices=["capture", "capture", "print", "drop", "stdout"], default="capture", help="") parser.add_argument('--stderr-write', metavar="N", type=str, default="0", help="0") parser.add_argument("--search", metavar="SEARCH", type=str, default="bfs", help="Statespace search strategy (bfs or dfs)") parser.add_argument("--stats", metavar="TICKS", type=int, default=None) parser.add_argument("--write-dot", action="store_true") parser.add_argument("--profile", action="store_true") # Internal debug options parser.add_argument("--debug-state", metavar="NAME", type=str, default=None) parser.add_argument("--debug-compare-states", metavar="STATE~STATE", type=str, default=None) parser.add_argument("--debug-statespace", action="store_true") parser.add_argument("--debug-seq", action="store_true") parser.add_argument("--debug-by-valgrind-tool", metavar="TOOL", type=str, default=None) parser.add_argument("--debug-profile", action="store_true") args = parser.parse_args() if args.verbose == 0: level = logging.ERROR elif args.verbose == 1: level = logging.INFO elif args.verbose == 2: level = logging.DEBUG else: print "Invalid verbose level (parameter --verbose)" sys.exit(1) if args.stdout_write != "all": if utils.is_integer(args.stdout_write): args.stdout_write = int(args.stdout_write) else: sys.stderr.write("Invalid argument for --stdout-write\n") sys.exit(1) if args.stderr_write != "all": if utils.is_integer(args.stderr_write): args.stderr_write = int(args.stderr_write) else: sys.stderr.write("Invalid argument for --stderr-write\n") sys.exit(1) logging.basicConfig(format="==AN== %(levelname)s: %(message)s", level=level) logging.info("Aislinn v%s", VERSION_STRING) if args.p <= 0: logging.error("Invalid number of processes (parameter -p)") sys.exit(1) if args.search != "bfs" and args.search != "dfs": logging.error("Invalid argument for --search") sys.exit(1) valgrind_args = [] if args.heap_size: size = utils.sizestr_to_int(args.heap_size) if size is None or size < 1: logging.error("Invalid heap size (parameter --heap-size)") sys.exit(1) valgrind_args.append("--heap-size={0}".format(size)) if args.redzone_size: size = int(args.redzone_size) if size < 0: logging.error("Invalid redzone size") sys.exit(1) valgrind_args.append("--alloc-redzone-size={0}".format(size)) if args.vgv: valgrind_args.append("--verbose={0}".format(args.vgv)) if args.send_protocol not in ("full", "eager", "rendezvous"): threshold = parse_threshold(args.send_protocol) if threshold is None: logging.error("Invalid send protocol (parameter -S or --send-protocol)") sys.exit(1) args.send_protocol = "threshold" args.send_protocol_eager_threshold = threshold[0] args.send_protocol_rendezvous_threshold = threshold[1] else: args.send_protocol_eager_threshold = 0 args.send_protocol_rendezvous_threshold = None if args.stdout_write and args.stdout != "capture": logging.error("--stdout-write is used but " "stdout is not captured (--stdout option)") sys.exit(1) if args.stderr_write and args.stderr != "capture": logging.error("--stderr-write is used but " "stderr is not captured (--stderr option)") sys.exit(1) return args, valgrind_args