-
Notifications
You must be signed in to change notification settings - Fork 8
[ROCm] Route in-memory HSACO LoadKernel through LoadModuleFromHsaco #787
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
base: main
Are you sure you want to change the base?
Changes from all commits
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
| Original file line number | Diff line number | Diff line change |
|---|---|---|
|
|
@@ -682,12 +682,9 @@ absl::StatusOr<std::unique_ptr<Kernel>> RocmExecutor::LoadKernel( | |
| const auto& cubin = spec.cuda_cubin_in_memory()->cubin_bytes; | ||
| const char* hsaco = reinterpret_cast<const char*>(cubin.data()); | ||
| absl::MutexLock lock{in_memory_modules_mu_}; | ||
| ModuleHandle module_handle = HsacoModuleHandle(hsaco, cubin.size()); | ||
| hipModule_t& module = in_memory_modules_[module_handle]; | ||
|
|
||
| if (module == nullptr) { | ||
| TF_ASSIGN_OR_RETURN(module, LoadHsaco(&rocm_context_, hsaco)); | ||
| } | ||
| TF_ASSIGN_OR_RETURN(ModuleHandle module_handle, | ||
| LoadModuleFromHsaco(hsaco, cubin.size())); | ||
| hipModule_t module = gpu_binary_to_module_.at(module_handle).first; | ||
|
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. nit: |
||
| kernel_to_gpu_binary_[rocm_kernel.get()] = module_handle; | ||
|
|
||
| VLOG(2) << "getting function " << kernel_name << " from module " << module; | ||
|
|
||
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This is the core fix and looks correct. Previously
LoadKernelpopulatedin_memory_modules_andkernel_to_gpu_binary_but skippedgpu_binary_to_module_, soUnloadGpuBinary(line 627) would find no entry and returnfalsewithout cleaning up. Routing throughLoadModuleFromHsaconow correctly populates bothgpu_binary_to_module_(with refcount) andin_memory_modules_, making load/unload symmetric.This also achieves full parity with the CUDA
LoadKernel->LoadModuleFromCuBinpath (cuda_executor.cc:971-984).