MCPcopy Create free account
hub / github.com/Tiiny-AI/PowerInfer / parse_cpu_mask

Function parse_cpu_mask

smallthinker/common/common.cpp:314–348  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

312}
313
314bool parse_cpu_mask(const std::string & mask, bool (&boolmask)[GGML_MAX_N_THREADS]) {
315 // Discard potential 0x prefix
316 size_t start_i = 0;
317 if (mask.length() >= 2 && mask.substr(0, 2) == "0x") {
318 start_i = 2;
319 }
320
321 size_t num_digits = mask.length() - start_i;
322 if (num_digits > 128) num_digits = 128;
323
324 size_t end_i = num_digits + start_i;
325
326 for (size_t i = start_i, n = (num_digits*4 - 1); i < end_i; i++, n-=4) {
327 char c = mask.at(i);
328 int8_t id = c;
329
330 if ((c >= '0' && c <= '9')) {
331 id -= '0';
332 } else if (c >= 'a' && c <= 'f') {
333 id -= 'a' - 10;
334 } else if (c >= 'A' && c <= 'F') {
335 id -= 'A' - 10;
336 } else {
337 LOG_ERR("Invalid hex character '%c' at position %d\n", c, int32_t(i));
338 return false;
339 }
340
341 boolmask[ n ] = boolmask[ n ] || ((id & 8) != 0);
342 boolmask[n - 1] = boolmask[n - 1] || ((id & 4) != 0);
343 boolmask[n - 2] = boolmask[n - 2] || ((id & 2) != 0);
344 boolmask[n - 3] = boolmask[n - 3] || ((id & 1) != 0);
345 }
346
347 return true;
348}
349
350void common_init() {
351 llama_log_set([](ggml_log_level level, const char * text, void * /*user_data*/) {

Callers 2

mainFunction · 0.85

Calls 2

lengthMethod · 0.80
substrMethod · 0.80

Tested by

no test coverage detected