Skip to content
This repository was archived by the owner on Jul 4, 2025. It is now read-only.

Commit 33be8d8

Browse files
authored
fix: check cpu info size (#1804)
* fix: check cpu info size * fix: sort gpus
1 parent 841a8df commit 33be8d8

File tree

2 files changed

+6
-3
lines changed

2 files changed

+6
-3
lines changed

engine/services/hardware_service.cc

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -235,8 +235,8 @@ bool HardwareService::SetActivateHardwareConfig(
235235
activated_ids.push_back(std::pair(e.software_id, e.priority));
236236
}
237237
}
238-
std::sort(activated_ids.begin(), activated_ids.end());
239-
std::sort(ahc_gpus.begin(), ahc_gpus.end());
238+
std::sort(activated_ids.begin(), activated_ids.end(),
239+
[](auto& p1, auto& p2) { return p1.second < p2.second; });
240240
if (ahc_gpus.size() != activated_ids.size()) {
241241
need_update = true;
242242
} else {

engine/utils/hardware/cpu_info.h

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -10,7 +10,10 @@
1010

1111
namespace cortex::hw {
1212
inline CPU GetCPUInfo() {
13-
auto cpu = hwinfo::getAllCPUs()[0];
13+
auto res = hwinfo::getAllCPUs();
14+
if (res.empty())
15+
return CPU{};
16+
auto cpu = res[0];
1417
cortex::cpuid::CpuInfo inst;
1518
return CPU{.cores = cpu.numPhysicalCores(),
1619
.arch = std::string(GetArch()),

0 commit comments

Comments
 (0)