示例#1
0
 def manipulator(self):
     manipulator = ConfigurationManipulator()
     for d in range(self.args.seq_len):
         # we add 1 to num_operators allow a ignored 'null' operator
         manipulator.add_parameter(
             SwitchParameter(d, self.num_operators + 1))
     return manipulator
示例#2
0
def main():
    parser = argparse.ArgumentParser(parents=opentuner.argparsers())
    args = parser.parse_args()
    manipulator = ConfigurationManipulator()
    manipulator.add_parameter(IntegerParameter('x', -200, 200))
    interface = DefaultMeasurementInterface(args=args,
                                            manipulator=manipulator,
                                            project_name='examples',
                                            program_name='api_test',
                                            program_version='0.1')
    api = TuningRunManager(interface, args)
    for x in xrange(500):
        desired_result = api.get_next_desired_result()
        if desired_result is None:
            # The search space for this example is very small, so sometimes
            # the techniques have trouble finding a config that hasn't already
            # been tested.  Change this to a continue to make it try again.
            break
        cfg = desired_result.configuration.data
        result = Result(time=test_func(cfg))
        api.report_result(desired_result, result)

    best_cfg = api.get_best_configuration()
    api.finish()
    print 'best x found was', best_cfg['x']
示例#3
0
    def manipulator(self):
        mp = ConfigurationManipulator()

        for p in self._lsgbinary.params:
            mp.add_parameter(p)

        return mp
示例#4
0
 def manipulator(self):
     manipulator = ConfigurationManipulator()
     for d in xrange(self.args.dimensions):
         manipulator.add_parameter(FloatParameter(d,
                                                  -self.args.domain,
                                                  self.args.domain))
     return manipulator
示例#5
0
 def manipulator(self):
   manipulator = ConfigurationManipulator()
   for d in xrange(self.args.dimensions):
     manipulator.add_parameter(FloatParameter(d,
                                              -self.args.domain,
                                              self.args.domain))
   return manipulator
示例#6
0
def main():
    parser = argparse.ArgumentParser(parents=opentuner.argparsers())
    args = parser.parse_args()
    manipulator = ConfigurationManipulator()
    manipulator.add_parameter(IntegerParameter('x', -200, 200))
    interface = DefaultMeasurementInterface(args=args,
                                            manipulator=manipulator,
                                            project_name='examples',
                                            program_name='api_test',
                                            program_version='0.1')
    api = TuningRunManager(interface, args)
    for x in range(500):
        desired_result = api.get_next_desired_result()
        if desired_result is None:
          # The search space for this example is very small, so sometimes
          # the techniques have trouble finding a config that hasn't already
          # been tested.  Change this to a continue to make it try again.
          break
        cfg = desired_result.configuration.data
        result = Result(time=test_func(cfg))
        api.report_result(desired_result, result)

    best_cfg = api.get_best_configuration()
    api.finish()
    print('best x found was', best_cfg['x'])
 def solve(self, job):
     logging.debug('Starting opentuner')
     failed_jobs_threshold = self.jobs_limit * _FAILED_JOBS_COEF
     manipulator = ConfigurationManipulator()
     for var in job.optimization_job.task_variables:
         if var.HasField('continuous_variable'):
             cont_var = var.continuous_variable
             param = FloatParameter(var.name, cont_var.l, cont_var.r)
         else:
             int_var = var.integer_variable
             param = IntegerParameter(var.name, int_var.l, int_var.r)
         manipulator.add_parameter(param)
     parser = argparse.ArgumentParser(parents=opentuner.argparsers())
     args = parser.parse_args([])
     args.parallelism = 4
     args.no_dups = True
     interface = DefaultMeasurementInterface(args=args,
                                             manipulator=manipulator,
                                             project_name=job.job_id)
     api = TuningRunManager(interface, args)
     jobs = []
     current_value = None
     failed_jobs = 0
     while failed_jobs < failed_jobs_threshold and not self._check_for_termination(
             job):
         remaining_jobs = []
         for job_id, desired_result in jobs:
             res = self._get_evaluation_job_result(job_id)
             if res is not None:
                 if current_value is None or current_value > res + _THRESHOLD_EPS:
                     failed_jobs = 0
                 else:
                     failed_jobs += 1
                 result = Result(time=res)
                 api.report_result(desired_result, result)
             else:
                 remaining_jobs.append((job_id, desired_result))
         jobs = remaining_jobs
         while len(jobs) < self.jobs_limit:
             desired_result = api.get_next_desired_result()
             if desired_result is None:
                 break
             job_id = self._start_evaluation_job(
                 job, desired_result.configuration.data)
             if job_id is None:
                 api.report_result(desired_result, Result(time=math.inf))
             else:
                 jobs.append((job_id, desired_result))
         if not jobs:
             break
         r = api.get_best_result()
         if r is not None:
             current_value = r.time
             logging.debug('Opentuner current state: %s %s', r.time,
                           api.get_best_configuration())
         time.sleep(5)
     res = api.get_best_result().time
     vars = api.get_best_configuration()
     api.finish()
     return res, vars
