示例#1
0
def output_to_json(test: str, output: RunnerOutput,
                   benchmark: bool) -> Dict[str, str]:
    result = {
        'name': test,
        'test': open(test, 'r').read(),
        'success': output.is_success(),
    }
    if output.is_success():
        result['time'] = output.time
        result['errors'] = output.errors
        if output.errors:
            result['input'] = output.input_data
            result['output'] = output.output_data
            result['output_errors'] = output.output_errors
        if benchmark:
            result['statistics'] = output.statistics
    else:
        result['timed_out'] = output.is_timed_out()
    if isinstance(output, AsanRunnerOutput):
        result['asanoutput'] = output.asanoutput
    if isinstance(output, MemcheckRunnerOutput):
        result['memcheckoutput'] = output.memcheckoutput
    if isinstance(output, NvprofRunnerOutput):
        result['nvprof'] = output.nvprof
    return result
示例#2
0
        def benchmark(self, test: str, output: RunnerOutput):
            if not self.header_printed:
                self.header_printed = True
                self.reporter.log(
                    f'{"test":<{self.test_name_width}}  {"time":>9}  {"result":6}',
                    'heading')
            if output.is_success():
                msg = "errors" if output.errors else "pass"
                self.reporter.log(
                    f'{self._simplify_name(test):<{self.test_name_width}}  {output.time:>8.3f}s  {msg:6}',
                    'error' if output.errors else 'pass')
            else:
                self.reporter.log(
                    f'{self._simplify_name(test):<{self.test_name_width}}  [failed]',
                    'error')

            if output.is_success() and not output.errors:
                human_readable = statistics_terminal(output)
                if human_readable is not None:
                    self.reporter.log_sep()
                    self.reporter.log(human_readable, 'preformatted')
                    self.reporter.log_sep()
示例#3
0
        def benchmark(self, test: str, output: RunnerOutput):
            if not self.header_printed:
                self.header_printed = True
                self.reporter.log(
                    f'{"test":<{self.test_name_width}}  {"time":>9}  {"result":6}',
                    'heading')
            if output.is_success():
                msg = "errors" if output.errors else "pass"
                self.reporter.log(
                    f'{self._simplify_name(test):<{self.test_name_width}}  {output.time:>8.3f}s  {msg:6}',
                    'error' if output.errors else 'pass')
            else:
                self.reporter.log(
                    f'{self._simplify_name(test):<{self.test_name_width}}  [failed]',
                    'error')

            if output.stdout:
                self.reporter.log_sep()
                self.reporter.log('Standard output:')
                self.reporter.log(output.stdout, 'output')
                self.reporter.log_sep()

            if output.stderr:
                self.reporter.log_sep()
                self.reporter.log('Standard error:')
                self.reporter.log(output.stderr, 'output')
                self.reporter.log_sep()

            if output.is_success() and not output.errors:
                human_readable = statistics_terminal(output)
                if human_readable is not None:
                    self.reporter.log_sep()
                    self.reporter.log(human_readable, 'preformatted')
                    self.reporter.log_sep()

                if isinstance(output, NvprofRunnerOutput):
                    if output.nvprof:
                        if output.nvprof.get('gpu_trace') is not None:

                            def safe_scale(value, scale):
                                if value is not None:
                                    return value * scale
                                return value

                            # Pick and format relevant columns for printing
                            t = []
                            for row in output.nvprof['gpu_trace']:
                                d = OrderedDict()

                                d['Start (s)'] = row['Start s']
                                d['Duration (s)'] = row['Duration s']
                                if row['Grid X'] and row['Grid Y'] and row[
                                        'Grid Z']:
                                    d['Grid Size'] = f"{row['Grid X']}, {row['Grid Y']}, {row['Grid Z']}"
                                else:
                                    d['Grid Size'] = ''
                                if row['Block X'] and row['Block Y'] and row[
                                        'Block Z']:
                                    d['Block Size'] = f"{row['Block X']}, {row['Block Y']}, {row['Block Z']}"
                                else:
                                    d['Block Size'] = ''
                                d['Regs'] = row['Registers Per Thread']
                                d['SMem (B)'] = row['Static SMem bytes']
                                d['DMem (B)'] = row['Dynamic SMem bytes']
                                d['Size (MB)'] = safe_scale(
                                    row['Size bytes'], 1e-6)
                                d['Throughput (GB/s)'] = safe_scale(
                                    row['Throughput bytes/s'], 1e-9)
                                d['Name'] = row['Name']

                                t.append(d)

                            if t:
                                self.reporter.log_sep()
                                self.reporter.log('Nvprof GPU trace:')
                                self.reporter.log(table(t, t[0].keys()),
                                                  'output')
                                self.reporter.log_sep()
                    elif output.nvprof_raw:
                        self.reporter.log_sep()
                        self.reporter.log(
                            'Failed to parse nvprof output. Here it is in raw form:'
                        )
                        self.reporter.log(output.nvprof_raw, 'output')
                        self.reporter.log_sep()
                    else:
                        self.reporter.log_sep()
                        self.reporter.log('No output from nvprof')
                        self.reporter.log_sep()
示例#4
0
        def test(self, test: str, output: RunnerOutput):
            if not self.header_printed:
                self.header_printed = True
                self.reporter.log(
                    f'{"test":<{self.test_name_width}}  {"time":>9}  {"result":6}',
                    'heading')
            if output.is_success():
                msg = "errors" if output.errors else "pass"
                self.reporter.log(
                    f'{self._simplify_name(test):<{self.test_name_width}}  {output.time:>8.3f}s  {msg:6}',
                    'error' if output.errors else 'pass')
            else:
                self.reporter.log(
                    f'{self._simplify_name(test):<{self.test_name_width}}  [failed]',
                    'error')

            if output.stdout:
                self.reporter.log_sep()
                self.reporter.log('Standard output:')
                self.reporter.log(output.stdout, 'output')
                self.reporter.log_sep()

            if output.stderr:
                self.reporter.log_sep()
                self.reporter.log('Standard error:')
                self.reporter.log(output.stderr, 'output')
                self.reporter.log_sep()

            if not output.is_success():
                self.reporter.log_sep()
                if output.is_timed_out():
                    self.reporter.log('It seems that your program timed out.')
                    self.reporter.log(
                        f'The test should have ran in less than {output.timeout} seconds.'
                    )
                    self.reporter.log(
                        'You can override allowed running time with --timeout [timeout in seconds]'
                    )
                else:
                    self.reporter.log(
                        'It seems that your program crashed unexpectedly.')
                self.reporter.log_sep()

            if isinstance(output, AsanRunnerOutput) and output.asanoutput:
                self.reporter.log_sep()
                self.reporter.log(
                    'AddressSanitizer reported the following errors:')
                self.reporter.log(output.asanoutput, 'output')
                self.reporter.log_sep()

            if isinstance(output,
                          MemcheckRunnerOutput) and output.memcheckoutput:
                self.reporter.log_sep()
                self.reporter.log('Memcheck reported the following errors:')
                self.reporter.log(output.memcheckoutput, 'output')
                self.reporter.log_sep()

            if output.errors and not self.reporter.config.ignore_errors:
                human_readable = self.reporter.config.explain_terminal(
                    output, self.reporter.color)
                if human_readable is not None:
                    self.reporter.log_sep()
                    self.reporter.log(human_readable, 'preformatted')
                    self.reporter.log_sep()