Skip to content

Commit 4136a79

Browse files
committed
Add comprehensive Doxygen documentation for task classes, utilities, and performance modules. Configure Doxyfile for extended metadata extraction.
1 parent 8927ddd commit 4136a79

File tree

8 files changed

+133
-26
lines changed

8 files changed

+133
-26
lines changed

Doxyfile

Lines changed: 12 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -4,9 +4,11 @@ PROJECT_BRIEF = "Parallel Programming Course"
44

55
# Input
66
INPUT = modules/core/task/include \
7-
modules/core/task/src \
87
modules/core/util/include \
9-
modules/core/util/src
8+
modules/core/util/src \
9+
modules/core/performance/include \
10+
modules/core/runners/include \
11+
modules/core/runners/src
1012
FILE_PATTERNS = *.h *.c *.hpp *.cpp
1113
RECURSIVE = YES
1214

@@ -15,3 +17,11 @@ GENERATE_HTML = NO
1517
GENERATE_LATEX = NO
1618
GENERATE_XML = YES
1719
XML_OUTPUT = xml
20+
21+
# Docs
22+
EXTRACT_ALL = YES
23+
EXTRACT_PRIVATE = YES
24+
EXTRACT_TEMPLATE_PARAMS = YES
25+
ENABLE_PREPROCESSING = YES
26+
MACRO_EXPANSION = YES
27+
EXPAND_ONLY_PREDEF = NO

docs/user_guide/api.rst

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -4,5 +4,5 @@ API Reference
44
.. toctree::
55
:maxdepth: 1
66

7-
.. doxygenindex::
8-
:project: ParallelProgrammingCourse
7+
.. .. doxygenindex::
8+
.. :project: ParallelProgrammingCourse

modules/core/performance/include/performance.hpp

