Esempio n. 1
0
def test_ExecClsmithSource_syntax_error():
  """Test outcome of kernel with syntax error."""
  env_ = env.OclgrindOpenCLEnvironment()
  proc = cl_launcher.ExecClsmithSource(
      env_, "!@!###syntax error!",
      driver.NDRange(1, 1, 1), driver.NDRange(1, 1, 1), '---debug')

  assert proc.returncode == 1
  assert proc.stdout == ''
  assert 'Error building program: -11' in proc.stderr
Esempio n. 2
0
def test_ExecClsmithSource_pass():
  """And end-to-end test of executing a CLSmith source."""
  env_ = env.OclgrindOpenCLEnvironment()
  proc = cl_launcher.ExecClsmithSource(
      env_, CLSMITH_EXAMPLE_SRC,
      driver.NDRange(1, 1, 1), driver.NDRange(1, 1, 1), '---debug')

  assert not proc.returncode
  assert '3-D global size 1 = [1, 1, 1]' in proc.stderr
  assert '3-D local size 1 = [1, 1, 1]' in proc.stderr
  assert 'OpenCL optimizations: on' in proc.stderr
  assert 'Platform: ' in proc.stderr
  assert 'Device: ' in proc.stderr
  assert 'Compilation terminated successfully...'
  assert proc.stdout == '0,'
Esempio n. 3
0
def RunTestcase(
    opencl_environment: env.OpenCLEnvironment,
    testbed: deepsmith_pb2.Testbed,
    testcase: deepsmith_pb2.Testcase,
    opts: typing.List[str],
) -> deepsmith_pb2.Result:
    """Run a testcase."""
    if testcase.toolchain != "opencl":
        raise ValueError(
            f"Unsupported testcase toolchain: '{testcase.toolchain}'")
    if testcase.harness.name != "cl_launcher":
        raise ValueError(
            f"Unsupported testcase harness: '{testcase.harness.name}'")
    result = deepsmith_pb2.Result()
    result.testbed.CopyFrom(testbed)
    result.testcase.CopyFrom(testcase)

    # Set up additional command line flags for cl_launcher. We always run with
    # debugging output enabled.
    opts.append("---debug")
    if testbed.opts["opencl_opt"] == "disabled":
        opts.append("---disable_opts")

    start_time_epoch_ms = labdate.MillisecondsTimestamp()
    process = cl_launcher.ExecClsmithSource(
        opencl_environment,
        testcase.inputs["src"],
        driver.NDRange.FromString(testcase.inputs["gsize"]),
        driver.NDRange.FromString(testcase.inputs["lsize"]),
        *opts,
        timeout_seconds=testcase.harness.opts.get("timeout_seconds", "60"),
    )

    wall_time = labdate.MillisecondsTimestamp() - start_time_epoch_ms
    result = deepsmith_pb2.Result()
    result.testcase.CopyFrom(testcase)
    result.testbed.CopyFrom(testbed)
    result.returncode = process.returncode
    result.outputs["stdout"] = process.stdout
    result.outputs["stderr"] = process.stderr
    prof = result.profiling_events.add()
    prof.client = socket.gethostname()
    prof.type = "runtime"
    prof.duration_ms = wall_time
    prof.event_start_epoch_ms = start_time_epoch_ms
    result.outcome = GetResultOutcome(result)
    return result