Add a vector constructor which allows a customized part. #12
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
Summary:
This constructor is important to correctly partition the variants of sparse matrix.
For example, considering the following matrix A(n*m):
0 0 0
0 1 2
0 0 0
0 0 0
3 0 4
0 0 0
As there are many empty rows, an efficient storage way for computing is:
row = [1 4] // row numbers
idx = [0 2 4] // pointers to col and val
col = [1 2 0 2] // col numbers
val = [1 2 3 4] // values
Suppose there are two dense vectors y and x, where y = A * x.
Assuming n >> m, then to efficiently use multiple devices for y=Ax,
we need to partition y and A across multiple devices, and copy x to multiple devices.
However, we need to build A's partition scheme to align with y's.
E.g. if y is evenly partitioned in 3 devices, then,
row = [1 0](with part = {0, 1, 1, 2})
idx = [0 2 0 2](with part = {0, 2, 2, 4})
col = [1 2 0 2](with part = {0, 2, 2, 4})
val = [1 2 3 4](with part = {0, 2, 2, 4})
Denis, if my understanding is right, another potential approach is to implement a new sub class of sparse_matrix in spmat.hpp which contains row, idx, col, and val. However, the mul() doesn't support local copy of x. And also when we want to use custom kernels, things become more complex. So it seems this variant of sparse matrix doesn't fit well in current class SpMat. But correct me if I'm wrong.