| 283 | namespace gpu_helper { |
| 284 | template <typename T, typename OutType = int32> |
| 285 | __device__ OutType upper_bound(const T* first, OutType count, T val) { |
| 286 | const T* orig = first; |
| 287 | const T* it = nullptr; |
| 288 | OutType step = 0; |
| 289 | while (count > 0) { |
| 290 | it = first; |
| 291 | step = count / 2; |
| 292 | it += step; |
| 293 | if (!(val < *it)) { |
| 294 | first = ++it; |
| 295 | count -= step + 1; |
| 296 | } else { |
| 297 | count = step; |
| 298 | } |
| 299 | } |
| 300 | |
| 301 | return first - orig; |
| 302 | } |
| 303 | |
| 304 | template <typename T, typename OutType = int32> |
| 305 | __device__ OutType lower_bound(const T* first, OutType count, T val) { |
no outgoing calls
no test coverage detected