MCPcopy Create free account
hub / github.com/XpuOS/xsched / HipDynamicKernelLaunchCommand

Method HipDynamicKernelLaunchCommand

platforms/hip/hal/src/hip_command.cpp:75–116  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

73}
74
75HipDynamicKernelLaunchCommand::HipDynamicKernelLaunchCommand(
76 hipFunction_t function, void **kernel_params, void **extra_params, bool copy_param)
77 : HipKernelCommand(kernel_params, extra_params, copy_param), function_(function)
78{
79 if (!copy_param) return;
80 uint32_t all_params_size, num_parameters;
81 KernelParamManager::Instance()->GetDynamicKernelParams(function_, &num_parameters, &all_params_size);
82 XDEBG("HipDynamicKernelLaunchCommand(%p): param_cnt_ = %u, size = %u", this, num_parameters, all_params_size);
83 XDEBG("HipDynamicKernelLaunchCommand(%p): kernel_params = %p, extra_params = %p", this, kernel_params, extra_params);
84
85 // if the kernel_params is nullptr and extra_params is not nullptr,
86 // we mofify the extra_params, instead of the kernel_params
87 void** copy_src = kernel_params;
88 if (copy_src == nullptr && extra_params != nullptr) {
89 // 'extra' is a struct that contains the following info: {
90 // HIP_LAUNCH_PARAM_BUFFER_POINTER, kernargs,
91 // HIP_LAUNCH_PARAM_BUFFER_SIZE, &kernargs_size,
92 // HIP_LAUNCH_PARAM_END }
93 copy_src = (void**) extra_params[1];
94 int buffer_size = *(int*)extra_params[3];
95 XDEBG("HipDynamicKernelLaunchCommand(%p): extra[1] = %p, extra[3] = %d", this, extra_params[1], *(int*)extra_params[3]);
96
97 kernel_params_ = (void**)malloc(buffer_size);
98 memcpy(kernel_params_, copy_src, buffer_size);
99 param_buffer_size_ = buffer_size;
100 return;
101 }
102
103 param_cnt_ = num_parameters;
104 if (param_cnt_ == 0) return;
105 param_copied_ = true;
106 param_buffer_size_ = param_cnt_ * sizeof(void*);
107 kernel_params_ = (void **)malloc(param_buffer_size_); // free in destructor
108 param_data_ = (char *)malloc(all_params_size); // free in destructor
109 for (size_t i = 0; i < param_cnt_; ++i) {
110 size_t offset, size;
111 KernelParamManager::Instance()->GetDynamicKernelParamInfo(function_, i, &offset, &size);
112 XDEBG("HipDynamicKernelLaunchCommand(%p): param %zu, size = %zu, offset = %zu", function_, i, size, offset);
113 kernel_params_[i] = (void*)&param_data_[offset];
114 memcpy(kernel_params_[i], copy_src[i], size);
115 }
116}
117
118hipError_t HipKernelLaunchCommand::Launch(hipStream_t stream)
119{

Callers

nothing calls this directly

Calls 2

Tested by

no test coverage detected