Skip to content

Commit

Permalink
Merge pull request #98 from tud-zih-energy/marenz.refactor-function-s…
Browse files Browse the repository at this point in the history
…election

Refactor Function Selection
  • Loading branch information
marenz2569 authored Dec 19, 2024
2 parents 96ca3f7 + 08fbfa1 commit d7661c3
Show file tree
Hide file tree
Showing 77 changed files with 2,347 additions and 1,176 deletions.
1 change: 1 addition & 0 deletions .git-blame-ignore-revs
Original file line number Diff line number Diff line change
@@ -1 +1,2 @@
9732bdb59717274f666e9c1497289d1f9a0d7858
57259a1c5dce3b90a71520abc068af8aab37bb56
5 changes: 2 additions & 3 deletions include/firestarter/CPUTopology.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -22,7 +22,6 @@
#pragma once

#include <optional>
#include <ostream>
#include <set>

extern "C" {
Expand Down Expand Up @@ -64,10 +63,10 @@ class CPUTopology {
virtual ~CPUTopology();

/// Print information about the number of packages, cores and threads.
void printSystemSummary(std::ostream& Stream) const;
void printSystemSummary() const;

/// Print information about the cache hierarchy.
void printCacheSummary(std::ostream& Stream) const;
void printCacheSummary() const;

/// Get the size of the first instruction cache.
[[nodiscard]] auto instructionCacheSize() const -> std::optional<unsigned>;
Expand Down
12 changes: 7 additions & 5 deletions include/firestarter/Config/Config.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -21,6 +21,8 @@

#pragma once

#include "firestarter/Config/InstructionGroups.hpp"

#include <chrono>
#include <cstdint>
#include <optional>
Expand Down Expand Up @@ -70,7 +72,7 @@ struct Config {
/// The optional cpu bind that allow pinning to specific cpus.
std::optional<std::set<uint64_t>> CpuBinding;
/// The optional selected instruction groups. If this is empty the default will be choosen.
std::string InstructionGroups;
std::optional<InstructionGroups> Groups;
/// The file where the dump register feature will safe its output to.
std::string DumpRegistersOutpath;
/// The name of the optimization algorithm.
Expand All @@ -82,10 +84,10 @@ struct Config {
int Argc;
/// The requested number of threads firestarter should run with. 0 means all threads.
std::optional<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 selected function id.
std::optional<unsigned> FunctionId;
/// The optional line count of the payload.
std::optional<unsigned> LineCount;
/// 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.
Expand Down
81 changes: 81 additions & 0 deletions include/firestarter/Config/InstructionGroups.hpp
Original file line number Diff line number Diff line change
@@ -0,0 +1,81 @@
/******************************************************************************
* 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 <sstream>
#include <string>
#include <utility>
#include <vector>

namespace firestarter {

/// Struct to parse selected from a string. The format is a comma delimited list of instruction value pairs. The values
/// are unsigned integers.
struct InstructionGroups {
using InternalType = std::vector<std::pair<std::string, unsigned>>;

InstructionGroups() = default;

explicit InstructionGroups(InternalType Groups)
: Groups(std::move(Groups)) {}

explicit operator const InternalType&() const noexcept { return Groups; }

friend auto operator<<(std::ostream& Stream, const InstructionGroups& IGroups) -> std::ostream&;

/// Parse the instruction group string. It is a comma delimited list of instruction value pairs. The values are
/// unsigned integers.
/// \arg Groups The instruction groups as a string.
[[nodiscard]] static auto fromString(const std::string& Groups) -> InstructionGroups;

/// Combine instructions and values for these instructions into the combined instruction groups.
/// \arg Instructions The vector of instructions
/// \arg Values The vector of values
/// \returns The combined instruction groups
[[nodiscard]] static auto fromInstructionAndValues(const std::vector<std::string>& Instructions,
const std::vector<unsigned>& Values) -> InstructionGroups;

/// The vector of used instructions that are saved in the instruction groups
[[nodiscard]] auto intructions() const -> std::vector<std::string>;

private:
/// The parsed instruction groups
std::vector<std::pair<std::string, unsigned>> Groups;
};

inline auto operator<<(std::ostream& Stream, const InstructionGroups& Groups) -> std::ostream& {
std::stringstream Ss;

for (auto const& [Key, Value] : static_cast<InstructionGroups::InternalType>(Groups)) {
Ss << Key << ":" << Value << ",";
}

auto S = Ss.str();
if (!S.empty()) {
S.pop_back();
}

Stream << S;
return Stream;
}

} // namespace firestarter
38 changes: 38 additions & 0 deletions include/firestarter/CpuFeatures.hpp
Original file line number Diff line number Diff line change
@@ -0,0 +1,38 @@
/******************************************************************************
* 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

namespace firestarter {

/// Abstract class that defines the methods required to check if cpu features are available.
class CpuFeatures {
public:
CpuFeatures() = default;
virtual ~CpuFeatures() = default;

/// Check if this class has all features which are given in the argument.
/// \arg Features The features which should be check if they are available.
/// \returns true if this class has all features given in the argument.
[[nodiscard]] virtual auto hasAll(const CpuFeatures& Features) const -> bool = 0;
};

} // namespace firestarter
42 changes: 42 additions & 0 deletions include/firestarter/CpuModel.hpp
Original file line number Diff line number Diff line change
@@ -0,0 +1,42 @@
/******************************************************************************
* 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

namespace firestarter {

/// Abstract class that defines the methods required to check if one cpu model is equal to another
class CpuModel {
public:
CpuModel() = default;
virtual ~CpuModel() = default;

/// \arg Other The model to which operator < should be checked.
/// \return true if this is less than other
[[nodiscard]] virtual auto operator<(const CpuModel& Other) const -> bool = 0;

/// Check if two models match.
/// \arg Other The model to which equality should be checked.
/// \return true if this and the other model match
[[nodiscard]] virtual auto operator==(const CpuModel& Other) const -> bool = 0;
};

} // namespace firestarter
101 changes: 0 additions & 101 deletions include/firestarter/Environment/Environment.hpp

This file was deleted.

40 changes: 0 additions & 40 deletions include/firestarter/Environment/X86/Platform/SkylakeConfig.hpp

This file was deleted.

Loading

0 comments on commit d7661c3

Please sign in to comment.