Skip to content

Commit 9f07b0d

Browse files
committed
Make readability-function-cognitive-complexity threshold more strict
1 parent 7e9c38d commit 9f07b0d

2 files changed

Lines changed: 27 additions & 18 deletions

File tree

.clang-tidy

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -85,7 +85,8 @@ CheckOptions:
8585
value: lower_case
8686
- key: readability-identifier-naming.IgnoreMainLikeFunctions
8787
value: 1
88+
# Functions with scores beyond 15 are typically flagged as potentially problematic (empirically)
8889
- key: readability-function-cognitive-complexity.Threshold
89-
value: 25 # default: 25
90+
value: 15 # default: 25
9091
- key: misc-include-cleaner.IgnoreHeaders
9192
value: '(opencv2/.*|__chrono/.*)'

tasks/mpi/example/src/ops_mpi.cpp

Lines changed: 25 additions & 17 deletions
Original file line numberDiff line numberDiff line change
@@ -25,29 +25,37 @@ bool nesterov_a_test_task_mpi::TestTaskMPI::ValidationImpl() {
2525
}
2626

2727
bool nesterov_a_test_task_mpi::TestTaskMPI::RunImpl() {
28-
int rank = -1;
29-
MPI_Comm_rank(MPI_COMM_WORLD, &rank);
30-
if (rank == 0) {
31-
// Multiply matrices
32-
for (int i = 0; i < rc_size_; ++i) {
33-
for (int j = 0; j < rc_size_; ++j) {
34-
for (int k = 0; k < rc_size_; ++k) {
35-
output_[(i * rc_size_) + j] += input_[(i * rc_size_) + k] * input_[(k * rc_size_) + j];
36-
}
37-
}
38-
}
28+
MultiplyMatrixBasedOnRank();
29+
return true;
30+
}
31+
32+
void nesterov_a_test_task_mpi::TestTaskMPI::MultiplyMatrixBasedOnRank() {
33+
if (world_.rank() == 0) {
34+
MultiplyRowMajor();
3935
} else {
40-
// Multiply matrices
36+
MultiplyColumnMajor();
37+
}
38+
world_.barrier();
39+
}
40+
41+
void nesterov_a_test_task_mpi::TestTaskMPI::MultiplyRowMajor() {
42+
for (int i = 0; i < rc_size_; ++i) {
4143
for (int j = 0; j < rc_size_; ++j) {
4244
for (int k = 0; k < rc_size_; ++k) {
43-
for (int i = 0; i < rc_size_; ++i) {
44-
output_[(i * rc_size_) + j] += input_[(i * rc_size_) + k] * input_[(k * rc_size_) + j];
45-
}
45+
output_[(i * rc_size_) + j] += input_[(i * rc_size_) + k] * input_[(k * rc_size_) + j];
46+
}
47+
}
48+
}
49+
}
50+
51+
void nesterov_a_test_task_mpi::TestTaskMPI::MultiplyColumnMajor() {
52+
for (int j = 0; j < rc_size_; ++j) {
53+
for (int k = 0; k < rc_size_; ++k) {
54+
for (int i = 0; i < rc_size_; ++i) {
55+
output_[(i * rc_size_) + j] += input_[(i * rc_size_) + k] * input_[(k * rc_size_) + j];
4656
}
4757
}
4858
}
49-
MPI_Barrier(MPI_COMM_WORLD);
50-
return true;
5159
}
5260

5361
bool nesterov_a_test_task_mpi::TestTaskMPI::PostProcessingImpl() {

0 commit comments

Comments
 (0)