How to use the opentuner.argparsers function in opentuner

To help you get started, we’ve selected a few opentuner examples, based on popular ways it is used in public projects.

Secure your code as it's written. Use Snyk Code to scan source code in minutes - no build needed - and fix issues immediately.

github jbosboom / streamjit / lib / opentuner / streamjit / tuner3.py View on Github external
freqInlineSize = jvmIntegerParameter("freqInlineSize", 100, 10000, 325, "-XX:FreqInlineSize=%d")
	inlineSmallCode = jvmIntegerParameter("inlineSmallCode", 500, 10000, 1000, "-XX:InlineSmallCode=%d")
	maxInlineSize = jvmIntegerParameter("maxInlineSize", 20, 1000, 35, "-XX:MaxInlineSize=%d")
	maxInlineLevel = jvmIntegerParameter("maxInlineLevel", 5, 20, 9, "-XX:MaxInlineLevel=%d")

	eliminateArrays = jvmIntegerParameter("eliminateAllocationArraySizeLimit", 64, 2048, 64, "-XX:EliminateAllocationArraySizeLimit=%d")
	useNuma = jvmFlag("useNuma", "-XX:+UseNUMA")
	bindGCTaskThreadsToCPUs = jvmFlag("bindGCTaskThreadsToCPUs", "-XX:+BindGCTaskThreadsToCPUs")

	enabledJvmOptions = [aggressiveOpts, compileThreshold, clipInlining, freqInlineSize,
		maxInlineSize, maxInlineLevel, eliminateArrays, useNuma, bindGCTaskThreadsToCPUs]
	return {x.name:x for x in enabledJvmOptions}

if __name__ == '__main__':
	logging.basicConfig(level=logging.INFO)
	parser = argparse.ArgumentParser(parents=opentuner.argparsers())
	parser.add_argument('--program', help='StreamJIT benchmark to tune (with first input)')
	parser.add_argument('--timestamp', help='timestamp to use for final config/errors',
		default=time.strftime('%Y%m%d-%H%M%S'))
	args = parser.parse_args()
	(cfg_json, error_str) = call_java([], "edu.mit.streamjit.tuner.ConfigGenerator2",
		["edu.mit.streamjit.impl.compiler2.Compiler2BlobFactory", args.program])
	if len(error_str) > 0:
		sys.exit("Getting config JSON: "+error_str)
	cfg = configuration.getConfiguration(cfg_json)
	jvm_options = make_jvm_options();

	manipulator = StreamJITConfigurationManipulator(cfg)
	for p in cfg.getAllParameters().values() + jvm_options.values():
		manipulator.add_parameter(p)

	# create seed configurations
github jansel / opentuner / examples / halide / halidetuner.py View on Github external
from opentuner.search.manipulator import ConfigurationManipulator
from opentuner.search.manipulator import PowerOfTwoParameter
from opentuner.search.manipulator import PermutationParameter
from opentuner.search.manipulator import BooleanParameter
from opentuner.search.manipulator import ScheduleParameter


COMPILE_CMD = (
  '{args.cxx} "{cpp}" -o "{bin}" -I "{args.halide_dir}/include" '
  '"{args.halide_dir}/bin/$BUILD_PREFIX/libHalide.a" -ldl -lcurses -lpthread {args.cxxflags} '
  '-DAUTOTUNE_N="{args.input_size}" -DAUTOTUNE_TRIALS={args.trials} '
  '-DAUTOTUNE_LIMIT={limit} -fno-rtti')

log = logging.getLogger('halide')

parser = argparse.ArgumentParser(parents=opentuner.argparsers())
parser.add_argument('source', help='Halide source file annotated with '
                                   'AUTOTUNE_HOOK')
parser.add_argument('--halide-dir', default=os.path.expanduser('~/Halide'),
                    help='Installation directory for Halide')
parser.add_argument('--input-size',
                    help='Input size to test with')
parser.add_argument('--trials', default=3, type=int,
                    help='Number of times to test each schedule')
parser.add_argument('--nesting', default=2, type=int,
                    help='Maximum depth for generated loops')
