MCPcopy Create free account
hub / github.com/DeepRec-AI/DeepRec / GetKernel

Method GetKernel

tensorflow/stream_executor/rocm/rocm_gpu_executor.cc:233–282  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

231}
232
233port::Status GpuExecutor::GetKernel(const MultiKernelLoaderSpec& spec,
234 KernelBase* kernel) {
235 GpuKernel* rocm_kernel = AsGpuKernel(kernel);
236 hipModule_t module = nullptr;
237 const string* kernelname;
238
239 const OnDiskKernelLoaderSpec* on_disk_spec = nullptr;
240 bool has_cubin = spec.has_cuda_cubin_on_disk();
241 if (has_cubin) {
242 on_disk_spec = &spec.cuda_cubin_on_disk();
243 }
244
245 if (on_disk_spec != nullptr) {
246 return port::InternalError(
247 "Loading ROCM kernel from disk is not supported");
248 } else if (spec.has_cuda_cubin_in_memory()) {
249 kernelname = &spec.cuda_cubin_in_memory().kernelname();
250
251 const char* hsaco = spec.cuda_cubin_in_memory().bytes();
252 absl::MutexLock lock{&in_memory_modules_mu_};
253 module = in_memory_modules_[hsaco];
254
255 if (module == nullptr) {
256 if (!GpuDriver::LoadHsaco(context_, hsaco, &module)) {
257 return port::InternalError("Failed to load HSACO");
258 }
259 }
260 kernel_to_gpu_binary_[kernel] = hsaco;
261 } else {
262 return port::InternalError("No method of loading ROCM kernel provided");
263 }
264
265 VLOG(2) << "getting function " << *kernelname << " from module " << module;
266 if (!GpuDriver::GetModuleFunction(context_, module, kernelname->c_str(),
267 rocm_kernel->gpu_function_ptr())) {
268 return port::InternalError("Failed getting module function");
269 }
270
271 // We have to trust the kernel loader spec arity because there doesn't appear
272 // to be a way to reflect on the number of expected arguments w/the ROCM API.
273 rocm_kernel->set_arity(spec.arity());
274
275 KernelMetadata kernel_metadata;
276 if (!GetKernelMetadata(rocm_kernel, &kernel_metadata)) {
277 LOG(WARNING) << "Unable to get metadata for kernel " << kernelname;
278 }
279 kernel->set_metadata(kernel_metadata);
280 kernel->set_name(*kernelname);
281 return port::Status::OK();
282}
283
284bool GpuExecutor::GetKernelMetadata(GpuKernel* rocm_kernel,
285 KernelMetadata* kernel_metadata) {

Callers

nothing calls this directly

Calls 12

AsGpuKernelFunction · 0.85
cuda_cubin_in_memoryMethod · 0.80
c_strMethod · 0.80
gpu_function_ptrMethod · 0.80
set_arityMethod · 0.80
arityMethod · 0.80
InternalErrorFunction · 0.50
bytesMethod · 0.45
set_metadataMethod · 0.45
set_nameMethod · 0.45

Tested by

no test coverage detected