-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathMPI9Matr6.cpp
More file actions
49 lines (39 loc) · 1.05 KB
/
MPI9Matr6.cpp
File metadata and controls
49 lines (39 loc) · 1.05 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
#include "pt4.h"
#include "mpi.h"
#include <cmath>
int k; // êîëè÷åñòâî ïðîöåññîâ
int r; // ðàíã òåêóùåãî ïðîöåññà
int m, p, q; // ðàçìåðû èñõîäíûõ ìàòðèö
int na, nb; // ðàçìåðû ïîëîñ ìàòðèö
int *a_, *b_, *c_; // ìàññèâû äëÿ õðàíåíèÿ èñõîäíûõ ìàòðèö â ãëàâíîì ïðîöåññå
int *a, *b, *c; // ìàññèâû äëÿ õðàíåíèÿ ïîëîñ ìàòðèö â êàæäîì ïðîöåññå
void Matr1GatherData()
{
int csize = m * q;
c_ = new int[na*k*q];
MPI_Gather(c, na * q, MPI_INT, c_, na * q, MPI_INT, 0, MPI_COMM_WORLD);
if (r == 0)
for (int i = 0; i < csize; i++)
pt << c_[i];
}
void Solve()
{
Task("MPI9Matr6");
int flag;
MPI_Initialized(&flag);
if (flag == 0)
return;
int rank, size;
MPI_Comm_size(MPI_COMM_WORLD, &size);
MPI_Comm_rank(MPI_COMM_WORLD, &rank);
k = size;
r = rank;
if (r == 0)
pt >> m;
pt >> na >> q;
int csize = na * q;
c = new int[csize];
for (int i = 0; i < csize; i++)
pt >> c[i];
Matr1GatherData();
}