コード例 #1
0
def main(argv):
  """Main entry point."""
  if len(argv) > 1:
    raise app.UsageError("Unknown arguments: '{}'.".format(" ".join(argv[1:])))

  config = pathlib.Path(FLAGS.generator)
  if not pbutil.ProtoIsReadable(config, generator_pb2.ClgenGenerator()):
    raise app.UsageError("--generator is not a deepsmith.ClgenGenerator proto")
  generator_config = pbutil.FromFile(config, generator_pb2.ClgenGenerator())
  output_directory = pathlib.Path(FLAGS.output_directory)
  GenerateTestcases(generator_config, output_directory, FLAGS.num_testcases)
コード例 #2
0
def test_GenerateTestcases(abc_instance_config, tempdir: pathlib.Path):
    """Run a tiny end-to-end test."""
    generator_config = generator_pb2.ClgenGenerator(
        instance=abc_instance_config,
        testcase_skeleton=[
            deepsmith_pb2.Testcase(
                toolchain="opencl",
                harness=deepsmith_pb2.Harness(name="cldrive",
                                              opts={"timeout_seconds": "60"}),
                inputs={
                    "gsize": "1,1,1",
                    "lsize": "1,1,1",
                },
            )
        ],
    )
    generator_path = tempdir / "generator.pbtxt"
    pbutil.ToFile(generator_config, generator_path)

    output_dir = tempdir / "outputs"

    subprocess.check_call([
        str(BIN),
        "--generator",
        generator_path,
        "--output_directory",
        str(output_dir),
        "--num_testcases",
        str(3),
    ])

    assert len(list((output_dir / "generated_testcases").iterdir())) >= 3
    assert len(list((output_dir / "generated_kernels").iterdir())) >= 3
    for f in (output_dir / "generated_testcases").iterdir():
        assert pbutil.ProtoIsReadable(f, deepsmith_pb2.Testcase())
コード例 #3
0
def main(argv):
  if len(argv) > 1:
    raise app.UsageError('Unrecognized arguments')
  if FLAGS.generator_batch_size <= 0:
    raise app.UsageError('--generator_batch_size must be positive')
  datastore_config = services.ServiceConfigFromFlag(
      'datastore_config', datastore_pb2.DataStore())
  generator_config = services.ServiceConfigFromFlag(
      'generator_config', generator_pb2.ClgenGenerator())

  datastore_stub = services.GetServiceStub(
      datastore_config, datastore_pb2_grpc.DataStoreServiceStub)
  generator_stub = services.GetServiceStub(
      generator_config, generator_pb2_grpc.GeneratorServiceStub)

  target_total_testcases = FLAGS.target_total_testcases
  generator_batch_size = FLAGS.generator_batch_size
  capabilities = GetGeneratorCapabilities(generator_stub)

  while True:
    num_testcases = GetNumberOfTestcasesInDataStore(
        datastore_stub, capabilities)
    logging.info(f'Number of testcases in datastore: %d', num_testcases)
    if 0 <= target_total_testcases <= num_testcases:
      logging.info('Stopping generation with %d testcases in the DataStore.',
                   num_testcases)
      break

    num_to_generate = generator_batch_size
    if target_total_testcases >= 0:
      num_to_generate = min(
          generator_batch_size, target_total_testcases - num_testcases)

    testcases = GenerateTestcases(generator_stub, num_to_generate)
    SubmitTestcases(datastore_stub, testcases)
コード例 #4
0
def test_GenerateTestcases(abc_instance_config):
    """Run a tiny end-to-end test."""
    generator_config = generator_pb2.ClgenGenerator(
        instance=abc_instance_config,
        testcase_skeleton=[
            deepsmith_pb2.Testcase(toolchain='opencl',
                                   harness=deepsmith_pb2.Harness(
                                       name='cldrive',
                                       opts={'timeout_seconds': '60'}),
                                   inputs={
                                       'gsize': '1,1,1',
                                       'lsize': '1,1,1',
                                   })
        ])
    with tempfile.TemporaryDirectory() as d:
        d = pathlib.Path(d)
        evaluate_generator.GenerateTestcases(generator_config, d, 3)
        assert len(list((d / 'generated_testcases').iterdir())) >= 3
        assert len(list((d / 'generated_kernels').iterdir())) >= 3
        for f in (d / 'generated_testcases').iterdir():
            assert pbutil.ProtoIsReadable(f, deepsmith_pb2.Testcase())