parser.add_argument('--max-split-factor', default=8, type=int,
                    help='The largest value a single split() can add')
parser.add_argument('--compile-command', default=COMPILE_CMD,
                    help='How to compile generated C++ code')
parser.add_argument('--cxx', default='c++',
                    help='C++ compiler to use (e.g., g++ or clang++)')
github jbosboom / streamjit / lib / opentuner / streamjit / tuner2.py View on Github external
def start(program):
	log = logging.getLogger(__name__)
	parser = argparse.ArgumentParser(parents=opentuner.argparsers())
	parser.add_argument('--program', help='Name of the StreamJit application')

	argv = ['--program', program,  '--test-limit', '6000']
	args = parser.parse_args(argv)

	if not args.database:
    		args.database = 'sqlite:///' + program + '.db'

	try: 
		conn = sqlite3.connect('streamjit.db')
		c = conn.cursor()
		query = 'SELECT configuration FROM apps WHERE name="%s"'%program
		c.execute(query)
		row = c.fetchone()
		if not row:
			data = raw_input ( "No entry found with name = %s \nPlease press anykey to exit"%program )
github GraphIt-DSL / graphit / autotune / pagerank_parallel_numa_tune.py View on Github external
# this pases in the id 0 for the configuration
        compile_result = self.compile(cfg, 0)
        # print "compile_result: " + str(compile_result)
        return self.run_precompiled(desired_result, input, limit, compile_result, 0)


    def save_final_config(self, configuration):
        """called at the end of tuning"""
        print 'Final Configuration:', configuration.data
        self.manipulator().save_to_file(configuration.data,'final_config.json')



if __name__ == '__main__':
    parser = argparse.ArgumentParser(parents=opentuner.argparsers())
    parser.add_argument('--graph', type=str, default="../test/graphs/4.sg",
                    help='the graph to tune on')
    parser.add_argument('--enable_NUMA_tuning', type=int, default=1, help='enable tuning NUMA-aware schedules. 1 for enable (default), 0 for disable')
    parser.add_argument('--enable_parallel_tuning', type=int, default=1, help='enable tuning paralleliation schedules. 1 for enable (default), 0 for disable')
    args = parser.parse_args()
    GraphItPageRankTuner.main(args)
github jbosboom / streamjit / lib / opentuner / streamjit / tuner.py View on Github external
def start(argv, cfg, ss):
	log = logging.getLogger(__name__)
	parser = argparse.ArgumentParser(parents=opentuner.argparsers())

	parser.add_argument('--program', help='Name of the StreamJit application')
	
	args = parser.parse_args(argv)

	if not args.database:
    		args.database = 'sqlite:///' + args.program + '.db'

	main(args, cfg, ss)
github jansel / opentuner / examples / py_api / multiple_tuning_runs.py View on Github external
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
github jansel / opentuner / examples / petabricks / pbtuner.py View on Github external
SelectorParameter,
                                          SwitchParameter,
                                          PermutationParameter, )

try:
  from lxml import etree
except ImportError:
  import xml.etree.ElementTree as etree

from opentuner.measurement import MeasurementInterface
from opentuner.measurement.inputmanager import FixedInputManager
from opentuner.search.objective import ThresholdAccuracyMinimizeTime

log = logging.getLogger("pbtuner")

parser = argparse.ArgumentParser(parents=opentuner.argparsers())
parser.add_argument('program',
                    help='PetaBricks binary program to autotune')
parser.add_argument('--program-cfg-default',
                    help="override default program config exemplar location")
parser.add_argument('--program-cfg-output',
                    help="location final autotuned configuration is written")
parser.add_argument('--program-settings',
                    help="override default program settings file location")
parser.add_argument('--program-input',
                    help="use only a given input for autotuning")
parser.add_argument('--upper-limit', type=float, default=30,
                    help="time limit to apply to initial test")
parser.add_argument('--test-config', action='store_true')


