Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
46 commits
Select commit Hold shift + click to select a range
cf5ed27
Add test task
Offsidetax Oct 25, 2025
8a464c5
Fix tests name
Offsidetax Oct 25, 2025
3372f3d
Tests are working correctly
Offsidetax Oct 26, 2025
1f1d15a
Correct tests with any vectors
Offsidetax Oct 26, 2025
810f8ca
Fix line endings
Offsidetax Oct 27, 2025
ecc2de5
Fix unused variable in perf tests
Offsidetax Oct 27, 2025
79f5e78
Broadcast vectors data to all MPI processes
Offsidetax Oct 27, 2025
89cf12a
Broadcast vectors data to all MPI processes (second try)
Offsidetax Oct 27, 2025
619a2a9
Fixed deadlock
Offsidetax Oct 27, 2025
8bcb400
Updated logic in mpi
Offsidetax Oct 27, 2025
36b0852
Easier mpi version
Offsidetax Oct 27, 2025
54c57c3
New mpi logic
Offsidetax Oct 27, 2025
9eb1410
Another one mpi version (changed because the last one doesn`t work on…
Offsidetax Oct 27, 2025
3ae94b0
Another one mpi version (changed because the last one doesn`t work on…
Offsidetax Oct 27, 2025
b199b91
Reduced vector size in perf test
Offsidetax Oct 27, 2025
82e1d73
Updated data distribution in mpi
Offsidetax Oct 27, 2025
4be148e
Fixed deadlock
Offsidetax Oct 29, 2025
d705f9c
Fixed deadlock for mac
Offsidetax Oct 29, 2025
d71a524
Second try to fix deadlock for mac
Offsidetax Oct 29, 2025
2cf133e
Third try to fix deadlock for mac and ubuntu
Offsidetax Oct 29, 2025
e26cc1c
Fourth try to fix deadlock for mac
Offsidetax Oct 29, 2025
04433c9
Fifth try to fix deadlock for mac
Offsidetax Oct 29, 2025
27fc027
Report added
Offsidetax Nov 2, 2025
25824fa
Report fixed
Offsidetax Nov 2, 2025
c3476f6
Report fixed 2
Offsidetax Nov 2, 2025
369ba74
Merge branch 'master' into spichek_d_dot_product_of_vectors
Offsidetax Nov 9, 2025
5d39b5b
Update files to match clang-tidy
Offsidetax Nov 9, 2025
fae0ea9
Update files to match clang-tidy
Offsidetax Nov 9, 2025
0e17e66
Update files to match clang-tidy
Offsidetax Nov 9, 2025
55428e5
Update files to match clang-tidy
Offsidetax Nov 9, 2025
833d1e3
Update files to match clang-tidy
Offsidetax Nov 9, 2025
4a0c98a
Added functional tests
Offsidetax Nov 10, 2025
3d28af9
Fixed functional tests
Offsidetax Nov 10, 2025
56c371d
Fixed functional tests
Offsidetax Nov 10, 2025
e0e1c6f
Fixed functional tests
Offsidetax Nov 10, 2025
46ce4ec
Fixed functional tests
Offsidetax Nov 10, 2025
e61ac49
Fixed work with empty vectors in seq version
Offsidetax Nov 10, 2025
05e990b
Fixed functional tests
Offsidetax Nov 10, 2025
b650621
Fix for proper operation of clang-tidy
Offsidetax Nov 10, 2025
7f6fd0e
Removed an unnecessary check from the code
Offsidetax Nov 13, 2025
27c3e2c
Fixed work with memory
Offsidetax Nov 26, 2025
6e8e886
Update report
Offsidetax Nov 26, 2025
5432fc8
Clang-tidy fix
Offsidetax Nov 26, 2025
d69d037
Clang-tidy fix
Offsidetax Nov 26, 2025
32c7efb
Correct info.json
Offsidetax Nov 29, 2025
debf6b4
Fix
Offsidetax Nov 30, 2025
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
Original file line number Diff line number Diff line change
@@ -0,0 +1,19 @@
#pragma once

#include <string>
#include <tuple>
#include <utility>
#include <vector>

#include "task/include/task.hpp"

namespace spichek_d_dot_product_of_vectors {
Comment thread
allnes marked this conversation as resolved.

// Пара векторов как входные данные
using InType = std::pair<std::vector<int>, std::vector<int>>;
using OutType = int;
// Тестовые параметры: (пара_векторов, описание)
using TestType = std::tuple<std::pair<std::vector<int>, std::vector<int>>, std::string>;
using BaseTask = ppc::task::Task<InType, OutType>;

} // namespace spichek_d_dot_product_of_vectors
9 changes: 9 additions & 0 deletions tasks/spichek_d_dot_product_of_vectors/info.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,9 @@
{
"student": {
"first_name": "Денис",
"last_name": "Спичек",
"middle_name": "Игоревич",
"group_number": "3823Б1ФИ1",
"task_number": "1"
}
}
22 changes: 22 additions & 0 deletions tasks/spichek_d_dot_product_of_vectors/mpi/include/ops_mpi.hpp
Original file line number Diff line number Diff line change
@@ -0,0 +1,22 @@
#pragma once

#include "spichek_d_dot_product_of_vectors/common/include/common.hpp"
#include "task/include/task.hpp"

namespace spichek_d_dot_product_of_vectors {

class SpichekDDotProductOfVectorsMPI : public BaseTask {
public:
static constexpr ppc::task::TypeOfTask GetStaticTypeOfTask() {
return ppc::task::TypeOfTask::kMPI;
}
explicit SpichekDDotProductOfVectorsMPI(const InType &in);

private:
bool ValidationImpl() override;
bool PreProcessingImpl() override;
bool RunImpl() override;
bool PostProcessingImpl() override;
};

} // namespace spichek_d_dot_product_of_vectors
86 changes: 86 additions & 0 deletions tasks/spichek_d_dot_product_of_vectors/mpi/src/ops_mpi.cpp
Original file line number Diff line number Diff line change
@@ -0,0 +1,86 @@
#include "spichek_d_dot_product_of_vectors/mpi/include/ops_mpi.hpp"

#include <mpi.h>

#include <algorithm>
#include <cstddef>
#include <cstdint>
#include <vector>

#include "spichek_d_dot_product_of_vectors/common/include/common.hpp"

namespace spichek_d_dot_product_of_vectors {

SpichekDDotProductOfVectorsMPI::SpichekDDotProductOfVectorsMPI(const InType &in) {
SetTypeOfTask(GetStaticTypeOfTask());
GetInput() = in;
GetOutput() = 0;
}

bool SpichekDDotProductOfVectorsMPI::ValidationImpl() {
const auto &[vector1, vector2] = GetInput();
return vector1.size() == vector2.size();
}

bool SpichekDDotProductOfVectorsMPI::PreProcessingImpl() {
GetOutput() = 0;
return true;
}

bool SpichekDDotProductOfVectorsMPI::RunImpl() {
Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

You don't scatter vectors across different ranks

int rank = 0;
int size = 0;
MPI_Comm_rank(MPI_COMM_WORLD, &rank);
MPI_Comm_size(MPI_COMM_WORLD, &size);
Comment thread
allnes marked this conversation as resolved.

const auto &[v1, v2] = GetInput();
int n = 0;
if (rank == 0) {
n = static_cast<int>(v1.size());
}
MPI_Bcast(&n, 1, MPI_INT, 0, MPI_COMM_WORLD);

if (n == 0 || (rank == 0 && static_cast<size_t>(n) != v2.size())) {
GetOutput() = 0;
return true;
}

std::vector<int> counts(size);
std::vector<int> displs(size);

int base = n / size;
int rem = n % size;

for (int i = 0; i < size; ++i) {
counts[i] = base + (i < rem ? 1 : 0);
// [Исправлено] Добавлены скобки для явного приоритета операций
displs[i] = (i * base) + std::min(i, rem);
}

int local_count = counts[rank];

std::vector<int> lv1(local_count);
std::vector<int> lv2(local_count);

MPI_Scatterv(rank == 0 ? v1.data() : nullptr, counts.data(), displs.data(), MPI_INT, lv1.data(), local_count, MPI_INT,
0, MPI_COMM_WORLD);
MPI_Scatterv(rank == 0 ? v2.data() : nullptr, counts.data(), displs.data(), MPI_INT, lv2.data(), local_count, MPI_INT,
0, MPI_COMM_WORLD);

int64_t local_dot = 0;
for (int i = 0; i < local_count; ++i) {
local_dot += static_cast<int64_t>(lv1[i]) * lv2[i];
}

int64_t global_dot = 0;
MPI_Allreduce(&local_dot, &global_dot, 1, MPI_INT64_T, MPI_SUM, MPI_COMM_WORLD);

GetOutput() = static_cast<OutType>(global_dot);
return true;
}

bool SpichekDDotProductOfVectorsMPI::PostProcessingImpl() {
return true;
}

} // namespace spichek_d_dot_product_of_vectors
Loading
Loading