mirror of
https://github.com/fastogt/fastocloud.git
synced 2025-03-09 23:18:50 +00:00
Init FastoCloud on Github
This commit is contained in:
parent
d0d234101d
commit
d0d6551903
359 changed files with 32676 additions and 23 deletions
83
src/server/gpu_stats/perf_monitor.cpp
Normal file
83
src/server/gpu_stats/perf_monitor.cpp
Normal file
|
|
@ -0,0 +1,83 @@
|
|||
/* 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
|
||||
Loading…
Add table
Add a link
Reference in a new issue