示例#8
0
    def manipulator(self):
        """
        Defines the search space across configuration parameters
        """
        manipulator = ConfigurationManipulator()

        for flag, param in self.ranged_param_dict.items():
            log.info("Adding flag: " + str(flag) + ", " + str(type(param)))
            if isinstance(param, SparkIntType):
                tuner_param = IntegerParameter(
                    flag,
                    param.get_range_start(),
                    param.get_range_end())
            elif isinstance(param, SparkMemoryType):
                tuner_param = ScaledIntegerParameter(
                    flag,
                    param.get_range_start(),
                    param.get_range_end(),
                    param.get_scale())
            elif isinstance(param, SparkBooleanType):
                tuner_param = BooleanParameter(flag)
            else:
                raise SparkTunerConfigError(
                    ValueError, "Invalid type for ConfigurationManipulator")
            log.info("Added config: " + str(type(tuner_param)) +
                     ": legal range " + str(tuner_param.legal_range(None)) +
                     ", search space size " +
                     str(tuner_param.search_space_size()))
            manipulator.add_parameter(tuner_param)
        return manipulator
    def manipulator(self):
        manipulator = ConfigurationManipulator()

        manipulator.add_parameter(
            CartesianMappingParameter('Perm', list(range(self.processes)),
                                      self.stencil, self.n_nodes, self.ppn, 2,
                                      utils.getCartDims(self.processes), 1, 1,
                                      1))
        return manipulator
 def manipulator(self):
     manipulator = ConfigurationManipulator()
     p = [-1 for _ in range(self.processes)]
     for i in range(self.G.getNumVertices()):
         p[i] = i
     manipulator.add_parameter(
         GraphMappingParameter('Perm', p, self.n_nodes,
                               self.pps * self.n_sockets, self.n_sockets,
                               self.graph_file, self.socket_factor,
                               self.node_factor, self.global_factor))
     return manipulator
示例#11
0
    def get_tuning_driver(self):
        from ctree.opentuner.driver import OpenTunerDriver
        from opentuner.search.manipulator import ConfigurationManipulator
        from opentuner.search.manipulator import FloatParameter
        from opentuner.search.objective import MinimizeTime

        manip = ConfigurationManipulator()
        manip.add_parameter(FloatParameter("x", -100.0, 100.0))
        manip.add_parameter(FloatParameter("y", -100.0, 100.0))

        return OpenTunerDriver(manipulator=manip, objective=MinimizeTime())
示例#12
0
    def get_tuning_driver(self):
        from ctree.opentuner.driver import OpenTunerDriver
        from opentuner.search.manipulator import ConfigurationManipulator
        from opentuner.search.manipulator import FloatParameter
        from opentuner.search.objective import MinimizeTime

        manip = ConfigurationManipulator()
        manip.add_parameter(FloatParameter("x", -100.0, 100.0))
        manip.add_parameter(FloatParameter("y", -100.0, 100.0))

        return OpenTunerDriver(manipulator=manip, objective=MinimizeTime())
示例#13
0
def create_test_tuning_run(db):
    parser = argparse.ArgumentParser(parents=opentuner.argparsers())
    args = parser.parse_args()
    args.database = db
    manipulator = ConfigurationManipulator()
    manipulator.add_parameter(IntegerParameter('x', -200, 200))
    interface = DefaultMeasurementInterface(args=args,
                                            manipulator=manipulator,
                                            project_name='examples',
                                            program_name='api_test',
                                            program_version='0.1')
    api = TuningRunManager(interface, args)
    return api
示例#14
0
def create_test_tuning_run(db):
  parser = argparse.ArgumentParser(parents=opentuner.argparsers())
  args = parser.parse_args()
  args.database = db
  manipulator = ConfigurationManipulator()
  manipulator.add_parameter(IntegerParameter('x', -200, 200))
  interface = DefaultMeasurementInterface(args=args,
                                          manipulator=manipulator,
                                          project_name='examples',
                                          program_name='api_test',
                                          program_version='0.1')
  api = TuningRunManager(interface, args)
  return api
示例#15
0
文件: dgemm.py 项目: mbdriscoll/ctree
    def get_tuning_driver(self):
        from ctree.opentuner.driver import OpenTunerDriver
        from opentuner.search.manipulator import ConfigurationManipulator
        from opentuner.search.manipulator import IntegerParameter
        from opentuner.search.manipulator import PowerOfTwoParameter
        from opentuner.search.objective import MinimizeTime, MinimizeEnergy

        manip = ConfigurationManipulator()
        manip.add_parameter(PowerOfTwoParameter("rx", 1, 8))
        manip.add_parameter(PowerOfTwoParameter("ry", 1, 8))
        manip.add_parameter(IntegerParameter("cx", 8, 32))
        manip.add_parameter(IntegerParameter("cy", 8, 32))

        return OpenTunerDriver(manipulator=manip, objective=MinimizeTime())
示例#16
0
    def build_search_space(self):
        """
        Set up search space via ConfigurationManipulator, which is responsible for choosing configurations across runs,
        where a configuration is a particular assignment of the parameters. 

        Tightly coupled with agent/system representations used in src.
        
        Repeating from above:
        *initial* search space 
        - parameter per action (candidate index column in index, where candidate index column is one of the query columns) 
          per query
        - see commit 8f94c4b

        *updated* search space
        - parameter per action (same, but here candidate index column is not one of query columns but any of columns in query table)
          per allowed index / indexing decision

         so, at risk of redundancy, an "action" refers to the particular assignment of a parameter, which is 
         an integer indicating noop or a column for a candidate index column 
         
        """

        self.logger.info('Building OpenTuner search space...')

        self.idx_2_idx_cols = {
        }  # store candidate index columns (OpenTuner operates on this) with candidate index (system operates on this)
        self.idx_2_tbl = {}

        manipulator = ConfigurationManipulator()

        for tbl in self.tbls:
            n_cols_per_tbl = len(tpch_table_columns[tbl])

            for candidate_idx in range(self.n_idxs_per_tbl):
                idx_id = "tbl_{}_idx_{}".format(tbl, candidate_idx)
                idx_col_ids = []

                for candidate_idx_col in range(self.n_cols_per_idx):
                    idx_col_id = idx_id + "_idx_col_{}".format(
                        candidate_idx_col)
                    idx_col_ids.append(idx_col_id)

                    manipulator.add_parameter(
                        IntegerParameter(idx_col_id, 0, n_cols_per_tbl))

                self.idx_2_idx_cols[idx_id] = idx_col_ids
                self.idx_2_tbl[idx_id] = tbl

        self.logger.info("... actions are: {}".format(self.idx_2_idx_cols))
        return manipulator
