Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Code style enforcing #95

Merged
merged 168 commits into from
Dec 5, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
168 commits
Select commit Hold shift + click to select a range
f67729b
enable compile commands generation
marenz2569 Sep 19, 2024
f24a0b2
add .clang-format file base on LLVM style
marenz2569 Sep 19, 2024
9732bdb
clang-format
marenz2569 Sep 19, 2024
f4fd0ec
ignore clang-format in blame
marenz2569 Sep 19, 2024
de5ffd6
add clang-format ci job
marenz2569 Sep 19, 2024
7473e5f
add .cache folder to gitignore
marenz2569 Sep 19, 2024
c513d31
add .clang-tidy
marenz2569 Sep 19, 2024
29df30a
disable clang-tidy extension that causes crash
marenz2569 Sep 24, 2024
f3960af
add clang-tidy workflow
marenz2569 Sep 24, 2024
742712e
Merge remote-tracking branch 'origin/master' into code-style-enforcing
marenz2569 Sep 24, 2024
b79754e
first pass of clang-tidy for the header files
marenz2569 Sep 24, 2024
37a8518
update .clang-tidy
marenz2569 Sep 27, 2024
90beb59
add an empty file as a workaround for clangd issue
marenz2569 Sep 27, 2024
ff6113b
second pass of clang-tidy for the header files. use unique_ptr for th…
marenz2569 Sep 27, 2024
c33291f
clang-tidy workflow: add .clang-tidy file location
marenz2569 Sep 27, 2024
a3b01b1
clang-tidy workflow: update .clang-tidy file location
marenz2569 Sep 27, 2024
d53a107
clang-tidy workflow: add comment and rum build before clang-tidy
marenz2569 Sep 27, 2024
fafd720
clang-tidy workflow: update fetch depth
marenz2569 Sep 27, 2024
6e4c880
clang-tidy workflow: clone with submodules
marenz2569 Sep 27, 2024
770b405
first pass of clang-tidy for the source files
marenz2569 Oct 2, 2024
1d98664
clang-tidy: allow big functions
marenz2569 Oct 3, 2024
5aa731a
use enum class for constants
marenz2569 Oct 3, 2024
334b872
clang-tidy: disable checks in lib folder
marenz2569 Oct 3, 2024
6b388f6
refactor cpp side memory management of the high-load function. remove…
marenz2569 Oct 4, 2024
3876411
fix divission by zero warning
marenz2569 Oct 4, 2024
ba43956
clang-tidy fixes. create struct for allocating whole cache lines. cle…
marenz2569 Oct 5, 2024
962c0da
clang-tidy fixes
marenz2569 Oct 5, 2024
5e04c5d
cleanup load worker thread
marenz2569 Oct 5, 2024
43fd6cb
refactor load worker data
marenz2569 Oct 5, 2024
d608e98
use std::chrono::microseconds instead of uint64_t
marenz2569 Oct 5, 2024
5583723
use throw instead of returns for Environment class
marenz2569 Oct 5, 2024
8ba518a
clang-tidy fixes
marenz2569 Oct 5, 2024
e87ef3c
remove some ifdefs. clang-tidy fixes
marenz2569 Oct 6, 2024
7208aeb
remove more ifdefs
marenz2569 Oct 6, 2024
3f32f6f
remove more ifdefs
marenz2569 Oct 6, 2024
35a73b1
remove more ifdefs
marenz2569 Oct 6, 2024
6fdcf47
remove more ifdefs
marenz2569 Oct 6, 2024
4da8714
remove more ifdefs
marenz2569 Oct 6, 2024
05ab312
remove more ifdefs
marenz2569 Oct 6, 2024
f58bfd5
fix mingw compatibility
marenz2569 Oct 6, 2024
f0e9439
fix some MSC errors
marenz2569 Oct 6, 2024
230103d
fix errors in MSC compile
marenz2569 Oct 7, 2024
bfc2167
fix errors in MSC compile
marenz2569 Oct 7, 2024
bc3e37d
add inline to functions define in the windows compat header
marenz2569 Oct 7, 2024
4910835
AlignedAlloc: try to fix infinite recursion in free function
marenz2569 Oct 7, 2024
6169843
WindowsCompat: fix _mm_mfence compatibilty
marenz2569 Oct 7, 2024
33fc035
fix Firestarter.cpp includes
marenz2569 Oct 7, 2024
7799e06
WindowsCompat: fix _mm_mfence compatibilty
marenz2569 Oct 7, 2024
e7efd15
WindowsCompat: fix _mm_mfence compatibilty
marenz2569 Oct 8, 2024
c29ccf8
fix static build
marenz2569 Oct 8, 2024
21c10be
fix get_current_dir_name in apple build
marenz2569 Oct 8, 2024
e8370bf
fix get_current_dir_name in apple build
marenz2569 Oct 8, 2024
e196bf2
cleanup cuda and hip code
marenz2569 Oct 16, 2024
eb0d6e5
Cuda: rename accellSafeCall
marenz2569 Oct 16, 2024
b961fb8
fix some cuda compile errors
marenz2569 Oct 17, 2024
0edf8d7
fix some cuda compile errors
marenz2569 Oct 17, 2024
4307b13
fix some cuda compile errors
marenz2569 Oct 17, 2024
14786a3
cuda/hip compat: replace some static_assert with assert to cope with …
marenz2569 Oct 18, 2024
73f3d88
ci: set cxx compiler correctly for openapi build
marenz2569 Oct 18, 2024
47fc326
windowscompat: remove inline
marenz2569 Oct 18, 2024
0e4fea0
remove compile error
marenz2569 Oct 18, 2024
a788273
windows compat: remove anonymous namespace for __cpuid and _mm_mfence
marenz2569 Oct 18, 2024
5912cb4
windows compat: remove anonymous namespaces from header
marenz2569 Oct 18, 2024
20b6360
ci: do not fail fast in linux build
marenz2569 Oct 18, 2024
aefe54c
windowscompat: use static inline
marenz2569 Oct 18, 2024
99c03f9
fix oneapi
marenz2569 Oct 18, 2024
c9d57c1
windows compat: efix compatibility with icx
marenz2569 Oct 18, 2024
4b652fd
remove warning
marenz2569 Oct 18, 2024
def3a9f
Revert "ci: set cxx compiler correctly for openapi build"
marenz2569 Oct 18, 2024
8973ddf
fix hip/cuda compat layer
marenz2569 Oct 18, 2024
b396920
fix problem with metric interface and hip compile
marenz2569 Oct 18, 2024
e3b01db
windows compat: fix hip build
marenz2569 Oct 18, 2024
a2f6033
fix link errors with metric interface restructure
marenz2569 Oct 18, 2024
ddd4b5e
fix windows msc build
marenz2569 Oct 18, 2024
f8a3bc5
fix windows msc build
marenz2569 Oct 18, 2024
e2cba76
windows compat: add #pragma message to debug _mm_mfence compatibility
marenz2569 Oct 19, 2024
78272ad
windows compat: add emmintrin.h header when compiling with clang.
marenz2569 Oct 19, 2024
30aceef
Revert "windows compat: add #pragma message to debug _mm_mfence compa…
marenz2569 Oct 19, 2024
d62dc1a
windows compat: less compiler warnings
marenz2569 Oct 19, 2024
ddfc1ae
Revert "ci: do not fail fast in linux build"
marenz2569 Oct 19, 2024
1fd90f4
restructure rapl: add callback back in again
marenz2569 Oct 19, 2024
6696817
cleanup cuda/hip and openapi code. add todo comments with links to t…
marenz2569 Oct 24, 2024
6b50a28
fix cuda compat layer
marenz2569 Oct 24, 2024
3e13ca0
remove redundant reinterpret cast
marenz2569 Oct 24, 2024
6e57460
fix cast in cuda compat malloc function
marenz2569 Oct 24, 2024
a0591db
fix cast in cuda compat malloc/free functions
marenz2569 Oct 24, 2024
0921c1f
fix oneapi refactor
marenz2569 Oct 24, 2024
a77e429
refactor oneapi code
marenz2569 Oct 24, 2024
77fec86
refactor oneapi code
marenz2569 Oct 24, 2024
badd0fe
add script to start clang-tidy
marenz2569 Oct 25, 2024
5c8f6c3
update clang-tidy ci action
marenz2569 Oct 25, 2024
93512a5
update todos
marenz2569 Oct 25, 2024
049d183
run clang-tidy useing 2 cores
marenz2569 Oct 25, 2024
dc5c9dc
clang-tidy: scramble files to reduce the runtime
marenz2569 Oct 25, 2024
4db1a5b
ci: run build before executing clang-tidy
marenz2569 Oct 25, 2024
e6ae34d
clang-tidy start with shell
marenz2569 Oct 25, 2024
4ae98e3
clang-tidy: launch processes in new python thread
marenz2569 Oct 25, 2024
2c26deb
run clang-tidy ci with 4 cores
marenz2569 Oct 25, 2024
077662a
clang-tidy: find the correct source files for the current build
marenz2569 Oct 25, 2024
ae95982
remove error message from cuda/hip compat header
marenz2569 Oct 25, 2024
25571c1
reformat clang-tidy
marenz2569 Oct 25, 2024
b9b468e
clang-tidy: use seed for shuffled files
marenz2569 Oct 25, 2024
219a262
clang-tidy: add check to ci action
marenz2569 Oct 25, 2024
5c4cb4c
clang-tidy: set python unbuffered in ci action
marenz2569 Oct 25, 2024
d978ca9
refactor config parser
marenz2569 Oct 26, 2024
f774833
reorder config fields
marenz2569 Oct 26, 2024
954bb30
do not access moved object
marenz2569 Oct 26, 2024
f1f8828
X86 payloads: remove using. fix deprecation warning.
marenz2569 Oct 26, 2024
6a6e261
remove unused variable
marenz2569 Oct 26, 2024
2443465
thin out payload class
marenz2569 Oct 26, 2024
48cc7a8
remove protected member
marenz2569 Oct 26, 2024
0742466
remove protected data members. fix clang-tidy warnings
marenz2569 Oct 26, 2024
73ee17b
fix clang-tidy warnings
marenz2569 Oct 26, 2024
bcd588b
remove warnings
marenz2569 Oct 27, 2024
295e538
fix string compare in default cpu frequency lookup
marenz2569 Oct 27, 2024
e7222db
fix more warnings
marenz2569 Oct 27, 2024
6f52af8
Perf: fix warnings
marenz2569 Oct 27, 2024
c05f47b
rapl: fix warnings
marenz2569 Oct 27, 2024
aac47aa
DumpRegisterStruct: fix warnings
marenz2569 Oct 27, 2024
ef90525
use shared ptr for payload. less clone(). make functions in payload p…
marenz2569 Oct 27, 2024
d9b2979
remove warnings
marenz2569 Oct 28, 2024
ba314d7
remove clone from payload
marenz2569 Oct 28, 2024
0dbe9d2
fix build with gcc
marenz2569 Oct 28, 2024
041acfe
replace std::quick_exit with a custom thread safe exit function
marenz2569 Oct 28, 2024
54fd662
refactor PlatformConfig and settings for the Payload. remove more non…
marenz2569 Oct 28, 2024
af06097
clang-tidy fixes
marenz2569 Oct 29, 2024
a6d9c3f
cleanup clang-tidy script
marenz2569 Oct 29, 2024
f8af514
make Config and Topology private in Environment class
marenz2569 Oct 29, 2024
738933f
clang-tidy: fix warnings
marenz2569 Oct 30, 2024
a218aad
add todo note
marenz2569 Oct 30, 2024
7362553
clang-tidy: fix warnings
marenz2569 Oct 30, 2024
6ad9537
clang-tidy fixes
marenz2569 Oct 31, 2024
de5bc81
clang-tidy: disable warnings from asmjit
marenz2569 Nov 2, 2024
7e0ee18
clang-tidy: fix issues in MeasurementWorker
marenz2569 Nov 2, 2024
42bfb04
clang-tidy: fixes
marenz2569 Nov 3, 2024
ef3b634
clang-tidy: nolint unnecessary warnings
marenz2569 Nov 4, 2024
d954fe9
add docstrings for cuda
marenz2569 Nov 5, 2024
523a1f4
move compiled payload into a new header. add docstrings for payload c…
marenz2569 Nov 5, 2024
ac82234
move functions for sequences of items into payloadsettings
marenz2569 Nov 5, 2024
d5c0311
add more documentation to the payload and platform
marenz2569 Nov 5, 2024
235e92b
refactor payload. add docstrings
marenz2569 Nov 6, 2024
982e2ca
add more docstrings
marenz2569 Nov 7, 2024
23ccb55
docstrings
marenz2569 Nov 7, 2024
5a301a3
add docstrings
marenz2569 Nov 7, 2024
e72b010
add docstrings
marenz2569 Nov 7, 2024
ad22452
change log error to log warn to not abort on failed metric init
marenz2569 Nov 7, 2024
7498853
add docstrings for measurement and metrics
marenz2569 Nov 8, 2024
eef129f
fix refactor in rapl metric
marenz2569 Nov 8, 2024
bbe6f57
rapl metric docstrings
marenz2569 Nov 8, 2024
283ec47
remove unused return argument in watchdogworker
marenz2569 Nov 8, 2024
dc6c80a
add docstrings to OneAPI
marenz2569 Nov 8, 2024
cfc2cf1
doc strings and rename funtions in optimization
marenz2569 Nov 8, 2024
29168c2
cleanup optimization worker. add docstrings
marenz2569 Nov 8, 2024
1690ec0
ci: remove GHC artifacts to make more space for the rocm build
marenz2569 Nov 8, 2024
dee9fc1
explicitly check if number of GPUs is not equal to 0.
marenz2569 Nov 8, 2024
9c32916
update docstring in cuda and oneapi files
marenz2569 Nov 8, 2024
08a3772
add docstring for config
marenz2569 Nov 8, 2024
0de3fa6
fix offset in error detection algorithm. add docstrings
marenz2569 Nov 8, 2024
427675a
docstring for DumpRegisterWorkerData
marenz2569 Nov 8, 2024
e04716f
add docstrings to Firestarter.hpp
marenz2569 Nov 8, 2024
32f1399
fix bug saving json in history
marenz2569 Nov 16, 2024
f045530
update comment in X86PlatformConfig.cpp
marenz2569 Nov 16, 2024
b16aa6a
fix MiB print in cuda
marenz2569 Nov 19, 2024
0fce1bb
unify firestarter includes for source files
marenz2569 Nov 19, 2024
9155ae2
fix crash when optimization is stoped
marenz2569 Nov 20, 2024
eb8eed7
unify firestarter includes in header files
marenz2569 Nov 21, 2024
92897b2
remove ifndefs
marenz2569 Nov 21, 2024
f53b736
silence modernice warning in c-style header
marenz2569 Nov 22, 2024
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
7 changes: 7 additions & 0 deletions .clang-format
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
64 changes: 64 additions & 0 deletions .clang-tidy
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' }
1 change: 1 addition & 0 deletions .git-blame-ignore-revs
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
9732bdb59717274f666e9c1497289d1f9a0d7858
19 changes: 19 additions & 0 deletions .github/workflows/clang-format.yml
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)
50 changes: 50 additions & 0 deletions .github/workflows/clang-tidy.yml
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
2 changes: 2 additions & 0 deletions .github/workflows/cmake.yml
Original file line number Diff line number Diff line change
Expand Up @@ -21,6 +21,8 @@ jobs:
run: |
sudo rm -rf /usr/local/lib/android
sudo rm -rf /usr/share/dotnet
sudo rm -rf /opt/ghc
sudo rm -rf /usr/local/.ghcup

- name: Install g++-9 (if needed)
if: matrix.compiler == 'g++-9'
Expand Down
1 change: 1 addition & 0 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -2,3 +2,4 @@ result*
*.swp
*.swo
build*/
.cache/
2 changes: 2 additions & 0 deletions CMakeLists.txt
Original file line number Diff line number Diff line change
@@ -1,6 +1,8 @@
cmake_minimum_required(VERSION 3.22)
project(FIRESTARTER)

set(CMAKE_EXPORT_COMPILE_COMMANDS ON)

include(cmake/GitSubmoduleUpdate.cmake)

# set FIRESTARTER version
Expand Down
78 changes: 78 additions & 0 deletions include/firestarter/AlignedAlloc.hpp
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
124 changes: 124 additions & 0 deletions include/firestarter/Config.hpp
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
Loading
Loading