| 251 | CREATE_CUDA_TYPE_ALIAS(Gpu2DLaunchConfig, Cuda2DLaunchConfig); |
| 252 | |
| 253 | inline Gpu2DLaunchConfig GetGpu2DLaunchConfig(int xdim, int ydim, |
| 254 | const Eigen::GpuDevice& d) { |
| 255 | Gpu2DLaunchConfig config; |
| 256 | |
| 257 | if (xdim <= 0 || ydim <= 0) { |
| 258 | return config; |
| 259 | } |
| 260 | |
| 261 | const int kThreadsPerBlock = 256; |
| 262 | int block_cols = std::min(xdim, kThreadsPerBlock); |
| 263 | // ok to round down here and just do more loops in the kernel |
| 264 | int block_rows = std::max(kThreadsPerBlock / block_cols, 1); |
| 265 | |
| 266 | const int physical_thread_count = |
| 267 | d.getNumGpuMultiProcessors() * d.maxGpuThreadsPerMultiProcessor(); |
| 268 | |
| 269 | const int max_blocks = std::max(physical_thread_count / kThreadsPerBlock, 1); |
| 270 | |
| 271 | config.virtual_thread_count = dim3(xdim, ydim, 1); |
| 272 | config.thread_per_block = dim3(block_cols, block_rows, 1); |
| 273 | |
| 274 | int grid_x = std::min(DivUp(xdim, block_cols), max_blocks); |
| 275 | |
| 276 | config.block_count = dim3( |
| 277 | grid_x, std::min(max_blocks / grid_x, std::max(ydim / block_rows, 1)), 1); |
| 278 | return config; |
| 279 | } |
| 280 | #ifndef TENSORFLOW_USE_ROCM |
| 281 | inline Cuda2DLaunchConfig GetCuda2DLaunchConfig(int xdim, int ydim, |
| 282 | const Eigen::GpuDevice& d) { |
no test coverage detected