Skip to content
Open
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
6 changes: 6 additions & 0 deletions CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,7 @@ project (konro)
list (APPEND CMAKE_MODULE_PATH "${PROJECT_SOURCE_DIR}/cmake/")

option(TIMING "Enable low level timing" OFF)
option(NVIDIA "Enable NVIDIA GPU management" OFF)

if (NOT DEFINED CGROUPBASEDIR)
set(CGROUPBASEDIR "/sys/fs/cgroup" CACHE STRING "The cgroup base directory")
Expand All @@ -22,6 +23,10 @@ if (TIMING)
add_definitions(-DTIMING)
endif()

if (NVIDIA)
add_definitions(-DNVIDIA)
endif()

add_subdirectory (common)
add_subdirectory (lib)
add_subdirectory (rm)
Expand All @@ -30,6 +35,7 @@ add_subdirectory (konrolib)
add_subdirectory (testplatformcontrol)
add_subdirectory (testthreadsafequeue)
add_subdirectory (testsensors)
add_subdirectory (testnvml)
add_subdirectory (testhwloc)
add_subdirectory (testkonrolib)
add_subdirectory (testtimer)
Expand Down
9 changes: 9 additions & 0 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -17,10 +17,19 @@ A modern resource manager
- libhwloc-dev
- libsensors-dev
- libopencv-dev
- Cuda Toolkit

OpenCV is required only for the peopledetect demo.
If it is not installed, peopledetect is not compiled.
# Optional: Nvidia GPU support
nvidia-cuda-toolkit is required in order to compile with NVIDIA GPU monitoring. It can be installed from your package manager or by manually by following this link https://developer.nvidia.com/cuda-downloads.
In order to compile, you need to add the NVIDIA flag to cmake:
* `mkdir build && cd build`
* `cmake -DNVIDIA=ON ..`
* `make`

If no NVIDIA GPUs are present, the manager will still work, but the monitor will just skip them.
If nothing is specified, NVIDIA GPU support will be disabled.
# Development

QtCreator has been used as IDE for development on Ubuntu 22.04.2 LTS.
Expand Down
17 changes: 17 additions & 0 deletions rm/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,10 @@ add_subdirectory (platformcontrol)
add_subdirectory (workloadmanager)
add_subdirectory (policymanager)
add_subdirectory (platformmonitor)
if(NVIDIA)
# Enable nvml code
add_subdirectory (nvidiamonitor)
endif(NVIDIA)

file(GLOB konro_SOURCES "src/*.cpp")
file(GLOB konro_HEADERS "src/*.h")
Expand All @@ -17,6 +21,18 @@ include_directories(${PROJECT_SOURCE_DIR}/rm/include)

add_executable (konro ${konro_SOURCES} ${konro_HEADERS})
target_compile_definitions(konro PUBLIC KONRO_RM)

