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

Function parse_cpu_mask

subprojects/llama.cpp/common/common.cpp:329–363  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

327}
328
329bool parse_cpu_mask(const std::string & mask, bool (&boolmask)[GGML_MAX_N_THREADS]) {
330 // Discard potential 0x prefix
331 size_t start_i = 0;
332 if (mask.length() >= 2 && mask.substr(0, 2) == "0x") {
333 start_i = 2;
334 }
335
336 size_t num_digits = mask.length() - start_i;
337 if (num_digits > 128) num_digits = 128;
338
339 size_t end_i = num_digits + start_i;
340
341 for (size_t i = start_i, n = (num_digits*4 - 1); i < end_i; i++, n-=4) {
342 char c = mask.at(i);
343 int8_t id = c;
344
345 if ((c >= '0' && c <= '9')) {
346 id -= '0';
347 } else if (c >= 'a' && c <= 'f') {
348 id -= 'a' - 10;
349 } else if (c >= 'A' && c <= 'F') {
350 id -= 'A' - 10;
351 } else {
352 LOG_ERR("Invalid hex character '%c' at position %d\n", c, int32_t(i));
353 return false;
354 }
355
356 boolmask[ n ] = boolmask[ n ] || ((id & 8) != 0);
357 boolmask[n - 1] = boolmask[n - 1] || ((id & 4) != 0);
358 boolmask[n - 2] = boolmask[n - 2] || ((id & 2) != 0);
359 boolmask[n - 3] = boolmask[n - 3] || ((id & 1) != 0);
360 }
361
362 return true;
363}
364
365void common_init() {
366 llama_log_set(common_log_default_callback, NULL);

Callers 2

mainFunction · 0.85

Calls 2

lengthMethod · 0.65
atMethod · 0.65

Tested by

no test coverage detected