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
20namespace combblas {
21
22// SplitB is already locally transposed
23// Returns an array of unmerged lists in C
24template <typename IT, typename NT>
26{
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
36
37 int Aself = CMG.RankInRow;
38 int Bself = CMG.RankInCol;
39
40 // Set the dimensions
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 {
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 {
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
74 double summa_beg = MPI_Wtime();
76 if(threaded)
77 {
79 (*ARecv, *BRecv, // parameters themselves
80 i != Aself, // 'delete A' condition
81 i != Bself); // 'delete B' condition
82 }
83 else
84 {
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 }
92 C.push_back(C_cont);
93 }
94
97}
98
99}
100
101#endif
int64_t IT
double comm_bcast
double comp_summa
static void deallocate2D(T **array, I m)
Definition SpHelper.h:249
static void GetSetSizes(const SpMat< IT, NT, DER > &Matrix, IT **&sizes, MPI_Comm &comm1d)
static void BCastMatrix(MPI_Comm &comm1d, SpMat< IT, NT, DER > &Matrix, const std::vector< IT > &essentials, int root)
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
double C
Definition options.h:15