1
0
Fork 0
mirror of https://github.com/fastogt/fastocloud.git synced 2025-03-09 23:18:50 +00:00
fastocloud/src/server/gpu_stats/perf_monitor.cpp
2023-01-21 05:21:27 +03:00

83 lines
2 KiB
C++

/* Copyright (C) 2014-2022 FastoGT. All right reserved.
This file is part of fastocloud.
fastocloud is free software: you can redistribute it and/or modify
it under the terms of the GNU General Public License as published by
the Free Software Foundation, either version 3 of the License, or
(at your option) any later version.
fastocloud is distributed in the hope that it will be useful,
but WITHOUT ANY WARRANTY; without even the implied warranty of
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
GNU General Public License for more details.
You should have received a copy of the GNU General Public License
along with fastocloud. If not, see <http://www.gnu.org/licenses/>.
*/
#include "server/gpu_stats/perf_monitor.h"
#include <common/macros.h>
#ifdef HAVE_NVML
#include "server/gpu_stats/nvidia_monitor.h"
#endif
#ifdef HAVE_CTT_METRICS
#include "server/gpu_stats/intel_monitor.h"
#endif
#define MAX_LEN 1024
namespace {
bool IsNvidiaGpuAvailable() {
#ifdef HAVE_NVML
return fastocloud::server::gpu_stats::NvidiaMonitor::IsGpuAvailable();
#else
return false;
#endif
}
bool IsIntelGpuAvailable() {
#ifdef HAVE_CTT_METRICS
return fastocloud::server::gpu_stats::IntelMonitor::IsGpuAvailable();
#else
return false;
#endif
}
} // namespace
namespace fastocloud {
namespace server {
namespace gpu_stats {
IPerfMonitor::~IPerfMonitor() {}
IPerfMonitor* CreateNvidiaPerfMonitor(double* load) {
#if !defined(HAVE_NVML) && !defined(HAVE_CTT_METRICS)
UNUSED(load);
#endif
if (IsNvidiaGpuAvailable()) {
#if defined(HAVE_NVML)
return new NvidiaMonitor(load);
#else
return nullptr;
#endif
}
return nullptr;
}
IPerfMonitor* CreateIntelPerfMonitor(double* load) {
#if !defined(HAVE_NVML) && !defined(HAVE_CTT_METRICS)
UNUSED(load);
#endif
if (IsIntelGpuAvailable()) {
#if defined(HAVE_CTT_METRICS)
return new IntelMonitor(load);
#else
return nullptr;
#endif
}
return nullptr;
}
} // namespace gpu_stats
} // namespace server
} // namespace fastocloud