| 275 | } |
| 276 | |
| 277 | bool parse_cpu_range(const std::string & range, bool (&boolmask)[GGML_MAX_N_THREADS]) { |
| 278 | size_t dash_loc = range.find('-'); |
| 279 | if (dash_loc == std::string::npos) { |
| 280 | LOG_ERR("Format of CPU range is invalid! Expected [<start>]-[<end>].\n"); |
| 281 | return false; |
| 282 | } |
| 283 | |
| 284 | size_t start_i; |
| 285 | size_t end_i; |
| 286 | |
| 287 | if (dash_loc == 0) { |
| 288 | start_i = 0; |
| 289 | } else { |
| 290 | start_i = std::stoull(range.substr(0, dash_loc)); |
| 291 | if (start_i >= GGML_MAX_N_THREADS) { |
| 292 | LOG_ERR("Start index out of bounds!\n"); |
| 293 | return false; |
| 294 | } |
| 295 | } |
| 296 | |
| 297 | if (dash_loc == range.length() - 1) { |
| 298 | end_i = GGML_MAX_N_THREADS - 1; |
| 299 | } else { |
| 300 | end_i = std::stoull(range.substr(dash_loc + 1)); |
| 301 | if (end_i >= GGML_MAX_N_THREADS) { |
| 302 | LOG_ERR("End index out of bounds!\n"); |
| 303 | return false; |
| 304 | } |
| 305 | } |
| 306 | |
| 307 | for (size_t i = start_i; i <= end_i; i++) { |
| 308 | boolmask[i] = true; |
| 309 | } |
| 310 | |
| 311 | return true; |
| 312 | } |
| 313 | |
| 314 | bool parse_cpu_mask(const std::string & mask, bool (&boolmask)[GGML_MAX_N_THREADS]) { |
| 315 | // Discard potential 0x prefix |
no test coverage detected