Skip to content

Commit

Permalink
Merge pull request #401 from willow-ahrens/wma/cleanup-atomics
Browse files Browse the repository at this point in the history
cleanup atomics
  • Loading branch information
willow-ahrens authored Feb 2, 2024
2 parents f26f147 + 62203a6 commit 7bf1a94
Show file tree
Hide file tree
Showing 7 changed files with 7 additions and 42 deletions.
4 changes: 1 addition & 3 deletions src/architecture.jl
Original file line number Diff line number Diff line change
Expand Up @@ -30,9 +30,7 @@ get_lock(dev::AbstractDevice, arr, idx, ty) = nothing
Makes a lock of type ty.
"""
function make_lock(ty)
return false
end
function make_lock end

struct CPU <: AbstractDevice
n::Int
Expand Down
14 changes: 2 additions & 12 deletions src/tensors/levels/atomiclevel.jl
Original file line number Diff line number Diff line change
Expand Up @@ -134,12 +134,7 @@ function assemble_level!(lvl::VirtualAtomicLevel, ctx, pos_start, pos_stop)
push!(ctx.code.preamble, quote
Finch.resize_if_smaller!($(lvl.locks), $(ctx(pos_stop)))
@inbounds for $idx = $(ctx(pos_start)):$(ctx(pos_stop))
lockVal = make_lock(eltype($(lvl.AVal)))
if lockVal == false
break
else
$(lvl.locks)[$idx] = lockVal
end
$(lvl.locks)[$idx] = make_lock(eltype($(lvl.AVal)))
end
end)
assemble_level!(lvl.lvl, ctx, pos_start, pos_stop)
Expand All @@ -154,12 +149,7 @@ function reassemble_level!(lvl::VirtualAtomicLevel, ctx, pos_start, pos_stop)
push!(ctx.code.preamble, quote
Finch.resize_if_smaller!($lvl.locks, $(ctx(pos_stop)))
@inbounds for $idx = $(ctx(pos_start)):$(ctx(pos_stop))
lockVal = Finch.make_lock(eltype($(lvl.AVal)))
if lockVal == false
break
else
$lvl.locks[$idx] = lockVal
end
$lvl.locks[$idx] = Finch.make_lock(eltype($(lvl.AVal)))
end
end)
reassemble_level!(lvl.lvl, ctx, pos_start, pos_stop)
Expand Down
3 changes: 0 additions & 3 deletions src/tensors/levels/sparselistlevels.jl
Original file line number Diff line number Diff line change
Expand Up @@ -194,11 +194,8 @@ function declare_level!(lvl::VirtualSparseListLevel, ctx::AbstractCompiler, pos,
#TODO check that init == default
Ti = lvl.Ti
Tp = postype(lvl)
# qosName = freshen(ctx.code, :dec_pos)
qos = call(-, call(getindex, :($(lvl.ptr)), call(+, pos, 1)), 1)
# qos = value(qosName, Tp)
push!(ctx.code.preamble, quote
# $qosName = $(lvl.ptr)[1 + $(ctx(pos))] - 1
$(lvl.qos_fill) = $(Tp(0))
$(lvl.qos_stop) = $(Tp(0))
end)
Expand Down
7 changes: 1 addition & 6 deletions test/reference32/debug_parallel_spmv_atomics.txt
Original file line number Diff line number Diff line change
Expand Up @@ -22,12 +22,7 @@ quote
A_lvl_2.shape == x_lvl.shape || throw(DimensionMismatch("mismatched dimension limits ($(A_lvl_2.shape) != $(x_lvl.shape))"))
Finch.resize_if_smaller!(y_lvl_locks, A_lvl.shape)
@inbounds for idx = 1:A_lvl.shape
lockVal = make_lock(eltype(Vector{Base.Threads.SpinLock}))
if lockVal == false
break
else
y_lvl_locks[idx] = lockVal
end
y_lvl_locks[idx] = make_lock(eltype(Vector{Base.Threads.SpinLock}))
end
Finch.resize_if_smaller!(y_lvl_2_val, A_lvl.shape)
Finch.fill_range!(y_lvl_2_val, 0.0, 1, A_lvl.shape)
Expand Down
7 changes: 1 addition & 6 deletions test/reference32/stress_dense_atomics.txt
Original file line number Diff line number Diff line change
Expand Up @@ -25,12 +25,7 @@ quote
end
Finch.resize_if_smaller!(y_lvl_locks, y_lvl.shape)
@inbounds for idx = 1:y_lvl.shape
lockVal = make_lock(eltype(Vector{Base.Threads.SpinLock}))
if lockVal == false
break
else
y_lvl_locks[idx] = lockVal
end
y_lvl_locks[idx] = make_lock(eltype(Vector{Base.Threads.SpinLock}))
end
Finch.resize_if_smaller!(y_lvl_2_val, y_lvl.shape)
Finch.fill_range!(y_lvl_2_val, 0.0, 1, y_lvl.shape)
Expand Down
7 changes: 1 addition & 6 deletions test/reference64/debug_parallel_spmv_atomics.txt
Original file line number Diff line number Diff line change
Expand Up @@ -22,12 +22,7 @@ quote
A_lvl_2.shape == x_lvl.shape || throw(DimensionMismatch("mismatched dimension limits ($(A_lvl_2.shape) != $(x_lvl.shape))"))
Finch.resize_if_smaller!(y_lvl_locks, A_lvl.shape)
@inbounds for idx = 1:A_lvl.shape
lockVal = make_lock(eltype(Vector{Base.Threads.SpinLock}))
if lockVal == false
break
else
y_lvl_locks[idx] = lockVal
end
y_lvl_locks[idx] = make_lock(eltype(Vector{Base.Threads.SpinLock}))
end
Finch.resize_if_smaller!(y_lvl_2_val, A_lvl.shape)
Finch.fill_range!(y_lvl_2_val, 0.0, 1, A_lvl.shape)
Expand Down
7 changes: 1 addition & 6 deletions test/reference64/stress_dense_atomics.txt
Original file line number Diff line number Diff line change
Expand Up @@ -25,12 +25,7 @@ quote
end
Finch.resize_if_smaller!(y_lvl_locks, y_lvl.shape)
@inbounds for idx = 1:y_lvl.shape
lockVal = make_lock(eltype(Vector{Base.Threads.SpinLock}))
if lockVal == false
break
else
y_lvl_locks[idx] = lockVal
end
y_lvl_locks[idx] = make_lock(eltype(Vector{Base.Threads.SpinLock}))
end
Finch.resize_if_smaller!(y_lvl_2_val, y_lvl.shape)
Finch.fill_range!(y_lvl_2_val, 0.0, 1, y_lvl.shape)
Expand Down

0 comments on commit 7bf1a94

Please sign in to comment.