File: PruneColumn.cpp

package info (click to toggle)
combblas 2.0.0-6
  • links: PTS, VCS
  • area: main
  • in suites: forky, sid, trixie
  • size: 190,476 kB
  • sloc: cpp: 55,912; ansic: 25,134; sh: 3,691; makefile: 548; csh: 66; python: 49; perl: 21
file content (40 lines) | stat: -rw-r--r-- 1,167 bytes parent folder | download
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
#include <mpi.h>
#include <iostream>
#include <vector>
#include <algorithm>
#include "CombBLAS/CombBLAS.h"

using namespace combblas;

int main(int argc, char *argv[])
{
    int myrank, nprocs;
    MPI_Init(&argc, &argv);
    MPI_Comm_rank(MPI_COMM_WORLD, &myrank);
    MPI_Comm_size(MPI_COMM_WORLD, &nprocs);

    {
        std::shared_ptr<CommGrid> fullWorld;
        fullWorld.reset(new CommGrid(MPI_COMM_WORLD, 0, 0));

        FullyDistVec<int, int> ri(fullWorld, 5, -1); FullyDistVec<int, int> ci(fullWorld, 5, -1);

        ri.SetElement(0, 1); ri.SetElement(1, 5); ri.SetElement(2, 9); ri.SetElement(3, 6); ri.SetElement(4, 10);
        ci.SetElement(0, 1); ci.SetElement(1, 2); ci.SetElement(2, 2); ci.SetElement(3, 4); ci.SetElement(4, 4);

        SpParMat<int, int, SpDCCols<int, int>> A(13, 5, ri, ci, 1);
        A.ParallelWriteMM("A.mm", false);

        FullyDistSpVec<int, int> ciprune(A.getcommgrid(), 5);
        ciprune.SetElement(2, 2); ciprune.SetElement(3, 0); ciprune.SetElement(4, 2);
        ciprune.DebugPrint();

        A.PruneColumnByIndex(ciprune);

        A.ParallelWriteMM("B.mm", false);
    }


    MPI_Finalize();
    return 0;
}