Skip to content

Commit

Permalink
feat: support GPU in M3
Browse files Browse the repository at this point in the history
  • Loading branch information
narugit committed May 1, 2024
1 parent d6fb32f commit ce4e68d
Show file tree
Hide file tree
Showing 2 changed files with 12 additions and 1 deletion.
9 changes: 8 additions & 1 deletion smctemp.cc
Original file line number Diff line number Diff line change
Expand Up @@ -522,7 +522,14 @@ 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("m2") != std::string::npos) { // Apple M2
if (cpumodel.find("m3") != std::string::npos) { // Apple M3
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
sensors.emplace_back(static_cast<std::string>(kSensorTg0b)); // GPU 4
sensors.emplace_back(static_cast<std::string>(kSensorTg0j)); // GPU 5
sensors.emplace_back(static_cast<std::string>(kSensorTg0v)); // GPU 6
} else if (cpumodel.find("m2") != std::string::npos) { // Apple M2
// ref: https://github.com/exelban/stats/blob/6b88eb1f60a0eb5b1a7b51b54f044bf637fd785b/Modules/Sensors/values.swift#L369-L370
sensors.emplace_back(static_cast<std::string>(kSensorTg0f)); // GPU 1
sensors.emplace_back(static_cast<std::string>(kSensorTg0j)); // GPU 2
Expand Down
4 changes: 4 additions & 0 deletions smctemp.h
Original file line number Diff line number Diff line change
Expand Up @@ -81,10 +81,14 @@ constexpr UInt32Char_t kSensorTg1b = "Tg1b";
constexpr UInt32Char_t kSensorTg4b = "Tg4b";
constexpr UInt32Char_t kSensorTg05 = "Tg05";
constexpr UInt32Char_t kSensorTg0D = "Tg0D";
constexpr UInt32Char_t kSensorTg0P = "Tg0P";
constexpr UInt32Char_t kSensorTg0L = "Tg0L";
constexpr UInt32Char_t kSensorTg0T = "Tg0T";
constexpr UInt32Char_t kSensorTg0X = "Tg0X";
constexpr UInt32Char_t kSensorTg0b = "Tg0b";
constexpr UInt32Char_t kSensorTg0f = "Tg0f";
constexpr UInt32Char_t kSensorTg0j = "Tg0j";
constexpr UInt32Char_t kSensorTg0v = "Tg0v";
#endif

class SmcAccessor {
Expand Down

0 comments on commit ce4e68d

Please sign in to comment.