Skip to content

Commit d78a2be

Browse files
committed
1. added support for valid index for command queue was implemented.2. support for checking whether the fence,cmd list, cmd queue triplet all share the same context before executing the command list was implemented
1 parent d2fc1eb commit d78a2be

4 files changed

Lines changed: 37 additions & 11 deletions

File tree

‎backends/ze/ze_validator_entry_exit_helpers.rb‎

Lines changed: 13 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -57,7 +57,7 @@ def check_valid_ordinal(state, ctx, defi, cqg_ordinal)
5757
end
5858
end
5959
else
60-
#hardcoded if the device property json wasn't generated
60+
#hardcode if the device property json wasn't generated
6161
copy_only_ords << 1
6262
copy_only_ords << 2
6363
end
@@ -177,6 +177,18 @@ def check_valid_module(state,ctx,defi)
177177
state.print_usage_error(ctx, "Improper hModule was handed")
178178
end
179179
end
180+
def check_list_and_fence_have_matching_context(state,ctx,defi,cmd_list,fence)
181+
unless fence && cmd_list && fence.command_queue &&
182+
cmd_list.context == fence.command_queue.context
183+
state.print_usage_error(ctx, "Mismatching context between command list #{state.get_handle_str(cmd_list.handle)} and fence #{state.get_handle_str(fence.handle)}")
184+
end
185+
end
186+
187+
def check_list_and_queue_have_matching_context(state,ctx,defi,cmd_list, cmd_queue)
188+
unless cmd_queue && cmd_list && cmd_list.context == cmd_queue.context
189+
state.print_usage_error(ctx, "Mismatching context between command queue #{state.get_handle_str(cmd_queue.handle)} and command list #{state.get_handle_str(cmd_list.handle)}")
190+
end
191+
end
180192

181193
def check_oob_memory_copy(state,ctx,defi)
182194
src_ptr = defi['srcptr']

‎backends/ze/ze_validator_function_entry_exit_callbacks.rb‎

Lines changed: 20 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -70,8 +70,14 @@
7070
#Retrieve the compute ordinal from the command list
7171
command_lists = state.find_objects(ctx, 'command_list')
7272
cmd_list = command_lists[defi['hCommandList']]
73-
cqg_ordinal = cmd_list.desc[:commandQueueGroupOrdinal]
74-
#puts "cqg_ordinal = #{cqg_ordinal}"
73+
cqg_ordinal = 0
74+
if cmd_list.desc
75+
cqg_ordinal = cmd_list.desc[:commandQueueGroupOrdinal]
76+
elsif cmd_list.altdesc
77+
cqg_ordinal = cmd_list.altdesc[:ordinal]
78+
else
79+
state.raise_internal_error(ctx, "No valid ordinal could be retrieved within the validator.")
80+
end
7581
check_valid_ordinal(state,ctx,defi,cqg_ordinal)
7682
check_kernel_created(state,ctx,defi)
7783
}
@@ -99,10 +105,21 @@
99105
check_fence_misuse(state,ctx,defi)
100106
#check if the group property was hardcoded
101107
command_queues = state.find_objects(ctx, 'command_queue')
108+
command_lists = state.find_objects(ctx, 'command_list')
102109
command_queue = command_queues[defi['hCommandQueue']]
110+
command_list_handles = defi['phCommandLists_vals']
111+
#puts "defi = #{defi}"
112+
fences = state.find_objects(ctx, 'fence')
113+
fence = fences[defi['hFence']]
103114
if command_queue
104115
check_group_property_queued(state,ctx,defi,command_queue.device)
105-
end
116+
command_list_handles.each do |command_list|
117+
check_list_and_queue_have_matching_context(state,ctx,defi,command_lists[command_list],command_queue)
118+
check_list_and_fence_have_matching_context(state,ctx,defi,command_lists[command_list],fence)
119+
end
120+
else
121+
state.raise_internal_error(ctx, "No command queue was found")
122+
end
106123
}
107124

108125
#When a fence signals the host, set the fence's status to signaled
@@ -244,7 +261,6 @@
244261
}
245262

246263
$on_successful_exit['zeCommandQueueCreate'] = lambda { |state, ctx, defi|
247-
#puts "create"
248264
command_queues = state.find_objects(ctx, 'command_queue')
249265
context = state.find_object(ctx, 'context', 'hContext')
250266
device = state.find_object(ctx, 'device', 'hDevice')
@@ -321,7 +337,6 @@
321337
check_group_property_queued(state,ctx,defi,device)
322338
command_lists[handle] = ZEModel::CommandList.new(handle, context, device, nil, altdesc)
323339
command_lists[handle].immediate = true #immdediate command lists cannot be passed to the execute command lists
324-
#puts "altdesc = #{altdesc}"
325340
command_lists[handle].associated_ordinal = altdesc[:ordinal]
326341
context.command_lists[handle] = command_lists[handle]
327342
}
@@ -417,7 +432,6 @@
417432
handle = defi['phKernel_val']
418433
kernelName = state.find_param(ctx, 'desc__pKernelName_val')
419434
kernel = ZEModel::Kernel.new(handle, mod, desc, kernelName)
420-
#puts "kernelName = #{state.find_param(ctx, 'desc__pKernelName_val')}"
421435
kernels[handle] = kernel
422436
mod.kernels[handle] = kernel
423437
}

‎backends/ze/ze_validator_state_object.rb‎

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -286,6 +286,7 @@ def on_exit(m,hostname,context,defi)
286286
l = $on_successful_exit[m[1]] #This might be a problem for tracking erroneous exits.
287287
l.call(self, context, defi) if l
288288
else
289+
#puts "failed: #{m[1]}"
289290
l = $on_erroneous_exit[m[1]]
290291
l.call(self, context, defi) if l
291292
end
@@ -313,7 +314,7 @@ def consume = lambda { |iterator, _|
313314
if m[2] == 'entry'
314315
on_entry(m, hostname, context, defi)
315316
elsif m[2] == 'exit'
316-
puts "#{m[1]}"
317+
#puts "#{m[1]}"
317318
on_exit(m, hostname, context, defi)
318319
end
319320
end

‎backends/ze/ze_validator_zemodel.rb‎

Lines changed: 2 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -198,14 +198,13 @@ class Fence < Object
198198
@typename = 'fence'
199199
attr_reader :command_queue
200200
attr_reader :desc
201-
attr_accessor :command_queue_history
201+
202202

203203
def initialize(handle, command_queue, desc)
204204
super(handle)
205205
@command_queue = command_queue
206206
@desc = desc
207-
@status = @@INITIALIZED
208-
@command_queue_history = []
207+
@status = @@INITIALIZED
209208
end
210209

211210
#is it suitable to put this here?

0 commit comments

Comments
 (0)