From 77742d180cef36b86b2456c3fc5a7c49c41462c5 Mon Sep 17 00:00:00 2001 From: Neal Sidhwaney Date: Tue, 27 Sep 2022 19:21:29 -0700 Subject: [PATCH 1/2] Changes suggested by include-what-you-use This commit applies changes suggested by include-what-you-use. I did not apply all of them as there are some false positives/negatives and it did not recognize forward decls in some cases, and also tends to suggest headers that should not be included, such as files in the bits/ directory on Linux, but most changes have been applied. --- src/CMakeLists.txt | 2 ++ src/bw.cpp | 4 +++- src/bw.h | 9 ++++++-- src/client/client.cpp | 8 ++----- src/client/client.h | 6 +---- src/client/main.cpp | 2 ++ src/cpucounters.cpp | 23 +++++++++++++++++-- src/cpucounters.h | 47 +++++++++++++++++---------------------- src/daemon/daemon.cpp | 17 ++++++++++++-- src/daemon/daemon.h | 6 +++-- src/dashboard.cpp | 2 ++ src/mmio.cpp | 10 +++------ src/mmio.h | 8 ++----- src/msr.cpp | 11 ++++----- src/msr.h | 1 + src/pci.cpp | 9 +++++--- src/pci.h | 2 -- src/pcm-core.cpp | 10 ++++----- src/pcm-iio.cpp | 15 ++++++++++--- src/pcm-latency.cpp | 17 +++++++------- src/pcm-lspci.cpp | 5 +++-- src/pcm-memory.cpp | 10 ++++----- src/pcm-mmio.cpp | 14 +++++++----- src/pcm-msr.cpp | 15 ++++++++----- src/pcm-numa.cpp | 17 +++++++------- src/pcm-pcicfg.cpp | 14 +++++++----- src/pcm-pcie.cpp | 7 ------ src/pcm-pcie.h | 6 +++++ src/pcm-power.cpp | 18 +++++++++++---- src/pcm-raw.cpp | 36 +++++++++++++++++------------- src/pcm-sensor-server.cpp | 27 +++++++++++++++++++--- src/pcm-sensor.cpp | 4 +++- src/pcm-tsx.cpp | 10 ++++----- src/pcm.cpp | 10 +++++---- src/resctrl.cpp | 12 ++++++++-- src/resctrl.h | 7 +++--- src/threadpool.h | 5 +++-- src/topology.cpp | 3 ++- src/topology.h | 28 +++++++++++++++-------- src/utils.cpp | 10 ++++++++- src/utils.h | 22 +++++++++++++----- tests/urltest.cpp | 4 ++++ 42 files changed, 309 insertions(+), 184 deletions(-) diff --git a/src/CMakeLists.txt b/src/CMakeLists.txt index 87ab9aa5..537b27ae 100644 --- a/src/CMakeLists.txt +++ b/src/CMakeLists.txt @@ -168,12 +168,14 @@ if(UNIX) # APPLE, LINUX, FREE_BSD # Daemon & client file(GLOB DAEMON_SOURCES "daemon/*.cpp") add_executable(daemon ${DAEMON_SOURCES}) + target_include_directories(daemon PRIVATE ${CMAKE_CURRENT_SOURCE_DIR}) target_link_libraries(daemon PRIVATE PCM_STATIC Threads::Threads) set_target_properties(daemon PROPERTIES OUTPUT_NAME "pcm-daemon") install(TARGETS daemon DESTINATION ${CMAKE_INSTALL_SBINDIR}) file(GLOB CLIENT_SOURCES "client/*.cpp") add_executable(client ${CLIENT_SOURCES}) + target_include_directories(client PRIVATE ${CMAKE_CURRENT_SOURCE_DIR}) target_link_libraries(client PRIVATE Threads::Threads) set_target_properties(client PROPERTIES OUTPUT_NAME "pcm-client") install(TARGETS client DESTINATION ${CMAKE_INSTALL_BINDIR}) diff --git a/src/bw.cpp b/src/bw.cpp index 09779df1..87508b25 100644 --- a/src/bw.cpp +++ b/src/bw.cpp @@ -5,6 +5,8 @@ // #include +#include +#include "mmio.h" #include "bw.h" #include "pci.h" #include "utils.h" @@ -179,4 +181,4 @@ uint64 ServerBW::getPMMWrites() return result; } -} // namespace pcm \ No newline at end of file +} // namespace pcm diff --git a/src/bw.h b/src/bw.h index 79dfaad6..36d28ec5 100644 --- a/src/bw.h +++ b/src/bw.h @@ -13,7 +13,12 @@ #include #include #include -#include "mmio.h" +#include +#include "types.h" + +namespace pcm { + class MMIORange; +} namespace pcm { @@ -70,4 +75,4 @@ class ServerBW uint64 getPMMWrites(); }; -} // namespace pcm \ No newline at end of file +} // namespace pcm diff --git a/src/client/client.cpp b/src/client/client.cpp index cff9ac67..d49bc38e 100644 --- a/src/client/client.cpp +++ b/src/client/client.cpp @@ -2,19 +2,15 @@ // Copyright (c) 2009-2017, Intel Corporation // written by Steven Briscoe -#include #include #include -#include -#include #include #include -#include -#include #include -#include #include #include +#include +#include #include "../daemon/common.h" #include "client.h" diff --git a/src/client/client.h b/src/client/client.h index 89b7220d..c387141e 100644 --- a/src/client/client.h +++ b/src/client/client.h @@ -2,16 +2,12 @@ // Copyright (c) 2009-2017, Intel Corporation // written by Steven Briscoe -#include #include -#include - +#include "../daemon/common.h" #ifndef CLIENT_H_ #define CLIENT_H_ -#include "../daemon/common.h" - namespace PCMDaemon { class Client { diff --git a/src/client/main.cpp b/src/client/main.cpp index 01e49b73..05d1a4d8 100644 --- a/src/client/main.cpp +++ b/src/client/main.cpp @@ -7,6 +7,8 @@ #include #include #include +#include +#include "daemon/common.h" #include "client.h" diff --git a/src/cpucounters.cpp b/src/cpucounters.cpp index 806b0116..c576dc81 100644 --- a/src/cpucounters.cpp +++ b/src/cpucounters.cpp @@ -46,7 +46,9 @@ #include "winring0/OlsApiInit.h" #include "windows/windriver.h" #else +#include #include +#include #if defined(__FreeBSD__) || (defined(__DragonFly__) && __DragonFly_version >= 400707) #include #include @@ -58,20 +60,37 @@ #include #include #include +#include + +#ifdef PCM_USE_PERF +#include +#include +#endif + #endif #endif #include -#include #include #include #include #include -#include #include #include #include #include +#include +#include +#include +#include +#include +#include +#include +#include +#include "bw.h" +#include "exceptions/unsupported_processor_exception.hpp" +#include "mutex.h" +#include "width_extender.h" #ifdef __APPLE__ #include diff --git a/src/cpucounters.h b/src/cpucounters.h index 25ead6e8..85d862cf 100644 --- a/src/cpucounters.h +++ b/src/cpucounters.h @@ -26,13 +26,9 @@ #include "topologyentry.h" #include "msr.h" #include "pci.h" -#include "bw.h" -#include "width_extender.h" -#include "exceptions/unsupported_processor_exception.hpp" #include #include -#include #include #include #include @@ -40,22 +36,19 @@ #include #include +#include +#include +#include +#include +#include +#include "mmio.h" +#include "utils.h" +#include "width_extender.h" + #ifdef PCM_USE_PERF -#include -#include #define PCM_PERF_COUNT_HW_REF_CPU_CYCLES (9) #endif -#ifndef _MSC_VER -#define NOMINMAX -#include -#include -#include -#include -#include -#include -#endif - #ifdef _MSC_VER #if _MSC_VER>= 1600 #include @@ -66,20 +59,24 @@ #include "resctrl.h" #endif +namespace pcm { + class FreeRunningBWCounters; + class ServerBW; + class SystemCounterState; + class SocketCounterState; + class CoreCounterState; + class ServerUncoreCounterState; + class PCM; + class CoreTaskQueue; + class SystemRoot; +} + namespace pcm { #ifdef _MSC_VER void PCM_API restrictDriverAccess(LPCTSTR path); #endif -class SystemCounterState; -class SocketCounterState; -class CoreCounterState; -class BasicCounterState; -class ServerUncoreCounterState; -class PCM; -class CoreTaskQueue; -class SystemRoot; /* CPU performance monitoring routines @@ -503,8 +500,6 @@ typedef SimpleCounterState PCIeCounterState; typedef SimpleCounterState IIOCounterState; typedef std::vector eventGroup_t; -class PerfVirtualControlRegister; - /*! \brief CPU Performance Monitor diff --git a/src/daemon/daemon.cpp b/src/daemon/daemon.cpp index 4f8395e3..96b923d7 100644 --- a/src/daemon/daemon.cpp +++ b/src/daemon/daemon.cpp @@ -4,7 +4,6 @@ #include #include -#include #include #include #include @@ -12,6 +11,20 @@ #include #include #include +#include +#include +#include +#include +#include +#include +#include +#include +#include "types.h" +#include "utils.h" + +#ifdef __linux__ +#include +#endif #ifndef CLOCK_MONOTONIC_RAW #define CLOCK_MONOTONIC_RAW (4) /* needed for SLES11 */ @@ -19,7 +32,7 @@ #include "daemon.h" #include "common.h" -#include "pcm.h" +#include "exceptions/unsupported_processor_exception.hpp" namespace PCMDaemon { diff --git a/src/daemon/daemon.h b/src/daemon/daemon.h index 3718282b..129c51c2 100644 --- a/src/daemon/daemon.h +++ b/src/daemon/daemon.h @@ -8,10 +8,12 @@ #include #include #include -#include #include "common.h" -#include "pcm.h" +#include +#include "cpucounters.h" + +using namespace pcm; namespace PCMDaemon { diff --git a/src/dashboard.cpp b/src/dashboard.cpp index fe4fc5e1..ba839291 100644 --- a/src/dashboard.cpp +++ b/src/dashboard.cpp @@ -4,6 +4,8 @@ #include #include #include +#include +#include #include "cpucounters.h" #include "dashboard.h" diff --git a/src/mmio.cpp b/src/mmio.cpp index 6ffd2f36..a8575605 100644 --- a/src/mmio.cpp +++ b/src/mmio.cpp @@ -6,12 +6,8 @@ #include #include -#ifndef _MSC_VER -#include -#endif -#include +#include #include -#include "pci.h" #include "mmio.h" #ifndef _MSC_VER @@ -22,10 +18,10 @@ #ifdef _MSC_VER #include #include "utils.h" +#else +#include #endif -#include - namespace pcm { #ifdef _MSC_VER diff --git a/src/mmio.h b/src/mmio.h index a71e028c..9e0ab359 100644 --- a/src/mmio.h +++ b/src/mmio.h @@ -17,12 +17,8 @@ #include "windows.h" #include "winpmem\winpmem.h" #include "Winmsrdriver\msrstruct.h" -#else -#include -#endif - #include "mutex.h" -#include +#endif namespace pcm { @@ -152,4 +148,4 @@ class MMIORange }; #endif -} // namespace pcm \ No newline at end of file +} // namespace pcm diff --git a/src/msr.cpp b/src/msr.cpp index 218863a8..c846beba 100644 --- a/src/msr.cpp +++ b/src/msr.cpp @@ -4,9 +4,7 @@ // Austen Ott // Jim Harris (FreeBSD) -#include #include -#include #include #ifndef _MSC_VER #include @@ -14,7 +12,12 @@ #include "types.h" #include "msr.h" #include "utils.h" -#include + +#include +#include +#include +#include +#include #ifdef _MSC_VER @@ -30,8 +33,6 @@ #include #endif -#include - namespace pcm { #ifdef _MSC_VER diff --git a/src/msr.h b/src/msr.h index d938d20c..4af522e8 100644 --- a/src/msr.h +++ b/src/msr.h @@ -13,6 +13,7 @@ */ #include "types.h" +#include #ifdef _MSC_VER #include "windows.h" diff --git a/src/pci.cpp b/src/pci.cpp index d8977c3f..dde26a6f 100644 --- a/src/pci.cpp +++ b/src/pci.cpp @@ -8,15 +8,18 @@ #include #include #include -#include -#include #include +#include +#include +#include +#include + #include "pci.h" #ifndef _MSC_VER #include #include -#include +#include #endif #ifdef _MSC_VER diff --git a/src/pci.h b/src/pci.h index ea9599ee..76f8bca5 100644 --- a/src/pci.h +++ b/src/pci.h @@ -17,8 +17,6 @@ #ifdef _MSC_VER #include "windows.h" -#else -#include #endif #ifdef __APPLE__ diff --git a/src/pcm-core.cpp b/src/pcm-core.cpp index 1aab41f5..b0495034 100644 --- a/src/pcm-core.cpp +++ b/src/pcm-core.cpp @@ -11,21 +11,19 @@ #define strtok_r strtok_s #include #include "windows/windriver.h" -#else -#include -#include -#include // for gettimeofday() #endif -#include #include #include #include #include #include -#include #include #include "cpucounters.h" #include "utils.h" +#include +#include +#include "types.h" + #ifdef _MSC_VER #include "freegetopt/getopt.h" #endif diff --git a/src/pcm-iio.cpp b/src/pcm-iio.cpp index 7a34d16e..e847d99d 100644 --- a/src/pcm-iio.cpp +++ b/src/pcm-iio.cpp @@ -8,11 +8,8 @@ #pragma warning(disable : 4996) // for sprintf #include #include "windows/windriver.h" -#else -#include #endif #include -#include #include #include // std::length_error #include @@ -22,6 +19,18 @@ #include "freegetopt/getopt.h" #endif +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include "pci.h" +#include "types.h" +#include "version.h" #include "lspci.h" #include "utils.h" using namespace std; diff --git a/src/pcm-latency.cpp b/src/pcm-latency.cpp index 95ce3b1f..d2010f14 100644 --- a/src/pcm-latency.cpp +++ b/src/pcm-latency.cpp @@ -7,22 +7,23 @@ #pragma warning(disable : 4996) // for sprintf #include #include "windows/windriver.h" -#else -#include #endif -#include #include #include -#include -#include -#include -#include #ifdef _MSC_VER #include "freegetopt/getopt.h" #endif -#include "lspci.h" #include "utils.h" +#include +#include +#include +#include +#include +#include +#include "types.h" +#include "version.h" + using namespace std; using namespace pcm; diff --git a/src/pcm-lspci.cpp b/src/pcm-lspci.cpp index 591f5f3e..9b02e28b 100644 --- a/src/pcm-lspci.cpp +++ b/src/pcm-lspci.cpp @@ -7,8 +7,6 @@ #pragma warning(disable : 4996) // for sprintf #include #include "windows/windriver.h" -#else -#include #endif #include #include @@ -17,6 +15,9 @@ #include "freegetopt/getopt.h" #endif +#include +#include "pci.h" +#include "types.h" #include "lspci.h" using namespace std; using namespace pcm; diff --git a/src/pcm-memory.cpp b/src/pcm-memory.cpp index 165bee0b..a18fed98 100644 --- a/src/pcm-memory.cpp +++ b/src/pcm-memory.cpp @@ -11,20 +11,18 @@ #ifdef _MSC_VER #include #include "windows/windriver.h" -#else -#include -#include -#include // for gettimeofday() #endif -#include #include #include #include #include #include -#include #include "cpucounters.h" #include "utils.h" +#include +#include +#include "types.h" +#include "version.h" #define PCM_DELAY_DEFAULT 1.0 // in seconds #define PCM_DELAY_MIN 0.015 // 15 milliseconds is practical on most modern CPUs diff --git a/src/pcm-mmio.cpp b/src/pcm-mmio.cpp index 77c22d01..c7f9a7ea 100644 --- a/src/pcm-mmio.cpp +++ b/src/pcm-mmio.cpp @@ -2,21 +2,23 @@ // Copyright (c) 2012-2020, Intel Corporation // written by Roman Dementiev -#include "cpucounters.h" #ifdef _MSC_VER #include #include "windows/windriver.h" -#else -#include #endif #include #include -#include -#include -#include #ifdef _MSC_VER #include "freegetopt/getopt.h" #endif +#ifdef __linux__ +#include +#endif +#include +#include "mmio.h" +#include "types.h" +#include "utils.h" +#include "version.h" using namespace pcm; diff --git a/src/pcm-msr.cpp b/src/pcm-msr.cpp index 20039a9a..d85d1989 100644 --- a/src/pcm-msr.cpp +++ b/src/pcm-msr.cpp @@ -6,13 +6,18 @@ #ifdef _MSC_VER #include #include "windows/windriver.h" -#else -#include #endif #include -#include -#include -#include + +#ifdef __linux__ +#include +#endif +#include +#include "msr.h" +#include "types.h" +#include "utils.h" +#include "version.h" + #ifdef _MSC_VER #include "freegetopt/getopt.h" #endif diff --git a/src/pcm-numa.cpp b/src/pcm-numa.cpp index 77dc40df..f438aa2f 100644 --- a/src/pcm-numa.cpp +++ b/src/pcm-numa.cpp @@ -10,23 +10,22 @@ #ifdef _MSC_VER #include #include "windows/windriver.h" -#else -#include -#include -#include // for gettimeofday() +#include "freegetopt/getopt.h" #endif -#include #include #include #include #include #include -#include #include "cpucounters.h" #include "utils.h" -#ifdef _MSC_VER -#include "freegetopt/getopt.h" -#endif +#include +#include +#include +#include "types.h" +#include "version.h" +#include +#include "exceptions/unsupported_processor_exception.hpp" #include #define PCM_DELAY_DEFAULT 1.0 // in seconds diff --git a/src/pcm-pcicfg.cpp b/src/pcm-pcicfg.cpp index 404d1373..40a3197f 100644 --- a/src/pcm-pcicfg.cpp +++ b/src/pcm-pcicfg.cpp @@ -2,20 +2,22 @@ // Copyright (c) 2012, 2018 Intel Corporation // written by Roman Dementiev -#include "cpucounters.h" #ifdef _MSC_VER #include #include "windows/windriver.h" -#else -#include #endif #include -#include -#include -#include #ifdef _MSC_VER #include "freegetopt/getopt.h" #endif +#ifdef __linux__ +#include +#endif +#include +#include "pci.h" +#include "types.h" +#include "utils.h" +#include "version.h" using namespace pcm; diff --git a/src/pcm-pcie.cpp b/src/pcm-pcie.cpp index 90e06267..48a138df 100644 --- a/src/pcm-pcie.cpp +++ b/src/pcm-pcie.cpp @@ -10,17 +10,10 @@ #ifdef _MSC_VER #include #include "windows/windriver.h" -#else -#include -#include #endif -#include -#include #include #include -#include #include -#include #include "pcm-pcie.h" #define PCM_DELAY_DEFAULT 1.0 // in seconds diff --git a/src/pcm-pcie.h b/src/pcm-pcie.h index 91930c0f..4c4f0f93 100644 --- a/src/pcm-pcie.h +++ b/src/pcm-pcie.h @@ -11,6 +11,12 @@ #include #include #include +#include +#include +#include +#include +#include +#include "types.h" #if defined(_MSC_VER) typedef unsigned int uint; diff --git a/src/pcm-power.cpp b/src/pcm-power.cpp index 6f8177a8..04980845 100644 --- a/src/pcm-power.cpp +++ b/src/pcm-power.cpp @@ -8,10 +8,6 @@ #ifdef _MSC_VER #include #include "windows/windriver.h" -#else -#include -#include -#include // for gettimeofday() #endif #include #include @@ -20,6 +16,20 @@ #include "freegetopt/getopt.h" #endif #include "utils.h" +#include +#include +#include "types.h" +#include +#include +#include +#include +#include +#include "types.h" +#include "version.h" + +#ifdef __linux__ +#include +#endif #define PCM_DELAY_DEFAULT 1.0 // in seconds #define PCM_DELAY_MIN 0.015 // 15 milliseconds is practical on most modern CPUs diff --git a/src/pcm-raw.cpp b/src/pcm-raw.cpp index 97fce9e1..96801e60 100644 --- a/src/pcm-raw.cpp +++ b/src/pcm-raw.cpp @@ -9,33 +9,39 @@ #define strtok_r strtok_s #include #include "windows/windriver.h" -#else -#include -#include -#include // for gettimeofday() +#include "freegetopt/getopt.h" #endif -#include -#include -#include -#include -#include -#include + #include +#include +#include +#include +#include +#include #include +#include +#include +#include +#include +#include +#include +#include #include +#include +#include +#include +#include #include +#include +#include #include "cpucounters.h" +#include "types.h" #include "utils.h" #if PCM_SIMDJSON_AVAILABLE #include "simdjson.h" #endif -#ifdef _MSC_VER -#include "freegetopt/getopt.h" -#endif - -#include #define PCM_DELAY_MIN 0.015 // 15 milliseconds is practical on most modern CPUs #define MAX_CORES 4096 diff --git a/src/pcm-sensor-server.cpp b/src/pcm-sensor-server.cpp index c9523083..f03fac7a 100644 --- a/src/pcm-sensor-server.cpp +++ b/src/pcm-sensor-server.cpp @@ -6,27 +6,48 @@ constexpr unsigned int DEFAULT_HTTP_PORT = 9738; constexpr unsigned int DEFAULT_HTTPS_PORT = DEFAULT_HTTP_PORT; -#include #include #include #include #include -#include #include #include #include #include #include -#include #include #include #include +#include #include "cpucounters.h" #include "debug.h" #include "topology.h" #include "dashboard.h" +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include "types.h" +#include "utils.h" #define PCMWebServerVersion "0.1" #if defined (USE_SSL) diff --git a/src/pcm-sensor.cpp b/src/pcm-sensor.cpp index 2e3a25b3..82013788 100644 --- a/src/pcm-sensor.cpp +++ b/src/pcm-sensor.cpp @@ -14,9 +14,11 @@ */ #include #include -#include #include "cpuasynchcounter.h" #include "utils.h" +#include "cpucounters.h" +#include "types.h" +#include "version.h" using namespace std; using namespace pcm; diff --git a/src/pcm-tsx.cpp b/src/pcm-tsx.cpp index ecd7ebfd..c5cd37db 100644 --- a/src/pcm-tsx.cpp +++ b/src/pcm-tsx.cpp @@ -10,18 +10,12 @@ #ifdef _MSC_VER #include #include "windows/windriver.h" -#else -#include -#include -#include // for gettimeofday() #endif -#include #include #include #include #include #include -#include #include "cpucounters.h" #include "utils.h" #ifdef _MSC_VER @@ -29,6 +23,10 @@ #endif #include +#include +#include +#include "types.h" + #define PCM_DELAY_DEFAULT 1.0 // in seconds #define PCM_DELAY_MIN 0.015 // 15 milliseconds is practical on most modern CPUs diff --git a/src/pcm.cpp b/src/pcm.cpp index 42433e94..79558b59 100644 --- a/src/pcm.cpp +++ b/src/pcm.cpp @@ -14,20 +14,22 @@ #include "windows/windriver.h" #else #include -#include // for atexit() -#include // for gettimeofday() #endif -#include #include #include #include #include #include #include -#include #include +#include +#include +#include +#include #include "cpucounters.h" #include "utils.h" +#include "types.h" +#include "version.h" #define SIZE (10000000) #define PCM_DELAY_DEFAULT 1.0 // in seconds diff --git a/src/resctrl.cpp b/src/resctrl.cpp index d52d99aa..56ac05e2 100644 --- a/src/resctrl.cpp +++ b/src/resctrl.cpp @@ -7,10 +7,18 @@ #include "resctrl.h" #include "cpucounters.h" #include -#include #include #include -#include +#include +#include +#include +#include +#include +#include +#include +#include +#include "types.h" +#include "utils.h" namespace pcm { diff --git a/src/resctrl.h b/src/resctrl.h index e389a568..50b3d926 100644 --- a/src/resctrl.h +++ b/src/resctrl.h @@ -10,17 +10,18 @@ #ifdef __linux__ -#include #include #include #include -#include -#include +#include namespace pcm { class PCM; +} +namespace pcm +{ class Resctrl { PCM & pcm; diff --git a/src/threadpool.h b/src/threadpool.h index 224c9e86..3b204d9e 100644 --- a/src/threadpool.h +++ b/src/threadpool.h @@ -11,6 +11,9 @@ #include #include #include +#include +#include +#include namespace pcm { @@ -42,8 +45,6 @@ class LambdaJob : public Work { std::packaged_task task_; }; -class WorkQueue; - class ThreadPool { private: ThreadPool( const int n ) { diff --git a/src/topology.cpp b/src/topology.cpp index 3993efeb..cb309e44 100644 --- a/src/topology.cpp +++ b/src/topology.cpp @@ -1,6 +1,7 @@ // SPDX-License-Identifier: BSD-3-Clause // Copyright (c) 2016-2020, Intel Corporation +#include #include "cpucounters.h" #include "topology.h" @@ -99,4 +100,4 @@ Aggregator::Aggregator() ucsFutures_.resize( pcm->getNumSockets() ); } -}// namespace pcm \ No newline at end of file +}// namespace pcm diff --git a/src/topology.h b/src/topology.h index 1864770e..36e201e3 100644 --- a/src/topology.h +++ b/src/topology.h @@ -11,18 +11,28 @@ #include "types.h" #include "cpucounters.h" #include "threadpool.h" +#include +#include +#include +#include +#include +#include +#include "debug.h" +// all can be done with forwards, anything hat actually uses PCM should be put in the topology.cpp file namespace pcm { + class SafeMsrHandle; + class PCM; + class SystemRoot; + class Socket; + class Core; + class HyperThread; + class ServerUncore; + class ClientUncore; -// all can be done with forwards, anything hat actually uses PCM should be put in the topology.cpp file -class PCM; - -class SystemRoot; -class Socket; -class Core; -class HyperThread; -class ServerUncore; -class ClientUncore; +} + +namespace pcm { class Visitor { public: diff --git a/src/utils.cpp b/src/utils.cpp index 329cbe23..1284f32c 100644 --- a/src/utils.cpp +++ b/src/utils.cpp @@ -3,7 +3,6 @@ // written by Andrey Semin and many others #include -#include #include #ifdef _MSC_VER #include @@ -11,7 +10,16 @@ #else #include // for waitpid() #include // for ::sleep +#include #endif + + +#include +#include +#include +#include +#include + #include "utils.h" #include "cpucounters.h" diff --git a/src/utils.h b/src/utils.h index bb2ac728..5f7c4a40 100644 --- a/src/utils.h +++ b/src/utils.h @@ -10,23 +10,34 @@ #pragma once #include -#include -#include -#include #include "types.h" #include #include #include #include +#include +#include +#include +#include +#include +#include +#include + +#ifdef __linux__ +#include +#endif #ifndef _MSC_VER -#include #include -#include +#include #else #include #endif +namespace pcm { + class PCM; +} + namespace pcm { #ifdef _MSC_VER @@ -313,7 +324,6 @@ inline void printDateForJson(const std::string& separator, const std::string &js std::vector split(const std::string & str, const char delim); -class PCM; bool CheckAndForceRTMAbortMode(const char * argv, PCM * m); void print_help_force_rtm_abort_mode(const int alignment); diff --git a/tests/urltest.cpp b/tests/urltest.cpp index fb843d99..f4b80fd6 100644 --- a/tests/urltest.cpp +++ b/tests/urltest.cpp @@ -1,6 +1,10 @@ #define UNIT_TEST 1 #include "../src/pcm-sensor-server.cpp" +#include +#include +#include +#include #undef UNIT_TEST From be07836b5567cce2c0bfb3cebebc6b6a861ff945 Mon Sep 17 00:00:00 2001 From: Neal Sidhwaney Date: Fri, 30 Sep 2022 14:03:54 -0700 Subject: [PATCH 2/2] Reorganize #include statements This commit applies a few cleanups to the #include sections: - Remove old version checks for Visual Studio, SUSE Linux, and DragonFly BSD - Alphabetize the includes - Consolidate multiple MSC_VER checks in the same file --- src/bw.cpp | 5 +- src/bw.h | 5 +- src/client/client.cpp | 8 +-- src/client/client.h | 1 + src/client/main.cpp | 6 +-- src/cpucounters.cpp | 106 +++++++++++++++++++++----------------- src/cpucounters.h | 26 ++++------ src/daemon/common.h | 1 + src/daemon/daemon.cpp | 34 ++++++------ src/daemon/daemon.h | 8 +-- src/dashboard.cpp | 11 ++-- src/mmio.cpp | 14 +++-- src/mmio.h | 4 +- src/msr.cpp | 21 ++++---- src/msr.h | 12 +++-- src/mutex.h | 1 + src/pci.cpp | 19 +++---- src/pci.h | 4 +- src/pcm-core.cpp | 26 +++++----- src/pcm-iio.cpp | 40 +++++++------- src/pcm-latency.cpp | 25 +++++---- src/pcm-lspci.cpp | 19 +++---- src/pcm-memory.cpp | 24 +++++---- src/pcm-mmio.cpp | 22 ++++---- src/pcm-msr.cpp | 20 +++---- src/pcm-numa.cpp | 33 ++++++------ src/pcm-pcicfg.cpp | 22 ++++---- src/pcm-pcie.cpp | 11 ++-- src/pcm-pcie.h | 15 +++--- src/pcm-power.cpp | 30 +++++------ src/pcm-raw.cpp | 31 +++++------ src/pcm-sensor-server.cpp | 43 +++++++--------- src/pcm-sensor.cpp | 7 +-- src/pcm-tsx.cpp | 24 ++++----- src/pcm.cpp | 32 ++++++------ src/resctrl.cpp | 19 +++---- src/resctrl.h | 2 +- src/threadpool.h | 8 +-- src/topology.cpp | 3 +- src/utils.cpp | 21 ++++---- src/utils.h | 13 ++--- tests/urltest.cpp | 5 +- 42 files changed, 400 insertions(+), 381 deletions(-) diff --git a/src/bw.cpp b/src/bw.cpp index 87508b25..9b36a608 100644 --- a/src/bw.cpp +++ b/src/bw.cpp @@ -4,10 +4,11 @@ // Patrick Konsor // -#include #include -#include "mmio.h" +#include + #include "bw.h" +#include "mmio.h" #include "pci.h" #include "utils.h" diff --git a/src/bw.h b/src/bw.h index 36d28ec5..a6bb9f47 100644 --- a/src/bw.h +++ b/src/bw.h @@ -10,10 +10,11 @@ */ -#include -#include #include +#include #include +#include + #include "types.h" namespace pcm { diff --git a/src/client/client.cpp b/src/client/client.cpp index d49bc38e..63e1c35d 100644 --- a/src/client/client.cpp +++ b/src/client/client.cpp @@ -2,15 +2,15 @@ // Copyright (c) 2009-2017, Intel Corporation // written by Steven Briscoe -#include -#include -#include #include +#include +#include #include #include #include #include -#include +#include +#include #include "../daemon/common.h" #include "client.h" diff --git a/src/client/client.h b/src/client/client.h index c387141e..3bbf0d11 100644 --- a/src/client/client.h +++ b/src/client/client.h @@ -3,6 +3,7 @@ // written by Steven Briscoe #include + #include "../daemon/common.h" #ifndef CLIENT_H_ diff --git a/src/client/main.cpp b/src/client/main.cpp index 05d1a4d8..72f93510 100644 --- a/src/client/main.cpp +++ b/src/client/main.cpp @@ -4,12 +4,12 @@ //Test program for PCM Daemon client -#include -#include #include +#include +#include #include -#include "daemon/common.h" +#include "daemon/common.h" #include "client.h" void printTitle(std::string title) diff --git a/src/cpucounters.cpp b/src/cpucounters.cpp index c576dc81..3c1240cb 100644 --- a/src/cpucounters.cpp +++ b/src/cpucounters.cpp @@ -13,89 +13,99 @@ //#define PCM_TEST_FALLBACK_TO_ATOM -#include -#include #ifdef PCM_EXPORTS -// pcm-lib.h includes cpucounters.h #include "windows\pcm-lib.h" -#else -#include "cpucounters.h" #endif + +#include "bw.h" +#include "cpucounters.h" +#include "exceptions/unsupported_processor_exception.hpp" #include "msr.h" +#include "mutex.h" #include "pci.h" +#include "topology.h" #include "types.h" #include "utils.h" -#include "topology.h" +#include "width_extender.h" -#if defined (__FreeBSD__) || defined(__DragonFly__) -#include -#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include #include -#include -#include -#include -#include -#include -#endif +#include #ifdef _MSC_VER -#include -#include + #include +#include #include -#include "winring0/OlsApiInit.h" +#include #include "windows/windriver.h" +#include "winring0/OlsApiInit.h" + #else + #include #include #include -#if defined(__FreeBSD__) || (defined(__DragonFly__) && __DragonFly_version >= 400707) -#include -#include -#include -#endif + #include #include + +#endif + #ifdef __linux__ + #include #include #include #include +#endif + #ifdef PCM_USE_PERF + #include #include -#endif #endif -#endif - -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include "bw.h" -#include "exceptions/unsupported_processor_exception.hpp" -#include "mutex.h" -#include "width_extender.h" #ifdef __APPLE__ -#include + +#include #include +#include + +#endif + +#if defined (__FreeBSD__) || defined(__DragonFly__) + +#include +#include +#include +#include +#include +#include +#include +#include #include +#include +#include + #endif namespace pcm { diff --git a/src/cpucounters.h b/src/cpucounters.h index 85d862cf..cd665c54 100644 --- a/src/cpucounters.h +++ b/src/cpucounters.h @@ -22,42 +22,36 @@ #undef PCM_DEBUG_TOPOLOGY // debug of topology enumeration routine #undef PCM_UNCORE_PMON_BOX_CHECK_STATUS // debug only -#include "types.h" -#include "topologyentry.h" #include "msr.h" #include "pci.h" +#include "types.h" +#include "topologyentry.h" -#include +#include #include -#include -#include -#include -#include -#include #include - -#include #include #include +#include +#include +#include +#include +#include #include #include +#include + #include "mmio.h" #include "utils.h" #include "width_extender.h" -#ifdef PCM_USE_PERF #define PCM_PERF_COUNT_HW_REF_CPU_CYCLES (9) -#endif #ifdef _MSC_VER -#if _MSC_VER>= 1600 #include #endif -#endif -#ifdef __linux__ #include "resctrl.h" -#endif namespace pcm { class FreeRunningBWCounters; diff --git a/src/daemon/common.h b/src/daemon/common.h index 0255e339..1cd0b720 100644 --- a/src/daemon/common.h +++ b/src/daemon/common.h @@ -5,6 +5,7 @@ #ifndef COMMON_H_ #define COMMON_H_ +#include #include #include diff --git a/src/daemon/daemon.cpp b/src/daemon/daemon.cpp index 96b923d7..edef6027 100644 --- a/src/daemon/daemon.cpp +++ b/src/daemon/daemon.cpp @@ -2,38 +2,34 @@ // Copyright (c) 2009-2018,2022 Intel Corporation // written by Steven Briscoe -#include -#include +#include "common.h" +#include "daemon.h" +#include "exceptions/unsupported_processor_exception.hpp" +#include "types.h" +#include "utils.h" + #include -#include -#include -#include -#include -#include -#include #include #include +#include #include +#include #include -#include +#include #include #include +#include +#include +#include +#include +#include +#include #include -#include "types.h" -#include "utils.h" #ifdef __linux__ #include #endif -#ifndef CLOCK_MONOTONIC_RAW -#define CLOCK_MONOTONIC_RAW (4) /* needed for SLES11 */ -#endif - -#include "daemon.h" -#include "common.h" -#include "exceptions/unsupported_processor_exception.hpp" - namespace PCMDaemon { std::string Daemon::shmIdLocation_; diff --git a/src/daemon/daemon.h b/src/daemon/daemon.h index 129c51c2..375a59cb 100644 --- a/src/daemon/daemon.h +++ b/src/daemon/daemon.h @@ -5,13 +5,13 @@ #ifndef DAEMON_H_ #define DAEMON_H_ +#include "common.h" +#include "cpucounters.h" + +#include #include #include -#include - -#include "common.h" #include -#include "cpucounters.h" using namespace pcm; diff --git a/src/dashboard.cpp b/src/dashboard.cpp index ba839291..dccb065d 100644 --- a/src/dashboard.cpp +++ b/src/dashboard.cpp @@ -1,14 +1,15 @@ // SPDX-License-Identifier: BSD-3-Clause // Copyright (c) 2020, Intel Corporation -#include -#include -#include -#include -#include #include "cpucounters.h" #include "dashboard.h" +#include +#include +#include +#include +#include + namespace pcm { class Target diff --git a/src/mmio.cpp b/src/mmio.cpp index a8575605..bdf27c3c 100644 --- a/src/mmio.cpp +++ b/src/mmio.cpp @@ -4,21 +4,19 @@ // Patrick Konsor // -#include -#include #include #include -#include "mmio.h" +#include +#include -#ifndef _MSC_VER -#include -#include -#endif +#include "mmio.h" +#include "utils.h" #ifdef _MSC_VER #include -#include "utils.h" #else +#include +#include #include #endif diff --git a/src/mmio.h b/src/mmio.h index 9e0ab359..5bb10164 100644 --- a/src/mmio.h +++ b/src/mmio.h @@ -14,10 +14,10 @@ #include "types.h" #ifdef _MSC_VER +#include "mutex.h" #include "windows.h" +#include "winmsrdriver\msrstruct.h" #include "winpmem\winpmem.h" -#include "Winmsrdriver\msrstruct.h" -#include "mutex.h" #endif namespace pcm { diff --git a/src/msr.cpp b/src/msr.cpp index c846beba..2bee2e38 100644 --- a/src/msr.cpp +++ b/src/msr.cpp @@ -4,33 +4,32 @@ // Austen Ott // Jim Harris (FreeBSD) -#include -#include -#ifndef _MSC_VER -#include -#endif -#include "types.h" #include "msr.h" +#include "types.h" #include "utils.h" #include -#include #include +#include #include +#include +#include #include #ifdef _MSC_VER - -#include #include "utils.h" #include "Winmsrdriver\msrstruct.h" #include "winring0/OlsApiInitExt.h" - +#include +#else +#include #endif #if defined(__FreeBSD__) || defined(__DragonFly__) -#include + #include +#include + #endif namespace pcm { diff --git a/src/msr.h b/src/msr.h index 4af522e8..933e1285 100644 --- a/src/msr.h +++ b/src/msr.h @@ -12,17 +12,19 @@ Implemented and tested for Linux and 64-bit Windows 7 */ +#include "mutex.h" #include "types.h" + +#include #include #ifdef _MSC_VER -#include "windows.h" -#elif __APPLE__ -#include +#include #endif -#include "mutex.h" -#include +#ifdef __APPLE__ +#include +#endif namespace pcm { diff --git a/src/mutex.h b/src/mutex.h index af8426c3..58a5b020 100644 --- a/src/mutex.h +++ b/src/mutex.h @@ -8,6 +8,7 @@ #endif #include +#include namespace pcm { diff --git a/src/pci.cpp b/src/pci.cpp index dde26a6f..27da4c08 100644 --- a/src/pci.cpp +++ b/src/pci.cpp @@ -5,30 +5,27 @@ // Austen Ott // Jim Harris (FreeBSD) -#include -#include -#include -#include +#include "pci.h" +#include "utils.h" + #include +#include #include +#include #include +#include +#include #include -#include "pci.h" - #ifndef _MSC_VER #include #include #include -#endif - -#ifdef _MSC_VER - +#else #include #include "Winmsrdriver\msrstruct.h" #include "winring0/OlsDef.h" #include "winring0/OlsApiInitExt.h" -#include "utils.h" #endif #if defined (__FreeBSD__) || defined(__DragonFly__) diff --git a/src/pci.h b/src/pci.h index 76f8bca5..94850de7 100644 --- a/src/pci.h +++ b/src/pci.h @@ -15,6 +15,8 @@ #include "types.h" +#include + #ifdef _MSC_VER #include "windows.h" #endif @@ -23,8 +25,6 @@ #include "PCIDriverInterface.h" #endif -#include - namespace pcm { class PciHandle diff --git a/src/pcm-core.cpp b/src/pcm-core.cpp index b0495034..beafb6a6 100644 --- a/src/pcm-core.cpp +++ b/src/pcm-core.cpp @@ -6,29 +6,29 @@ /*! \file pcm-core.cpp \brief Example of using CPU counters: implements a performance counter monitoring utility for Intel Core, Offcore events */ -#include -#ifdef _MSC_VER -#define strtok_r strtok_s -#include -#include "windows/windriver.h" -#endif + +#include "cpucounters.h" +#include "types.h" +#include "utils.h" + +#include #include -#include +#include +#include #include +#include #include #include -#include -#include "cpucounters.h" -#include "utils.h" -#include #include -#include "types.h" +#include #ifdef _MSC_VER +#define strtok_r strtok_s #include "freegetopt/getopt.h" +#include "windows/windriver.h" +#include #endif -#include #define PCM_DELAY_DEFAULT 1.0 // in seconds #define PCM_DELAY_MIN 0.015 // 15 milliseconds is practical on most modern CPUs #define MAX_CORES 4096 diff --git a/src/pcm-iio.cpp b/src/pcm-iio.cpp index e847d99d..eda5fef3 100644 --- a/src/pcm-iio.cpp +++ b/src/pcm-iio.cpp @@ -3,36 +3,38 @@ // written by Patrick Lu, // Aaron Cruz + #include "cpucounters.h" -#ifdef _MSC_VER -#pragma warning(disable : 4996) // for sprintf -#include -#include "windows/windriver.h" -#endif -#include -#include -#include // std::length_error -#include -#include -#include -#ifdef _MSC_VER -#include "freegetopt/getopt.h" -#endif +#include "lspci.h" +#include "pci.h" +#include "types.h" +#include "utils.h" +#include "version.h" +#include +#include #include #include #include #include #include #include +#include +#include +#include // std::length_error +#include #include #include #include -#include "pci.h" -#include "types.h" -#include "version.h" -#include "lspci.h" -#include "utils.h" + +#ifdef _MSC_VER +#pragma warning(disable : 4996) // for sprintf +#include +#include "windows/windriver.h" +#include "freegetopt/getopt.h" +#endif + + using namespace std; using namespace pcm; diff --git a/src/pcm-latency.cpp b/src/pcm-latency.cpp index d2010f14..44e681d5 100644 --- a/src/pcm-latency.cpp +++ b/src/pcm-latency.cpp @@ -2,27 +2,26 @@ // Copyright (c) 2018, Intel Corporation // // written by Subhiksha Ravisundar -#include "cpucounters.h" -#ifdef _MSC_VER -#pragma warning(disable : 4996) // for sprintf -#include -#include "windows/windriver.h" -#endif -#include -#include -#ifdef _MSC_VER -#include "freegetopt/getopt.h" -#endif +#include "cpucounters.h" +#include "types.h" #include "utils.h" +#include "version.h" +#include #include #include #include +#include #include #include #include -#include "types.h" -#include "version.h" + +#ifdef _MSC_VER +#pragma warning(disable : 4996) // for sprintf +#include +#include "windows/windriver.h" +#include "freegetopt/getopt.h" +#endif using namespace std; using namespace pcm; diff --git a/src/pcm-lspci.cpp b/src/pcm-lspci.cpp index 9b02e28b..4389c242 100644 --- a/src/pcm-lspci.cpp +++ b/src/pcm-lspci.cpp @@ -2,23 +2,24 @@ // Copyright (c) 2017-2018, Intel Corporation // written by Patrick Lu + #include "cpucounters.h" +#include "lspci.h" +#include "pci.h" +#include "types.h" + +#include +#include +#include +#include + #ifdef _MSC_VER #pragma warning(disable : 4996) // for sprintf #include #include "windows/windriver.h" -#endif -#include -#include -#include -#ifdef _MSC_VER #include "freegetopt/getopt.h" #endif -#include -#include "pci.h" -#include "types.h" -#include "lspci.h" using namespace std; using namespace pcm; diff --git a/src/pcm-memory.cpp b/src/pcm-memory.cpp index a18fed98..2fe5ce48 100644 --- a/src/pcm-memory.cpp +++ b/src/pcm-memory.cpp @@ -7,22 +7,24 @@ /*! \file pcm-memory.cpp \brief Example of using CPU counters: implements a performance counter monitoring utility for memory controller channels and DIMMs (ranks) + PMM memory traffic */ -#include -#ifdef _MSC_VER -#include -#include "windows/windriver.h" -#endif +#include "cpucounters.h" +#include "types.h" +#include "utils.h" +#include "version.h" + +#include #include -#include +#include #include +#include #include #include -#include "cpucounters.h" -#include "utils.h" -#include #include -#include "types.h" -#include "version.h" + +#ifdef _MSC_VER +#include +#include "windows/windriver.h" +#endif #define PCM_DELAY_DEFAULT 1.0 // in seconds #define PCM_DELAY_MIN 0.015 // 15 milliseconds is practical on most modern CPUs diff --git a/src/pcm-mmio.cpp b/src/pcm-mmio.cpp index c7f9a7ea..21878923 100644 --- a/src/pcm-mmio.cpp +++ b/src/pcm-mmio.cpp @@ -2,23 +2,25 @@ // Copyright (c) 2012-2020, Intel Corporation // written by Roman Dementiev -#ifdef _MSC_VER -#include -#include "windows/windriver.h" -#endif -#include + +#include "mmio.h" +#include "types.h" +#include "utils.h" +#include "version.h" + +#include #include +#include + #ifdef _MSC_VER #include "freegetopt/getopt.h" +#include "windows/windriver.h" +#include #endif + #ifdef __linux__ #include #endif -#include -#include "mmio.h" -#include "types.h" -#include "utils.h" -#include "version.h" using namespace pcm; diff --git a/src/pcm-msr.cpp b/src/pcm-msr.cpp index d85d1989..f7701732 100644 --- a/src/pcm-msr.cpp +++ b/src/pcm-msr.cpp @@ -2,24 +2,24 @@ // Copyright (c) 2012-2020, Intel Corporation // written by Roman Dementiev -#include "cpucounters.h" -#ifdef _MSC_VER -#include -#include "windows/windriver.h" -#endif -#include -#ifdef __linux__ -#include -#endif -#include +#include "cpucounters.h" #include "msr.h" #include "types.h" #include "utils.h" #include "version.h" +#include +#include + #ifdef _MSC_VER #include "freegetopt/getopt.h" +#include +#include "windows/windriver.h" +#endif + +#ifdef __linux__ +#include #endif using namespace pcm; diff --git a/src/pcm-numa.cpp b/src/pcm-numa.cpp index f438aa2f..cc8c10a0 100644 --- a/src/pcm-numa.cpp +++ b/src/pcm-numa.cpp @@ -6,28 +6,31 @@ /*! \file pcm-numa.cpp \brief Example of using CPU counters: implements a performance counter monitoring utility for NUMA (remote and local memory accesses counting). Example for programming offcore response events */ -#include -#ifdef _MSC_VER -#include -#include "windows/windriver.h" -#include "freegetopt/getopt.h" -#endif + +#include "cpucounters.h" +#include "exceptions/unsupported_processor_exception.hpp" +#include "types.h" +#include "utils.h" +#include "version.h" + #include -#include +#include +#include #include +#include #include #include -#include "cpucounters.h" -#include "utils.h" -#include #include -#include -#include "types.h" -#include "version.h" #include -#include "exceptions/unsupported_processor_exception.hpp" - #include +#include + +#ifdef _MSC_VER +#include "freegetopt/getopt.h" +#include "windows/windriver.h" +#include +#endif + #define PCM_DELAY_DEFAULT 1.0 // in seconds #define PCM_DELAY_MIN 0.015 // 15 milliseconds is practical on most modern CPUs diff --git a/src/pcm-pcicfg.cpp b/src/pcm-pcicfg.cpp index 40a3197f..008b9613 100644 --- a/src/pcm-pcicfg.cpp +++ b/src/pcm-pcicfg.cpp @@ -2,22 +2,24 @@ // Copyright (c) 2012, 2018 Intel Corporation // written by Roman Dementiev -#ifdef _MSC_VER -#include -#include "windows/windriver.h" -#endif + +#include "pci.h" +#include "types.h" +#include "utils.h" +#include "version.h" + +#include #include + #ifdef _MSC_VER #include "freegetopt/getopt.h" +#include +#include "windows/windriver.h" #endif + #ifdef __linux__ -#include +#include #endif -#include -#include "pci.h" -#include "types.h" -#include "utils.h" -#include "version.h" using namespace pcm; diff --git a/src/pcm-pcie.cpp b/src/pcm-pcie.cpp index 48a138df..71e034e6 100644 --- a/src/pcm-pcie.cpp +++ b/src/pcm-pcie.cpp @@ -7,14 +7,17 @@ /*! \file pcm-pcie.cpp \brief Example of using uncore CBo counters: implements a performance counter monitoring utility for monitoring PCIe bandwidth */ + +#include "pcm-pcie.h" + +#include +#include +#include + #ifdef _MSC_VER #include #include "windows/windriver.h" #endif -#include -#include -#include -#include "pcm-pcie.h" #define PCM_DELAY_DEFAULT 1.0 // in seconds #define PCM_DELAY_MIN 0.015 // 15 milliseconds is practical on most modern CPUs diff --git a/src/pcm-pcie.h b/src/pcm-pcie.h index 4c4f0f93..1631b5d2 100644 --- a/src/pcm-pcie.h +++ b/src/pcm-pcie.h @@ -3,20 +3,21 @@ #pragma once //written by Roman Sudarikov -#include #include "cpucounters.h" +#include "types.h" #include "utils.h" -#include + +#include #include -#include #include -#include +#include +#include +#include #include #include +#include #include -#include -#include -#include "types.h" +#include #if defined(_MSC_VER) typedef unsigned int uint; diff --git a/src/pcm-power.cpp b/src/pcm-power.cpp index 04980845..0163b755 100644 --- a/src/pcm-power.cpp +++ b/src/pcm-power.cpp @@ -5,27 +5,27 @@ // added PPD cycles by Thomas Willhalm #include "cpucounters.h" -#ifdef _MSC_VER -#include -#include "windows/windriver.h" -#endif -#include -#include -#include -#ifdef _MSC_VER -#include "freegetopt/getopt.h" -#endif -#include "utils.h" -#include -#include #include "types.h" +#include "types.h" +#include "utils.h" +#include "version.h" + #include +#include +#include #include +#include +#include #include #include +#include #include -#include "types.h" -#include "version.h" + +#ifdef _MSC_VER +#include "freegetopt/getopt.h" +#include +#include "windows/windriver.h" +#endif #ifdef __linux__ #include diff --git a/src/pcm-raw.cpp b/src/pcm-raw.cpp index 96801e60..dca7a89a 100644 --- a/src/pcm-raw.cpp +++ b/src/pcm-raw.cpp @@ -4,39 +4,40 @@ /*! \file pcm-raw.cpp \brief Example of using CPU counters: implements a performance counter monitoring utility with raw events interface */ -#include -#ifdef _MSC_VER -#define strtok_r strtok_s -#include -#include "windows/windriver.h" -#include "freegetopt/getopt.h" -#endif -#include -#include -#include -#include +#include "cpucounters.h" +#include "types.h" +#include "utils.h" + #include #include +#include #include #include #include +#include #include #include +#include #include #include #include #include -#include #include #include +#include +#include +#include #include #include #include #include -#include "cpucounters.h" -#include "types.h" -#include "utils.h" + +#ifdef _MSC_VER +#include "freegetopt/getopt.h" +#include "windows/windriver.h" +#include +#endif #if PCM_SIMDJSON_AVAILABLE #include "simdjson.h" diff --git a/src/pcm-sensor-server.cpp b/src/pcm-sensor-server.cpp index f03fac7a..116eb52d 100644 --- a/src/pcm-sensor-server.cpp +++ b/src/pcm-sensor-server.cpp @@ -6,34 +6,22 @@ constexpr unsigned int DEFAULT_HTTP_PORT = 9738; constexpr unsigned int DEFAULT_HTTPS_PORT = DEFAULT_HTTP_PORT; -#include -#include -#include -#include -#include -#include -#include -#include - -#include -#include -#include -#include -#include - #include "cpucounters.h" +#include "dashboard.h" #include "debug.h" #include "topology.h" -#include "dashboard.h" +#include "types.h" +#include "utils.h" + +#include #include -#include -#include +#include +#include +#include #include #include -#include -#include -#include #include +#include #include #include #include @@ -41,13 +29,22 @@ constexpr unsigned int DEFAULT_HTTPS_PORT = DEFAULT_HTTP_PORT; #include #include #include +#include +#include +#include #include +#include +#include +#include #include +#include +#include #include #include +#include +#include #include -#include "types.h" -#include "utils.h" +#include #define PCMWebServerVersion "0.1" #if defined (USE_SSL) diff --git a/src/pcm-sensor.cpp b/src/pcm-sensor.cpp index 82013788..b19ec522 100644 --- a/src/pcm-sensor.cpp +++ b/src/pcm-sensor.cpp @@ -12,14 +12,15 @@ /*! \file pcm-sensor.cpp \brief Example of using CPU counters: implements a graphical plugin for KDE ksysguard */ -#include -#include #include "cpuasynchcounter.h" -#include "utils.h" #include "cpucounters.h" #include "types.h" +#include "utils.h" #include "version.h" +#include +#include + using namespace std; using namespace pcm; diff --git a/src/pcm-tsx.cpp b/src/pcm-tsx.cpp index c5cd37db..4171ee73 100644 --- a/src/pcm-tsx.cpp +++ b/src/pcm-tsx.cpp @@ -7,26 +7,26 @@ \brief Example of using CPU counters: implements a performance counter monitoring utility for Intel Transactional Synchronization Extensions */ #include -#ifdef _MSC_VER -#include -#include "windows/windriver.h" -#endif + +#include "cpucounters.h" +#include "types.h" +#include "utils.h" + #include -#include +#include #include +#include #include #include -#include "cpucounters.h" -#include "utils.h" +#include +#include + #ifdef _MSC_VER #include "freegetopt/getopt.h" +#include +#include "windows/windriver.h" #endif -#include -#include -#include -#include "types.h" - #define PCM_DELAY_DEFAULT 1.0 // in seconds #define PCM_DELAY_MIN 0.015 // 15 milliseconds is practical on most modern CPUs diff --git a/src/pcm.cpp b/src/pcm.cpp index 79558b59..2276ff11 100644 --- a/src/pcm.cpp +++ b/src/pcm.cpp @@ -8,28 +8,30 @@ /*! \file pcm.cpp \brief Example of using CPU counters: implements a simple performance counter monitoring utility */ +#include "cpucounters.h" +#include "types.h" +#include "utils.h" +#include "version.h" + +#include +#include +#include #include +#include +#include +#include +#include +#include +#include +#include +#include + #ifdef _MSC_VER #include #include "windows/windriver.h" #else #include #endif -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include "cpucounters.h" -#include "utils.h" -#include "types.h" -#include "version.h" #define SIZE (10000000) #define PCM_DELAY_DEFAULT 1.0 // in seconds diff --git a/src/resctrl.cpp b/src/resctrl.cpp index 56ac05e2..41dc04c1 100644 --- a/src/resctrl.cpp +++ b/src/resctrl.cpp @@ -4,21 +4,22 @@ #ifdef __linux__ -#include "resctrl.h" #include "cpucounters.h" -#include -#include -#include +#include "resctrl.h" +#include "types.h" +#include "utils.h" + #include -#include -#include -#include #include +#include #include #include +#include +#include +#include +#include +#include #include -#include "types.h" -#include "utils.h" namespace pcm { diff --git a/src/resctrl.h b/src/resctrl.h index 50b3d926..0443427b 100644 --- a/src/resctrl.h +++ b/src/resctrl.h @@ -11,9 +11,9 @@ #ifdef __linux__ #include +#include #include #include -#include namespace pcm { diff --git a/src/threadpool.h b/src/threadpool.h index 3b204d9e..cab5a488 100644 --- a/src/threadpool.h +++ b/src/threadpool.h @@ -5,14 +5,14 @@ #include "debug.h" -#include -#include +#include #include +#include +#include #include -#include #include #include -#include +#include #include namespace pcm { diff --git a/src/topology.cpp b/src/topology.cpp index cb309e44..47dfdd14 100644 --- a/src/topology.cpp +++ b/src/topology.cpp @@ -1,10 +1,11 @@ // SPDX-License-Identifier: BSD-3-Clause // Copyright (c) 2016-2020, Intel Corporation -#include #include "cpucounters.h" #include "topology.h" +#include + namespace pcm { UncoreCounterState ServerUncore::uncoreCounterState( void ) const diff --git a/src/utils.cpp b/src/utils.cpp index 1284f32c..a72175b1 100644 --- a/src/utils.cpp +++ b/src/utils.cpp @@ -2,8 +2,17 @@ // Copyright (c) 2009-2018, Intel Corporation // written by Andrey Semin and many others -#include +#include "cpucounters.h" +#include "utils.h" + #include +#include +#include +#include +#include +#include +#include + #ifdef _MSC_VER #include #include @@ -13,16 +22,6 @@ #include #endif - -#include -#include -#include -#include -#include - -#include "utils.h" -#include "cpucounters.h" - namespace pcm { void (*post_cleanup_callback)(void) = NULL; diff --git a/src/utils.h b/src/utils.h index 5f7c4a40..fa5b56f5 100644 --- a/src/utils.h +++ b/src/utils.h @@ -9,22 +9,23 @@ #pragma once -#include #include "types.h" -#include -#include -#include + #include -#include +#include +#include #include #include #include +#include +#include #include #include #include +#include #ifdef __linux__ -#include +#include #endif #ifndef _MSC_VER diff --git a/tests/urltest.cpp b/tests/urltest.cpp index f4b80fd6..1e78b5a2 100644 --- a/tests/urltest.cpp +++ b/tests/urltest.cpp @@ -1,13 +1,12 @@ #define UNIT_TEST 1 - #include "../src/pcm-sensor-server.cpp" +#undef UNIT_TEST + #include #include #include #include -#undef UNIT_TEST - std::vector urls{ "http://otto:test@www.intel.com/~otto/file1.txt", "file://localhost/c/mnt/cd/file2.txt",