COMBINATORIAL_BLAS
1.6
Loading...
Searching...
No Matches
SUMMALayer.h
Go to the documentation of this file.
1
#ifndef _SUMMA_LAYER_H_
2
#define _SUMMA_LAYER_H_
3
4
#include <mpi.h>
5
#include <
sys/time.h
>
6
#include <iostream>
7
#include <iomanip>
8
#include <functional>
9
#include <algorithm>
10
#include <vector>
11
#include <string>
12
#include <sstream>
13
14
15
#include "CombBLAS/CombBLAS.h"
16
#include "
Glue.h
"
17
#include "CombBLAS/mtSpGEMM.h"
18
#include "
CCGrid.h
"
19
20
namespace
combblas
{
21
22
// SplitB is already locally transposed
23
// Returns an array of unmerged lists in C
24
template
<
typename
IT,
typename
NT>
25
void
SUMMALayer
(
SpDCCols<IT,NT>
&
SplitA
,
SpDCCols<IT,NT>
&
SplitB
, std::vector<
SpTuples<IT,NT>
* > &
C
,
CCGrid
&
CMG
,
bool
isBT
,
bool
threaded
)
26
{
27
typedef
PlusTimesSRing<NT,NT>
PTDD
;
28
29
int
stages
=
CMG
.GridCols;
// total number of "essential" summa stages
30
IT
**
ARecvSizes
= SpHelper::allocate2D<IT>(
SpDCCols<IT,NT>::esscount
,
stages
);
31
IT
**
BRecvSizes
= SpHelper::allocate2D<IT>(
SpDCCols<IT,NT>::esscount
,
stages
);
32
33
// Remotely fetched matrices are stored as pointers
34
SpDCCols<IT,NT>
*
ARecv
;
35
SpDCCols<IT,NT>
*
BRecv
;
36
37
int
Aself
=
CMG
.RankInRow;
38
int
Bself
=
CMG
.RankInCol;
39
40
// Set the dimensions
41
SpParHelper::GetSetSizes
(
SplitA
,
ARecvSizes
,
CMG
.rowWorld);
42
SpParHelper::GetSetSizes
(
SplitB
,
BRecvSizes
,
CMG
.colWorld);
43
44
for
(
int
i = 0; i <
stages
; ++i)
45
{
46
double
bcast_beg
=
MPI_Wtime
();
47
std::vector<IT>
ess
;
48
49
if
(i ==
Aself
)
ARecv
= &
SplitA
;
// shallow-copy
50
else
51
{
52
ess
.resize(
SpDCCols<IT,NT>::esscount
);
53
for
(
int
j
=0;
j< SpDCCols<IT,NT>::esscount
; ++
j
)
54
ess
[
j
] =
ARecvSizes
[
j
][i];
// essentials of the ith matrix in this row
55
56
ARecv
=
new
SpDCCols<IT,NT>
();
// first, create the object
57
}
58
SpParHelper::BCastMatrix
(
CMG
.rowWorld, *
ARecv
,
ess
, i);
// then, receive its elements
59
ess
.clear();
60
61
if
(i ==
Bself
)
BRecv
= &
SplitB
;
// shallow-copy
62
else
63
{
64
ess
.resize(
SpDCCols<IT,NT>::esscount
);
65
for
(
int
j
=0;
j< SpDCCols<IT,NT>::esscount
; ++
j
)
66
{
67
ess
[
j
] =
BRecvSizes
[
j
][i];
68
}
69
BRecv
=
new
SpDCCols<IT,NT>
();
70
}
71
SpParHelper::BCastMatrix
(
CMG
.colWorld, *
BRecv
,
ess
, i);
// then, receive its elements
72
73
comm_bcast
+= (
MPI_Wtime
() -
bcast_beg
);
74
double
summa_beg
=
MPI_Wtime
();
75
SpTuples<IT,NT>
*
C_cont
;
76
if
(
threaded
)
77
{
78
C_cont
=
LocalSpGEMM<PTDD, NT>
79
(*
ARecv
, *
BRecv
,
// parameters themselves
80
i !=
Aself
,
// 'delete A' condition
81
i !=
Bself
);
// 'delete B' condition
82
}
83
else
84
{
85
C_cont
=
MultiplyReturnTuples<PTDD, NT>
86
(*
ARecv
, *
BRecv
,
// parameters themselves
87
false
,
isBT
,
// transpose information (B is transposed)
88
i !=
Aself
,
// 'delete A' condition
89
i !=
Bself
);
// 'delete B' condition
90
}
91
comp_summa
+= (
MPI_Wtime
() -
summa_beg
);
92
C
.push_back(
C_cont
);
93
}
94
95
SpHelper::deallocate2D
(
ARecvSizes
,
SpDCCols<IT,NT>::esscount
);
96
SpHelper::deallocate2D
(
BRecvSizes
,
SpDCCols<IT,NT>::esscount
);
97
}
98
99
}
100
101
#endif
IT
int64_t IT
Definition
BlockedSpGEMM.cpp:9
CCGrid.h
Glue.h
comm_bcast
double comm_bcast
Definition
mpipspgemm.cpp:22
comp_summa
double comp_summa
Definition
mpipspgemm.cpp:24
combblas::CCGrid
Definition
CCGrid.h:7
combblas::DistEdgeList
Definition
DistEdgeList.h:82
combblas::SpDCCols
Definition
SpDCCols.h:52
combblas::SpHelper::deallocate2D
static void deallocate2D(T **array, I m)
Definition
SpHelper.h:249
combblas::SpParHelper::GetSetSizes
static void GetSetSizes(const SpMat< IT, NT, DER > &Matrix, IT **&sizes, MPI_Comm &comm1d)
Definition
SpParHelper.cpp:798
combblas::SpParHelper::BCastMatrix
static void BCastMatrix(MPI_Comm &comm1d, SpMat< IT, NT, DER > &Matrix, const std::vector< IT > &essentials, int root)
Definition
SpParHelper.cpp:583
combblas
Definition
CCGrid.h:4
combblas::SUMMALayer
void SUMMALayer(SpDCCols< IT, NT > &SplitA, SpDCCols< IT, NT > &SplitB, std::vector< SpTuples< IT, NT > * > &C, CCGrid &CMG, bool isBT, bool threaded)
Definition
SUMMALayer.h:25
C
double C
Definition
options.h:15
time.h
3DSpGEMM
SUMMALayer.h
Generated by
1.9.8