示例#17
0
def main(args, cfg, ss):
	logging.basicConfig(level=logging.INFO)
	manipulator = ConfigurationManipulator()

	params = cfg.getAllParameters()
	print "\nFeature variables...."
	for key in params.keys():
		print "\t", key
  		manipulator.add_parameter(cfg.getParameter(key))
	
	mi = StreamJitMI(args, ss, manipulator, FixedInputManager(),
                    MinimizeTime())

	m = TuningRunMain(mi, args)
	m.main()
示例#18
0
    def test_1d_config(self):
        from ctree.opentuner.driver import OpenTunerDriver
        from opentuner.search.objective import MinimizeTime
        from opentuner.search.manipulator import ConfigurationManipulator, IntegerParameter

        cfg = ConfigurationManipulator()
        cfg.add_parameter(IntegerParameter("foo", 0, 199))
        driver = OpenTunerDriver(manipulator=cfg, objective=MinimizeTime())

        unsearched = set(range(200))
        for cfg in islice(driver.configs, 20):
            val = cfg["foo"]
            driver.report(time=val)
            unsearched.remove(val)
        self.assertEqual(len(unsearched), 180)
示例#19
0
def main(args, cfg, jvmOptions):
    logging.basicConfig(level=logging.INFO)
    manipulator = ConfigurationManipulator()

    params = dict(cfg.items() + jvmOptions.items())
    #print "\nFeature variables...."
    for key in params.keys():
        #print "\t", key
        manipulator.add_parameter(params.get(key))

    mi = StreamJitMI(args, jvmOptions, manipulator, FixedInputManager(),
                     MinimizeTime())

    m = TuningRunMain(mi, args)
    m.main()
示例#20
0
def main(args, cfg, ss):
    logging.basicConfig(level=logging.INFO)
    manipulator = ConfigurationManipulator()

    params = cfg.getAllParameters()
    print "\nFeature variables...."
    for key in params.keys():
        print "\t", key
        manipulator.add_parameter(cfg.getParameter(key))

    mi = StreamJitMI(args, ss, manipulator, FixedInputManager(),
                     MinimizeTime())

    m = TuningRunMain(mi, args)
    m.main()
示例#21
0
def main(args, cfg, jvmOptions):
	logging.basicConfig(level=logging.INFO)
	manipulator = ConfigurationManipulator()

	params = dict(cfg.items() + jvmOptions.items())
	#print "\nFeature variables...."
	for key in params.keys():
		#print "\t", key
  		manipulator.add_parameter(params.get(key))
	
	mi = StreamJitMI(args,jvmOptions, manipulator, FixedInputManager(),
                    MinimizeTime())

	m = TuningRunMain(mi, args)
	m.main()
示例#22
0
    def build_manipulator(api_config):
        """Build a ConfigurationManipulator object to be used by opentuner.

        Parameters
        ----------
        api_config : dict-like of dict-like
            Configuration of the optimization variables. See API description.

        Returns
        -------
        manipulator : ConfigurationManipulator
            Some over complexified class required by opentuner to run.
        """
        manipulator = ConfigurationManipulator()

        for pname in api_config:
            ptype = api_config[pname]["type"]
            pspace = api_config[pname].get("space", None)
            pmin, pmax = api_config[pname].get("range", (None, None))

            if ptype == "real":
                if pspace in ("linear", "logit"):
                    ot_param = FloatParameter(pname, pmin, pmax)
                elif pspace in ("log", "bilog"):
                    LogFloatParameter_ = ClippedParam(LogFloatParameter)
                    ot_param = LogFloatParameter_(pname, pmin, pmax)
                else:
                    assert False, "unsupported param space = %s" % pspace
            elif ptype == "int":
                if pspace in ("linear", "logit"):
                    ot_param = IntegerParameter(pname, pmin, pmax)
                elif pspace in ("log", "bilog"):
                    ot_param = LogIntegerParameter(pname, pmin, pmax)
                else:
                    assert False, "unsupported param space = %s" % pspace
            elif ptype == "bool":
                # The actual bool parameter seems not to work in Py3 :(
                ot_param = IntegerParameter(pname, 0, 1)
            elif ptype in ("cat", "ordinal"):
                # Treat ordinal and categorical variables the same for now.
                assert "values" in api_config[pname]
                pvalues = api_config[pname]["values"]
                ot_param = EnumParameter(pname, pvalues)
            else:
                assert False, "type=%s/space=%s not handled in opentuner yet" % (
                    ptype, pspace)
            manipulator.add_parameter(ot_param)
        return manipulator
示例#23
0
    def __init__(self, args=None):
        manipulator = ConfigurationManipulator()
        conv_args = ast.literal_eval(args.conv2d)
        input_shape = ast.literal_eval(args.input)
        self.conv = torch.nn.Conv2d(*conv_args)
        self.image = torch.randn(*input_shape)

        # Dry run codegen to capture config
        cg = ConvolutionGenerator(ConfigRecorder(manipulator), self.conv,
                                  self.image)
        assert len(manipulator.params)
        # import pprint; pprint.pprint(manipulator.random())
        sec = float(
            median(
                timeit.repeat(lambda: cg(self.image), number=1,
                              repeat=REPEAT)))
        self.times = max(1, int(0.1 / sec))

        super(ConvTuner, self).__init__(
            args=args,
            project_name="ConvTuner",
            program_name=repr(conv_args),
            program_version=repr(input_shape),
            manipulator=manipulator,
        )
