MCPcopy Create free account
hub / github.com/AdaptiveCpp/AdaptiveCpp / submit_ze_kernel

Function submit_ze_kernel

src/runtime/ze/ze_queue.cpp:48–140  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

46
47
48result submit_ze_kernel(ze_kernel_handle_t kernel,
49 ze_command_list_handle_t command_list,
50 ze_event_handle_t completion_evt,
51 const std::vector<ze_event_handle_t>& wait_events,
52 const rt::range<3> &group_size,
53 const rt::range<3> &num_groups, void **kernel_args,
54 const std::size_t *arg_sizes, std::size_t num_args,
55 // If non-null, will be used to check whether kernel args
56 // are pointers, and if so, check for null pointers
57 const hcf_kernel_info *info = nullptr) {
58
59 HIPSYCL_DEBUG_INFO << "ze_queue: Configuring kernel launch for group size "
60 << group_size[0] << " " << group_size[1] << " "
61 << group_size[2] << std::endl;
62 ze_result_t err =
63 zeKernelSetGroupSize(kernel, static_cast<uint32_t>(group_size[0]),
64 static_cast<uint32_t>(group_size[1]),
65 static_cast<uint32_t>(group_size[2]));
66 if(err != ZE_RESULT_SUCCESS) {
67 return make_error(
68 __acpp_here(),
69 error_info{"ze_module_invoker: Could not set kernel group size",
70 error_code{"ze", static_cast<int>(err)}});
71 }
72
73 HIPSYCL_DEBUG_INFO << "ze_queue: Configuring kernel launch for group count "
74 << num_groups[0] << " " << num_groups[1] << " "
75 << num_groups[2] << std::endl;
76 ze_group_count_t group_count;
77 group_count.groupCountX = static_cast<uint32_t>(num_groups[0]);
78 group_count.groupCountY = static_cast<uint32_t>(num_groups[1]);
79 group_count.groupCountZ = static_cast<uint32_t>(num_groups[2]);
80
81 for(std::size_t i = 0; i < num_args; ++i ){
82 HIPSYCL_DEBUG_INFO << "ze_module_invoker: Setting kernel argument " << i
83 << " of size " << arg_sizes[i] << " at " << kernel_args[i]
84 << std::endl;
85
86 auto points_to_nullptr = [](void* arg) -> bool {
87 void* ptr = nullptr;
88 std::memcpy(&ptr, arg, sizeof(void*));
89 return ptr == nullptr;
90 };
91
92 if (info && (info->get_argument_type(i) == hcf_kernel_info::pointer) &&
93 points_to_nullptr(kernel_args[i])) {
94 // Level Zero absolutely does not like when nullptrs are passed
95 // in as values at kernel_args[i] - it validates that those are non-null.
96 // So instead, we need to set the argument to zeKernelSetArgumentValue
97 // to null.
98 err = zeKernelSetArgumentValue(
99 kernel, i, static_cast<uint32_t>(arg_sizes[i]), nullptr);
100 } else {
101 err = zeKernelSetArgumentValue(
102 kernel, i, static_cast<uint32_t>(arg_sizes[i]), kernel_args[i]);
103 }
104 if(err != ZE_RESULT_SUCCESS) {
105 return make_error(

Calls 4

make_errorFunction · 0.85
make_successFunction · 0.85
get_argument_typeMethod · 0.80
sizeMethod · 0.45

Tested by

no test coverage detected