-
Notifications
You must be signed in to change notification settings - Fork 26
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #95 from tud-zih-energy/code-style-enforcing
Code style enforcing
- Loading branch information
Showing
107 changed files
with
9,618 additions
and
8,273 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,7 @@ | ||
--- | ||
BasedOnStyle: LLVM | ||
Language: Cpp | ||
BreakConstructorInitializersBeforeComma: 'true' | ||
AllowShortFunctionsOnASingleLine: All | ||
PointerAlignment: Left | ||
ColumnLimit: 120 |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,64 @@ | ||
--- | ||
# Configure clang-tidy for this project. | ||
|
||
# -bugprone-narrowing-conversions: too many false positives around | ||
# `std::size_t` vs. `*::difference_type`. | ||
|
||
# -boost-use-ranges: crash of clangd https://github.com/llvm/llvm-project/issues/109037 | ||
|
||
# -readability-identifier-length length of at least 3 does not make sense for some variables | ||
|
||
# -cppcoreguidelines-avoid-magic-numbers | ||
# -readability-magic-numbers currently we have too may numbers in this code | ||
|
||
# -bugprone-easily-swappable-parameters we are not using strong typedefs | ||
|
||
# -readability-function-cognitive-complexity allow big functions | ||
|
||
Checks: > | ||
-*, | ||
boost-*, | ||
bugprone-*, | ||
cert-*, | ||
clang-analyzer-*, | ||
concurrency-*, | ||
cppcoreguidelines-*, | ||
google-*, | ||
misc-*, | ||
modernize-*, | ||
performance-*, | ||
portability-*, | ||
readability-*, | ||
-bugprone-narrowing-conversions, | ||
-cppcoreguidelines-special-member-functions, | ||
-boost-use-ranges, | ||
-readability-identifier-length, | ||
-cppcoreguidelines-avoid-magic-numbers, | ||
-readability-magic-numbers, | ||
-bugprone-easily-swappable-parameters, | ||
-readability-function-cognitive-complexity | ||
# Turn all the warnings from the checks above into errors. | ||
WarningsAsErrors: "*" | ||
|
||
HeaderFilterRegex: "include/firestarter/.*\\.(h|hpp)$" | ||
|
||
CheckOptions: | ||
- { key: readability-identifier-naming.NamespaceCase, value: lower_case } | ||
- { key: readability-identifier-naming.ClassCase, value: CamelCase } | ||
- { key: readability-identifier-naming.StructCase, value: CamelCase } | ||
- { key: readability-identifier-naming.FunctionCase, value: camelBack } | ||
- { key: readability-identifier-naming.MemberCase, value: CamelCase } | ||
- { key: readability-identifier-naming.VariableCase, value: CamelCase } | ||
- { key: readability-identifier-naming.EnumCase, value: CamelCase } | ||
- { key: readability-identifier-naming.ParameterCase, value: CamelCase } | ||
- { key: readability-identifier-naming.UnionCase, value: CamelCase } | ||
- { key: readability-identifier-naming.IgnoreMainLikeFunctions, value: 1 } | ||
- { key: readability-redundant-member-init.IgnoreBaseInCopyConstructors, value: 1 } | ||
- { key: modernize-use-default-member-init.UseAssignment, value: 1 } | ||
- { key: readability-implicit-bool-conversion.AllowIntegerConditions, value: 1 } | ||
- { key: readability-implicit-bool-conversion.AllowPointerConditions, value: 1 } | ||
- { key: readability-function-cognitive-complexity.IgnoreMacros, value: 1 } | ||
- { key: misc-non-private-member-variables-in-classes.IgnoreClassesWithAllMemberVariablesBeingPublic, value: "true" } | ||
# disable warnings is asmjit | ||
- { key: 'clang-analyzer-optin.cplusplus.UninitializedObject:IgnoreRecordsWithField', value: 'asmjit::Operand_::Signature' } |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1 @@ | ||
9732bdb59717274f666e9c1497289d1f9a0d7858 |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,19 @@ | ||
name: clang-format-review | ||
|
||
# You can be more specific, but it currently only works on pull requests | ||
on: [push, pull_request] | ||
|
||
jobs: | ||
clang-format: | ||
runs-on: ubuntu-latest | ||
steps: | ||
- uses: actions/checkout@v3 | ||
- name: Install clang-tidy | ||
run: | | ||
sudo apt-get update | ||
sudo apt-get install -y clang-tidy | ||
- name: Analyze | ||
run: | | ||
clang-format --dry-run --Werror -style=file $(find ./src/ -name '*.cpp' -print) | ||
clang-format --dry-run --Werror -style=file $(find ./include/ -name '*.hpp' -print) | ||
clang-format --dry-run --Werror -style=file $(find ./include/ -name '*.h' -print) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,50 @@ | ||
name: clang-tidy-review | ||
|
||
on: [push, pull_request] | ||
|
||
env: | ||
PYTHONUNBUFFERED: 1 | ||
|
||
jobs: | ||
build: | ||
runs-on: ubuntu-latest | ||
|
||
steps: | ||
- uses: actions/checkout@v4 | ||
with: | ||
submodules: 'true' | ||
|
||
# Ideally we would want to run the clang-tidy for every kind of build. | ||
# This would make shure that we will check all platform dependent code parts. | ||
# Here we only test the standard linux build. | ||
- name: Install python3 and libraries | ||
run: | | ||
sudo apt update | ||
sudo apt install python3 python3-pip | ||
pip install click | ||
- name: Create build directory | ||
run: | | ||
mkdir build | ||
- name: Run CMake configure (default) | ||
run: | | ||
cd build | ||
cmake .. | ||
- name: Build | ||
run: | | ||
cd build | ||
make -j4 | ||
- name: Run clang-tidy | ||
run: | | ||
./tooling/clang-tidy.py clang-tidy-report --build-root build --cores 4 | ||
- name: Print report | ||
run: | | ||
cat build/clang-tidy-report.txt | ||
- name: Check if report is empty | ||
run: | | ||
./tooling/clang-tidy.py check --build-root build |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -2,3 +2,4 @@ result* | |
*.swp | ||
*.swo | ||
build*/ | ||
.cache/ |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,78 @@ | ||
/****************************************************************************** | ||
* FIRESTARTER - A Processor Stress Test Utility | ||
* Copyright (C) 2024 TU Dresden, Center for Information Services and High | ||
* Performance Computing | ||
* | ||
* This program 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. | ||
* | ||
* This program 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 this program. If not, see <http://www.gnu.org/licenses/\>. | ||
* | ||
* Contact: [email protected] | ||
*****************************************************************************/ | ||
|
||
#pragma once | ||
|
||
#include <cmath> | ||
#include <cstddef> | ||
#include <cstdlib> | ||
|
||
namespace firestarter { | ||
|
||
struct AlignedAlloc { | ||
private: | ||
/// Round the size to the nearest multiple of the aligment | ||
/// \arg Size The number to be rounded up. | ||
/// \arg Alignment The number to whoose multiple to be round up to. | ||
/// \returns Size rounded up to the nearest multiple of the Alignment | ||
static auto padSize(const std::size_t Size, const std::size_t Alignment) -> std::size_t { | ||
return Alignment * static_cast<int>(std::ceil(static_cast<double>(Size) / static_cast<double>(Alignment))); | ||
}; | ||
|
||
public: | ||
/// Allocate memory with a given alignment. The size will automatically increased to the nearest multiple of the | ||
/// alignment. | ||
/// \arg Size The minimum required memory. | ||
/// \arg Alignment describes to which boundary the memory should be aligned. The default is 64B which will account to | ||
/// the size of a cache line on most systems. | ||
/// \returns The pointer to the allocated memory. | ||
static auto malloc(const std::size_t Size, const std::size_t Alignment = 64) -> void* { | ||
// NOLINTBEGIN(cppcoreguidelines-owning-memory) | ||
#if defined(__APPLE__) | ||
return aligned_alloc(Alignment, padSize(Size, Alignment)); | ||
#elif defined(__MINGW64__) | ||
return _mm_malloc(padSize(Size, Alignment), Alignment); | ||
#elif defined(_MSC_VER) | ||
return _aligned_malloc(padSize(Size, Alignment), Alignment); | ||
#else | ||
return aligned_alloc(Alignment, padSize(Size, Alignment)); | ||
#endif | ||
// NOLINTEND(cppcoreguidelines-owning-memory) | ||
}; | ||
|
||
/// Deallocate memory which has been allocated by the AlignedAlloc::malloc function. | ||
/// \arg Ptr The pointer to the allocated memory. | ||
static void free(void* Ptr) { | ||
// NOLINTBEGIN(cppcoreguidelines-owning-memory,cppcoreguidelines-no-malloc) | ||
#if defined(__APPLE__) | ||
::free(Ptr); | ||
#elif defined(__MINGW64__) | ||
_mm_free(Ptr); | ||
#elif defined(_MSC_VER) | ||
_aligned_free(Ptr); | ||
#else | ||
std::free(Ptr); | ||
#endif | ||
// NOLINTEND(cppcoreguidelines-owning-memory,cppcoreguidelines-no-malloc) | ||
}; | ||
}; | ||
|
||
} // namespace firestarter |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,124 @@ | ||
/****************************************************************************** | ||
* FIRESTARTER - A Processor Stress Test Utility | ||
* Copyright (C) 2024 TU Dresden, Center for Information Services and High | ||
* Performance Computing | ||
* | ||
* This program 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. | ||
* | ||
* This program 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 this program. If not, see <http://www.gnu.org/licenses/\>. | ||
* | ||
* Contact: [email protected] | ||
*****************************************************************************/ | ||
|
||
#pragma once | ||
|
||
#include <chrono> | ||
#include <string> | ||
#include <vector> | ||
|
||
namespace firestarter { | ||
|
||
/// This struct contains the parsed config from the command line for Firestarter. | ||
struct Config { | ||
/// The argument vector from the command line. | ||
const char** Argv; | ||
|
||
/// The timeout after which firestarter terminates. This is available in combination with optimization. | ||
std::chrono::seconds Timeout{}; | ||
/// The period after with which the low/high load routine is switched. | ||
std::chrono::microseconds Period{}; | ||
/// The load in the range of 0 < Load <= Period, which controls how long of the period the high-load loop runs. | ||
std::chrono::microseconds Load{}; | ||
|
||
/// The interval every which the register will be dumped to the file. | ||
std::chrono::seconds DumpRegistersTimeDelta = std::chrono::seconds(0); | ||
/// The time to skip from the measurement start | ||
std::chrono::milliseconds StartDelta = std::chrono::milliseconds(0); | ||
/// The time to skip from the measurement stop | ||
std::chrono::milliseconds StopDelta = std::chrono::milliseconds(0); | ||
/// Metric values will be polled by the MeasurementInterval. | ||
std::chrono::milliseconds MeasurementInterval = std::chrono::milliseconds(0); | ||
/// The time how long the processor will be preheated before starting a measurement or optimization. | ||
std::chrono::seconds Preheat{}; | ||
/// The time how long a measurement should take. | ||
std::chrono::seconds EvaluationDuration{}; | ||
|
||
/// The crossover probability used in the NSGA2 optimization algorithm. | ||
double Nsga2Cr; | ||
/// The mutation probability used in the NSGA2 optimization algorithm. | ||
double Nsga2M; | ||
|
||
/// The name of the metrics that are read from stdin. | ||
std::vector<std::string> StdinMetrics; | ||
/// The paths to the metrics that are loaded using shared libraries. | ||
std::vector<std::string> MetricPaths; | ||
/// The list of metrics that are used for maximization. If a metric is prefixed with '-' it will be minimized. | ||
std::vector<std::string> OptimizationMetrics; | ||
|
||
/// The optional cpu bind that allow pinning to specific cpus. | ||
std::string CpuBind; | ||
/// The optional selected instruction groups. If this is empty the default will be choosen. | ||
std::string InstructionGroups; | ||
/// The file where the dump register feature will safe its output to. | ||
std::string DumpRegistersOutpath; | ||
/// The name of the optimization algorithm. | ||
std::string OptimizationAlgorithm; | ||
/// The file where the data saved during optimization is saved. | ||
std::string OptimizeOutfile; | ||
|
||
/// The argument count from the command line. | ||
int Argc; | ||
/// The requested number of threads firestarter should run with. 0 means all threads. | ||
unsigned RequestedNumThreads; | ||
/// The selected function id. 0 means automatic selection. | ||
unsigned FunctionId; | ||
/// The line count of the payload. 0 means default. | ||
unsigned LineCount = 0; | ||
/// The number of gpus firestarter should stress. Default is -1 means all gpus. | ||
int Gpus = 0; | ||
/// The matrix size which should be used. 0 means automatic detections. | ||
unsigned GpuMatrixSize = 0; | ||
/// The number of individuals that should be used for the optimization. | ||
unsigned Individuals; | ||
/// The number of generations that should be used for the optimization. | ||
unsigned Generations; | ||
|
||
/// If the function summary should be printed. | ||
bool PrintFunctionSummary; | ||
/// If the available instruction groups for a function should be printed. | ||
bool ListInstructionGroups; | ||
/// Allow payloads that are not supported on the current processor. | ||
bool AllowUnavailablePayload = false; | ||
/// Is the dump registers debug feature enabled? | ||
bool DumpRegisters = false; | ||
/// Is the error detection feature enabled? | ||
bool ErrorDetection = false; | ||
/// Should the GPUs use floating point precision? If neither GpuUseFloat or GpuUseDouble is set, precision will be | ||
/// choosen automatically. | ||
bool GpuUseFloat = false; | ||
/// Should the GPUs use double point precision? If neither GpuUseFloat or GpuUseDouble is set, precision will be | ||
/// choosen automatically. | ||
bool GpuUseDouble = false; | ||
/// Should we print all available metrics. | ||
bool ListMetrics = false; | ||
/// Do we perform an measurement. | ||
bool Measurement = false; | ||
/// Do we perform optimization. | ||
bool Optimize = false; | ||
|
||
Config() = delete; | ||
|
||
/// Parser the config from the command line argumens. | ||
Config(int Argc, const char** Argv); | ||
}; | ||
|
||
} // namespace firestarter |
Oops, something went wrong.