Ejemplo n.º 1
0
def main(args):
    os.path.exists("bins") or os.mkdir("bins")
    try:
        multiprocessing.set_start_method("spawn")
        opentuner.init_logging()
        ConvTuner.main(parser.parse_args(args))
    finally:
        shutil.rmtree("./bins")
Ejemplo n.º 2
0
  def main(self, args, default_output_dir):
    """
    This is the main function of the tuner.
    """

    # Determine the output directory.
    output_root = default_output_dir
    if args.output_dir != None:
      output_root = os.path.abspath(args.output_dir)

    # Start logging messages.
    opentuner.init_logging()

    # Change some logging settings.
    for handler in logging.getLogger().handlers:
      if isinstance(handler, logging.FileHandler):
        # Make sure that information messages are also logged.
        handler.setLevel(logging.INFO)
        # Move the log file to the output directory.
        handler.close()
        handler.baseFilename = output_root + LOG_FILE

    # Set the database location if the user did not specify anything.
    if args.database == None:
      args.database = output_root + TUNER_DB_FILE

    # Extract the directory name from the database name.
    db_dir = os.path.dirname(args.database)

    # Create the directory if it does not exist.
    if db_dir != "" and not os.path.isdir(db_dir):
      os.makedirs(db_dir)

    # Select the random forest search technique by default.
    if not args.technique:
      args.technique = ['SpaceContractorRandomForest']

    # Start the tuner.
    super(MeasurementInterface, self).main(args, output_root = output_root)
Ejemplo n.º 3
0
                log.warning("gcc error %s", compile_result['stderr'])
                self.debug_gcc_error(flags)
                return self.compile_results['error']
        return self.compile_results['ok']

    def save_final_config(self, configuration):
        """called at the end of tuning"""
        print "Best flags written to gccflags_final_config.{json,cmd}"
        self.manipulator().save_to_file(configuration.data,
                                        'gccflags_final_config.json')
        with open('gccflags_final_config.cmd', 'w') as fd:
            fd.write(self.make_command(configuration.data))

    def prefix_hook(self, session):
        if self.args.flags_histogram:
            counter = collections.Counter()
            q = session.query(TuningRun).filter_by(state='COMPLETE')
            total = q.count()
            for tr in q:
                print tr.program.name
                for flag in self.cfg_to_flags(tr.final_config.data):
                    counter[flag] += 1.0 / total
            print counter.most_common(20)
            sys.exit(0)


if __name__ == '__main__':
    opentuner.init_logging()
    args = argparser.parse_args()
    GccFlagsTuner.main(args)
Ejemplo n.º 4
0
  def getArgs(self):
    """
    output = self.call_program('opt --help')['stdout']
    output = output.split("\n")
    args_list = []
    readingArgs = False
    leadingSpaces = 0

    for i in output:
      if "Optimizations available:" in i:
        readingArgs = True
        leadingSpaces = len(i) - len(i.lstrip(' '))
        continue
      if readingArgs:
        if (len(i) - len(i.lstrip(' '))) > leadingSpaces:
          args_list.append(i.lstrip(' ').split(' ')[0])
        else:
          break
    """
    for i in args_blacklist:
      if i in args_list:
        args_list.remove(i)
    return args_list

      
if __name__ == '__main__':
  opentuner.init_logging()
  args = parser.parse_args()
  #call_program()
  LLVMFlagsTuner.main(args)