void numa_node::parse_cpu_string( std::string &line) { std::vector<int> indices; this->total_cpus = 0; this->available_cpus = 0; translate_range_string_to_vector(line.c_str(), indices); for (int i = 0; i < indices.size(); i++) { #ifdef PENABLE_LINUX26_CPUSETS if ((MOMConfigUseSMT == 1) || (is_physical_core(indices[i]) == true)) #endif { this->cpu_indices.push_back(indices[i]); this->cpu_avail.push_back(true); this->total_cpus++; this->available_cpus++; } } } /* END parse_cpu_string */
void numa_node::recover_reservation( int num_cpus, unsigned long memory, const char *jobid, allocation &alloc) { char cpuset_buf[MAXPATHLEN + 1]; std::vector<int> indices; bool matches_this_numa_node = false; alloc.jobid = jobid; #ifdef PENABLE_LINUX26_CPUSETS get_cpu_list(jobid, cpuset_buf, sizeof(cpuset_buf)); #endif translate_range_string_to_vector(cpuset_buf, indices); for (int i = 0; i < indices.size(); i++) { #ifdef PENABLE_LINUX26_CPUSETS if ((MOMConfigUseSMT == 1) || (is_physical_core(indices[i]) == true)) #endif { int my_index = in_this_numa_node(indices[i]); if (my_index == -1) continue; matches_this_numa_node = true; if (this->cpu_avail[my_index] == true) { mark_cpu_as_in_use(my_index, alloc); } } } if (matches_this_numa_node == true) { mark_memory_as_in_use(memory, alloc); this->allocations.push_back(alloc); } } /* END recover_reservation() */
/* * parse_cpu_string * parses a string for indices in the format int[-int][,int[-int]...] * * @pre-cond: str is a valid string pointer * @post-cond: internal variables representing cpus are populated */ void numa_node::parse_cpu_string( std::string &line) { char *str = strdup(line.c_str()); char *ptr = str; int prev = -1; int curr = -1; bool parsing_range = false; this->total_cpus = 0; this->available_cpus = 0; while (*ptr != '\0') { prev = strtol(ptr, &ptr, 10); if (*ptr == '-') { ptr++; curr = strtol(ptr, &ptr, 10); while (prev <= curr) { #ifdef PENABLE_LINUX26_CPUSETS if ((MOMConfigUseSMT == 1) || (is_physical_core(prev) == true)) #endif { this->cpu_indices.push_back(prev); this->cpu_avail.push_back(true); this->total_cpus++; this->available_cpus++; } prev++; } if (*ptr == ',') ptr++; } else if ((*ptr == ',') || (*ptr == '\0')) { #ifdef PENABLE_LINUX26_CPUSETS if ((MOMConfigUseSMT == 1) || (is_physical_core(prev) == true)) #endif { this->cpu_indices.push_back(prev); this->cpu_avail.push_back(true); this->total_cpus++; this->available_cpus++; } if (*ptr == ',') ptr++; } } free(str); } /* END parse_cpu_string */