mirror of https://github.com/pvnis/srsRAN_4G.git
You cannot select more than 25 topics
Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
69 lines
1.8 KiB
C
69 lines
1.8 KiB
C
4 years ago
|
/**
|
||
4 years ago
|
*
|
||
4 years ago
|
* \section COPYRIGHT
|
||
4 years ago
|
*
|
||
4 years ago
|
* Copyright 2013-2021 Software Radio Systems Limited
|
||
4 years ago
|
*
|
||
4 years ago
|
* By using this file, you agree to the terms and conditions set
|
||
|
* forth in the LICENSE file which can be found at the top level of
|
||
|
* the distribution.
|
||
4 years ago
|
*
|
||
|
*/
|
||
|
|
||
|
/**
|
||
|
* @file common_helper.h
|
||
4 years ago
|
* @brief Common helper functions shared among srsRAN applications.
|
||
4 years ago
|
*/
|
||
|
|
||
4 years ago
|
#ifndef SRSRAN_COMMON_HELPER_H
|
||
|
#define SRSRAN_COMMON_HELPER_H
|
||
4 years ago
|
|
||
4 years ago
|
#include "srsran/srslog/srslog.h"
|
||
4 years ago
|
#include <fstream>
|
||
4 years ago
|
#include <sstream>
|
||
4 years ago
|
#include <thread>
|
||
4 years ago
|
|
||
4 years ago
|
namespace srsran {
|
||
4 years ago
|
|
||
4 years ago
|
inline void log_args(int argc, char* argv[], const std::string& service)
|
||
4 years ago
|
{
|
||
|
std::ostringstream s1;
|
||
|
s1 << "Using binary " << argv[0] << " with arguments: ";
|
||
|
for (int32_t i = 1; i < argc; i++) {
|
||
|
s1 << argv[i] << " ";
|
||
|
}
|
||
|
|
||
4 years ago
|
srslog::fetch_basic_logger(service, false).set_level(srslog::basic_levels::info);
|
||
|
srslog::fetch_basic_logger(service).info("%s", s1.str().c_str());
|
||
4 years ago
|
}
|
||
|
|
||
4 years ago
|
inline void check_scaling_governor(const std::string& device_name)
|
||
|
{
|
||
|
if (device_name == "zmq") {
|
||
|
return;
|
||
|
}
|
||
4 years ago
|
int nof_cpus = std::thread::hardware_concurrency();
|
||
|
for (int cpu = 0; cpu < nof_cpus; ++cpu) {
|
||
|
char buffer[128];
|
||
|
snprintf(buffer, sizeof(buffer), "/sys/devices/system/cpu/cpu%d/cpufreq/scaling_governor", cpu);
|
||
|
std::ifstream file(buffer);
|
||
|
if (file.is_open()) {
|
||
|
std::stringstream ss;
|
||
|
ss << file.rdbuf();
|
||
|
if (ss.str().find("performance") == std::string::npos) {
|
||
|
printf(
|
||
|
"WARNING: cpu%d scaling governor is not set to performance mode. Realtime processing could be compromised. "
|
||
|
"Consider setting it to performance mode before running the application.\n",
|
||
|
cpu);
|
||
4 years ago
|
break;
|
||
|
}
|
||
4 years ago
|
} else {
|
||
|
printf("WARNING: Could not verify cpu%d scaling governor\n", cpu);
|
||
4 years ago
|
}
|
||
|
}
|
||
|
}
|
||
|
|
||
4 years ago
|
} // namespace srsran
|
||
4 years ago
|
|
||
4 years ago
|
#endif // SRSRAN_COMMON_HELPER_H
|