Пример #1
0
def run(args):
  if not cere_configure.init():
    return False

  invocations = find_invocations(args.invocation, args.region)
  if not invocations:
    return False
  for invocation in invocations:
    if not args.force:
      if utils.dump_exist(args.region, invocation):
        logger.info("Dump already exists for region {0} invocation {1}".format(args.region, invocation))
        return True
      if utils.is_invalid(args.region):
        logger.warning("{0} is invalid. Skipping capture".format(args.region))
        return False
    else:
      shutil.rmtree(os.path.join(var.CERE_DUMPS_PATH, args.region, str(invocation)), ignore_errors=True)

    logger.info("Compiling capture mode for region {0} invocation {1}".format(args.region, invocation))
    try:
      logger.debug(subprocess.check_output("{0} && {1} CERE_MODE=\"dump --region={2} --invocation={3}\"".format(cere_configure.cere_config["clean_cmd"],
                                          cere_configure.cere_config["build_cmd"], args.region, invocation), stderr=subprocess.STDOUT, shell=True))
    except subprocess.CalledProcessError as err:
      logger.error(str(err))
      logger.error(err.output)
      logger.error("Compiling capture mode for region {0} invocation {1} failed".format(args.region, invocation))
      utils.mark_invalid(args.region, cere_error.EDUMP)
      return False
    if not args.norun:
      logger.info("Capturing invocation {1} for region {0}".format(args.region, invocation))
      try:
        logger.info(subprocess.check_output(cere_configure.cere_config["run_cmd"], stderr=subprocess.STDOUT, shell=True))
      except subprocess.CalledProcessError as err:
        #even if the capture run fails, maybe the region is dumped.
        logger.error(str(err))
        logger.error(err.output)
      if not os.path.isdir("{0}/{1}/{2}".format(var.CERE_DUMPS_PATH, args.region, invocation)):
        logger.error("Capture failed for region {0} invocation {1}".format(args.region, invocation))
        utils.mark_invalid(args.region, cere_error.EDUMP)
        return False
      else:
        logger.info("Invocation {1} succesfully captured for region {0} ".format(args.region, invocation))
  return True
Пример #2
0
def run(args):
    if not cere_configure.init():
        return False
    if utils.is_invalid(args.region) and not args.force:
        logger.warning("{0} is invalid. Skipping replay".format(args.region))
        return False

    invocations = find_invocations(args.invocation, args.region)
    if not invocations:
        return False
    if PREDICTION_MODE and args.plugin_instr != var.RDTSC_WRAPPER:
        logger.warning(
            "You are not using the default library. Computing predicted time\n\
                    may not work if the replay output is not the same"
        )
    for invocation, part in invocations.iteritems():
        if os.path.isfile("{0}/{1}_{2}.csv".format(var.CERE_REPLAY_PATH, args.region, invocation)) and not args.force:
            logger.warning("Replay already measured for {0} invocation {1}.".format(args.region, invocation))
            continue
        if not utils.dump_exist(args.region, invocation):
            logger.error(
                "Memory dump is missing for {0} invocation {1}.\n\
                    Run cere capture --region={0} [--invocation={1}]".format(
                    args.region, invocation
                )
            )
            return False
        if args.noinstrumentation:
            instru_cmd = ""
            logger.info(
                "Compiling replay mode for region {0} invocation {1} without instrumentation".format(
                    args.region, invocation
                )
            )
        else:
            instru_cmd = "--instrument"
            logger.info(
                "Compiling replay mode for region {0} invocation {1} with instrumentation".format(
                    args.region, invocation
                )
            )

        if args.static:
            static_cmd = "--static"
            logger.info("Static mode enabled".format(args.region, invocation))
        else:
            static_cmd = ""

        try:
            logger.debug(
                subprocess.check_output(
                    '{0} && {1} CERE_REPLAY_REPETITIONS={6} CERE_MODE="replay --region={2} --invocation={3} {4} --wrapper={5} {7}"'.format(
                        cere_configure.cere_config["clean_cmd"],
                        cere_configure.cere_config["build_cmd"],
                        args.region,
                        invocation,
                        instru_cmd,
                        args.plugin_instr,
                        args.invitro_callcount,
                        static_cmd,
                    ),
                    stderr=subprocess.STDOUT,
                    shell=True,
                )
            )
        except subprocess.CalledProcessError as err:
            logger.error(str(err))
            logger.error(err.output)
            logger.error("Compiling replay mode for region {0} invocation {1} Failed".format(args.region, invocation))
            utils.mark_invalid(args.region, cere_error.EREPLAY)
            return False
        if not args.norun:
            logger.info("Replaying invocation {1} for region {0}".format(args.region, invocation))
            try:
                logger.debug(
                    subprocess.check_output(cere_configure.cere_config["run_cmd"], stderr=subprocess.STDOUT, shell=True)
                )
            except subprocess.CalledProcessError as err:
                logger.error(str(err))
                logger.error(err.output)
                logger.error("Replay failed for {0} invocation {1}".format(args.region, invocation))
                utils.mark_invalid(args.region, cere_error.EREPLAY)
                return False
            # Save replay measures files
            if PREDICTION_MODE:
                try:
                    shutil.move(
                        "{0}.csv".format(args.region),
                        "{0}/{1}_{2}.csv".format(var.CERE_REPLAY_PATH, args.region, invocation),
                    )
                except IOError as err:
                    logger.error(str(err))
                    logger.error("  No results file. Maybe replay failed".format(invocation))
                    return False
    if PREDICTION_MODE:
        predicted_cycles = compute_predicted_time(args.region, invocations)
        dump_result(args.region, predicted_cycles)
        logger.info(" Overall predicted cycles = {0}".format(predicted_cycles))
    return True
