Compare commits
1 Commits
8ff1d8be9d
...
OptionalLi
| Author | SHA1 | Date | |
|---|---|---|---|
|
|
b4e234f307 |
1
app/.clang-format
Normal file
1
app/.clang-format
Normal file
@@ -0,0 +1 @@
|
||||
BasedOnStyle: Google
|
||||
@@ -4,15 +4,29 @@ project(fantasize VERSION 0.1.7)
|
||||
|
||||
set(CMAKE_EXPORT_COMPILE_COMMANDS ON)
|
||||
|
||||
find_package(nlohmann_json 3.11.2 REQUIRED)
|
||||
find_package(nlohmann_json 3.7 REQUIRED)
|
||||
find_package(Boost 1.80 COMPONENTS program_options log log_setup date_time REQUIRED)
|
||||
|
||||
find_library(NVML_LIB nvidia-ml)
|
||||
|
||||
set(ADDITIONAL_LIBS)
|
||||
|
||||
if (NVML_LIB)
|
||||
set(HAVE_NVML)
|
||||
|
||||
add_library(nvidia-sensor-lib STATIC
|
||||
src/sensor/NvidiaSensor.cxx
|
||||
src/sensor/GPUSensorsFacade.cxx)
|
||||
|
||||
target_link_libraries(nvidia-sensor-lib PUBLIC NVML_LIB)
|
||||
|
||||
list(APPEND ADDITIONAL_LIBS nvidia-sensor-lib)
|
||||
endif()
|
||||
|
||||
add_executable(${PROJECT_NAME}
|
||||
src/main.cxx
|
||||
src/sensor/LMSensorsFacade.cxx
|
||||
src/sensor/GPUSensorsFacade.cxx
|
||||
src/sensor/Sensor.cxx
|
||||
src/sensor/NvidiaSensor.cxx
|
||||
src/sensor/LMSensor.cxx
|
||||
src/pwm/PWMControl.cxx
|
||||
src/pwm/PWMControlFacade.cxx
|
||||
@@ -30,7 +44,8 @@ add_executable(${PROJECT_NAME}
|
||||
set_property(TARGET ${PROJECT_NAME} PROPERTY CXX_STANDARD 20)
|
||||
|
||||
target_include_directories(${PROJECT_NAME} PUBLIC include /opt/cuda)
|
||||
target_link_libraries(${PROJECT_NAME} PUBLIC sensors nvidia-ml nlohmann_json::nlohmann_json tbb ${Boost_LIBRARIES})
|
||||
|
||||
target_link_libraries(${PROJECT_NAME} PUBLIC sensors nlohmann_json::nlohmann_json tbb ${Boost_LIBRARIES} ${ADDITIONAL_LIBS})
|
||||
|
||||
install(TARGETS ${PROJECT_NAME} DESTINATION usr/local/bin)
|
||||
install(FILES ${CMAKE_CURRENT_SOURCE_DIR}/unit/fantasize.service DESTINATION usr/lib/systemd/system)
|
||||
|
||||
@@ -1,10 +1,9 @@
|
||||
#include <boost/log/attributes/named_scope.hpp>
|
||||
#include <iostream>
|
||||
|
||||
#include <boost/log/trivial.hpp>
|
||||
|
||||
#include <fan/FanCurve.h>
|
||||
|
||||
#include <boost/log/attributes/named_scope.hpp>
|
||||
#include <boost/log/trivial.hpp>
|
||||
#include <sstream>
|
||||
|
||||
using namespace std;
|
||||
|
||||
FanCurve::FanCurve(std::vector<FanStep> steps,
|
||||
|
||||
@@ -1,8 +1,10 @@
|
||||
#include <boost/json/object.hpp>
|
||||
#include <include/nvml.h>
|
||||
#ifdef HAVE_NVML
|
||||
|
||||
#include <include/nvml.h>
|
||||
#include <sensor/NvidiaSensor.h>
|
||||
|
||||
#include <boost/json/object.hpp>
|
||||
|
||||
using namespace std;
|
||||
|
||||
NvidiaSensor::NvidiaSensor() { nvmlInit_v2(); }
|
||||
@@ -25,3 +27,5 @@ json NvidiaSensor::toJson() const {
|
||||
json obj = {"NvidiaSensor", toString()};
|
||||
return obj;
|
||||
}
|
||||
|
||||
#endif
|
||||
|
||||
@@ -3,20 +3,26 @@
|
||||
using namespace std;
|
||||
|
||||
SensorManager::SensorManager()
|
||||
: mLMSensorsFacade(make_unique<LMSensorsFacade>()),
|
||||
mGPUSensorsFacade(make_unique<GPUSensorsFacade>()) {}
|
||||
|
||||
vector<shared_ptr<Sensor>> SensorManager::TemperatureSensors() {
|
||||
vector<shared_ptr<Sensor>> tempSensors;
|
||||
|
||||
tempSensors = mLMSensorsFacade->TemperatureSensors();
|
||||
|
||||
auto gpuSensors = mGPUSensorsFacade->TemperatureSensors();
|
||||
tempSensors.insert(tempSensors.end(), gpuSensors.begin(), gpuSensors.end());
|
||||
|
||||
return tempSensors;
|
||||
: mLMSensorsFacade(make_unique<LMSensorsFacade>())
|
||||
, mGPUSensorsFacade(make_unique<GPUSensorsFacade>())
|
||||
{
|
||||
}
|
||||
|
||||
vector<shared_ptr<Sensor>> SensorManager::RPMSensors() {
|
||||
return mLMSensorsFacade->RPMSensors();
|
||||
vector<shared_ptr<Sensor>> SensorManager::TemperatureSensors()
|
||||
{
|
||||
vector<shared_ptr<Sensor>> tempSensors;
|
||||
|
||||
tempSensors = mLMSensorsFacade->TemperatureSensors();
|
||||
|
||||
#ifdef HAVE_NVML
|
||||
auto gpuSensors = mGPUSensorsFacade->TemperatureSensors();
|
||||
tempSensors.insert(tempSensors.end(), gpuSensors.begin(), gpuSensors.end());
|
||||
#endif
|
||||
|
||||
return tempSensors;
|
||||
}
|
||||
|
||||
vector<shared_ptr<Sensor>> SensorManager::RPMSensors()
|
||||
{
|
||||
return mLMSensorsFacade->RPMSensors();
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user