def __setitem__(self, key, value): super(MicroprobeConfiguration, self).__setitem__(key, value) if key in ["debug", "verbosity"]: if "debug" in self: if self["debug"]: loglevel = DEBUG elif "verbosity" in self: loglevel = max((DISABLE - (self['verbosity'] * 10)), INFO) else: raise NotImplementedError elif "verbosity" in self: loglevel = max((DISABLE - (self['verbosity'] * 10)), INFO) else: raise NotImplementedError if loglevel != DISABLE: self['verbose'] = True set_log_level(loglevel) if key in ["hex_all", "hex_address", "hex_none"] and value is True: if key is "hex_all": super(MicroprobeConfiguration, self).__setitem__( 'hex_address', False ) super(MicroprobeConfiguration, self).__setitem__( 'hex_none', False ) elif key is "hex_address": super(MicroprobeConfiguration, self).__setitem__( 'hex_all', False ) super(MicroprobeConfiguration, self).__setitem__( 'hex_none', False ) elif key is "hex_none": super(MicroprobeConfiguration, self).__setitem__( 'hex_all', False ) super(MicroprobeConfiguration, self).__setitem__( 'hex_address', False ) if key.endswith("_paths"): nvalue = [] for path in value: if not os.path.isdir(path): continue path = os.path.abspath(path) path = os.path.realpath(path) if path not in nvalue: nvalue.append(path) super(MicroprobeConfiguration, self).__setitem__( key, nvalue )
def synthesize(self): """Synthesize a benchmark. Synthesize a benchmark based on the set of passes that have been added using the :meth:`add_pass` method. :return: A new synthesized benchmark :rtype: :class:`~.Benchmark` """ LOG.info("Start synthesizing benchmark") # Create benchmark object bench = benchmark_factory(threads=self._threads) for thread_id in range(1, self._threads + 1): LOG.info("Start synthesizing benchmark thread %d" % thread_id) self.set_current_thread(thread_id) self._target.set_wrapper(self._wrappers[thread_id - 1]) bench.set_current_thread(thread_id) # Set default context -- environment context bench.set_context(self.wrapper.context()) # bench.set_context(Context()) for var in self.wrapper.required_global_vars(): bench.register_var(var, bench.context) if not self._no_scratch: bench.register_var(self._target.scratch_var, bench.context) # Basic context reserved_registers = self._target.reserved_registers reserved_registers += self.wrapper.reserved_registers( reserved_registers, self._target ) bench.context.add_reserved_registers(reserved_registers) if MICROPROBE_RC['debugpasses']: previous_level = LOG.getEffectiveLevel() set_log_level(DEBUG) passes = self._passes[thread_id] starttime = time() for idx, step in enumerate(passes): LOG.info("Applying pass %03d: %s", idx, step.__class__.__name__) if MICROPROBE_RC['verbose']: cmd.cmdline.print_info("Applying pass %03d: %s" % (idx, step.__class__.__name__)) step(bench, self.target) bench.add_pass_info(step.info()) endtime = time() LOG.debug( "Applying pass %03d: %s : Execution time: %s", idx, step.__class__.__name__, datetime.timedelta(seconds=endtime - starttime) ) starttime = endtime starttime = time() for idx, step in enumerate(passes): LOG.info("Checking pass %03d: %s", idx, step.__class__.__name__) try: pass_ok = step.check(bench, self.target) except NotImplementedError: LOG.warning( "Checking pass %03d: %s. NOT IMPLEMENTED", idx, step.__class__.__name__ ) pass_ok = False endtime = time() if not pass_ok: LOG.warning( "Checking pass %03d: %s. Test result: FAIL", idx, step.__class__.__name__ ) bench.add_warning( "Pass %03d: %s did not pass the check test" % (idx, step.__class__.__name__) ) else: LOG.debug( "Checking pass %03d: %s. Test result: OK", idx, step.__class__.__name__ ) LOG.debug( "Checking pass %03d: %s : Execution time: %s", idx, step.__class__.__name__, datetime.timedelta(seconds=endtime - starttime) ) starttime = endtime if MICROPROBE_RC['debugpasses']: set_log_level(previous_level) return bench
from microprobe.target import Target from microprobe.target.env import import_env_definition from microprobe.target.isa import import_isa_definition from microprobe.utils.asm import interpret_asm from microprobe.utils.bin import interpret_bin from microprobe.utils.logger import get_logger, set_log_level if six.PY2: import subprocess32 as subprocess # @UnresolvedImport @UnusedImport from exceptions import AssertionError # pylint: disable=import-error else: import subprocess # @Reimport # Constants LOG = get_logger(__name__) set_log_level(50) MP_TESTING_ARCH = os.environ.get("MP_TESTING_ARCH", None) MP_TESTING_INSTR = os.environ.get("MP_TESTING_INSTR", None) MP_CI = os.environ.get("TRAVIS", None) if MP_TESTING_ARCH is None and MP_TESTING_INSTR is None: SKIPGENERATION = False SKIPCOMPILATION = True SKIPCODIFICATION = True SKIPSELFBINARY = False SKIPSELFASSEMBLY = False BENCH_SIZE = 5 REPETITIONS = 5 TRIALS = 1 else: