Убрал поддиректорию

This commit is contained in:
2025-12-02 12:00:42 +00:00
parent 8b0c57db63
commit 49b18bc199
15 changed files with 1 additions and 1 deletions

87
src/main.cpp Normal file
View File

@@ -0,0 +1,87 @@
#include <mpi.h>
#include <iostream>
#include <vector>
#include <map>
#include "csv_loader.hpp"
#include "utils.hpp"
#include "record.hpp"
#include "gpu_loader.hpp"
// Функция: отобрать записи для конкретного ранга
std::vector<Record> select_records_for_rank(
const std::map<long long, std::vector<Record>>& days,
const std::vector<long long>& day_list)
{
std::vector<Record> out;
for (auto d : day_list) {
auto it = days.find(d);
if (it != days.end()) {
const auto& vec = it->second;
out.insert(out.end(), vec.begin(), vec.end());
}
}
return out;
}
int main(int argc, char** argv) {
MPI_Init(&argc, &argv);
int rank, size;
MPI_Comm_rank(MPI_COMM_WORLD, &rank);
MPI_Comm_size(MPI_COMM_WORLD, &size);
std::vector<Record> local_records;
if (rank == 0) {
std::cout << "Rank 0 loading CSV..." << std::endl;
// Запускаем из build
auto records = load_csv("../data/data.csv");
auto days = group_by_day(records);
auto parts = split_days(days, size);
// Рассылаем данные
for (int r = 0; r < size; r++) {
auto vec = select_records_for_rank(days, parts[r]);
if (r == 0) {
// себе не отправляем — сразу сохраняем
local_records = vec;
continue;
}
int count = vec.size();
MPI_Send(&count, 1, MPI_INT, r, 0, MPI_COMM_WORLD);
MPI_Send(vec.data(), count * sizeof(Record), MPI_BYTE, r, 1, MPI_COMM_WORLD);
}
}
else {
// Принимает данные
int count = 0;
MPI_Recv(&count, 1, MPI_INT, 0, 0, MPI_COMM_WORLD, MPI_STATUS_IGNORE);
local_records.resize(count);
MPI_Recv(local_records.data(), count * sizeof(Record),
MPI_BYTE, 0, 1, MPI_COMM_WORLD, MPI_STATUS_IGNORE);
}
MPI_Barrier(MPI_COMM_WORLD);
std::cout << "Rank " << rank << " received "
<< local_records.size() << " records" << std::endl;
auto gpu_is_available = load_gpu_is_available();
int have_gpu = 0;
if (gpu_is_available) {
std::cout << "Rank " << rank << " dll loaded" << std::endl;
have_gpu = gpu_is_available();
}
std::cout << "Rank " << rank << ": gpu_available=" << have_gpu << "\n";
MPI_Finalize();
return 0;
}