| 123 | } |
| 124 | |
| 125 | bool ThreadDimOk(const DeviceDescription &device_description, |
| 126 | const ThreadDim &thread_dim) { |
| 127 | auto total_threads = thread_dim.x * thread_dim.y * thread_dim.z; |
| 128 | auto threads_per_block_limit = device_description.threads_per_block_limit(); |
| 129 | if (total_threads > threads_per_block_limit) { |
| 130 | VLOG(2) << "exceeded total-thread-per-block limit: " << total_threads |
| 131 | << " vs limit " << threads_per_block_limit; |
| 132 | return false; |
| 133 | } |
| 134 | |
| 135 | const auto &limit = device_description.thread_dim_limit(); |
| 136 | bool ok = thread_dim.x <= limit.x && thread_dim.y <= limit.y && |
| 137 | thread_dim.z <= limit.z; |
| 138 | if (!ok) { |
| 139 | VLOG(2) << "thread dim " << thread_dim.ToString() |
| 140 | << " exceeds limit contraints of " << limit.ToString(); |
| 141 | } |
| 142 | return ok; |
| 143 | } |
| 144 | |
| 145 | uint64 DivideCeil(uint64 x, uint64 y) { |
| 146 | return port::MathUtil::CeilOfRatio(x, y); |