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
4 changes: 4 additions & 0 deletions .clang-tidy
Original file line number Diff line number Diff line change
Expand Up @@ -27,6 +27,7 @@ Checks: >
readability-*,
-bugprone-casting-through-void,
-bugprone-easily-swappable-parameters,
-bugprone-throwing-static-initialization,
-cppcoreguidelines-avoid-magic-numbers,
-cppcoreguidelines-non-private-member-variables-in-classes,
-cppcoreguidelines-owning-memory,
Expand All @@ -37,9 +38,12 @@ Checks: >
-misc-const-correctness,
-misc-non-private-member-variables-in-classes,
-modernize-avoid-c-arrays,
-misc-override-with-different-visibility,
-misc-use-internal-linkage,
-modernize-use-trailing-return-type,
-portability-avoid-pragma-once,
-portability-template-virtual-member-function,
-readability-inconsistent-ifelse-braces,
-readability-magic-numbers

HeaderFilterRegex: '.*/(modules|tasks)/.*'
Expand Down
11 changes: 3 additions & 8 deletions modules/performance/tests/perf_tests.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -39,8 +39,8 @@ class TestPerfTask : public ppc::task::Task<InType, OutType> {
}

bool RunImpl() override {
for (unsigned i = 0; i < this->GetInput().size(); i++) {
this->GetOutput() += this->GetInput()[i];
for (const auto &value : this->GetInput()) {
this->GetOutput() += value;
}
return true;
}
Expand Down Expand Up @@ -201,12 +201,7 @@ class GetStringTaskTypeTest : public ::testing::TestWithParam<TaskTypeTestCase>
void SetUp() override {
temp_path = (std::filesystem::temp_directory_path() / "test_settings.json").string();
auto j = ppc::util::InitJSONPtr();
(*j)["tasks"]["all"] = "ALL";
(*j)["tasks"]["stl"] = "STL";
(*j)["tasks"]["omp"] = "OMP";
(*j)["tasks"]["mpi"] = "MPI";
(*j)["tasks"]["tbb"] = "TBB";
(*j)["tasks"]["seq"] = "SEQ";
*j = {{"tasks", {{"all", "ALL"}, {"stl", "STL"}, {"omp", "OMP"}, {"mpi", "MPI"}, {"tbb", "TBB"}, {"seq", "SEQ"}}}};

std::ofstream(temp_path) << j->dump();
}
Expand Down
24 changes: 13 additions & 11 deletions modules/task/include/task.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -13,6 +13,7 @@
#include <sstream>
#include <stdexcept>
#include <string>
#include <string_view>
#include <util/include/util.hpp>
#include <utility>

Expand All @@ -37,17 +38,17 @@ enum class TypeOfTask : uint8_t {
kUnknown,
};

using TaskMapping = std::pair<TypeOfTask, std::string>;
using TaskMapping = std::pair<TypeOfTask, std::string_view>;
using TaskMappingArray = std::array<TaskMapping, 6>;

const TaskMappingArray kTaskTypeMappings = {{{TypeOfTask::kALL, "all"},
{TypeOfTask::kMPI, "mpi"},
{TypeOfTask::kOMP, "omp"},
{TypeOfTask::kSEQ, "seq"},
{TypeOfTask::kSTL, "stl"},
{TypeOfTask::kTBB, "tbb"}}};
inline constexpr TaskMappingArray kTaskTypeMappings = {{{TypeOfTask::kALL, "all"},
{TypeOfTask::kMPI, "mpi"},
{TypeOfTask::kOMP, "omp"},
{TypeOfTask::kSEQ, "seq"},
{TypeOfTask::kSTL, "stl"},
{TypeOfTask::kTBB, "tbb"}}};

inline std::string TypeOfTaskToString(TypeOfTask type) {
constexpr std::string_view TypeOfTaskToString(TypeOfTask type) {
for (const auto &[key, value] : kTaskTypeMappings) {
if (key == type) {
return value;
Expand Down Expand Up @@ -88,12 +89,13 @@ inline std::string GetStringTaskType(TypeOfTask type_of_task, const std::string
auto list_settings = ppc::util::InitJSONPtr();
file >> *list_settings;

std::string type_str = TypeOfTaskToString(type_of_task);
const std::string_view type_str = TypeOfTaskToString(type_of_task);
if (type_str == "unknown") {
return type_str;
return std::string(type_str);
}

return type_str + "_" + std::string((*list_settings)["tasks"][type_str]);
const auto &tasks = list_settings->at("tasks");
return std::string(type_str) + "_" + std::string(tasks.at(std::string(type_str)));
}

enum class StateOfTesting : uint8_t {
Expand Down
10 changes: 5 additions & 5 deletions modules/task/tests/task_tests.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -26,14 +26,14 @@ using ppc::task::TypeOfTask;

class ScopedFile {
public:
explicit ScopedFile(std::string path) : path_(std::move(path)) {}
~ScopedFile() {
explicit ScopedFile(std::filesystem::path path) : path_(std::move(path)) {}
~ScopedFile() noexcept {
std::error_code ec;
std::filesystem::remove(path_, ec);
}

private:
std::string path_;
std::filesystem::path path_;
};

namespace ppc::test {
Expand All @@ -55,8 +55,8 @@ class TestTask : public ppc::task::Task<InType, OutType> {
}

bool RunImpl() override {
for (unsigned i = 0; i < this->GetInput().size(); i++) {
this->GetOutput() += this->GetInput()[i];
for (const auto &value : this->GetInput()) {
this->GetOutput() += value;
}
return true;
}
Expand Down
10 changes: 4 additions & 6 deletions modules/util/include/func_test_util.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -76,17 +76,15 @@ class BaseRunFuncTests : public ::testing::TestWithParam<FuncTestParam<InType, O
}

void ValidateTestName(const std::string &test_name) {
EXPECT_FALSE(test_name.find("unknown") != std::string::npos);
EXPECT_FALSE(test_name.contains("unknown"));
}

bool IsTestDisabled(const std::string &test_name) {
return test_name.find("disabled") != std::string::npos;
return test_name.contains("disabled");
}

bool ShouldSkipNonMpiTask(const std::string &test_name) {
auto contains_substring = [&](const std::string &substring) {
return test_name.find(substring) != std::string::npos;
};
auto contains_substring = [&](const std::string &substring) { return test_name.contains(substring); };

return !ppc::util::IsUnderMpirun() && (contains_substring("_all") || contains_substring("_mpi"));
}
Expand Down Expand Up @@ -128,7 +126,7 @@ auto GenTaskTuplesImpl(const SizesContainer &sizes, const std::string &settings_
return std::make_tuple(std::make_tuple(ppc::task::TaskGetter<Task, InType>,
std::string(GetNamespace<Task>()) + "_" +
ppc::task::GetStringTaskType(Task::GetStaticTypeOfTask(), settings_path),
sizes[Is])...);
std::get<Is>(sizes))...);
}

template <typename Task, typename InType, typename SizesContainer>
Expand Down
2 changes: 1 addition & 1 deletion tasks/example_processes/mpi/include/ops_mpi.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,7 @@ class NesterovATestTaskMPI : public BaseTask {
}
explicit NesterovATestTaskMPI(const InType &in);

private:
protected:
bool ValidationImpl() override;
bool PreProcessingImpl() override;
bool RunImpl() override;
Expand Down
2 changes: 1 addition & 1 deletion tasks/example_processes/seq/include/ops_seq.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,7 @@ class NesterovATestTaskSEQ : public BaseTask {
}
explicit NesterovATestTaskSEQ(const InType &in);

private:
protected:
bool ValidationImpl() override;
bool PreProcessingImpl() override;
bool RunImpl() override;
Expand Down
2 changes: 1 addition & 1 deletion tasks/example_processes_2/mpi/include/ops_mpi.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,7 @@ class NesterovATestTaskMPI : public BaseTask {
}
explicit NesterovATestTaskMPI(const InType &in);

private:
protected:
bool ValidationImpl() override;
bool PreProcessingImpl() override;
bool RunImpl() override;
Expand Down
2 changes: 1 addition & 1 deletion tasks/example_processes_2/seq/include/ops_seq.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,7 @@ class NesterovATestTaskSEQ : public BaseTask {
}
explicit NesterovATestTaskSEQ(const InType &in);

private:
protected:
bool ValidationImpl() override;
bool PreProcessingImpl() override;
bool RunImpl() override;
Expand Down
2 changes: 1 addition & 1 deletion tasks/example_processes_3/mpi/include/ops_mpi.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,7 @@ class NesterovATestTaskMPI : public BaseTask {
}
explicit NesterovATestTaskMPI(const InType &in);

private:
protected:
bool ValidationImpl() override;
bool PreProcessingImpl() override;
bool RunImpl() override;
Expand Down
2 changes: 1 addition & 1 deletion tasks/example_processes_3/seq/include/ops_seq.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,7 @@ class NesterovATestTaskSEQ : public BaseTask {
}
explicit NesterovATestTaskSEQ(const InType &in);

private:
protected:
bool ValidationImpl() override;
bool PreProcessingImpl() override;
bool RunImpl() override;
Expand Down
2 changes: 1 addition & 1 deletion tasks/example_threads/all/include/ops_all.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,7 @@ class NesterovATestTaskALL : public BaseTask {
}
explicit NesterovATestTaskALL(const InType &in);

private:
protected:
bool ValidationImpl() override;
bool PreProcessingImpl() override;
bool RunImpl() override;
Expand Down
6 changes: 3 additions & 3 deletions tasks/example_threads/all/src/ops_all.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -60,9 +60,9 @@ bool NesterovATestTaskALL::RunImpl() {
GetOutput() *= num_threads;
std::vector<std::thread> threads(num_threads);
std::atomic<int> counter(0);
for (int i = 0; i < num_threads; i++) {
threads[i] = std::thread([&]() { counter++; });
threads[i].join();
for (std::thread &thread : threads) {
thread = std::thread([&counter]() { counter++; });
thread.join();
}
GetOutput() /= counter;
}
Expand Down
2 changes: 1 addition & 1 deletion tasks/example_threads/omp/include/ops_omp.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,7 @@ class NesterovATestTaskOMP : public BaseTask {
}
explicit NesterovATestTaskOMP(const InType &in);

private:
protected:
bool ValidationImpl() override;
bool PreProcessingImpl() override;
bool RunImpl() override;
Expand Down
2 changes: 1 addition & 1 deletion tasks/example_threads/seq/include/ops_seq.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,7 @@ class NesterovATestTaskSEQ : public BaseTask {
}
explicit NesterovATestTaskSEQ(const InType &in);

private:
protected:
bool ValidationImpl() override;
bool PreProcessingImpl() override;
bool RunImpl() override;
Expand Down
2 changes: 1 addition & 1 deletion tasks/example_threads/stl/include/ops_stl.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,7 @@ class NesterovATestTaskSTL : public BaseTask {
}
explicit NesterovATestTaskSTL(const InType &in);

private:
protected:
bool ValidationImpl() override;
bool PreProcessingImpl() override;
bool RunImpl() override;
Expand Down
6 changes: 3 additions & 3 deletions tasks/example_threads/stl/src/ops_stl.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -41,9 +41,9 @@ bool NesterovATestTaskSTL::RunImpl() {
GetOutput() *= num_threads;

std::atomic<int> counter(0);
for (int i = 0; i < num_threads; i++) {
threads[i] = std::thread([&]() { counter++; });
threads[i].join();
for (std::thread &thread : threads) {
thread = std::thread([&counter]() { counter++; });
thread.join();
}

GetOutput() /= counter;
Expand Down
2 changes: 1 addition & 1 deletion tasks/example_threads/tbb/include/ops_tbb.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,7 @@ class NesterovATestTaskTBB : public BaseTask {
}
explicit NesterovATestTaskTBB(const InType &in);

private:
protected:
bool ValidationImpl() override;
bool PreProcessingImpl() override;
bool RunImpl() override;
Expand Down
Loading