Example #1
0
def test_DatabaseObserver(db: grewe_features_db.Database):
  with db.Session(commit=True) as s:
    s.add(
      _StaticFeatures("benchmarks_suite:benchmark:kernel", "kernel void A() {}")
    )

  observer = run_gpgpu_benchmarks.DatabaseObserver(db)

  observer.OnBenchmarkRun(
    gpgpu_pb2.GpgpuBenchmarkRun(
      benchmark_suite="suite",
      benchmark_name="benchmark",
      dataset_name="dataset",
      hostname="hostname",
      run=libcecl_pb2.LibceclExecutableRun(
        returncode=0,
        device=clinfo_pb2.OpenClDevice(name="opencl_env"),
        kernel_invocation=[
          libcecl_pb2.OpenClKernelInvocation(
            kernel_name="kernel",
            global_size=128,
            local_size=64,
            transferred_bytes=123,
            transfer_time_ns=3000,
            kernel_time_ns=1000,
          )
        ],
      ),
    )
  )

  with db.Session() as s:
    assert s.query(grewe_features_db.DynamicFeatures).count() == 0

  observer.CommitRecords()

  with db.Session() as s:
    assert s.query(grewe_features_db.DynamicFeatures).count() == 1
    record = s.query(grewe_features_db.DynamicFeatures).one()
    assert record.driver == grewe_features_db.DynamicFeaturesDriver.LIBCECL
    assert (
      record.static_features_id
      == s.query(grewe_features_db.StaticFeatures.id).one()
    )

    assert record.opencl_env == "opencl_env"
    assert record.hostname == "hostname"
    assert record.outcome == "PASS"

    assert record.gsize == 128
    assert record.wgsize == 64

    assert record.work_item_local_mem_size == None
    assert record.work_item_private_mem_size == None
    assert record.transferred_bytes == 123
    assert record.transfer_time_ns == 3000
    assert record.kerenl_time_ns == 1000
Example #2
0
def test_KernelInvocationsFromCeclLog():
  device = cldrive_env.OpenCLEnvironment(
    clinfo_pb2.OpenClDevice(device_type="CPU", device_name="OpenCL Device",)
  )
  invocations = libcecl_runtime.KernelInvocationsFromCeclLog(
    [
      "clCreateProgramWithSource",
      "BEGIN PROGRAM SOURCE",
      "kernel void Kernel(global int* a) {}",
      "END PROGRAM SOURCE",
      "clCreateCommandQueue ; CPU ; OpenCL Device",
      "clBuildProgram ; Kernel" "clEnqueueMapBuffer ; Buffer ; 1024 ; 2000",
      "clEnqueueNDRangeKernel ; Kernel ; 128 ; 64 ; 3000",
      "clEnqueueTask ; Kernel ; 4000",
    ],
    expected_device_name=device.device_name,
    expected_devtype=device.device_type,
  )
  assert len(invocations) == 2
Example #3
0
from gpu.clinfo.proto import clinfo_pb2
from phd.lib.labm8 import bazelutil
from phd.lib.labm8 import system

FLAGS = flags.FLAGS

_OCLGRIND_PKG = 'oclgrind_linux' if system.is_linux() else 'oclgrind_mac'
# The path to the oclgrind binary.
OCLGRIND_PATH = bazelutil.DataPath(f'{_OCLGRIND_PKG}/bin/oclgrind')
# The clinfo description of the local Oclgrind binary.
CLINFO_DESCRIPTION = clinfo_pb2.OpenClDevice(
    name='Emulator|Oclgrind|Oclgrind_Simulator|Oclgrind_18.3|1.2',
    platform_name='Oclgrind',
    device_name='Oclgrind Simulator',
    driver_version='Oclgrind 18.3',
    opencl_version='1.2',
    device_type='Emulator',
    platform_id=0,
    device_id=0,
)


def Exec(argv: typing.List[str],
         env: typing.Dict[str, str] = None) -> subprocess.Popen:
    """Execute a command using oclgrind.

  This creates a Popen process, executes it, and sets the stdout and stderr
  attributes to the process output.

  Args:
    argv: A list of arguments to pass to the oclgrind executable.
Example #4
0
import typing

from gpu.clinfo.proto import clinfo_pb2
from labm8.py import app
from labm8.py import bazelutil

FLAGS = app.FLAGS

OCLGRIND_PATH = bazelutil.DataPath("phd/third_party/oclgrind/oclgrind")

# The clinfo description of the local Oclgrind binary.
CLINFO_DESCRIPTION = clinfo_pb2.OpenClDevice(
  name="Emulator|Oclgrind|Oclgrind_Simulator|Oclgrind_18.3|1.2",
  platform_name="Oclgrind",
  device_name="Oclgrind Simulator",
  driver_version="Oclgrind 18.3",
  opencl_version="1.2",
  device_type="Emulator",
  platform_id=0,
  device_id=0,
)


def Exec(
  argv: typing.List[str],
  stdin: typing.Optional[str] = None,
  env: typing.Dict[str, str] = None,
) -> subprocess.Popen:
  """Execute a command using oclgrind.

  This creates a Popen process, executes it, and sets the stdout and stderr
  attributes to the process output.