From 2ac0d2d1e9375de9267846b66a40038e629f4ec7 Mon Sep 17 00:00:00 2001 From: jussi Date: Thu, 24 Jan 2019 18:26:47 +0200 Subject: [PATCH] More xnvctrl code and start adding nvml code --- nvidia.cpp | 138 +++++++++++++++++++++++++++++++++++++++++++++++++--- nvidia.h | 29 +++++++++-- rojekti.pro | 4 +- 3 files changed, 159 insertions(+), 12 deletions(-) diff --git a/nvidia.cpp b/nvidia.cpp index a688ea4..14bf375 100644 --- a/nvidia.cpp +++ b/nvidia.cpp @@ -9,6 +9,7 @@ nvidia::nvidia(QObject *parent) : QObject(parent) } bool nvidia::setupXNVCtrl() { + setupNVML(); // Open the x-server connection and check if the extension exists dpy = XOpenDisplay(nullptr); Bool ret; @@ -78,22 +79,86 @@ void nvidia::queryGPUFeatures() Bool ret; NVCTRLAttributeValidValuesRec values; for (int i=0; i #include #include +#include "/opt/cuda/include/nvml.h" class nvidia : public QObject { @@ -17,15 +18,29 @@ public: int index; char *name; char *uuid; - bool overVoltAvailable; - bool overClockAvailable; + char *utils; + bool overVoltAvailable = false; + bool overClockAvailable = false; + bool memOverClockAvailable = false; + bool voltageReadable = false; + bool coreClkReadable = false; + bool memClkReadable = false; + bool manualFanCtrl = false; int maxVoltageOffset; + int minVoltageOffset; + int minCoreClkOffset; + int maxCoreClkOffset; + int minMemClkOffset; + int maxMemClkOffset; int coreFreq; int memFreq; int temp; int voltage; int fanSpeed; + + int totalVRAM; + int usedVRAM; }; QVector GPUList; int gpuCount = 0; @@ -35,16 +50,22 @@ signals: public slots: bool setupXNVCtrl(); + bool setupNVML(); void queryGPUCount(); void queryGPUNames(); void queryGPUUIDs(); void queryGPUFeatures(); void queryGPUVoltage(int GPUIndex); void queryGPUTemp(int GPUIndex); - void queryGPUFrequency(int GPUIndex); + void queryGPUFrequencies(int GPUIndex); void queryGPUFanSpeed(int GPUIndex); + void queryGPUUtils(int GPUIndex); - bool assignFanSpeed(int GPUIndex, int targetValue); + bool assignGPUFanSpeed(int GPUIndex, int targetValue); + bool assignGPUFanCtlMode(int GPUIndex, int targetValue); + bool assignGPUFreqOffset(int GPUIndex, int targetValue); + bool assignGPUMemClockOffset(int GPUIndex, int targetValue); + bool assignGPUVoltageOffset(int GPUIndex, int targetValue); private slots: }; diff --git a/rojekti.pro b/rojekti.pro index 8a876a9..9d91161 100644 --- a/rojekti.pro +++ b/rojekti.pro @@ -50,9 +50,9 @@ FORMS += \ editprofile.ui \ newprofile.ui -INCLUDEPATH += "/usr/lib" +INCLUDEPATH += "/usr/lib" "/lib/" -LIBS += -lXext -lXNVCtrl -lX11 +LIBS += -lXext -lXNVCtrl -lX11 -lnvidia-ml # Default rules for deployment. qnx: target.path = /tmp/$${TARGET}/bin else: unix:!android: target.path = /opt/$${TARGET}/bin