示例#24
0
 def manipulator(self):
     m = ConfigurationManipulator()
     for i in range(0, 12000):
         m.add_parameter(BooleanParameter('L{}'.format(i)))
         m.add_parameter(BooleanParameter('R{}'.format(i)))
         m.add_parameter(BooleanParameter('D{}'.format(i)))
         m.add_parameter(BooleanParameter('B{}'.format(i)))
         m.add_parameter(BooleanParameter('A{}'.format(i)))
     return m
示例#25
0
 def manipulator(self):
     m = ConfigurationManipulator()
     for i in xrange(0, 1000):
         #bias 3:1 in favor of moving right
         m.add_parameter(
             EnumParameter('move{}'.format(i), [
                 "R", "L", "RB", "LB", "N", "LR", "LRB", "R2", "RB2", "R3",
                 "RB3"
             ]))
         m.add_parameter(
             IntegerParameter('move_duration{}'.format(i), 1, 60))
         #m.add_parameter(BooleanParameter("D"+str(i)))
     for i in xrange(0, 1000):
         m.add_parameter(
             IntegerParameter('jump_frame{}'.format(i), 0, 24000))
         m.add_parameter(
             IntegerParameter('jump_duration{}'.format(i), 1, 32))
     return m
示例#26
0
    def test_1d_config(self):
        from ctree.opentuner.driver import OpenTunerDriver
        from opentuner.search.objective import MinimizeTime
        from opentuner.search.manipulator import (
            ConfigurationManipulator,
            IntegerParameter,
        )

        cfg = ConfigurationManipulator()
        cfg.add_parameter( IntegerParameter("foo", 0, 199) )
        driver = OpenTunerDriver(manipulator=cfg, objective=MinimizeTime())

        unsearched = set(range(200))
        for cfg in islice(driver.configs, 20):
            val = cfg["foo"]
            driver.report(time=val)
            unsearched.remove(val)
        self.assertEqual(len(unsearched), 180)
示例#27
0
    def manipulator(self):
        """create the configuration manipulator, from example config"""
        upper_limit = self.program_settings['n'] + 1
        cfg = open(self.args.program_cfg_default).read()
        manipulator = ConfigurationManipulator()

        self.choice_sites = dict()

        for m in re.finditer(
                r" *([a-zA-Z0-9_-]+)[ =]+([0-9e.+-]+) *"
                r"[#] *([a-z]+).* ([0-9]+) to ([0-9]+)", cfg):
            k, v, valtype, minval, maxval = m.group(1, 2, 3, 4, 5)
            minval = float(minval)
            maxval = float(maxval)
            if upper_limit:
                maxval = min(maxval, upper_limit)
            assert valtype == 'int'
            # log.debug("param %s %f %f", k, minval, maxval)

            m1 = re.match(r'(.*)_lvl[0-9]+_rule', k)
            m2 = re.match(r'(.*)_lvl[0-9]+_cutoff', k)
            if m1:
                self.choice_sites[m1.group(1)] = int(maxval)
            elif m2:
                pass
            elif k == 'worker_threads':
                manipulator.add_parameter(IntegerParameter(k, 1, 16))
            elif k == 'distributedcutoff':
                pass
            elif minval == 0 and maxval < 64:
                manipulator.add_parameter(SwitchParameter(k, maxval))
            else:
                manipulator.add_parameter(
                    LogIntegerParameter(k, minval, maxval))

        for name, choices in list(self.choice_sites.items()):
            manipulator.add_parameter(
                SelectorParameter('.' + name, list(range(choices + 1)),
                                  old_div(upper_limit, choices)))

        self.manipulator = manipulator
        return manipulator
示例#28
0
 def manipulator(self):
     m = ConfigurationManipulator()
     for i in range(0, 12000):
         m.add_parameter(BooleanParameter("L{}".format(i)))
         m.add_parameter(BooleanParameter("R{}".format(i)))
         m.add_parameter(BooleanParameter("D{}".format(i)))
         m.add_parameter(BooleanParameter("B{}".format(i)))
         m.add_parameter(BooleanParameter("A{}".format(i)))
     return m
示例#29
0
文件: mario.py 项目: WeiFoo/opentuner
 def manipulator(self):
   m = ConfigurationManipulator()
   for i in xrange(0, 12000):
     m.add_parameter(BooleanParameter('L{}'.format(i)))
     m.add_parameter(BooleanParameter('R{}'.format(i)))
     m.add_parameter(BooleanParameter('D{}'.format(i)))
     m.add_parameter(BooleanParameter('B{}'.format(i)))
     m.add_parameter(BooleanParameter('A{}'.format(i)))
   return m
示例#30
0
  def manipulator(self):
    '''create the configuration manipulator, from example config'''
    upper_limit = self.program_settings['n']+1
    cfg = open(self.args.program_cfg_default).read()
    manipulator = ConfigurationManipulator()

    for m in re.finditer(r" *([a-zA-Z0-9_-]+)[ =]+([0-9e.+-]+) *"
                         r"[#] *([a-z]+).* ([0-9]+) to ([0-9]+)", cfg):
      k, v, valtype, minval, maxval =  m.group(1,2,3,4,5)
      minval = float(minval)
      maxval = float(maxval)
      if upper_limit:
        maxval = min(maxval, upper_limit)
      assert valtype=='int'
      #log.debug("param %s %f %f", k, minval, maxval)
      if minval == 0 and maxval < 64:
        manipulator.add_parameter(SwitchParameter(k, maxval))
      else:
        manipulator.add_parameter(LogIntegerParameter(k, minval, maxval))

    return manipulator
示例#31
0
文件: mario.py 项目: jrk/opentuner
 def manipulator(self):
   m = ConfigurationManipulator()
   for i in xrange(0, 1000):
     m.add_parameter(EnumParameter('move{}'.format(i), ["R", "L", "RB", "LB", "N", "LR", "LRB", "R2", "RB2", "R3", "RB3"]))
     m.add_parameter(IntegerParameter('move_duration{}'.format(i), 1, 60))
     #m.add_parameter(BooleanParameter("D"+str(i)))
   for i in xrange(0, 1000):
     m.add_parameter(IntegerParameter('jump_frame{}'.format(i), 0, 24000))
     m.add_parameter(IntegerParameter('jump_duration{}'.format(i), 1, 32))
   return m
