| 290 | } |
| 291 | |
| 292 | bool parse_cpu_range(const std::string & range, bool (&boolmask)[GGML_MAX_N_THREADS]) { |
| 293 | size_t dash_loc = range.find('-'); |
| 294 | if (dash_loc == std::string::npos) { |
| 295 | LOG_ERR("Format of CPU range is invalid! Expected [<start>]-[<end>].\n"); |
| 296 | return false; |
| 297 | } |
| 298 | |
| 299 | size_t start_i; |
| 300 | size_t end_i; |
| 301 | |
| 302 | if (dash_loc == 0) { |
| 303 | start_i = 0; |
| 304 | } else { |
| 305 | start_i = std::stoull(range.substr(0, dash_loc)); |
| 306 | if (start_i >= GGML_MAX_N_THREADS) { |
| 307 | LOG_ERR("Start index out of bounds!\n"); |
| 308 | return false; |
| 309 | } |
| 310 | } |
| 311 | |
| 312 | if (dash_loc == range.length() - 1) { |
| 313 | end_i = GGML_MAX_N_THREADS - 1; |
| 314 | } else { |
| 315 | end_i = std::stoull(range.substr(dash_loc + 1)); |
| 316 | if (end_i >= GGML_MAX_N_THREADS) { |
| 317 | LOG_ERR("End index out of bounds!\n"); |
| 318 | return false; |
| 319 | } |
| 320 | } |
| 321 | |
| 322 | for (size_t i = start_i; i <= end_i; i++) { |
| 323 | boolmask[i] = true; |
| 324 | } |
| 325 | |
| 326 | return true; |
| 327 | } |
| 328 | |
| 329 | bool parse_cpu_mask(const std::string & mask, bool (&boolmask)[GGML_MAX_N_THREADS]) { |
| 330 | // Discard potential 0x prefix |
no test coverage detected