https://github.com/kumar-shivam-ranjan/sparse-matrix-multiplication
This repository consists of sparse Matrix multiplication algorithms implemented in C/C++
https://github.com/kumar-shivam-ranjan/sparse-matrix-multiplication
c cpp14 sparse-matrix
Last synced: 2 months ago
JSON representation
This repository consists of sparse Matrix multiplication algorithms implemented in C/C++
- Host: GitHub
- URL: https://github.com/kumar-shivam-ranjan/sparse-matrix-multiplication
- Owner: kumar-shivam-ranjan
- Created: 2020-07-19T01:40:49.000Z (almost 6 years ago)
- Default Branch: master
- Last Pushed: 2020-07-19T02:02:38.000Z (almost 6 years ago)
- Last Synced: 2025-03-03T00:42:02.311Z (over 1 year ago)
- Topics: c, cpp14, sparse-matrix
- Language: C++
- Homepage:
- Size: 1.99 MB
- Stars: 3
- Watchers: 1
- Forks: 0
- Open Issues: 0
-
Metadata Files:
- Readme: README.md
Awesome Lists containing this project
README
# Sparse-Matrix-Multiplication
Code for heterogeneous computing of product of two sparse matrices
### Algorithm: Gustavson’s Row-wise SpGEMM 3
Input: Sparse matrices A and B
Output: Sparse matrix C
set matrix C to ∅
for all a i ∗ in matrix A in parallel do
for all a ik in row a i ∗ do
for all b k j in row b k ∗ do
value ← a ik b k j
if c i j #∈ c i ∗ then
insert ( c i j ← v alue ) to c i ∗
else
c i j ← c i j + value
end if
end for
end for
end for
## Algorithm 2 RowsToThreads.
Input: Sparse matrices A and B
Output: Array o f f set
{1. Set FLOP vector}
for i ← 0 to m in parallel do
flop [ i ] ← 0
for j ← r pts A [ i ] to r pts A [ i + 1] do
rnz ← r pts B [ cols A [ j] + 1] − r pt B [ cols A [ j]]
flop [ i ] ← flop [ i ] + rnz
end for
end for
{ 2 . Assign rows to thread }
flop ps ← ParallelPrefixSum ( flop )
sum flop ← flop ps [ m ]
tnum ← omp_get_max_threads ()
a v e flop ← sum flop / tnum
o f f set[0] ← 0
for tid ← 1 to tnum in parallel do
o f f set [ tid ] ← lowbnd ( flop ps , a v e flop ∗ tid )
end for
o f f set [ t num ] ← m
## Algorithm : Hash SpGEMM.
Input: Sparse matrices A and B
Output: Sparse matrix C
off set ← RowsToThreads ( A, B )
{Determine hash-table size for each thread}
tnum ← omp_get_max_threads ()
for tid ← 0 to tnum in parallel do
size t ← 0
for i ← o f f set [ t id] to o f f set [ t id + 1] do
size t ← max ( size t , flop [ i ] )
end for
{Required maximum hash-table size is N col }
size t ← min ( N col , size t )
{Return minimum 2 n so that 2 n > size t }
size t ← lowest_p2 ( size t )
end for
Symbolic ( r pts C , A, B )
Numeric ( C, A, B )