示例#32
0
  def manipulator(self):
    """create the configuration manipulator, from example config"""
    upper_limit = self.program_settings['n'] + 1
    cfg = open(self.args.program_cfg_default).read()
    manipulator = ConfigurationManipulator()

    self.choice_sites = dict()

    for m in re.finditer(r" *([a-zA-Z0-9_-]+)[ =]+([0-9e.+-]+) *"
                         r"[#] *([a-z]+).* ([0-9]+) to ([0-9]+)", cfg):
      k, v, valtype, minval, maxval = m.group(1, 2, 3, 4, 5)
      minval = float(minval)
      maxval = float(maxval)
      if upper_limit:
        maxval = min(maxval, upper_limit)
      assert valtype == 'int'
      #log.debug("param %s %f %f", k, minval, maxval)

      m1 = re.match(r'(.*)_lvl[0-9]+_rule', k)
      m2 = re.match(r'(.*)_lvl[0-9]+_cutoff', k)
      if m1:
        self.choice_sites[m1.group(1)] = int(maxval)
      elif m2:
        pass
      elif k == 'worker_threads':
        manipulator.add_parameter(IntegerParameter(k, 1, 16))
      elif k == 'distributedcutoff':
        pass
      elif minval == 0 and maxval < 64:
        manipulator.add_parameter(SwitchParameter(k, maxval))
      else:
        manipulator.add_parameter(LogIntegerParameter(k, minval, maxval))

    for name, choices in self.choice_sites.items():
      manipulator.add_parameter(
        SelectorParameter('.' + name, range(choices + 1),
                          upper_limit / choices))

    self.manipulator = manipulator
    return manipulator
    def manipulator(self):
        "Returns an object that represents the parameters that can be tuned."

        self.param_map = {}
        self.disabled_inlines = []
        manipulator = ConfigurationManipulator()
        handlers = {
            "unroll": self.handle_add_unroll,
            "pipeline": self.handle_add_pipeline,
            "inline": self.handle_add_inline,
            "dataflow": self.handle_add_dataflow,
            "array_partition": self.handle_add_array_partition
        }
        for pragma in self.pragmas:
            handlers[pragma['type']](manipulator, pragma)
        return manipulator
示例#34
0
    def get_tuning_driver(self):
        from ctree.opentuner.driver import OpenTunerDriver
        from opentuner.search.manipulator import ConfigurationManipulator
        from opentuner.search.manipulator import IntegerParameter
        from opentuner.search.manipulator import PowerOfTwoParameter
        from opentuner.search.objective import MinimizeTime, MinimizeEnergy

        manip = ConfigurationManipulator()
        manip.add_parameter(PowerOfTwoParameter("rx", 1, 8))
        manip.add_parameter(PowerOfTwoParameter("ry", 1, 8))
        manip.add_parameter(IntegerParameter("cx", 8, 32))
        manip.add_parameter(IntegerParameter("cy", 8, 32))

        return OpenTunerDriver(manipulator=manip, objective=MinimizeEnergy())
示例#35
0
 def manipulator(self):
     manipulator = ConfigurationManipulator()
     manipulator.add_parameter(
         PermutationParameter(0, list(range(len(self.distance)))))
     return manipulator
示例#36
0
 def manipulator(self):
     manipulator = ConfigurationManipulator()
     manipulator.add_parameter(IntegerParameter('pixeldiff_similarity_cutoff', 20, 50))
     manipulator.add_parameter(IntegerParameter('min_max_colorful_cutoff', 5, 20))
     manipulator.add_parameter(IntegerParameter('filter_grayscale_cutoff', 170, 215))
     manipulator.add_parameter(IntegerParameter('black_and_white_grayscale_cutoff', 170, 215))
     manipulator.add_parameter(IntegerParameter('count_around_delete_cutoff', 2, 4))
     manipulator.add_parameter(IntegerParameter('count_around_add_cutoff', 2, 5))
     manipulator.add_parameter(IntegerParameter('conway_many_count', 0, 5))
     manipulator.add_parameter(BooleanParameter('overlay'))
     return manipulator
示例#37
0
文件: tuner.py 项目: phrb/legup-tuner
def tuning_loop():
    report_delay = 200
    last_time    = time.time()
    start_time   = last_time
    parser       = argparse.ArgumentParser(parents = opentuner.argparsers())

    parser.add_argument("--processes",
                        type = int,
                        help = "Number of Python threads available.")
    parser.add_argument("--no-wait",
                        action = "store_true",
                        help   = "Do not wait for requested results to generate more requests.")

    args         = parser.parse_args()
    pool         = ThreadPool(args.processes)
    manipulator  = ConfigurationManipulator()

    for name in legup_parameters.parameters:
        parameter_type = legup_parameters.parameter_type(name)
        values = legup_parameters.parameter_values(name)
        if parameter_type == int:
            manipulator.add_parameter(IntegerParameter(name, values[0], values[1]))
        elif parameter_type == bool:
            manipulator.add_parameter(BooleanParameter(name))
        elif parameter_type == Enum:
            manipulator.add_parameter(EnumParameter(name, values))
        else:
            print("ERROR: No such parameter type \"{0}\"".format(name))

    interface = DefaultMeasurementInterface(args            = args,
                                            manipulator     = manipulator,
                                            project_name    = 'HLS-FPGAs',
                                            program_name    = 'legup-tuner',
                                            program_version = '0.0.1')

    manager = TuningRunManager(interface, args)

    current_time      = time.time()
    computing_results = []
    computed_results  = []
    desired_results   = manager.get_desired_results()

    while current_time - start_time < args.stop_after:
        if args.no_wait:
            if len(desired_results) != 0 or len(computing_results) != 0:
                for desired_result in desired_results:
                    computing_results.append([desired_result,
                                              pool.apply_async(get_wallclock_time,
                                                              (desired_result.configuration.data, ))])

                for result in computing_results:
                    if result[1].ready() and result[0] not in computed_results:
                        cost = result[1].get()
                        manager.report_result(result[0], Result(time = cost))
                        computed_results.append(result)

                for result in computed_results:
                    if result in computing_results:
                        computing_results.remove(result)

                computed_results = []
        else:
            if len(desired_results) != 0:
                cfgs    = [dr.configuration.data for dr in desired_results]
                results = pool.map_async(get_wallclock_time, cfgs).get(timeout = None)

                for dr, result in zip(desired_results, results):
                    manager.report_result(dr, Result(time = result))

        desired_results = manager.get_desired_results()

        current_time = time.time()

        if (current_time - last_time) >= report_delay:
            log_intermediate(current_time - start_time, manager)
            last_time = current_time

    current_time = time.time()
    log_intermediate(current_time - start_time, manager)

    save_final_configuration(manager.get_best_configuration())
    manager.finish()
