Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 1 addition & 0 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,7 @@
Print CPU and GPU temperatures on macOS.

It works on following macs.
- arm64 (M5 mac)
- arm64 (M4 mac)
- arm64 (M3 mac)
- arm64 (M2 mac)
Expand Down
36 changes: 34 additions & 2 deletions smctemp.cc
Original file line number Diff line number Diff line change
Expand Up @@ -465,7 +465,29 @@ double SmcTemp::GetCpuTemp() {
const std::pair<unsigned int, unsigned int> valid_temperature_limits{10, 120};

const std::string cpumodel = getCPUModel();
if (cpumodel.find("m4") != std::string::npos) { // Apple M4
if (cpumodel.find("m5") != std::string::npos) { // Apple M5
// ref: https://github.com/exelban/stats/blob/ab28d72/Modules/Sensors/values.swift#L469-L487
// CPU super cores
sensors.emplace_back(static_cast<std::string>(kSensorTp00));
sensors.emplace_back(static_cast<std::string>(kSensorTp04));
sensors.emplace_back(static_cast<std::string>(kSensorTp08));
sensors.emplace_back(static_cast<std::string>(kSensorTp0C));
sensors.emplace_back(static_cast<std::string>(kSensorTp0G));
sensors.emplace_back(static_cast<std::string>(kSensorTp0K));
// CPU performance cores
sensors.emplace_back(static_cast<std::string>(kSensorTp0O));
sensors.emplace_back(static_cast<std::string>(kSensorTp0R));
sensors.emplace_back(static_cast<std::string>(kSensorTp0U));
sensors.emplace_back(static_cast<std::string>(kSensorTp0X));
sensors.emplace_back(static_cast<std::string>(kSensorTp0a));
sensors.emplace_back(static_cast<std::string>(kSensorTp0d));
sensors.emplace_back(static_cast<std::string>(kSensorTp0g));
sensors.emplace_back(static_cast<std::string>(kSensorTp0j));
sensors.emplace_back(static_cast<std::string>(kSensorTp0m));
sensors.emplace_back(static_cast<std::string>(kSensorTp0p));
sensors.emplace_back(static_cast<std::string>(kSensorTp0u));
sensors.emplace_back(static_cast<std::string>(kSensorTp0y));
} else if (cpumodel.find("m4") != std::string::npos) { // Apple M4
sensors.emplace_back(static_cast<std::string>(kSensorTp01));
sensors.emplace_back(static_cast<std::string>(kSensorTp09));
sensors.emplace_back(static_cast<std::string>(kSensorTp0f));
Expand Down Expand Up @@ -577,7 +599,17 @@ double SmcTemp::GetGpuTemp() {
std::vector<std::string> sensors;
const std::pair<unsigned int, unsigned int> valid_temperature_limits{10, 120};
const std::string cpumodel = getCPUModel();
if (cpumodel.find("m4") != std::string::npos) { // Apple M4
if (cpumodel.find("m5") != std::string::npos) { // Apple M5
// ref: https://github.com/exelban/stats/blob/ab28d72/Modules/Sensors/values.swift#L489-L496
sensors.emplace_back(static_cast<std::string>(kSensorTg0U)); // GPU 1
sensors.emplace_back(static_cast<std::string>(kSensorTg0X)); // GPU 2
sensors.emplace_back(static_cast<std::string>(kSensorTg0d)); // GPU 3
sensors.emplace_back(static_cast<std::string>(kSensorTg0g)); // GPU 4
sensors.emplace_back(static_cast<std::string>(kSensorTg0j)); // GPU 5
sensors.emplace_back(static_cast<std::string>(kSensorTg1Y)); // GPU 6
sensors.emplace_back(static_cast<std::string>(kSensorTg1c)); // GPU 7
sensors.emplace_back(static_cast<std::string>(kSensorTg1g)); // GPU 8
} else if (cpumodel.find("m4") != std::string::npos) { // Apple M4
sensors.emplace_back(static_cast<std::string>(kSensorTg0D)); // GPU 1
sensors.emplace_back(static_cast<std::string>(kSensorTg0P)); // GPU 2
sensors.emplace_back(static_cast<std::string>(kSensorTg0X)); // GPU 3
Expand Down
22 changes: 22 additions & 0 deletions smctemp.h
Original file line number Diff line number Diff line change
Expand Up @@ -62,20 +62,36 @@ constexpr UInt32Char_t kSensorTc0a = "Tc0a";
constexpr UInt32Char_t kSensorTc0b = "Tc0b";
constexpr UInt32Char_t kSensorTc0x = "Tc0x";
constexpr UInt32Char_t kSensorTc0z = "Tc0z";
constexpr UInt32Char_t kSensorTp00 = "Tp00";
constexpr UInt32Char_t kSensorTp01 = "Tp01";
constexpr UInt32Char_t kSensorTp04 = "Tp04";
constexpr UInt32Char_t kSensorTp05 = "Tp05";
constexpr UInt32Char_t kSensorTp08 = "Tp08";
constexpr UInt32Char_t kSensorTp09 = "Tp09";
constexpr UInt32Char_t kSensorTp0C = "Tp0C";
constexpr UInt32Char_t kSensorTp0D = "Tp0D";
constexpr UInt32Char_t kSensorTp0G = "Tp0G";
constexpr UInt32Char_t kSensorTp0H = "Tp0H";
constexpr UInt32Char_t kSensorTp0K = "Tp0K";
constexpr UInt32Char_t kSensorTp0L = "Tp0L";
constexpr UInt32Char_t kSensorTp0O = "Tp0O";
constexpr UInt32Char_t kSensorTp0P = "Tp0P";
constexpr UInt32Char_t kSensorTp0R = "Tp0R";
constexpr UInt32Char_t kSensorTp0T = "Tp0T";
constexpr UInt32Char_t kSensorTp0U = "Tp0U";
constexpr UInt32Char_t kSensorTp0X = "Tp0X";
constexpr UInt32Char_t kSensorTp0a = "Tp0a";
constexpr UInt32Char_t kSensorTp0b = "Tp0b";
constexpr UInt32Char_t kSensorTp0d = "Tp0d";
constexpr UInt32Char_t kSensorTp0f = "Tp0f";
constexpr UInt32Char_t kSensorTp0g = "Tp0g";
constexpr UInt32Char_t kSensorTp0j = "Tp0j";
constexpr UInt32Char_t kSensorTp0m = "Tp0m";
constexpr UInt32Char_t kSensorTp0n = "Tp0n";
constexpr UInt32Char_t kSensorTp0p = "Tp0p";
constexpr UInt32Char_t kSensorTp0r = "Tp0r";
constexpr UInt32Char_t kSensorTp0u = "Tp0u";
constexpr UInt32Char_t kSensorTp0y = "Tp0y";
constexpr UInt32Char_t kSensorTp1h = "Tp1h";
constexpr UInt32Char_t kSensorTp1t = "Tp1t";
constexpr UInt32Char_t kSensorTp1p = "Tp1p";
Expand All @@ -86,12 +102,18 @@ constexpr UInt32Char_t kSensorTg0D = "Tg0D";
constexpr UInt32Char_t kSensorTg0L = "Tg0L";
constexpr UInt32Char_t kSensorTg0P = "Tg0P";
constexpr UInt32Char_t kSensorTg0T = "Tg0T";
constexpr UInt32Char_t kSensorTg0U = "Tg0U";
constexpr UInt32Char_t kSensorTg0X = "Tg0X";
constexpr UInt32Char_t kSensorTg0b = "Tg0b";
constexpr UInt32Char_t kSensorTg0d = "Tg0d";
constexpr UInt32Char_t kSensorTg0f = "Tg0f";
constexpr UInt32Char_t kSensorTg0g = "Tg0g";
constexpr UInt32Char_t kSensorTg0j = "Tg0j";
constexpr UInt32Char_t kSensorTg0v = "Tg0v";
constexpr UInt32Char_t kSensorTg1Y = "Tg1Y";
constexpr UInt32Char_t kSensorTg1b = "Tg1b";
constexpr UInt32Char_t kSensorTg1c = "Tg1c";
constexpr UInt32Char_t kSensorTg1g = "Tg1g";
constexpr UInt32Char_t kSensorTg4b = "Tg4b";
#endif

Expand Down
Loading