Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Spgemm par #41

Open
wants to merge 2 commits into
base: main
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
3 changes: 3 additions & 0 deletions spgemm/run_spgemm.jl
Original file line number Diff line number Diff line change
Expand Up @@ -64,6 +64,8 @@ datasets = Dict(

include("spgemm_finch.jl")
include("spgemm_taco.jl")
include("spgemm_finch_par.jl")


results = []

Expand All @@ -72,6 +74,7 @@ for mtx in datasets[parsed_args["dataset"]]
B = A
C_ref = nothing
for (key, method) in [
"spgemm_finch_gustavson_parallel" => spgemm_finch_gustavson_parallel,
"spgemm_taco_inner" => spgemm_taco_inner,
"spgemm_taco_gustavson" => spgemm_taco_gustavson,
"spgemm_taco_outer" => spgemm_taco_outer,
Expand Down
40 changes: 40 additions & 0 deletions spgemm/spgemm_finch_par.jl
Original file line number Diff line number Diff line change
@@ -0,0 +1,40 @@
using Finch
using BenchmarkTools
using Base.Threads


function spgemm_finch_gustavson_kernel_parallel(A, B)
# @assert Threads.nthreads() >= 2
z = default(A) * default(B) + false
C = Tensor(Dense(Seperation(SparseList(Element(z)))))
w = moveto(Tensor(Dense(Element(z))), CPULocalMemory(CPU()))
@finch_code begin
C .= 0
for j=parallel(_)
w .= 0
for k=_, i=_; w[i] += A[i, k] * B[k, j] end
for i=_; C[i, j] = w[i] end
end
end
@finch begin
C .= 0
for j=parallel(_)
w .= 0
for k=_, i=_; w[i] += A[i, k] * B[k, j] end
for i=_; C[i, j] = w[i] end
end
end
return C
end


function spgemm_finch_parallel(f, A, B)
_A = Tensor(A)
_B = Tensor(B)
C = Ref{Any}()
time = @belapsed $C[] = $f($_A, $_B)
return (;time = time, C = C[])
end


spgemm_finch_gustavson_parallel(A, B) = spgemm_finch_parallel(spgemm_finch_gustavson_kernel_parallel, A, B)