-
Notifications
You must be signed in to change notification settings - Fork 163
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Зиновьев Александр Задача 1 Вариант 12 Сумма значений по столбцам матрицы #282
base: master
Are you sure you want to change the base?
Conversation
Codecov ReportAttention: Patch coverage is
Additional details and impacted files@@ Coverage Diff @@
## master #282 +/- ##
==========================================
- Coverage 97.12% 96.34% -0.78%
==========================================
Files 87 445 +358
Lines 2263 11421 +9158
Branches 786 4808 +4022
==========================================
+ Hits 2198 11004 +8806
- Misses 29 136 +107
- Partials 36 281 +245 ☔ View full report in Codecov by Sentry. |
|
||
#include <thread> | ||
|
||
using namespace std::chrono_literals; |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Do you use it?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
fixed
#include <thread> | ||
#include <vector> | ||
|
||
using namespace std::chrono_literals; |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Do you use it?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
fixed
|
||
using namespace std::chrono_literals; | ||
|
||
std::vector<int> zinoviev_a_sum_cols_matrix_mpi::generateRandomVector(int sz) { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Your tests are failed because there function generateRandomVector has parametr - int sz, but in include function generateRandomVector has parametr - int size. Thats why tests give an error zinoviev_a_sum_cols_matrix_mpi::generateRandomVector has a definition with different parameter names. Change parametr name - give the parematr only one name.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
fixed
} | ||
return sums; | ||
} | ||
|
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
In functions computeLinearCoordinates and calculateMatrixSumSequential the same problem. Change parametr name - give the parematr only one name.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
fixed
std::vector<int> zinoviev_a_sum_cols_matrix_mpi::generateRandomVector(int size) { | ||
std::random_device dev; | ||
std::mt19937 gen(dev()); | ||
std::vector<int> vec(size); | ||
for (int i = 0; i < size; i++) { | ||
vec[i] = gen() % 100; | ||
} | ||
return vec; | ||
} | ||
|
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Please, move test functions to the test module
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
fixed
broadcast(mpiWorld, numCols, 0); | ||
broadcast(mpiWorld, numRows, 0); | ||
|
||
if (mpiWorld.rank() == 0) { | ||
// Initialize the input vector | ||
inputData_ = std::vector<int>(taskData->inputs_count[0]); | ||
auto* temp_ptr = reinterpret_cast<int*>(taskData->inputs[0]); | ||
for (unsigned int i = 0; i < taskData->inputs_count[0]; i++) { | ||
inputData_[i] = temp_ptr[i]; | ||
} | ||
} else { | ||
inputData_ = std::vector<int>(numCols * numRows); | ||
} |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Please, move MPI data transfer to ::run()
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
fixed
::testing::InitGoogleTest(&argc, argv); | ||
return RUN_ALL_TESTS(); | ||
} | ||
} |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Please, do not modify common files!
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
fixed
std::mt19937 gen(dev()); | ||
std::vector<int> vec(size); | ||
for (int i = 0; i < size; i++) { | ||
vec[i] = gen() % 100; |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
please use negative values too
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
fixed
Здесь представлены последовательная и параллельная реализации суммы значений по столбцам матрицы. В последовательной реализуем вложенный цикл, проходя по каждому столбцу матрицы, суммируя значения её элементов. Итоговые суммы помещаются в отдельный вектор. В параллельной распределяем столбцы матрицы в зависимости от числа доступных процессов. Определяем величину, которая обозначает количество столбцов, отведенных каждому процессу, а также индекс последнего обрабатываемого столбца для каждого процесса. Каждая группа столбцов суммируется с использованием функции, аналогичной той, что применяется в последовательной версии. Полученные результаты затем консолидируются в общий вектор.