ACloudViewer  3.9.4
A Modern Library for 3D Data Processing
HardwareResources.cpp
Go to the documentation of this file.
1 // ----------------------------------------------------------------------------
2 // - CloudViewer: www.cloudViewer.org -
3 // ----------------------------------------------------------------------------
4 // Copyright (c) 2018-2024 www.cloudViewer.org
5 // SPDX-License-Identifier: MIT
6 // ----------------------------------------------------------------------------
7 
8 #include "CloudViewer.h"
9 
10 using namespace cloudViewer;
11 
12 int main(int argc, char **argv) {
13  // command-line parameters
15 
16  // print GPU Information
18 
19  // print CPU Information
20  system::MemoryInfo memoryInformation = system::getMemoryInfo();
21  utility::LogInfo("hardware.cpu.freq {}",
22  system::cpu_clock_by_os()); // cpu frequency
23  utility::LogInfo("hardware.cpu.cores {}",
24  system::get_total_cpus()); // cpu cores
25  utility::LogInfo("hardware.ram.size {}",
26  memoryInformation.totalRam); // ram size
27 
28  utility::LogInfo("Memory information:\n {}",
29  memoryInformation.toString().c_str());
30 
31  if (memoryInformation.availableRam == 0) {
33  "Cannot find available system memory, this can be due to OS "
34  "limitation.\n"
35  "Use only one thread for CPU feature extraction.");
36  } else {
37  const double oneGB = 1024.0 * 1024.0 * 1024.0;
38  if (memoryInformation.availableRam < 0.5 * memoryInformation.totalRam) {
40  "More than half of the RAM is used by other applications. "
41  "It would be more efficient to close them.");
43  " => {} GB are used by other applications for a total RAM "
44  "capacity of {} GB.",
45  std::size_t(
46  std::round(double(memoryInformation.totalRam -
47  memoryInformation.availableRam) /
48  oneGB)),
49  std::size_t(std::round(double(memoryInformation.totalRam) /
50  oneGB)));
51  }
52  }
53 
54  return 0;
55 }
int main(int argc, char **argv)
#define LogWarning(...)
Definition: Logging.h:72
#define LogInfo(...)
Definition: Logging.h:81
std::string gpuInformationCUDA()
gpuInformationCUDA
Definition: Gpu.cpp:73
int get_total_cpus()
Returns the total number of CPUs.
Definition: Cpu.cpp:133
int cpu_clock_by_os()
Returns the CPU clock, as reported by the OS.
Definition: Cpu.cpp:62
MemoryInfo getMemoryInfo()
Definition: MemoryInfo.cpp:63
void SetVerbosityLevel(VerbosityLevel level)
Definition: Logging.cpp:89
Generic file read and write utility for python interface.