class PetaBricksInterface(MeasurementInterface):
github GraphIt-DSL / graphit / autotune / graphit_autotuner.py View on Github external
# this pases in the id 0 for the configuration
        compile_result = self.compile(cfg, 0)
        # print "compile_result: " + str(compile_result)
        return self.run_precompiled(desired_result, input, limit, compile_result, 0)


    def save_final_config(self, configuration):
        """called at the end of tuning"""
        print ('Final Configuration:', configuration.data)
        self.manipulator().save_to_file(configuration.data,'final_config.json')



if __name__ == '__main__':
    parser = argparse.ArgumentParser(parents=opentuner.argparsers())
    parser.add_argument('--graph', type=str, default="../test/graphs/4.sg",
                    help='the graph to tune on')
    parser.add_argument('--enable_NUMA_tuning', type=int, default=0, help='enable tuning NUMA-aware schedules. 1 for enable (default), 0 for disable')
    parser.add_argument('--enable_parallel_tuning', type=int, default=1, help='enable tuning paralleliation schedules. 1 for enable (default), 0 for disable')
    parser.add_argument('--enable_denseVertexSet_tuning', type=int, default=1, help='enable tuning denseVertexSet schedules. 1 for enable (default), 0 for disable')
    parser.add_argument('--algo_file', type=str, required=True, help='input algorithm file')
    parser.add_argument('--default_schedule_file', type=str, required=False, default="", help='default schedule file')
    parser.add_argument('--runtime_limit', type=float, default=300, help='a limit on the running time of each program')
    parser.add_argument('--max_num_segments', type=int, default=24, help='maximum number of segments to try for cache and NUMA optimizations')
    parser.add_argument('--max_delta', type=int, default=800000, help='maximum delta used for priority coarsening')
    parser.add_argument('--memory_limit', type=int, default=-1,help='set memory limit on unix based systems [does not quite work yet]')    
    parser.add_argument('--killed_process_report_runtime_limit', type=int, default=0, help='reports runtime_limit when a process is killed by the shell. 0 for disable (default), 1 for enable')
    args = parser.parse_args()
    # pass the argumetns into the tuner
    GraphItTuner.main(args)
github jansel / opentuner / examples / hpl / hpl.py View on Github external
import argparse
import logging

import opentuner
from opentuner.search.manipulator import (ConfigurationManipulator,
                                          IntegerParameter,
                                          FloatParameter)
from opentuner.search.objective import MinimizeTime
from opentuner.measurement import MeasurementInterface
from opentuner.measurement.inputmanager import FixedInputManager
from opentuner.tuningrunmain import TuningRunMain

log = logging.getLogger(__name__)

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

parser.add_argument('--size', type=int, default=800,
                    help='dimensions for the HPL matrix')
parser.add_argument('--nprocs', type=int, default=4,
                    help='number of processors for each HPL run (minimum=4)')
parser.add_argument('--xhpl', type=str, default="hpl-2.1/bin/OSX/xhpl",
                    help='location of xhpl binary')

class HPLinpack(MeasurementInterface):
    def run(self, desired_result, input, limit):
        self.output_hpl_datfile(desired_result.configuration.data)
        import subprocess, os
        binary = self.args.xhpl
        subprocess.call(["mpirun", "-np", str(self.args.nprocs), binary])
        
        val = self.get_time_from_hpl_output()
github phrb / gpu-autotuning / src / tuner / nvcc_flags_tuner.py View on Github external
import opentuner
from opentuner import ConfigurationManipulator
from opentuner import EnumParameter
from opentuner import IntegerParameter
from opentuner import MeasurementInterface
from opentuner import Result

import time
import argparse
import logging
import subprocess

log = logging.getLogger('nvccflags')

argparser = argparse.ArgumentParser(parents=opentuner.argparsers())
argparser.add_argument( "-f", "--file",
                        dest     = "filename",
                        type     = str,
                        required = True,
                        help     = "A file to tune.")
argparser.add_argument( "-fargs", "--file-args",
                        dest     = "fargs",
                        type     = str,
                        nargs    = '*',
                        help     = "Program arguments.")
argparser.add_argument( "-ld", "--log-dir",
                        dest     = "logdir",
                        type     = str,
                        required = True,
                        help     = "Directory to save this tuning run.")
argparser.add_argument( "-lc", "--log-cmd",