예제 #1
0
  def test_handles_tuples(self):
    num_iters = 16
    results = lec_characterizer_pb2.LecTiming()
    tuple_type = xls_type_pb2.TypeProto(
        type_enum=xls_type_pb2.TypeProto.TypeEnum.TUPLE)
    tuple_type.tuple_elements.add().CopyFrom(self._byte_type)
    tuple_type.tuple_elements.add().CopyFrom(self._byte_type)
    tuple_type.tuple_elements.add().CopyFrom(self._byte_type)

    function_type = xls_type_pb2.FunctionTypeProto()
    function_type.parameters.add().CopyFrom(self._byte_type)
    function_type.parameters.add().CopyFrom(self._byte_type)
    function_type.parameters.add().CopyFrom(self._byte_type)
    function_type.return_type.CopyFrom(tuple_type)

    self._lc.run(
        results=results,
        op=op_pb2.OpProto.OP_TUPLE,
        function_type=function_type,
        num_iters=num_iters,
        cell_library_textproto=self._cell_lib_text,
        lec_fn=lambda a, b, c, d: True,
        results_fn=lambda x: None)

    self.assertLen(results.test_cases, 1)
    test_case = results.test_cases[0]
    self.assertLen(test_case.exec_times_us, num_iters)
예제 #2
0
def main(argv):
    if len(argv) > 3:
        raise app.UsageError('Too many command-line arguments.')

    # Read in the results file to see what configs to test.
    results = lc_pb2.LecTiming()
    if FLAGS.results_path and gfile.exists(FLAGS.results_path):
        with gfile.open(FLAGS.results_path, 'r') as fd:
            results = text_format.ParseLines(fd, lc_pb2.LecTiming())

    with gfile.open(FLAGS.cell_library_textproto_path, 'r') as fd:
        cell_library_textproto = fd.read()

    lc = lc_mod.LecCharacterizer(FLAGS.synthesis_server_address)

    for width in FLAGS.widths:
        bits_type = xls_type_pb2.TypeProto(
            type_enum=xls_type_pb2.TypeProto.BITS, bit_count=int(width))

        function_type = xls_type_pb2.FunctionTypeProto()
        function_type.parameters.add().CopyFrom(bits_type)
        function_type.parameters.add().CopyFrom(bits_type)
        function_type.return_type.CopyFrom(bits_type)

        test_case = None
        for result_case in results.test_cases:
            # Find or create a matching test case for this function type.
            if result_case.function_type == function_type:
                test_case = result_case

        if test_case is None:
            test_case = results.test_cases.add()
            test_case.function_type.CopyFrom(function_type)

        runs_left = FLAGS.runs_per_type - len(test_case.exec_times_us)
        if runs_left > 0:
            lc.run(results, op_pb2.OpProto.Value(FLAGS.op), function_type,
                   int(runs_left), cell_library_textproto, z3_lec.run,
                   _save_results)