if(NVIDIA)
target_link_libraries(konro PUBLIC
konro-common
rmcommon
platformcontrol
workloadmanager
policymanager
platformmonitor
nvidiamonitor
${LOG4CPP_LIBRARIES})
else(NVIDIA)
target_link_libraries(konro PUBLIC
konro-common
rmcommon
Expand All @@ -25,5 +41,6 @@ target_link_libraries(konro PUBLIC
policymanager
platformmonitor
${LOG4CPP_LIBRARIES})
endif(NVIDIA)

configure_file(konro.ini.in konro.ini)
52 changes: 52 additions & 0 deletions rm/librmcommon/events/monitorgpuevent.h
Original file line number Diff line number Diff line change
@@ -0,0 +1,52 @@
#ifndef MONITORGPUEVENT_H
#define MONITORGPUEVENT_H

#include "baseevent.h"
#include "../gpuload.h"
#include "../gpupower.h"
#include "../gputemperature.h"
#include <vector>
#include <iostream>

namespace rmcommon {

/*!
* \class event generated by the periodical sampling of machine status information.
*/
class MonitorGpuEvent : public BaseEvent {
GpuTemperature gpuTemp_;
GpuPower gpuActualPower_;
GpuLoad gpuLoad_;
public:
MonitorGpuEvent(GpuTemperature temp, GpuPower power, GpuLoad load) :
BaseEvent("MonitorEvent"),
gpuTemp_(temp),
gpuActualPower_(power),
gpuLoad_(load)
{}
virtual ~MonitorGpuEvent() = default;

GpuTemperature getGpuTemperature() const {
return gpuTemp_;
}

GpuPower getGpuPower() const {
return gpuActualPower_;
}

GpuLoad getGpuLoad() const {
return gpuLoad_;
}

virtual void printOnOstream(std::ostream &os) const {
os << "{";
os << "\"gpuTemp\":" << gpuTemp_;
os << ",\"gpuPower\":" << gpuActualPower_;
os << ",\"gpuLoad\":" << gpuLoad_;
os << "}";
}
};

} // namespace rmcommon

#endif // MONITORGPUEVENT_H
46 changes: 46 additions & 0 deletions rm/librmcommon/gpuload.h
Original file line number Diff line number Diff line change
@@ -0,0 +1,46 @@
#ifndef GPULOAD_H
#define GPULOAD_H

#include <vector>
#include <iostream>

namespace rmcommon {
/*!
* \class encapsulates GPU utilization information
*/
class GpuLoad {
/*! % Usage of each GPU */
std::vector<int> gpu_;

public:
void addGpuLoad(int load) {
gpu_.push_back(load);
}

int getGpuLoad(int idx) {
return gpu_[idx];
}


friend std::ostream &operator << (std::ostream &os, const GpuLoad &pt) {
bool first;
os << '{'
<< "\"gpus\":";
os << '[';
first = true;
for (const auto &gpu: pt.gpu_) {
if (first)
first = false;
else
os << ',';
os << gpu;
}
os << ']';
os << '}';
return os;
}
};

} // namespace rmcommon

#endif // GPULOAD_H
44 changes: 44 additions & 0 deletions rm/librmcommon/gpupower.h
Original file line number Diff line number Diff line change
@@ -0,0 +1,44 @@
#ifndef GPUPOWER_H
#define GPUPOWER_H

#include <iostream>

namespace rmcommon {
/*!
* \class encapsulates power information about the GPU
*/
class GpuPower {
/* Current power in mW */
std::vector<int> gpu_;
public:

void addGpuPower(int val) {
gpu_.push_back(val);
}

int getGpuPower(int index) {
return gpu_[index];
}

friend std::ostream &operator << (std::ostream &os, const GpuPower &pp) {
bool first;
os << '{'
<< "\"gpus\":";
os << '[';
first = true;
for (const auto &gpu: pp.gpu_) {
if (first)
first = false;
else
os << ',';
os << gpu;
}
os << ']';
os << '}';
return os;
}
};

} // namespace rmcommon

#endif // GPUPOWER_H
44 changes: 44 additions & 0 deletions rm/librmcommon/gputemperature.h
Original file line number Diff line number Diff line change
@@ -0,0 +1,44 @@
#ifndef GPUTEMPERATURE_H
#define GPUTEMPERATURE_H

#include <iostream>

namespace rmcommon {
/*!
* \class encapsulates temperature information about the GPU
*/
class GpuTemperature {
/* Current temperature in CELSIUS */
std::vector<int> gpu_;
public:

void addGpuTemperature(int val) {
gpu_.push_back(val);
}

int getGpuTemperature(int index) {
return gpu_[index];
}

friend std::ostream &operator << (std::ostream &os, const GpuTemperature &pp) {
bool first;
os << '{'
<< "\"gpus\":";
os << '[';
first = true;
for (const auto &gpu: pp.gpu_) {
if (first)
first = false;
else
os << ',';
os << gpu;
}
os << ']';
os << '}';
return os;
}
};

} // namespace rmcommon

#endif // GPUTEMPERATURE_H
13 changes: 13 additions & 0 deletions rm/nvidiamonitor/CMakeLists.txt
Original file line number Diff line number Diff line change
@@ -0,0 +1,13 @@
set(CMAKE_CXX_STANDARD 14)

find_package(CUDAToolkit REQUIRED)

file(GLOB nvidiamonitor_SOURCES "*.cpp")
file(GLOB nvidiamonitor_HEADERS "*.h")
add_library(nvidiamonitor
${nvidiamonitor_HEADERS}
${nvidiamonitor_SOURCES}
)

target_include_directories(nvidiamonitor INTERFACE .)
target_link_libraries(nvidiamonitor PUBLIC policymanager CUDA::nvml)
Loading