def need_to_measure(region): if utils.is_invalid(region): return False if utils.trace_exists(region): return False return True
def run(args): if not cere_configure.init(): return False if not check_arguments(args): return False # Find loops to trace regions = find_regions_to_trace(args) # When force is off, filter already measured regions if not args.force: regions = [r for r in regions if need_to_measure(r)] result = True # Are there any regions to trace ? if len(regions) == 0: logger.info("No regions to trace") else: result = launch_trace(args, regions) # Move trace files to cere_measures if not args.norun: for region in regions: try: shutil.move("{0}.bin".format(region), var.CERE_TRACES_PATH) shutil.move("{0}.csv".format(region), var.CERE_TRACES_PATH) except IOError as err: logger.error(str(err)) logger.error( "Trace failed for region {0}: No output files, maybe the selected region does not exist." .format(region)) utils.mark_invalid(region, cere_error.ETRACE) result = False # If read is used, read given invocation from trace file if args.read and utils.trace_exists(args.region): base_name = "{0}/{1}".format(var.CERE_TRACES_PATH, args.region) trace = parse_trace_file(base_name + '.bin') cycles = int(trace['cycles'][trace['invocations'] == args.read]) print(cycles) return result
def run(args): if not cere_configure.init(): return False if not check_arguments(args): return False # Find loops to trace regions = find_regions_to_trace(args) # When force is off, filter already measured regions if not args.force: regions = [r for r in regions if need_to_measure(r)] result = True # Are there any regions to trace ? if len(regions) == 0: logger.info("No regions to trace") else: result = launch_trace(args, regions) # Move trace files to cere_measures if not args.norun: for region in regions: try: shutil.move("{0}.bin".format(region), var.CERE_TRACES_PATH) shutil.move("{0}.csv".format(region), var.CERE_TRACES_PATH) except IOError as err: logger.error(str(err)) logger.error("Trace failed for region {0}: No output files, maybe the selected region does not exist.".format(region)) utils.mark_invalid(region, cere_error.ETRACE) result = False # If read is used, read given invocation from trace file if args.read and utils.trace_exists(args.region): base_name = "{0}/{1}".format(var.CERE_TRACES_PATH, args.region) trace = parse_trace_file(base_name + '.bin') cycles = int(trace['cycles'][trace['invocations'] == args.read]) print(cycles) return result
def run(args): if not cere_configure.init(): return False invocation_file = os.path.join(var.CERE_TRACES_PATH, args.region+".invocations") if os.path.isfile(invocation_file) and not args.force: logger.info("Invocations already selected for {0}. If you want to reselect use -f".format(args.region, invocation_file)) return True if not utils.trace_exists(args.region): logger.error("No trace for {0}.\n\ Please first run cere trace --region={0}".format(args.region)) return False bin_file = os.path.join(var.CERE_TRACES_PATH, args.region+".bin") csv_file = os.path.join(var.CERE_TRACES_PATH, args.region+".csv") clusterize_invocations(args.region, csv_file, bin_file) try: shutil.move("{0}.invocations".format(args.region), "{0}/{1}.invocations".format(var.CERE_TRACES_PATH, args.region)) except IOError as err: logger.error(str(err)) return False return True