@@ -163,7 +163,7 @@ CPU::CPU() {
163163
164164 numa_node_list.assign (_sockets, std::vector<int >());
165165 for (int i = 0 ; i < _processors; i++) {
166- if (CPU_ISSET (i , mask)) {
166+ if (CPU_ISSET (_cpu_mapping_table[i][CPU_MAP_PROCESSOR_ID] , mask)) {
167167 valid_cpu_mapping_table.emplace_back (_cpu_mapping_table[i]);
168168 if (_cpu_mapping_table[i][CPU_MAP_CORE_TYPE] == MAIN_CORE_PROC) {
169169 phy_core_list.emplace_back (_cpu_mapping_table[i][CPU_MAP_CORE_ID]);
@@ -340,33 +340,28 @@ void parse_node_info_linux(const std::vector<std::string> node_info_table,
340340 int core_1 = 0 ;
341341 int core_2 = 0 ;
342342 std::string::size_type pos = 0 ;
343- std::string::size_type endpos = 0 ;
343+ std::string::size_type endpos_1 = 0 ;
344+ std::string::size_type endpos_2 = 0 ;
344345 std::string sub_str = " " ;
345346
346- if (((endpos = one_info.find (' -' , pos)) == std::string::npos) &&
347- ((endpos = one_info.find (' ,' , pos)) != std::string::npos)) {
348- while (endpos != std::string::npos) {
347+ while (pos != std::string::npos) {
348+ endpos_1 = one_info.find (' ,' , pos);
349+ endpos_2 = one_info.find (' -' , pos);
350+ if ((endpos_1 < endpos_2) || (endpos_1 == std::string::npos && endpos_2 == std::string::npos)) {
349351 sub_str = one_info.substr (pos);
350352 core_1 = std::stoi (sub_str);
351353 nodes_table.push_back ({core_1, core_1, node_index});
352- endpos = one_info.find (' ,' , pos);
353- pos = endpos + 1 ;
354+ } else if (endpos_2 != std::string::npos) {
355+ sub_str = one_info.substr (pos, endpos_2 - pos);
356+ core_1 = std::stoi (sub_str);
357+ sub_str = one_info.substr (endpos_2 + 1 );
358+ core_2 = std::stoi (sub_str);
359+ nodes_table.push_back ({core_1, core_2, node_index});
354360 }
355- } else {
356- while (endpos != std::string::npos) {
357- if ((endpos = one_info.find (' -' , pos)) != std::string::npos) {
358- sub_str = one_info.substr (pos, endpos - pos);
359- core_1 = std::stoi (sub_str);
360- sub_str = one_info.substr (endpos + 1 );
361- core_2 = std::stoi (sub_str);
362- nodes_table.push_back ({core_1, core_2, node_index});
363- pos = one_info.find (' ,' , endpos);
364- if (pos == std::string::npos) {
365- break ;
366- } else {
367- pos = pos + 1 ;
368- }
369- }
361+ if (endpos_1 == std::string::npos) {
362+ break ;
363+ } else {
364+ pos = endpos_1 + 1 ;
370365 }
371366 }
372367 node_index++;
0 commit comments