Skip to content
Open
22 changes: 22 additions & 0 deletions backends/ze/Makefile.am
Original file line number Diff line number Diff line change
Expand Up @@ -175,6 +175,11 @@ CLEANFILES += tracer_ze.c
bin_SCRIPTS = \
tracer_ze.sh

if ZE_VALIDATOR
bin_SCRIPTS += validator/ze_validator
endif


noinst_LTLIBRARIES = libzetracepoints.la

nodist_libzetracepoints_la_SOURCES = \
Expand Down Expand Up @@ -251,6 +256,23 @@ data_DATA = \
ze_bindings_base.rb \
babeltrace_zeprofiling_apis.txt

# Everything the ze_validator needs
ZE_VALIDATOR_SOURCES = \
validator/errors.rb \
validator/allocation_map.rb \
validator/model.rb \
validator/callbacks.rb \
validator/semantics.rb \
validator/state_object.rb \
validator/api_metadata.yaml

EXTRA_DIST += $(ZE_VALIDATOR_SOURCES)

if ZE_VALIDATOR
ze_validatordir = $(datadir)/ze/validator
ze_validator_DATA = $(ZE_VALIDATOR_SOURCES)
endif

xprof_utils.hpp: $(top_srcdir)/utils/xprof_utils.hpp
cp $< $@

Expand Down
2 changes: 2 additions & 0 deletions backends/ze/validator/.gitignore
Original file line number Diff line number Diff line change
@@ -0,0 +1,2 @@
ze_validator
!api_metadata.yaml
57 changes: 57 additions & 0 deletions backends/ze/validator/allocation_map.rb
Original file line number Diff line number Diff line change
@@ -0,0 +1,57 @@
require 'rbtree'

module ZEModel

# A collection of pairwise disjoint intervals, keyed on their base pointer.
class AllocationMap

class OverlapError < StandardError
attr_reader :entries
def initialize(entries)
@entries = entries
super('range overlaps a live entry')
end
end

def initialize
@tree = RBTree.new
end

def [](addr)
pair = @tree.upper_bound(addr)
pair && addr < pair[1].base + pair[1].size ? pair[1] : nil
end

def insert(obj)
clashes = overlapping(obj.base, obj.size)
raise OverlapError, clashes unless clashes.empty?
@tree[obj.base] = obj
end

def delete(base)
@tree.delete(base)
end

# The entries meeting [base, base + size), in ascending base order.
def overlapping(base, size)
return [] unless size.positive?
hits = @tree.bound(base, base + size - 1).map { |_base, obj| obj }
pred = @tree.upper_bound(base - 1)
hits.unshift(pred[1]) if pred && pred[1].base + pred[1].size > base
hits
end

def each(&block)
@tree.each_value(&block)
end
alias each_value each

def empty?
@tree.empty?
end

def size
@tree.size
end
end
end
50 changes: 50 additions & 0 deletions backends/ze/validator/api_metadata.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,50 @@
---
# API -> [version it was deprecated in, replacement].
deprecated:
zeInit: ['1.10', zeInitDrivers]
zeDriverGet: ['1.10', zeInitDrivers]
zeCommandListImmediateAppendCommandListsExp: ['1.16', zeCommandListImmediateAppendCommandListsWithParameters]
zeImageViewCreateExp: ['', zeImageViewCreateExt]
zesRasGetConfig: ['1.16', zesRasGetConfigExp]
zesRasSetConfig: ['1.16', zesRasSetConfigExp]

# API -> the [arg name, arg type]
thread_unsafe:
zeCommandListDestroy:
- [hCommandList, command_list]
zeCommandListClose:
- [hCommandList, command_list]
zeCommandListReset:
- [hCommandList, command_list]
zeCommandListAppendWriteGlobalTimestamp:
- [hCommandList, command_list]
zeCommandListAppendLaunchKernel:
- [hCommandList, command_list]
zeCommandListAppendBarrier:
- [hCommandList, command_list]
zeCommandListAppendLaunchCooperativeKernel:
- [hCommandList, command_list]
zeCommandListAppendMemoryCopy:
- [hCommandList, command_list]
zeCommandListAppendMemoryFill:
- [hCommandList, command_list]
zeCommandListAppendMemoryCopyRegion:
- [hCommandList, command_list]
zeCommandListAppendSignalEvent:
- [hCommandList, command_list]
zeCommandListAppendWaitOnEvents:
- [hCommandList, command_list]
zeCommandListAppendEventReset:
- [hCommandList, command_list]
zeCommandQueueExecuteCommandLists:
- [phCommandLists_vals, command_list]
zeKernelSetGroupSize:
- [hKernel, kernel]
zeKernelSetArgumentValue:
- [hKernel, kernel]
zeKernelSetCacheConfig:
- [hKernel, kernel]
zeKernelSetIndirectAccess:
- [hKernel, kernel]
zeKernelSetGlobalOffsetExp:
- [hKernel, kernel]
Loading
Loading