Fix C-style hipLaunchKernel (#1835)
* Fix bug in LaunchKernel test Instead of passing the address of the gpu buffer, pass the address of the pointer that holds the address of the gpu buffer * Fix hipLaunchKernel's kernarg buffer construction. The hipLaunchKernel implementation should rely on ihipModuleLaunchKernel to construct the kernarg buffer correctly based on kernel metadata. * Fix a bug in get_functions where the Kernel_descriptor wasn't constructed with the correct kernarg layout information. * Fix a bug in kernarg layout parsing dealing with kernel without any arg * teach ihipModuleLaunchKernel to handle kernel without any arg * Add a more interesting test
This commit is contained in:
@@ -188,7 +188,8 @@ hipError_t ihipModuleLaunchKernel(TlsData *tls, hipFunction_t f, uint32_t gridSi
|
||||
return hipErrorNotInitialized;
|
||||
}
|
||||
|
||||
} else {
|
||||
}
|
||||
else if (f->_kernarg_layout.size() != 0) {
|
||||
return hipErrorInvalidValue;
|
||||
}
|
||||
|
||||
@@ -1470,21 +1471,7 @@ hipError_t hipLaunchKernel(
|
||||
hipFunction_t kd = hip_impl::get_program_state().kernel_descriptor((std::uintptr_t)func_addr,
|
||||
hip_impl::target_agent(stream));
|
||||
|
||||
if(kd == nullptr || kd->_header == nullptr)
|
||||
return ihipLogStatus(hipErrorInvalidValue);
|
||||
|
||||
size_t szKernArg = kd->_header->kernarg_segment_byte_size;
|
||||
|
||||
if(args == NULL && szKernArg != 0)
|
||||
return ihipLogStatus(hipErrorInvalidValue);
|
||||
|
||||
void* config[]{
|
||||
HIP_LAUNCH_PARAM_BUFFER_POINTER,
|
||||
args,
|
||||
HIP_LAUNCH_PARAM_BUFFER_SIZE,
|
||||
&szKernArg,
|
||||
HIP_LAUNCH_PARAM_END};
|
||||
|
||||
return ihipLogStatus(ihipModuleLaunchKernel(tls, kd, numBlocks.x, numBlocks.y, numBlocks.z,
|
||||
dimBlocks.x, dimBlocks.y, dimBlocks.z, sharedMemBytes, stream, nullptr, (void**)&config, nullptr, nullptr, 0));
|
||||
return hipModuleLaunchKernel(kd, numBlocks.x, numBlocks.y, numBlocks.z,
|
||||
dimBlocks.x, dimBlocks.y, dimBlocks.z, sharedMemBytes,
|
||||
stream, args, nullptr);
|
||||
}
|
||||
|
||||
@@ -613,7 +613,8 @@ public:
|
||||
for (auto&& kernel_symbol : it->second) {
|
||||
functions[aa].second.emplace(
|
||||
function.first,
|
||||
Kernel_descriptor{kernel_object(kernel_symbol), it->first});
|
||||
Kernel_descriptor{kernel_object(kernel_symbol), it->first,
|
||||
kernargs_size_align(function.first)});
|
||||
}
|
||||
}
|
||||
}, agent);
|
||||
@@ -672,11 +673,12 @@ public:
|
||||
auto dx1 = kernels_md.find("CodeProps", dx);
|
||||
dx = kernels_md.find("Args:", dx);
|
||||
|
||||
if (dx1 < dx) {
|
||||
if (dx1 < dx || dx == std::string::npos) {
|
||||
dx = dx1;
|
||||
// create an empty kernarg laybout vector for kernels without any arg
|
||||
kernargs[fn];
|
||||
continue;
|
||||
}
|
||||
if (dx == std::string::npos) break;
|
||||
|
||||
static constexpr decltype(kernels_md.size()) args_sz{5};
|
||||
dx = parse_args_v2(kernels_md, dx + args_sz, dx1, kernargs[fn]);
|
||||
|
||||
Reference in New Issue
Block a user