Lines changed: 7 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -14,13 +14,16 @@
1414
namespace ppc::core {
1515

1616
struct PerfAttr {
17-
// count of task's running
17+
/// @brief Number of times the task is run for performance evaluation.
1818
uint64_t num_running = 5;
19+
/// @brief Timer function returning current time in seconds.
20+
/// @cond
1921
std::function<double()> current_timer = [&] { return -1.0; };
22+
/// @endcond
2023
};
2124

2225
struct PerfResults {
23-
// measurement of task's time (in seconds)
26+
/// @brief Measured execution time in seconds.
2427
double time_sec = 0.0;
2528
enum TypeOfRunning : uint8_t { kPipeline, kTaskRun, kNone } type_of_running = kNone;
2629
constexpr static double kMaxTime = 10.0;
@@ -87,7 +90,8 @@ class Perf {
8790
throw std::runtime_error(err_msg.str().c_str());
8891
}
8992
}
90-
// Get performance result structure of the current task
93+
/// @brief Retrieves the performance test results.
94+
/// @return The latest PerfResults structure.
9195
PerfResults GetPerfResults() { return perf_results_; }
9296

9397
private:

modules/core/runners/include/runners.hpp

Lines changed: 14 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -7,25 +7,39 @@
77

88
namespace ppc::core {
99

10+
/// @brief GTest event listener that checks for unread MPI messages after each test.
11+
/// @note Used to detect unexpected inter-process communication leftovers.
1012
class UnreadMessagesDetector : public ::testing::EmptyTestEventListener {
1113
public:
1214
UnreadMessagesDetector() = default;
15+
/// @brief Called by GTest after a test ends. Checks for unread messages.
1316
void OnTestEnd(const ::testing::TestInfo& /*test_info*/) override;
1417

1518
private:
1619
};
1720

21+
/// @brief GTest event listener that prints additional information on test failures in worker processes.
22+
/// @details Includes MPI rank info in failure output for debugging.
1823
class WorkerTestFailurePrinter : public ::testing::EmptyTestEventListener {
1924
public:
25+
/// @brief Constructs the listener with a base listener for delegation.
26+
/// @param base A shared pointer to another GTest event listener.
2027
explicit WorkerTestFailurePrinter(std::shared_ptr<::testing::TestEventListener> base) : base_(std::move(base)) {}
28+
/// @brief Called after a test ends. Passes call to base listener and prints failures with rank.
2129
void OnTestEnd(const ::testing::TestInfo& test_info) override;
30+
/// @brief Called when a test part fails. Prints MPI rank info along with the failure.
2231
void OnTestPartResult(const ::testing::TestPartResult& test_part_result) override;
2332

2433
private:
34+
/// @brief Prints the MPI rank of the current process to stderr.
2535
static void PrintProcessRank();
2636
std::shared_ptr<::testing::TestEventListener> base_;
2737
};
2838

39+
/// @brief Initializes the testing environment (e.g., MPI, logging).
40+
/// @param argc Argument count.
41+
/// @param argv Argument vector.
42+
/// @return Exit code: 0 for success, non-zero for failure.
2943
int Init(int argc, char** argv);
3044

3145
} // namespace ppc::core

modules/core/task/include/task.hpp

Lines changed: 83 additions & 17 deletions
Original file line numberDiff line numberDiff line change
@@ -19,16 +19,48 @@ using namespace std::chrono;
1919

2020
namespace ppc::core {
2121

22-
enum TypeOfTask : uint8_t { kALL, kMPI, kOMP, kSEQ, kSTL, kTBB, kUnknown };
23-
enum StatusOfTask : uint8_t { kEnabled, kDisabled };
22+
/// @brief Represents the type of task (parallelization technology).
23+
/// @details Used to select the implementation type in tests and execution logic.
24+
enum TypeOfTask : uint8_t {
25+
/// Use all available implementations
26+
kALL,
27+
/// MPI (Message Passing Interface)
28+
kMPI,
29+
/// OpenMP (Open Multi-Processing)
30+
kOMP,
31+
/// Sequential implementation
32+
kSEQ,
33+
/// Standard Thread Library (STL threads)
34+
kSTL,
35+
/// Intel Threading Building Blocks (TBB)
36+
kTBB,
37+
/// Unknown task type
38+
kUnknown
39+
};
40+
41+
/// @brief Indicates whether a task is enabled or disabled.
42+
enum StatusOfTask : uint8_t {
43+
/// Task is enabled and should be executed
44+
kEnabled,
45+
/// Task is disabled and will be skipped
46+
kDisabled
47+
};
2448

49+
/// @brief Returns a string representation of the task status.
50+
/// @param status_of_task Task status (enabled or disabled).
51+
/// @return "enabled" if the task is enabled, otherwise "disabled".
2552
inline std::string GetStringTaskStatus(StatusOfTask status_of_task) {
2653
if (status_of_task == kDisabled) {
2754
return "disabled";
2855
}
2956
return "enabled";
3057
}
3158

59+
/// @brief Returns a string representation of the task type based on the JSON settings file.
60+
/// @param type_of_task Type of the task.
61+
/// @param settings_file_path Path to the JSON file containing task type strings.
62+
/// @return Formatted string combining the task type and its corresponding value from the file.
63+
/// @throws std::runtime_error If the file cannot be opened.
3264
inline std::string GetStringTaskType(TypeOfTask type_of_task, const std::string &settings_file_path) {
3365
std::ifstream file(settings_file_path);
3466
if (!file.is_open()) {
@@ -65,20 +97,24 @@ inline std::string GetStringTaskType(TypeOfTask type_of_task, const std::string
6597

6698
enum StateOfTesting : uint8_t { kFunc, kPerf };
6799

68-
// Memory of inputs and outputs need to be initialized before create an object of
69-
// Task class
70100
template <typename InType, typename OutType>
101+
/// @brief Base abstract class representing a generic task with a defined pipeline.
102+
/// @tparam InType Input data type.
103+
/// @tparam OutType Output data type.
71104
class Task {
72105
public:
106+
/// @brief Constructs a new Task object.
73107
explicit Task(StateOfTesting /*state_of_testing*/ = StateOfTesting::kFunc) { functions_order_.clear(); }
74108

75-
// validation of data and validation of task attributes before running
109+
/// @brief Validates input data and task attributes before execution.
110+
/// @return True if validation is successful.
76111
virtual bool Validation() final {
77112
InternalOrderTest(__builtin_FUNCTION());
78113
return ValidationImpl();
79114
}
80115

81-
// pre-processing of input data
116+
/// @brief Performs preprocessing on the input data.
117+
/// @return True if preprocessing is successful.
82118
virtual bool PreProcessing() final {
83119
InternalOrderTest(__builtin_FUNCTION());
84120
if (state_of_testing_ == StateOfTesting::kFunc) {
@@ -87,13 +123,15 @@ class Task {
87123
return PreProcessingImpl();
88124
}
89125

90-
// realization of the current task
126+
/// @brief Executes the main logic of the task.
127+
/// @return True if execution is successful.
91128
virtual bool Run() final {
92129
InternalOrderTest(__builtin_FUNCTION());
93130
return RunImpl();
94131
}
95132

96-
// post-processing of output data
133+
/// @brief Performs postprocessing on the output data.
134+
/// @return True if postprocessing is successful.
97135
virtual bool PostProcessing() final {
98136
InternalOrderTest(__builtin_FUNCTION());
99137
if (state_of_testing_ == StateOfTesting::kFunc) {
@@ -102,25 +140,36 @@ class Task {
102140
return PostProcessingImpl();
103141
}
104142

105-
// get state of testing
143+
/// @brief Returns the current testing mode.
144+
/// @return Reference to the current StateOfTesting.
106145
StateOfTesting &GetStateOfTesting() { return state_of_testing_; }
107146

108-
// set a type of task
147+
/// @brief Sets the dynamic task type.
148+
/// @param type_of_task Task type to set.
109149
void SetTypeOfTask(TypeOfTask type_of_task) { type_of_task_ = type_of_task; }
110150

111-
// get a dynamic type of task
151+
/// @brief Returns the dynamic task type.
152+
/// @return Current dynamic task type.
112153
[[nodiscard]] TypeOfTask GetDynamicTypeOfTask() const { return type_of_task_; }
113154

114-
// get a dynamic type of task
155+
/// @brief Returns the current task status.
156+
/// @return Task status (enabled or disabled).
115157
[[nodiscard]] StatusOfTask GetStatusOfTask() const { return status_of_task_; }
116158

117-
// get a static type of task
159+
/// @brief Returns the static task type.
160+
/// @return Static task type (default: kUnknown).
118161
static constexpr TypeOfTask GetStaticTypeOfTask() { return TypeOfTask::kUnknown; }
119162

163+
/// @brief Returns a reference to the input data.
164+
/// @return Reference to the task's input data.
120165
InType &GetInput() { return input_; }
121166

167+
/// @brief Returns a reference to the output data.
168+
/// @return Reference to the task's output data.
122169
OutType &GetOutput() { return output_; }
123170

171+
/// @brief Destructor. Verifies that the pipeline was executed in the correct order.
172+
/// @note Terminates the program if pipeline order is incorrect or incomplete.
124173
virtual ~Task() {
125174
if (!functions_order_.empty() || !was_worked_) {
126175
std::cerr << "ORDER OF FUNCTIONS IS NOT RIGHT! \n Expected - \"Validation\", \"PreProcessing\", \"Run\", "
@@ -132,6 +181,8 @@ class Task {
132181
}
133182

134183
protected:
184+
/// @brief Verifies the correct order of pipeline method calls.
185+
/// @param str Name of the method being called.
135186
virtual void InternalOrderTest(const std::string &str) final {
136187
functions_order_.push_back(str);
137188
if (str == "PostProcessing" && IsFullPipelineStage()) {
@@ -141,6 +192,9 @@ class Task {
141192
}
142193
}
143194

195+
/// @brief Measures execution time between preprocessing and postprocessing steps.
196+
/// @param str Name of the method being timed.
197+
/// @throws std::runtime_error If execution exceeds the allowed time limit.
144198
virtual void InternalTimeTest(const std::string &str) final {
145199
if (str == "PreProcessing") {
146200
tmp_time_point_ = std::chrono::high_resolution_clock::now();
@@ -162,16 +216,20 @@ class Task {
162216
}
163217
}
164218

165-
// implementation of "Validation" function
219+
/// @brief User-defined validation logic.
220+
/// @return True if validation is successful.
166221
virtual bool ValidationImpl() = 0;
167222

168-
// implementation of "PreProcessing" function
223+
/// @brief User-defined preprocessing logic.
224+
/// @return True if preprocessing is successful.
169225
virtual bool PreProcessingImpl() = 0;
170226

171-
// implementation of "Run" function
227+
/// @brief User-defined task execution logic.
228+
/// @return True if run is successful.
172229
virtual bool RunImpl() = 0;
173230

174-
// implementation of "PostProcessing" function
231+
/// @brief User-defined postprocessing logic.
232+
/// @return True if postprocessing is successful.
175233
virtual bool PostProcessingImpl() = 0;
176234

177235
private:
@@ -198,9 +256,17 @@ class Task {
198256
}
199257
};
200258

259+
/// @brief Smart pointer alias for Task.
260+
/// @tparam InType Input data type.
261+
/// @tparam OutType Output data type.
201262
template <typename InType, typename OutType>
202263
using TaskPtr = std::shared_ptr<Task<InType, OutType>>;
203264

265+
/// @brief Constructs and returns a shared pointer to a task with the given input.
266+
/// @tparam TaskType Type of the task to create.
267+
/// @tparam InType Type of the input.
268+
/// @param in Input to pass to the task constructor.
269+
/// @return Shared pointer to the newly created task.
204270
template <typename TaskType, typename InType>
205271
std::shared_ptr<TaskType> TaskGetter(InType in) {
206272
return std::make_shared<TaskType>(in);

modules/core/util/include/func_test_util.hpp

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -31,9 +31,15 @@ concept HasPrintTestParam = requires(TestType value) {
3131
};
3232

3333
template <typename InType, typename OutType, typename TestType = void>
34+
/// @brief Base class for running functional tests on parallel tasks.
35+
/// @tparam InType Type of input data.
36+
/// @tparam OutType Type of output data.
37+
/// @tparam TestType Type of the test case or parameter.
3438
class BaseRunFuncTests : public ::testing::TestWithParam<FuncTestParam<InType, OutType, TestType>> {
3539
public:
3640
virtual bool CheckTestOutputData(OutType& output_data) = 0;
41+
/// @brief Provides input data for the task.
42+
/// @return Initialized input data.
3743
virtual InType GetTestInputData() = 0;
3844

3945
template <typename Derived>
@@ -79,6 +85,7 @@ class BaseRunFuncTests : public ::testing::TestWithParam<FuncTestParam<InType, O
7985
return !ppc::util::IsUnderMpirun() && (contains_substring("_all") || contains_substring("_mpi"));
8086
}
8187

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

modules/core/util/include/perf_test_util.hpp

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -28,15 +28,20 @@ using PerfTestParam = std::tuple<std::function<ppc::core::TaskPtr<InType, OutTyp
2828
ppc::core::PerfResults::TypeOfRunning>;
2929

3030
template <typename InType, typename OutType>
31+
/// @brief Base class for performance testing of parallel tasks.
32+
/// @tparam InType Input data type.
33+
/// @tparam OutType Output data type.
3134
class BaseRunPerfTests : public ::testing::TestWithParam<PerfTestParam<InType, OutType>> {
3235
public:
36+
/// @brief Generates a readable name for the performance test case.
3337
static std::string CustomPerfTestName(const ::testing::TestParamInfo<PerfTestParam<InType, OutType>>& info) {
3438
return ppc::core::GetStringParamName(std::get<GTestParamIndex::kTestParams>(info.param)) + "_" +
3539
std::get<GTestParamIndex::kNameTest>(info.param);
3640
}
3741

3842
protected:
3943
virtual bool CheckTestOutputData(OutType& output_data) = 0;
44+
/// @brief Supplies input data for performance testing.
4045
virtual InType GetTestInputData() = 0;
4146

4247
virtual void SetPerfAttributes(ppc::core::PerfAttr& perf_attrs) {

modules/core/util/include/util.hpp

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -13,9 +13,10 @@
1313

1414
#include <nlohmann/json.hpp> // NOLINT(misc-include-cleaner)
1515

16+
/// @brief JSON namespace used for settings and config parsing.
1617
using NlohmannJsonParseError = nlohmann::json::parse_error; // NOLINT(misc-include-cleaner)
17-
using NlohmannJsonTypeError = nlohmann::json::type_error; // NOLINT(misc-include-cleaner)
18-
18+
/// @brief JSON namespace used for settings and config typing.
19+
using NlohmannJsonTypeError = nlohmann::json::type_error; // NOLINT(misc-include-cleaner)
1920
#ifdef _MSC_VER
2021
#pragma warning(pop)
2122
#endif

0 commit comments

Comments
 (0)