| 294 | } |
| 295 | |
| 296 | port::Status GpuExecutor::Launch(Stream* stream, const ThreadDim& thread_dims, |
| 297 | const BlockDim& block_dims, |
| 298 | const KernelBase& kernel, |
| 299 | const KernelArgsArrayBase& args) { |
| 300 | CHECK_EQ(kernel.Arity(), args.number_of_arguments()); |
| 301 | GpuStreamHandle hipstream = AsGpuStreamValue(stream); |
| 302 | const GpuKernel* rocm_kernel = AsGpuKernel(&kernel); |
| 303 | hipFunction_t hipfunc = rocm_kernel->AsGpuFunctionHandle(); |
| 304 | |
| 305 | // Only perform/print the occupancy check once. Even just checking to see |
| 306 | // whether we've done an occupancy check on this kernel before isn't free |
| 307 | // (because we have to synchronize), so we only do this at -v 2+. |
| 308 | if (VLOG_IS_ON(2)) { |
| 309 | absl::MutexLock lock(&launched_kernels_mu_); |
| 310 | if (!launched_kernels_.count(hipfunc)) { |
| 311 | VlogOccupancyInfo(kernel, thread_dims, block_dims); |
| 312 | // TODO(rspringer): Remove elements from launched_kernels_...if we ever |
| 313 | // expose a kernel/module deallocation method. |
| 314 | launched_kernels_.insert(hipfunc); |
| 315 | } |
| 316 | } |
| 317 | |
| 318 | if (rocm_kernel->GetPreferredCacheConfig() != |
| 319 | KernelCacheConfig::kNoPreference) { |
| 320 | GpuDriver::FuncSetCacheConfig(hipfunc, rocm_kernel->GetGpuCacheConfig()); |
| 321 | } |
| 322 | |
| 323 | // prepare kernargs |
| 324 | // KernelArgsArrayBase keeps the pointer of arguments |
| 325 | // deference them here |
| 326 | std::vector<void*> kernargs; |
| 327 | KernelArgIterator iter = args.arg_iterator(); |
| 328 | while (iter.has_next()) { |
| 329 | KernelArg arg = iter.next(); |
| 330 | VLOG(2) << "*(arg.address): " |
| 331 | << reinterpret_cast<void*>( |
| 332 | *static_cast<const uint64_t*>(arg.address)); |
| 333 | kernargs.push_back( |
| 334 | reinterpret_cast<void*>(*static_cast<const uint64_t*>(arg.address))); |
| 335 | } |
| 336 | |
| 337 | size_t size = sizeof(void*) * kernargs.size(); |
| 338 | void* config[] = {HIP_LAUNCH_PARAM_BUFFER_POINTER, kernargs.data(), |
| 339 | HIP_LAUNCH_PARAM_BUFFER_SIZE, &size, HIP_LAUNCH_PARAM_END}; |
| 340 | |
| 341 | return GpuDriver::LaunchKernel( |
| 342 | GetGpuContext(stream), hipfunc, block_dims.x, block_dims.y, block_dims.z, |
| 343 | thread_dims.x, thread_dims.y, thread_dims.z, |
| 344 | args.number_of_shared_bytes(), hipstream, nullptr, (void**)&config); |
| 345 | } |
| 346 | |
| 347 | port::Status GpuExecutor::LaunchExecutableGraph(Stream* main_stream, |
| 348 | void* graph_exec) { |
nothing calls this directly
no test coverage detected