示例#38
0
	def manipulator(self):
		'''
		Define the search space by creating a ConfigurationManipulator
		'''
		manipulator = ConfigurationManipulator()
		if self.args.window is None:
			manipulator.add_parameter(IntegerParameter('window', 1000, 5000))
		if self.args.interval is None:
			manipulator.add_parameter(IntegerParameter('interval', 2000, 10000))
		if self.args.sketch_size is None:
			manipulator.add_parameter(IntegerParameter('sketch-size', 1000, 5000))
		if self.args.k_hops is None:
			manipulator.add_parameter(IntegerParameter('k-hops', 1, 5))
		if self.args.chunk_size is None:
			manipulator.add_parameter(IntegerParameter('chunk-size', 5, 20))
		if self.args.lambda_param is None:
			manipulator.add_parameter(FloatParameter('lambda-param', 0.0, 1.0))
		# manipulator.add_parameter(EnumParameter('threshold-metric', ['mean', 'max']))
		# manipulator.add_parameter(FloatParameter('num-stds', 3.5, 6.0))
		return manipulator
示例#39
0
 def manipulator(self):
     m = ConfigurationManipulator()
     for i in range(0, 400 * 60):
         m.add_parameter(EnumParameter('{}'.format(i), list(range(0, 16))))
     return m
示例#40
0
 def manipulator(self):
     #FIXME: should some of these be expressed as booleans or switch parameters?
     #FIXME: how to express P and Q, given PxQ=nprocs, with nprocs being fixed?
     #FIXME: how to express logscaled parameter with a particular base?
     manipulator = ConfigurationManipulator()
     manipulator.add_parameter(IntegerParameter("blocksize", 1, 64))
     manipulator.add_parameter(IntegerParameter("row_or_colmajor_pmapping", 0, 1))
     manipulator.add_parameter(IntegerParameter("pfact", 0, 2))
     manipulator.add_parameter(IntegerParameter("nbmin", 1, 4))
     manipulator.add_parameter(IntegerParameter("ndiv", 2, 2))
     manipulator.add_parameter(IntegerParameter("rfact", 0, 4))
     manipulator.add_parameter(IntegerParameter("bcast", 0, 5))
     manipulator.add_parameter(IntegerParameter("depth", 0, 4))
     manipulator.add_parameter(IntegerParameter("swap", 0, 2))
     manipulator.add_parameter(IntegerParameter("swapping_threshold", 64, 128))
     manipulator.add_parameter(IntegerParameter("L1_transposed", 0, 1))
     manipulator.add_parameter(IntegerParameter("U_transposed", 0, 1))
     manipulator.add_parameter(IntegerParameter("mem_alignment", 4, 16))
     
     return manipulator
示例#41
0
    def manipulator(self):
        # FIXME: should some of these be expressed as booleans or switch parameters?
        # FIXME: how to express P and Q, given PxQ=nprocs, with nprocs being fixed?
        # FIXME: how to express logscaled parameter with a particular base?
        manipulator = ConfigurationManipulator()
        manipulator.add_parameter(IntegerParameter("blocksize", 1, 64))
        manipulator.add_parameter(IntegerParameter("row_or_colmajor_pmapping", 0, 1))
        manipulator.add_parameter(IntegerParameter("pfact", 0, 2))
        manipulator.add_parameter(IntegerParameter("nbmin", 1, 4))
        manipulator.add_parameter(IntegerParameter("ndiv", 2, 2))
        manipulator.add_parameter(IntegerParameter("rfact", 0, 4))
        manipulator.add_parameter(IntegerParameter("bcast", 0, 5))
        manipulator.add_parameter(IntegerParameter("depth", 0, 4))
        manipulator.add_parameter(IntegerParameter("swap", 0, 2))
        manipulator.add_parameter(IntegerParameter("swapping_threshold", 64, 128))
        manipulator.add_parameter(IntegerParameter("L1_transposed", 0, 1))
        manipulator.add_parameter(IntegerParameter("U_transposed", 0, 1))
        manipulator.add_parameter(IntegerParameter("mem_alignment", 4, 16))

        return manipulator
示例#42
0
import argparse

def get_next_desired_result():
    global desired_result
    desired_result = api.get_next_desired_result()
    while desired_result is None:
        desired_result = api.get_next_desired_result()
    return desired_result.configuration.data

def report_result(runtime):
    api.report_result(desired_result, Result(time=runtime))

def finish():
    api.finish()