Пример #3
0
def run(args):
  if not cere_configure.init():
    return False
  if utils.is_invalid(args.region) and not args.force:
    logger.warning("{0} is invalid. Skipping replay".format(args.region))
    return False

  invocations = find_invocations(args.invocation, args.region)
  if not invocations:
    return False
  if (PREDICTION_MODE and args.plugin_instr != var.RDTSC_WRAPPER):
    logger.warning("You are not using the default library. Computing predicted time\n\
                    may not work if the replay output is not the same")
  for invocation, part in invocations.iteritems():
    if os.path.isfile("{0}/{1}_{2}.csv".format(var.CERE_REPLAY_PATH, args.region, invocation)) and not args.force:
      logger.warning("Replay already measured for {0} invocation {1}.".format(args.region, invocation))
      continue
    if not utils.dump_exist(args.region, invocation):
      logger.error("Memory dump is missing for {0} invocation {1}.\n\
                    Run cere capture --region={0} [--invocation={1}]".format(args.region, invocation))
      return False
    if args.noinstrumentation:
      instru_cmd = ""
      logger.info("Compiling replay mode for region {0} invocation {1} without instrumentation".format(args.region, invocation))
    else:
      instru_cmd = "--instrument"
      logger.info("Compiling replay mode for region {0} invocation {1} with instrumentation".format(args.region, invocation))

    if args.static:
      static_cmd = "--static"
      logger.info("Static mode enabled".format(args.region, invocation))
    else:
      static_cmd = ""

    try:
      logger.debug(
        subprocess.check_output("{0} && {1} CERE_REPLAY_REPETITIONS={6} CERE_MODE=\"replay --region={2} --invocation={3} {4} --wrapper={5} {7}\"".format(
        cere_configure.cere_config["clean_cmd"], cere_configure.cere_config["build_cmd"],
          args.region, invocation, instru_cmd, args.plugin_instr, args.invitro_callcount, static_cmd), stderr=subprocess.STDOUT, shell=True))
    except subprocess.CalledProcessError as err:
      logger.error(str(err))
      logger.error(err.output)
      logger.error("Compiling replay mode for region {0} invocation {1} Failed".format(args.region, invocation))
      utils.mark_invalid(args.region, cere_error.EREPLAY)
      return False
    if not args.norun:
      logger.info("Replaying invocation {1} for region {0}".format(args.region, invocation))
      try:
        logger.debug(subprocess.check_output(cere_configure.cere_config["run_cmd"], stderr=subprocess.STDOUT, shell=True))
      except subprocess.CalledProcessError as err:
        logger.error(str(err))
        logger.error(err.output)
        logger.error("Replay failed for {0} invocation {1}".format(args.region, invocation))
        utils.mark_invalid(args.region, cere_error.EREPLAY)
        return False
      #Save replay measures files
      if PREDICTION_MODE:
        try:
          shutil.move("{0}.csv".format(args.region), "{0}/{1}_{2}.csv".format(var.CERE_REPLAY_PATH, args.region, invocation))
        except IOError as err:
          logger.error(str(err))
          logger.error("  No results file. Maybe replay failed".format(invocation))
          return False
  if PREDICTION_MODE:
    predicted_cycles = compute_predicted_time(args.region, invocations)
    dump_result(args.region, predicted_cycles)
    logger.info(" Overall predicted cycles = {0}".format(predicted_cycles))
  return True