Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
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
1 change: 1 addition & 0 deletions .clang-tidy
Original file line number Diff line number Diff line change
Expand Up @@ -36,6 +36,7 @@ Checks: >
-misc-non-private-member-variables-in-classes,
-modernize-avoid-c-arrays,
-modernize-use-trailing-return-type,
-portability-avoid-pragma-once,
-portability-template-virtual-member-function,
-readability-magic-numbers

Expand Down
10 changes: 7 additions & 3 deletions .github/actions/clang-tidy-native/action.yml
Original file line number Diff line number Diff line change
Expand Up @@ -77,15 +77,19 @@ runs:
while IFS= read -r file; do
if [ -n "$file" ] && [ -f "$file" ]; then
echo "Analyzing $file..."
FILE_OUTPUT=$(mktemp)
if clang-tidy-${{ inputs.clang_tidy_version }} "$file" \
-p ${{ inputs.build_dir }} --format-style=file 2>&1 | \
tee -a "$COMMENTS_FILE"; then
ISSUES=$(grep -c "warning:\|error:" "$COMMENTS_FILE" || echo "0")
TOTAL_ISSUES=$((TOTAL_ISSUES + ISSUES))
tee "$FILE_OUTPUT"; then
ISSUES=$(grep -c "warning:\|error:" "$FILE_OUTPUT" 2>/dev/null || echo "0")
ISSUES=$(echo "$ISSUES" | tr -d '[:space:]')
TOTAL_ISSUES=$((TOTAL_ISSUES + ${ISSUES:-0}))
cat "$FILE_OUTPUT" >> "$COMMENTS_FILE"
else
echo "::error::Failed to analyze $file"
TOTAL_ISSUES=$((TOTAL_ISSUES + 1))
fi
rm -f "$FILE_OUTPUT"
fi
done <<< "${{ steps.changed-files.outputs.changed_files }}"

