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";
180 MPI_Initialized(&flag);
int read_matrix(std::string fname, int offset, int row_offset, vec64_t &lrow_ids, vec64_t &lcol_ids, vec64_t &lvals)
SpParMat< IU, NUO, UDERO > Mult_AnXBn_Synch(SpParMat< IU, NU1, UDERA > &A, SpParMat< IU, NU2, UDERB > &B, bool clearA=false, bool clearB=false)