Пример #1
0
def run(args):
    flags = args.flags.split(',')
    for f in flags:
        logger.info("Measuring with {0} flag".format(f))
        os.environ["CERE_BACKEND_FLAGS"] = f
        cere_replay.run(args)

    if "CERE_BACKEND_FLAGS" in os.environ:
        del os.environ["CERE_BACKEND_FLAGS"]
    return True
Пример #2
0
def run(args):
  flags = args.flags.split(',')
  for f in flags:
    logger.info("Measuring with {0} flag".format(f))
    os.environ["CERE_BACKEND_FLAGS"] = f
    cere_replay.run(args)

  if "CERE_BACKEND_FLAGS" in os.environ:
    del os.environ["CERE_BACKEND_FLAGS"]
  return True
Пример #3
0
 def replay_invocations(self, force):
     if not os.path.isfile("{0}/{1}.invocations".format(
             var.CERE_TRACES_PATH, self.region)):
         logger.error("No invocation file for region {0}".format(
             self.region))
         return False
     err = False
     clust = 0
     with open("{0}/{1}.invocations".format(
             var.CERE_TRACES_PATH, self.region)) as invocation_file:
         for line in invocation_file:
             self.force = False
             res = True
             clust = clust + 1
             infos = line.strip().split()
             self.invocation = infos[0]
             self.invitro_callcount = 10
             #Dump the required invocation
             cere_capture.run(self)
             #Replay it and compute error between invivo and invitro cycles for this invocation
             self.force = force
             if not cere_replay.run(self):
                 err = True
                 invitro_cycles = 0.
             else:
                 try:
                     if not os.path.isfile("{0}/{1}_{2}.csv".format(
                             var.CERE_REPLAY_PATH, self.region,
                             self.invocation)):
                         shutil.move(
                             "{0}.csv".format(self.region),
                             "{0}/{1}_{2}.csv".format(
                                 var.CERE_REPLAY_PATH, self.region,
                                 self.invocation))
                 except IOError as err:
                     logger.error(str(err))
                     logger.error(
                         "No results file. Maybe replay failed for {0} invocation {1}"
                         .format(self.region, self.invocation))
                     err = True
                     invitro_cycles = 0.
                 else:
                     with open("{0}/{1}_{2}.csv".format(
                             var.CERE_REPLAY_PATH, self.region,
                             self.invocation)) as invitro:
                         reader = csv.DictReader(invitro)
                         for row in reader:
                             invitro_cycles = float(
                                 row["CPU_CLK_UNHALTED_CORE"]) / float(
                                     row["Call Count"])
             matching_err = compute_error(invitro_cycles, float(infos[2]))
             #Aggregate invocations cycles, needed to compute invitro measure for the codelet
             self.invitro_cycles = self.invitro_cycles + invitro_cycles * float(
                 infos[1])
             self.invocations_data.append([
                 infos[0], clust, infos[1], invitro_cycles, infos[2],
                 matching_err
             ])
     return not err
Пример #4
0
 def replay_invocations(self, force):
     if not os.path.isfile("{0}/{1}.invocations".format(var.CERE_TRACES_PATH, self.region)):
         logger.error("No invocation file for region {0}".format(self.region))
         return False
     err=False
     clust=0
     with open("{0}/{1}.invocations".format(var.CERE_TRACES_PATH, self.region)) as invocation_file:
         for line in invocation_file:
             self.force = False
             res=True
             clust = clust + 1
             infos = line.strip().split()
             self.invocation = infos[0]
             self.invitro_callcount = 10
             #Dump the required invocation
             cere_capture.run(self)
             #Replay it and compute error between invivo and invitro cycles for this invocation
             self.force = force
             if not cere_replay.run(self):
                 err=True
                 invitro_cycles = 0.
             else:
                 try:
                     if not os.path.isfile("{0}/{1}_{2}.csv".format(var.CERE_REPLAY_PATH, self.region, self.invocation)) or self.force:
                         shutil.move("{0}.csv".format(self.region), "{0}/{1}_{2}.csv".format(var.CERE_REPLAY_PATH, self.region, self.invocation))
                 except IOError as err:
                     logger.error(str(err))
                     logger.error("No results file. Maybe replay failed for {0} invocation {1}".format(self.region, self.invocation))
                     err=True
                     invitro_cycles = 0.
                 else:
                     with open("{0}/{1}_{2}.csv".format(var.CERE_REPLAY_PATH, self.region, self.invocation)) as invitro:
                         reader = csv.DictReader(invitro)
                         for row in reader:
                             invitro_cycles = float(row["CPU_CLK_UNHALTED_CORE"]) / float(row["Call Count"])
             matching_err = compute_error(invitro_cycles, float(infos[2]))
             #Aggregate invocations cycles, needed to compute invitro measure for the codelet
             self.invitro_cycles = self.invitro_cycles + invitro_cycles * float(infos[1])
             self.invocations_data.append([infos[0], clust, infos[1], invitro_cycles, infos[2], matching_err])
     return not err
Пример #5
0
def run_replay(flags, args, history):
  best_id = -1
  best_cycles = float("inf")

  #Open result file
  with open("{0}/{1}.csv".format(var.CERE_FLAGS_PATH, args.region), 'a') as region_file:
    region_writer = csv.writer(region_file)
    for line in flags:
      #Replay if "id" not already measured
      if line["id"] not in history:
        logger.info("Running ID: {0}".format(line["id"]))
        set_env(line)

        #Set attributes for the replay pass.
        args.static=False
        args.force=True
        args.invocation=None
        args.noinstrumentation=False
        args.norun=False
        args.plugin_instr=var.RDTSC_WRAPPER

        if cere_replay.run(args):
          predicted_cycles = get_predicted_cycles(args.region)
          region_writer.writerow([line["id"], line["mid_end"], line["back_end"], predicted_cycles])
          region_file.flush()
        else:
          predicted_cycles = float("inf")
      #Get previous measure for this sequence of flags
      else:
        predicted_cycles = float(history[line["id"]]["cycles"])

      if predicted_cycles < best_cycles:
        best_cycles = predicted_cycles
        best_id = line["id"]

  args.FLAGSFILE.seek(0)
  flags.next()

  return best_id, best_cycles