Expand Down
7 changes: 4 additions & 3 deletions modules/performance/include/performance.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -30,7 +30,8 @@ struct PerfAttr {
struct PerfResults {
/// @brief Measured execution time in seconds.
double time_sec = 0.0;
enum TypeOfRunning : uint8_t { kPipeline, kTaskRun, kNone } type_of_running = kNone;
enum class TypeOfRunning : uint8_t { kPipeline, kTaskRun, kNone };
TypeOfRunning type_of_running = TypeOfRunning::kNone;
constexpr static double kMaxTime = 10.0;
};

Expand Down Expand Up @@ -116,10 +117,10 @@ class Perf {
};

inline std::string GetStringParamName(PerfResults::TypeOfRunning type_of_running) {
if (type_of_running == PerfResults::kTaskRun) {
if (type_of_running == PerfResults::TypeOfRunning::kTaskRun) {
return "task_run";
}
if (type_of_running == PerfResults::kPipeline) {
if (type_of_running == PerfResults::TypeOfRunning::kPipeline) {
return "pipeline";
}
return "none";
Expand Down
14 changes: 7 additions & 7 deletions modules/performance/tests/perf_tests.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -175,8 +175,8 @@ TEST_P(GetStringParamNameParamTest, ReturnsExpectedString) {
}

INSTANTIATE_TEST_SUITE_P(ParamTests, GetStringParamNameParamTest,
::testing::Values(ParamTestCase{PerfResults::kTaskRun, "task_run"},
ParamTestCase{PerfResults::kPipeline, "pipeline"},
::testing::Values(ParamTestCase{PerfResults::TypeOfRunning::kTaskRun, "task_run"},
ParamTestCase{PerfResults::TypeOfRunning::kPipeline, "pipeline"},
ParamTestCase{PerfResults::TypeOfRunning::kNone, "none"}),
[](const ::testing::TestParamInfo<ParamTestCase>& info) {
return info.param.expected_output;
Expand Down Expand Up @@ -360,12 +360,12 @@ TEST(PerfTest, PipelineRunAndTaskRun) {

EXPECT_NO_THROW(perf.PipelineRun(attr));
auto res_pipeline = perf.GetPerfResults();
EXPECT_EQ(res_pipeline.type_of_running, PerfResults::kPipeline);
EXPECT_EQ(res_pipeline.type_of_running, PerfResults::TypeOfRunning::kPipeline);
EXPECT_GT(res_pipeline.time_sec, 0.0);

EXPECT_NO_THROW(perf.TaskRun(attr));
auto res_taskrun = perf.GetPerfResults();
EXPECT_EQ(res_taskrun.type_of_running, PerfResults::kTaskRun);
EXPECT_EQ(res_taskrun.type_of_running, PerfResults::TypeOfRunning::kTaskRun);
EXPECT_GT(res_taskrun.time_sec, 0.0);
}

Expand All @@ -380,9 +380,9 @@ TEST(PerfTest, PrintPerfStatisticThrowsOnNone) {
}

TEST(PerfTest, GetStringParamNameTest) {
EXPECT_EQ(GetStringParamName(PerfResults::kTaskRun), "task_run");
EXPECT_EQ(GetStringParamName(PerfResults::kPipeline), "pipeline");
EXPECT_EQ(GetStringParamName(PerfResults::kNone), "none");
EXPECT_EQ(GetStringParamName(PerfResults::TypeOfRunning::kTaskRun), "task_run");
EXPECT_EQ(GetStringParamName(PerfResults::TypeOfRunning::kPipeline), "pipeline");
EXPECT_EQ(GetStringParamName(PerfResults::TypeOfRunning::kNone), "none");
}

TEST(TaskTest, Destructor_InvalidPipelineOrderTerminates_PartialPipeline) {
Expand Down
14 changes: 7 additions & 7 deletions modules/task/include/task.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,7 @@ namespace ppc::task {

/// @brief Represents the type of task (parallelization technology).
/// @details Used to select the implementation type in tests and execution logic.
enum TypeOfTask : uint8_t {
enum class TypeOfTask : uint8_t {
/// Use all available implementations
kALL,
/// MPI (Message Passing Interface)
Expand Down Expand Up @@ -57,7 +57,7 @@ inline std::string TypeOfTaskToString(TypeOfTask type) {
}

/// @brief Indicates whether a task is enabled or disabled.
enum StatusOfTask : uint8_t {
enum class StatusOfTask : uint8_t {
/// Task is enabled and should be executed
kEnabled,
/// Task is disabled and will be skipped
Expand All @@ -68,7 +68,7 @@ enum StatusOfTask : uint8_t {
/// @param status_of_task Task status (enabled or disabled).
/// @return "enabled" if the task is enabled, otherwise "disabled".
inline std::string GetStringTaskStatus(StatusOfTask status_of_task) {
if (status_of_task == kDisabled) {
if (status_of_task == StatusOfTask::kDisabled) {
return "disabled";
}
return "enabled";
Expand Down Expand Up @@ -96,7 +96,7 @@ inline std::string GetStringTaskType(TypeOfTask type_of_task, const std::string
return type_str + "_" + std::string((*list_settings)["tasks"][type_str]);
}

enum StateOfTesting : uint8_t { kFunc, kPerf };
enum class StateOfTesting : uint8_t { kFunc, kPerf };

template <typename InType, typename OutType>
/// @brief Base abstract class representing a generic task with a defined pipeline.
Expand Down Expand Up @@ -257,9 +257,9 @@ class Task {
private:
InType input_{};
OutType output_{};
StateOfTesting state_of_testing_ = kFunc;
TypeOfTask type_of_task_ = kUnknown;
StatusOfTask status_of_task_ = kEnabled;
StateOfTesting state_of_testing_ = StateOfTesting::kFunc;
TypeOfTask type_of_task_ = TypeOfTask::kUnknown;
StatusOfTask status_of_task_ = StatusOfTask::kEnabled;
std::chrono::high_resolution_clock::time_point tmp_time_point_;
enum class PipelineStage : uint8_t {
kNone,
Expand Down
10 changes: 6 additions & 4 deletions modules/util/include/func_test_util.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -50,13 +50,14 @@ class BaseRunFuncTests : public ::testing::TestWithParam<FuncTestParam<InType, O
template <typename Derived>
static std::string PrintFuncTestName(const GTestFuncParam<InType, OutType, TestType>& info) {
RequireStaticInterface<Derived>();
TestType test_param = std::get<ppc::util::GTestParamIndex::kTestParams>(info.param);
return std::get<GTestParamIndex::kNameTest>(info.param) + "_" + Derived::PrintTestParam(test_param);
TestType test_param = std::get<static_cast<std::size_t>(ppc::util::GTestParamIndex::kTestParams)>(info.param);
return std::get<static_cast<std::size_t>(GTestParamIndex::kNameTest)>(info.param) + "_" +
Derived::PrintTestParam(test_param);
}

protected:
void ExecuteTest(FuncTestParam<InType, OutType, TestType> test_param) {
const std::string& test_name = std::get<GTestParamIndex::kNameTest>(test_param);
const std::string& test_name = std::get<static_cast<std::size_t>(GTestParamIndex::kNameTest)>(test_param);

ValidateTestName(test_name);

Expand Down Expand Up @@ -90,11 +91,12 @@ class BaseRunFuncTests : public ::testing::TestWithParam<FuncTestParam<InType, O

/// @brief Initializes task instance and runs it through the full pipeline.
void InitializeAndRunTask(const FuncTestParam<InType, OutType, TestType>& test_param) {
task_ = std::get<GTestParamIndex::kTaskGetter>(test_param)(GetTestInputData());
task_ = std::get<static_cast<std::size_t>(GTestParamIndex::kTaskGetter)>(test_param)(GetTestInputData());
ExecuteTaskPipeline();
}

/// @brief Executes the full task pipeline with validation.
// NOLINTNEXTLINE(readability-function-cognitive-complexity)
void ExecuteTaskPipeline() {
EXPECT_TRUE(task_->Validation());
EXPECT_TRUE(task_->PreProcessing());
Expand Down
13 changes: 7 additions & 6 deletions modules/util/include/perf_test_util.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -35,8 +35,9 @@ class BaseRunPerfTests : public ::testing::TestWithParam<PerfTestParam<InType, O
public:
/// @brief Generates a readable name for the performance test case.
static std::string CustomPerfTestName(const ::testing::TestParamInfo<PerfTestParam<InType, OutType>>& info) {
return ppc::performance::GetStringParamName(std::get<GTestParamIndex::kTestParams>(info.param)) + "_" +
std::get<GTestParamIndex::kNameTest>(info.param);
return ppc::performance::GetStringParamName(
std::get<static_cast<std::size_t>(GTestParamIndex::kTestParams)>(info.param)) +
"_" + std::get<static_cast<std::size_t>(GTestParamIndex::kNameTest)>(info.param);
}

protected:
Expand Down Expand Up @@ -67,9 +68,9 @@ class BaseRunPerfTests : public ::testing::TestWithParam<PerfTestParam<InType, O
}

void ExecuteTest(const PerfTestParam<InType, OutType>& perf_test_param) {
auto task_getter = std::get<GTestParamIndex::kTaskGetter>(perf_test_param);
auto test_name = std::get<GTestParamIndex::kNameTest>(perf_test_param);
auto mode = std::get<GTestParamIndex::kTestParams>(perf_test_param);
auto task_getter = std::get<static_cast<std::size_t>(GTestParamIndex::kTaskGetter)>(perf_test_param);
auto test_name = std::get<static_cast<std::size_t>(GTestParamIndex::kNameTest)>(perf_test_param);
auto mode = std::get<static_cast<std::size_t>(GTestParamIndex::kTestParams)>(perf_test_param);

ASSERT_FALSE(test_name.find("unknown") != std::string::npos);
if (test_name.find("disabled") != std::string::npos) {
Expand Down Expand Up @@ -121,7 +122,7 @@ auto TupleToGTestValuesImpl(const Tuple& tup, std::index_sequence<I...> /*unused

template <typename Tuple>
auto TupleToGTestValues(Tuple&& tup) {
constexpr size_t kSize = std::tuple_size<std::decay_t<Tuple>>::value;
constexpr size_t kSize = std::tuple_size_v<std::decay_t<Tuple>>;
return TupleToGTestValuesImpl(std::forward<Tuple>(tup), std::make_index_sequence<kSize>{});
}

Expand Down
4 changes: 2 additions & 2 deletions modules/util/include/util.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -53,7 +53,7 @@ class DestructorFailureFlag {
inline static std::atomic<bool> failure_flag{false};
};

enum GTestParamIndex : uint8_t { kTaskGetter, kNameTest, kTestParams };
enum class GTestParamIndex : uint8_t { kTaskGetter, kNameTest, kTestParams };

std::string GetAbsoluteTaskPath(const std::string& id_path, const std::string& relative_path);
int GetNumThreads();
Expand All @@ -70,7 +70,7 @@ std::string GetNamespace() {
std::free};
name = (status == 0) ? demangled.get() : name;
#endif
#if defined(_MSC_VER)
#ifdef _MSC_VER
const std::string prefixes[] = {"class ", "struct ", "enum ", "union "};
for (const auto& prefix : prefixes) {
if (name.starts_with(prefix)) {
Expand Down
2 changes: 1 addition & 1 deletion tasks/example_processes/tests/functional/main.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -46,7 +46,7 @@ class NesterovARunFuncTestsProcesses : public ppc::util::BaseRunFuncTests<InType
}
}

TestType params = std::get<ppc::util::GTestParamIndex::kTestParams>(GetParam());
TestType params = std::get<static_cast<std::size_t>(ppc::util::GTestParamIndex::kTestParams)>(GetParam());
input_data_ = width - height + std::min(std::accumulate(img.begin(), img.end(), 0), channels);
}

Expand Down
2 changes: 1 addition & 1 deletion tasks/example_threads/tests/functional/main.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -49,7 +49,7 @@ class NesterovARunFuncTestsThreads : public ppc::util::BaseRunFuncTests<InType,
}
}

TestType params = std::get<ppc::util::GTestParamIndex::kTestParams>(GetParam());
TestType params = std::get<static_cast<std::size_t>(ppc::util::GTestParamIndex::kTestParams)>(GetParam());
input_data_ = width - height + std::min(std::accumulate(img.begin(), img.end(), 0), channels);
}

Expand Down
Loading