parser = argparse.ArgumentParser(parents=opentuner.argparsers())
args = parser.parse_args()

manipulator = ConfigurationManipulator()
:::parameters:::
interface = DefaultMeasurementInterface(args=args,
                                        manipulator=manipulator,
                                        project_name='atf_library',
                                        program_name='atf_library',
                                        program_version='0.1')


api = TuningRunManager(interface, args)

)"
示例#43
0
文件: tuner.py 项目: phrb/legup-tuner
def tuning_loop():
    report_delay = 30
    last_time    = time.time()
    start_time   = last_time
    iterations   = 5
    parser       = argparse.ArgumentParser(parents = opentuner.argparsers())

    parser.add_argument("--processes",
                        type = int,
                        help = "Number of Python threads available.")
    parser.add_argument("--no-wait",
                        action = "store_true",
                        help   = "Do not wait for requested results to generate more requests.")
    parser.add_argument("--application",
                        type = str,
                        help = "Application name.")
    parser.add_argument("--verilog-file",
                        type = str,
                        help = "Verilog file for the application.")

    args         = parser.parse_args()
    pool         = ThreadPool(args.processes)
    manipulator  = ConfigurationManipulator()

    global application
    global verilog_file
    global application_path
    global container_path
    global host_path
    global image_name
    global script_name

    global tuning_init

    application      = args.application
    verilog_file     = args.verilog_file
    application_path = "/root/legup_src/legup-4.0/examples/chstone/{0}".format(application)
    container_path   = "/root/legup_src/legup-4.0/examples/chstone/{0}/tuner".format(application)
    host_path        = "/home/bruelp/legup-tuner/post_place_and_route/py"
    image_name       = "legup_quartus"
    script_name      = "measure.sh"

    print(application, container_path, application_path)

    for name in legup_parameters.parameters:
        parameter_type = legup_parameters.parameter_type(name)
        values = legup_parameters.parameter_values(name)
        if parameter_type == int:
            manipulator.add_parameter(IntegerParameter(name, values[0], values[1]))
        elif parameter_type == bool:
            manipulator.add_parameter(BooleanParameter(name))
        elif parameter_type == Enum:
            manipulator.add_parameter(EnumParameter(name, values))
        else:
            print("ERROR: No such parameter type \"{0}\"".format(name))

    interface = DefaultMeasurementInterface(args            = args,
                                            manipulator     = manipulator,
                                            project_name    = 'HLS-FPGAs',
                                            program_name    = 'legup-tuner',
                                            program_version = '0.0.1')

    manager = TuningRunManager(interface, args)

    current_time      = time.time()
    computing_results = []
    computed_results  = []
    desired_results   = manager.get_desired_results()

    while current_time - start_time < args.stop_after:
        if args.no_wait:
            if len(desired_results) != 0 or len(computing_results) != 0:
                for desired_result in desired_results:
                    computing_results.append([desired_result,
                                              pool.apply_async(get_wallclock_time,
                                                              (desired_result.configuration.data, ))])

                for result in computing_results:
                    if result[1].ready() and result[0] not in computed_results:
                        cost = result[1].get()
                        manager.report_result(result[0], Result(time = cost))
                        computed_results.append(result)

                for result in computed_results:
                    if result in computing_results:
                        computing_results.remove(result)

                computed_results = []
        else:
            if len(desired_results) != 0:
                cfgs    = [dr.configuration.data for dr in desired_results]
                results = pool.map_async(get_wallclock_time, cfgs).get(timeout = None)

                for dr, result in zip(desired_results, results):
                    manager.report_result(dr,
                                          Result(time = result['value'],
                                                 cycles = result['cycles'],
                                                 fmax = result['fmax'],
                                                 LU = result['lu'],
                                                 pins = result['pins'],
                                                 regs = result['regs'],
                                                 block = result['block'],
                                                 ram = result['ram'],
                                                 dsp = result['dsp']))

        desired_results = manager.get_desired_results()

        current_time = time.time()

        if (current_time - last_time) >= report_delay:
            log_intermediate(current_time - start_time, manager)
            last_time = current_time

    current_time = time.time()
    log_intermediate(current_time - start_time, manager)

    save_final_configuration(manager.get_best_configuration())
    manager.finish()
示例#44
0
 def manipulator(self):
     manipulator = ConfigurationManipulator()
     manipulator.add_parameter(PermutationParameter(0, range(SIZE)))
     return manipulator
示例#45
0
文件: tsp.py 项目: WeiFoo/opentuner
 def manipulator(self):
     manipulator = ConfigurationManipulator()
     manipulator.add_parameter(PermutationParameter(0, range(len(self.distance))))
     return manipulator
示例#46
0
 def manipulator(self):
   manipulator = ConfigurationManipulator()
   for d in range(self.args.seq_len):
     # we add 1 to num_operators allow a ignored 'null' operator
     manipulator.add_parameter(SwitchParameter(d, self.num_operators + 1))
   return manipulator
