4#include "CombBLAS/CombBLAS.h"
23 std::pair<int64_t, int64_t>
first;
35template<
typename IN,
typename OUT>
44 static OUT
add(
const OUT &arg1,
const OUT &arg2) {
46 res.count = arg1.count + arg2.count;
47 res.first.first = arg1.first.first;
48 res.first.second = arg1.first.second;
49 res.second.first = arg2.first.first;
50 res.second.second = arg2.first.second;
54 static OUT
multiply(
const IN &arg1,
const IN &arg2) {
58 a.first.second = arg2;
62 static void axpy(IN a,
const IN &x, OUT &y) {
68 static bool exists =
false;
72 MPI_Op_create(
MPI_func,
true, &mpiop);
79 MPI_func(
void *invec,
void *inoutvec,
int *len, MPI_Datatype *datatype) {
80 for (
int i = 0; i < *len; ++i) {
81 *((OUT) inoutvec + i) =
add(*((OUT) invec + i), *((OUT) inoutvec + i));
87int read_matrix(std::string fname,
int offset,
int row_offset,
90int main(
int argc,
char **argv) {
92 int world_size, world_rank;
93 MPI_Init(&argc, &argv);
94 MPI_Comm_size(MPI_COMM_WORLD, &world_size);
95 MPI_Comm_rank(MPI_COMM_WORLD, &world_rank);
108 unsigned int base = 20;
110 unsigned long total_k =
static_cast<unsigned int>(pow(base, k));
113 int nnzs[4] = {146, 56, 100, 141};
114 int lrows[4] = {2, 1, 1, 1};
116 int vec_size = world_size > 1 ? nnzs[world_rank] : (146 + 56 + 100 + 141);
117 std::vector<int64_t> lrow_ids(
static_cast<unsigned long>(vec_size));
118 std::vector<int64_t> lcol_ids(
static_cast<unsigned long>(vec_size));
119 std::vector<int64_t> lvals(
static_cast<unsigned long>(vec_size));
121 std::string fnames[4] = {
"mat.0.txt",
"mat.1.txt",
"mat.2.txt",
"mat.3.txt"};
123 if (world_size > 1) {
124 offset =
read_matrix(fnames[world_rank], offset, 0, lrow_ids, lcol_ids,
128 for (
int i = 0; i < 4; ++i) {
129 offset =
read_matrix(fnames[i], offset, row_offset, lrow_ids, lcol_ids,
131 row_offset += lrows[i];
146 std::printf(
"Rank: %d lrow_ids %ld lcol_ids %ld lvals %ld\n",
147 world_rank, lrow_ids.size(), lcol_ids.size(), lvals.size());
149 std::shared_ptr<CommGrid> grid =
150 std::make_shared<CommGrid>(MPI_COMM_WORLD, std::sqrt(world_size),
151 std::sqrt(world_size));
157 int m = 5, n =
static_cast<int>(total_k);
167 if (world_rank == 0){
168 std::cout<<
"before multiplication";
171 Mult_AnXBn_Synch<KmerIntersectSR_t, CommonKmers, PSpMat<CommonKmers>::DCCols>(
180 MPI_Initialized(&flag);
188 std::ifstream f(fname);
192 if (v.empty())
break;
194 lrow_ids[offset] = val+row_offset;
197 lcol_ids[offset] = val;
int read_matrix(std::string fname, int offset, int row_offset, vec64_t &lrow_ids, vec64_t &lcol_ids, vec64_t &lvals)
int main(int argc, char **argv)
std::vector< int64_t > vec64_t
SpParMat< int64_t, NT, DCCols > MPI_DCCols
SpDCCols< int64_t, NT > DCCols
std::pair< int64_t, int64_t > second
friend std::ostream & operator<<(std::ostream &os, const CommonKmers &m)
std::pair< int64_t, int64_t > first
static bool returnedSAID()
static OUT add(const OUT &arg1, const OUT &arg2)
static void MPI_func(void *invec, void *inoutvec, int *len, MPI_Datatype *datatype)
static OUT multiply(const IN &arg1, const IN &arg2)
static void axpy(IN a, const IN &x, OUT &y)