MCPcopy Create free account
hub / github.com/appdevforall/CodeOnTheGo / parse_cpu_range

Function parse_cpu_range

subprojects/llama.cpp/common/common.cpp:292–327  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

290}
291
292bool 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
329bool parse_cpu_mask(const std::string & mask, bool (&boolmask)[GGML_MAX_N_THREADS]) {
330 // Discard potential 0x prefix

Callers 1

Calls 2

findMethod · 0.65
lengthMethod · 0.65

Tested by

no test coverage detected