def tuning_loop():
    report_delay = 5
    last_time = time.time()
    start_time = last_time
    parser = argparse.ArgumentParser(parents=opentuner.argparsers())

    parser.add_argument("--processes",
                        type=int,
                        help="Number of Python threads available.")
    parser.add_argument(
        "--no-wait",
        action="store_true",
        help="Do not wait for requested results to generate more requests.")

    args = parser.parse_args()
    pool = ThreadPool(args.processes)
    manipulator = ConfigurationManipulator()

    for name in legup_parameters.parameters:
        parameter_type = legup_parameters.parameter_type(name)
        values = legup_parameters.parameter_values(name)
        if parameter_type == int:
            manipulator.add_parameter(
                IntegerParameter(name, values[0], values[1]))
        elif parameter_type == bool:
            manipulator.add_parameter(BooleanParameter(name))
        elif parameter_type == Enum:
            manipulator.add_parameter(EnumParameter(name, values))
        else:
            print("ERROR: No such parameter type \"{0}\"".format(name))

    interface = DefaultMeasurementInterface(args=args,
                                            manipulator=manipulator,
                                            project_name='HLS-FPGAs',
                                            program_name='legup-tuner',
                                            program_version='0.0.1')

    manager = TuningRunManager(interface, args)

    current_time = time.time()
    computing_results = []
    computed_results = []
    desired_results = manager.get_desired_results()

    while current_time - start_time < args.stop_after:
        if args.no_wait:
            if len(desired_results) != 0 or len(computing_results) != 0:
                for desired_result in desired_results:
                    computing_results.append([
                        desired_result,
                        pool.apply_async(get_wallclock_time,
                                         (desired_result.configuration.data, ))
                    ])

                for result in computing_results:
                    if result[1].ready() and result[0] not in computed_results:
                        cost = result[1].get()
                        manager.report_result(result[0], Result(time=cost))
                        computed_results.append(result)

                for result in computed_results:
                    if result in computing_results:
                        computing_results.remove(result)

                computed_results = []
        else:
            if len(desired_results) != 0:
                cfgs = [dr.configuration.data for dr in desired_results]
                results = pool.map_async(get_wallclock_time,
                                         cfgs).get(timeout=None)

                for dr, result in zip(desired_results, results):
                    manager.report_result(dr, Result(time=result))

        desired_results = manager.get_desired_results()

        current_time = time.time()

        if (current_time - last_time) >= report_delay:
            log_intermediate(current_time - start_time, manager)
            last_time = current_time

    current_time = time.time()
    log_intermediate(current_time - start_time, manager)

    save_final_configuration(manager.get_best_configuration())
    manager.finish()
示例#48
0
 def manipulator(self):
   m = ConfigurationManipulator()
   for i in xrange(0, 400*60):
     m.add_parameter(EnumParameter('{}'.format(i), xrange(0, 16)))
   return m
示例#49
0
 def manipulator(self):
     manipulator = ConfigurationManipulator()
     manipulator.add_parameter(PermutationParameter(0, range(SIZE)))
     return manipulator
示例#50
0
def tuning_loop():
    report_delay = 30
    last_time = time.time()
    start_time = last_time
    iterations = 5
    parser = argparse.ArgumentParser(parents=opentuner.argparsers())

    parser.add_argument("--processes",
                        type=int,
                        help="Number of Python threads available.")
    parser.add_argument(
        "--no-wait",
        action="store_true",
        help="Do not wait for requested results to generate more requests.")
    parser.add_argument("--application", type=str, help="Application name.")
    parser.add_argument("--verilog-file",
                        type=str,
                        help="Verilog file for the application.")

    args = parser.parse_args()
    pool = ThreadPool(args.processes)
    manipulator = ConfigurationManipulator()

    global application
    global verilog_file
    global application_path
    global container_path
    global host_path
    global image_name
    global script_name

    global tuning_init

    application = args.application
    verilog_file = args.verilog_file
    application_path = "/root/legup_src/legup-4.0/examples/chstone/{0}".format(
        application)
    container_path = "/root/legup_src/legup-4.0/examples/chstone/{0}/tuner".format(
        application)
    host_path = "/home/bruelp/legup-tuner/post_place_and_route/py"
    image_name = "legup_quartus"
    script_name = "measure.sh"

    print(application, container_path, application_path)

    for name in legup_parameters.parameters:
        parameter_type = legup_parameters.parameter_type(name)
        values = legup_parameters.parameter_values(name)
        if parameter_type == int:
            manipulator.add_parameter(
                IntegerParameter(name, values[0], values[1]))
        elif parameter_type == bool:
            manipulator.add_parameter(BooleanParameter(name))
        elif parameter_type == Enum:
            manipulator.add_parameter(EnumParameter(name, values))
        else:
            print("ERROR: No such parameter type \"{0}\"".format(name))

    interface = DefaultMeasurementInterface(args=args,
                                            manipulator=manipulator,
                                            project_name='HLS-FPGAs',
                                            program_name='legup-tuner',
                                            program_version='0.0.1')

    manager = TuningRunManager(interface, args)

    current_time = time.time()
    computing_results = []
    computed_results = []
    desired_results = manager.get_desired_results()

    while current_time - start_time < args.stop_after:
        if args.no_wait:
            if len(desired_results) != 0 or len(computing_results) != 0:
                for desired_result in desired_results:
                    computing_results.append([
                        desired_result,
                        pool.apply_async(get_wallclock_time,
                                         (desired_result.configuration.data, ))
                    ])

                for result in computing_results:
                    if result[1].ready() and result[0] not in computed_results:
                        cost = result[1].get()
                        manager.report_result(result[0], Result(time=cost))
                        computed_results.append(result)

                for result in computed_results:
                    if result in computing_results:
                        computing_results.remove(result)

                computed_results = []
        else:
            if len(desired_results) != 0:
                cfgs = [dr.configuration.data for dr in desired_results]
                results = pool.map_async(get_wallclock_time,
                                         cfgs).get(timeout=None)

                for dr, result in zip(desired_results, results):
                    manager.report_result(
                        dr,
                        Result(time=result['value'],
                               cycles=result['cycles'],
                               fmax=result['fmax'],
                               LU=result['lu'],
                               pins=result['pins'],
                               regs=result['regs'],
                               block=result['block'],
                               ram=result['ram'],
                               dsp=result['dsp']))

        desired_results = manager.get_desired_results()

        current_time = time.time()

        if (current_time - last_time) >= report_delay:
            log_intermediate(current_time - start_time, manager)
            last_time = current_time

    current_time = time.time()
    log_intermediate(current_time - start_time, manager)

    save_final_configuration(manager.get_best_configuration())
    manager.finish()