diff --git a/src/tensors/levels/sparsebytemaplevels.jl b/src/tensors/levels/sparsebytemaplevels.jl index 699ca6ebb..7d0c8e80a 100644 --- a/src/tensors/levels/sparsebytemaplevels.jl +++ b/src/tensors/levels/sparsebytemaplevels.jl @@ -244,12 +244,6 @@ function thaw_level!(lvl::VirtualSparseByteMapLevel, ctx::AbstractCompiler, pos) Ti = lvl.Ti Tp = postype(lvl) p = freshen(ctx.code, lvl.ex, :_p) - push!(ctx.code.preamble, quote - for $p = 1:$(ctx(pos)) - $(lvl.ptr)[$p] -= $(lvl.ptr)[$p + 1] - end - $(lvl.ptr)[1] = 1 - end) lvl.lvl = thaw_level!(lvl.lvl, ctx, call(*, pos, lvl.shape)) return lvl end diff --git a/src/tensors/levels/sparsehashlevels.jl b/src/tensors/levels/sparsehashlevels.jl index 08706c97a..0e5c3e95a 100644 --- a/src/tensors/levels/sparsehashlevels.jl +++ b/src/tensors/levels/sparsehashlevels.jl @@ -271,8 +271,8 @@ function thaw_level!(lvl::VirtualSparseHashLevel, ctx::AbstractCompiler, pos) Tp = postype(lvl) p = freshen(ctx.code, lvl.ex, :_p) push!(ctx.code.preamble, quote - for $p = 1:$(ctx(pos)) - $(lvl.ptr)[$p] -= $(lvl.ptr)[$p + 1] + for $p = $(ctx(pos)) + 1:-1:2 + $(lvl.ptr)[$p] -= $(lvl.ptr)[$p - 1] end $(lvl.ptr)[1] = 1 $(lvl.qos_fill) = length($(lvl.tbl)) diff --git "a/test/reference64/increment_to_0\303\2270 Fiber!(SparseHash{2}(Element(0.0))).jl" "b/test/reference64/increment_to_0\303\2270 Fiber!(SparseHash{2}(Element(0.0))).jl" new file mode 100644 index 000000000..f2e8d23c9 --- /dev/null +++ "b/test/reference64/increment_to_0\303\2270 Fiber!(SparseHash{2}(Element(0.0))).jl" @@ -0,0 +1,94 @@ +begin + fmt_lvl = ex.body.body.lhs.tns.bind.lvl + fmt_lvl_qos_fill = length(fmt_lvl.tbl) + fmt_lvl_qos_stop = fmt_lvl_qos_fill + fmt_lvl_ptr = ex.body.body.lhs.tns.bind.lvl.ptr + fmt_lvl_tbl = ex.body.body.lhs.tns.bind.lvl.tbl + fmt_lvl_srt = ex.body.body.lhs.tns.bind.lvl.srt + fmt_lvl_2 = fmt_lvl.lvl + fmt_lvl_val = fmt_lvl.lvl.val + arr_2_lvl = ex.body.body.rhs.tns.bind.lvl + arr_2_lvl_ptr = ex.body.body.rhs.tns.bind.lvl.ptr + arr_2_lvl_tbl1 = ex.body.body.rhs.tns.bind.lvl.tbl[1] + arr_2_lvl_tbl2 = ex.body.body.rhs.tns.bind.lvl.tbl[2] + arr_2_lvl_val = arr_2_lvl.lvl.val + arr_2_lvl.shape[1] == fmt_lvl.shape[1] || throw(DimensionMismatch("mismatched dimension limits ($(arr_2_lvl.shape[1]) != $(fmt_lvl.shape[1]))")) + arr_2_lvl.shape[2] == fmt_lvl.shape[2] || throw(DimensionMismatch("mismatched dimension limits ($(arr_2_lvl.shape[2]) != $(fmt_lvl.shape[2]))")) + for fmt_lvl_p = 1:1 + fmt_lvl_ptr[fmt_lvl_p] = fmt_lvl_ptr[fmt_lvl_p] - fmt_lvl_ptr[fmt_lvl_p + 1] + end + fmt_lvl_ptr[1] = 1 + fmt_lvl_qos_fill = length(fmt_lvl_tbl) + arr_2_lvl_q = arr_2_lvl_ptr[1] + arr_2_lvl_q_stop = arr_2_lvl_ptr[1 + 1] + if arr_2_lvl_q < arr_2_lvl_q_stop + arr_2_lvl_i_stop = arr_2_lvl_tbl2[arr_2_lvl_q_stop - 1] + else + arr_2_lvl_i_stop = 0 + end + phase_stop = min(arr_2_lvl.shape[2], arr_2_lvl_i_stop) + if phase_stop >= 1 + j = 1 + if arr_2_lvl_tbl2[arr_2_lvl_q] < 1 + arr_2_lvl_q = Finch.scansearch(arr_2_lvl_tbl2, 1, arr_2_lvl_q, arr_2_lvl_q_stop - 1) + end + while j <= phase_stop + arr_2_lvl_i = arr_2_lvl_tbl2[arr_2_lvl_q] + arr_2_lvl_q_step = arr_2_lvl_q + if arr_2_lvl_tbl2[arr_2_lvl_q] == arr_2_lvl_i + arr_2_lvl_q_step = Finch.scansearch(arr_2_lvl_tbl2, arr_2_lvl_i + 1, arr_2_lvl_q, arr_2_lvl_q_stop - 1) + end + phase_stop_2 = min(phase_stop, arr_2_lvl_i) + if arr_2_lvl_i == phase_stop_2 + arr_2_lvl_q_2 = arr_2_lvl_q + if arr_2_lvl_q < arr_2_lvl_q_step + arr_2_lvl_i_stop_2 = arr_2_lvl_tbl1[arr_2_lvl_q_step - 1] + else + arr_2_lvl_i_stop_2 = 0 + end + phase_stop_3 = min(arr_2_lvl.shape[1], arr_2_lvl_i_stop_2) + if phase_stop_3 >= 1 + i = 1 + if arr_2_lvl_tbl1[arr_2_lvl_q] < 1 + arr_2_lvl_q_2 = Finch.scansearch(arr_2_lvl_tbl1, 1, arr_2_lvl_q, arr_2_lvl_q_step - 1) + end + while i <= phase_stop_3 + arr_2_lvl_i_2 = arr_2_lvl_tbl1[arr_2_lvl_q_2] + phase_stop_4 = min(phase_stop_3, arr_2_lvl_i_2) + if arr_2_lvl_i_2 == phase_stop_4 + arr_2_lvl_2_val = arr_2_lvl_val[arr_2_lvl_q_2] + fmt_lvl_key_2 = (1, (phase_stop_4, phase_stop_2)) + fmt_lvl_q_2 = get(fmt_lvl_tbl, fmt_lvl_key_2, fmt_lvl_qos_fill + 1) + if fmt_lvl_q_2 > fmt_lvl_qos_stop + fmt_lvl_qos_stop = max(fmt_lvl_qos_stop << 1, 1) + Finch.resize_if_smaller!(fmt_lvl_val, fmt_lvl_qos_stop) + Finch.fill_range!(fmt_lvl_val, 0.0, fmt_lvl_q_2, fmt_lvl_qos_stop) + end + fmt_lvl_val[fmt_lvl_q_2] = arr_2_lvl_2_val + fmt_lvl_val[fmt_lvl_q_2] + if fmt_lvl_q_2 > fmt_lvl_qos_fill + fmt_lvl_qos_fill = fmt_lvl_q_2 + fmt_lvl_tbl[fmt_lvl_key_2] = fmt_lvl_q_2 + fmt_lvl_ptr[1 + 1] += 1 + end + arr_2_lvl_q_2 += 1 + end + i = phase_stop_4 + 1 + end + end + arr_2_lvl_q = arr_2_lvl_q_step + end + j = phase_stop_2 + 1 + end + end + resize!(fmt_lvl_srt, length(fmt_lvl_tbl)) + copyto!(fmt_lvl_srt, pairs(fmt_lvl_tbl)) + sort!(fmt_lvl_srt, by = hashkeycmp) + for p = 2:1 + 1 + fmt_lvl_ptr[p] += fmt_lvl_ptr[p - 1] + end + resize!(fmt_lvl_ptr, 1 + 1) + qos = fmt_lvl_ptr[end] - 1 + resize!(fmt_lvl_srt, qos) + resize!(fmt_lvl_val, qos) + (fmt = Fiber((SparseHashLevel){2, Tuple{Int64, Int64}}(fmt_lvl_2, (fmt_lvl.shape[1], fmt_lvl.shape[2]), fmt_lvl_ptr, fmt_lvl_tbl, fmt_lvl_srt)),) +end diff --git "a/test/reference64/increment_to_10\303\22710 Fiber!(Dense(SparseByteMap(Element(0.0)))).jl" "b/test/reference64/increment_to_10\303\22710 Fiber!(Dense(SparseByteMap(Element(0.0)))).jl" new file mode 100644 index 000000000..cdae67aee --- /dev/null +++ "b/test/reference64/increment_to_10\303\22710 Fiber!(Dense(SparseByteMap(Element(0.0)))).jl" @@ -0,0 +1,94 @@ +begin + fmt_lvl = ex.body.body.lhs.tns.bind.lvl + fmt_lvl_2 = fmt_lvl.lvl + fmt_lvl_ptr = fmt_lvl.lvl.ptr + fmt_lvl_tbl = fmt_lvl.lvl.tbl + fmt_lvl_srt = fmt_lvl.lvl.srt + fmt_lvl_2_qos_stop = (fmt_lvl_2_qos_fill = length(fmt_lvl_2.srt)) + fmt_lvl_3 = fmt_lvl_2.lvl + fmt_lvl_2_val = fmt_lvl_2.lvl.val + arr_2_lvl = ex.body.body.rhs.tns.bind.lvl + arr_2_lvl_ptr = ex.body.body.rhs.tns.bind.lvl.ptr + arr_2_lvl_tbl1 = ex.body.body.rhs.tns.bind.lvl.tbl[1] + arr_2_lvl_tbl2 = ex.body.body.rhs.tns.bind.lvl.tbl[2] + arr_2_lvl_val = arr_2_lvl.lvl.val + arr_2_lvl.shape[1] == fmt_lvl_2.shape || throw(DimensionMismatch("mismatched dimension limits ($(arr_2_lvl.shape[1]) != $(fmt_lvl_2.shape))")) + arr_2_lvl.shape[2] == fmt_lvl.shape || throw(DimensionMismatch("mismatched dimension limits ($(arr_2_lvl.shape[2]) != $(fmt_lvl.shape))")) + arr_2_lvl_q = arr_2_lvl_ptr[1] + arr_2_lvl_q_stop = arr_2_lvl_ptr[1 + 1] + if arr_2_lvl_q < arr_2_lvl_q_stop + arr_2_lvl_i_stop = arr_2_lvl_tbl2[arr_2_lvl_q_stop - 1] + else + arr_2_lvl_i_stop = 0 + end + phase_stop = min(arr_2_lvl.shape[2], arr_2_lvl_i_stop) + if phase_stop >= 1 + j = 1 + if arr_2_lvl_tbl2[arr_2_lvl_q] < 1 + arr_2_lvl_q = Finch.scansearch(arr_2_lvl_tbl2, 1, arr_2_lvl_q, arr_2_lvl_q_stop - 1) + end + while j <= phase_stop + arr_2_lvl_i = arr_2_lvl_tbl2[arr_2_lvl_q] + arr_2_lvl_q_step = arr_2_lvl_q + if arr_2_lvl_tbl2[arr_2_lvl_q] == arr_2_lvl_i + arr_2_lvl_q_step = Finch.scansearch(arr_2_lvl_tbl2, arr_2_lvl_i + 1, arr_2_lvl_q, arr_2_lvl_q_stop - 1) + end + phase_stop_2 = min(phase_stop, arr_2_lvl_i) + if arr_2_lvl_i == phase_stop_2 + fmt_lvl_q = (1 - 1) * fmt_lvl.shape + phase_stop_2 + arr_2_lvl_q_2 = arr_2_lvl_q + if arr_2_lvl_q < arr_2_lvl_q_step + arr_2_lvl_i_stop_2 = arr_2_lvl_tbl1[arr_2_lvl_q_step - 1] + else + arr_2_lvl_i_stop_2 = 0 + end + phase_stop_3 = min(arr_2_lvl.shape[1], arr_2_lvl_i_stop_2) + if phase_stop_3 >= 1 + i = 1 + if arr_2_lvl_tbl1[arr_2_lvl_q] < 1 + arr_2_lvl_q_2 = Finch.scansearch(arr_2_lvl_tbl1, 1, arr_2_lvl_q, arr_2_lvl_q_step - 1) + end + while i <= phase_stop_3 + arr_2_lvl_i_2 = arr_2_lvl_tbl1[arr_2_lvl_q_2] + phase_stop_4 = min(phase_stop_3, arr_2_lvl_i_2) + if arr_2_lvl_i_2 == phase_stop_4 + arr_2_lvl_2_val = arr_2_lvl_val[arr_2_lvl_q_2] + fmt_lvl_2_q = (fmt_lvl_q - 1) * fmt_lvl_2.shape + phase_stop_4 + fmt_lvl_2_val[fmt_lvl_2_q] = arr_2_lvl_2_val + fmt_lvl_2_val[fmt_lvl_2_q] + if !(fmt_lvl_tbl[fmt_lvl_2_q]) + fmt_lvl_tbl[fmt_lvl_2_q] = true + fmt_lvl_2_qos_fill += 1 + if fmt_lvl_2_qos_fill > fmt_lvl_2_qos_stop + fmt_lvl_2_qos_stop = max(fmt_lvl_2_qos_stop << 1, 1) + Finch.resize_if_smaller!(fmt_lvl_srt, fmt_lvl_2_qos_stop) + end + fmt_lvl_srt[fmt_lvl_2_qos_fill] = (fmt_lvl_q, phase_stop_4) + end + arr_2_lvl_q_2 += 1 + end + i = phase_stop_4 + 1 + end + end + arr_2_lvl_q = arr_2_lvl_q_step + end + j = phase_stop_2 + 1 + end + end + sort!(view(fmt_lvl_srt, 1:fmt_lvl_2_qos_fill)) + fmt_lvl_2_p_prev = 0 + for fmt_lvl_2_r = 1:fmt_lvl_2_qos_fill + fmt_lvl_2_p_2 = first(fmt_lvl_srt[fmt_lvl_2_r]) + if fmt_lvl_2_p_2 != fmt_lvl_2_p_prev + fmt_lvl_ptr[fmt_lvl_2_p_prev + 1] = fmt_lvl_2_r + fmt_lvl_ptr[fmt_lvl_2_p_2] = fmt_lvl_2_r + end + fmt_lvl_2_p_prev = fmt_lvl_2_p_2 + end + fmt_lvl_ptr[fmt_lvl_2_p_2 + 1] = fmt_lvl_2_qos_fill + 1 + qos = 1 * fmt_lvl.shape + resize!(fmt_lvl_ptr, qos + 1) + resize!(fmt_lvl_tbl, qos * fmt_lvl_2.shape) + resize!(fmt_lvl_srt, fmt_lvl_2_qos_fill) + resize!(fmt_lvl_2_val, qos * fmt_lvl_2.shape) + (fmt = Fiber((DenseLevel){Int64}((SparseByteMapLevel){Int64}(fmt_lvl_3, fmt_lvl_2.shape, fmt_lvl_ptr, fmt_lvl_tbl, fmt_lvl_srt), fmt_lvl.shape)),) +end diff --git "a/test/reference64/increment_to_10\303\22710 Fiber!(Dense(SparseHash{1}(Element(0.0)))).jl" "b/test/reference64/increment_to_10\303\22710 Fiber!(Dense(SparseHash{1}(Element(0.0)))).jl" new file mode 100644 index 000000000..9f6370f84 --- /dev/null +++ "b/test/reference64/increment_to_10\303\22710 Fiber!(Dense(SparseHash{1}(Element(0.0)))).jl" @@ -0,0 +1,97 @@ +begin + fmt_lvl = ex.body.body.lhs.tns.bind.lvl + fmt_lvl_2 = fmt_lvl.lvl + fmt_lvl_2_qos_fill = length(fmt_lvl_2.tbl) + fmt_lvl_2_qos_stop = fmt_lvl_2_qos_fill + fmt_lvl_ptr = fmt_lvl.lvl.ptr + fmt_lvl_tbl = fmt_lvl.lvl.tbl + fmt_lvl_srt = fmt_lvl.lvl.srt + fmt_lvl_3 = fmt_lvl_2.lvl + fmt_lvl_2_val = fmt_lvl_2.lvl.val + arr_2_lvl = ex.body.body.rhs.tns.bind.lvl + arr_2_lvl_ptr = ex.body.body.rhs.tns.bind.lvl.ptr + arr_2_lvl_tbl1 = ex.body.body.rhs.tns.bind.lvl.tbl[1] + arr_2_lvl_tbl2 = ex.body.body.rhs.tns.bind.lvl.tbl[2] + arr_2_lvl_val = arr_2_lvl.lvl.val + arr_2_lvl.shape[1] == fmt_lvl_2.shape[1] || throw(DimensionMismatch("mismatched dimension limits ($(arr_2_lvl.shape[1]) != $(fmt_lvl_2.shape[1]))")) + arr_2_lvl.shape[2] == fmt_lvl.shape || throw(DimensionMismatch("mismatched dimension limits ($(arr_2_lvl.shape[2]) != $(fmt_lvl.shape))")) + for fmt_lvl_2_p = 1 * fmt_lvl.shape:-1:1 + fmt_lvl_ptr[fmt_lvl_2_p + 1] = fmt_lvl_ptr[fmt_lvl_2_p + 1] - fmt_lvl_ptr[fmt_lvl_2_p] + end + fmt_lvl_ptr[1] = 1 + fmt_lvl_2_qos_fill = length(fmt_lvl_tbl) + arr_2_lvl_q = arr_2_lvl_ptr[1] + arr_2_lvl_q_stop = arr_2_lvl_ptr[1 + 1] + if arr_2_lvl_q < arr_2_lvl_q_stop + arr_2_lvl_i_stop = arr_2_lvl_tbl2[arr_2_lvl_q_stop - 1] + else + arr_2_lvl_i_stop = 0 + end + phase_stop = min(arr_2_lvl.shape[2], arr_2_lvl_i_stop) + if phase_stop >= 1 + j = 1 + if arr_2_lvl_tbl2[arr_2_lvl_q] < 1 + arr_2_lvl_q = Finch.scansearch(arr_2_lvl_tbl2, 1, arr_2_lvl_q, arr_2_lvl_q_stop - 1) + end + while j <= phase_stop + arr_2_lvl_i = arr_2_lvl_tbl2[arr_2_lvl_q] + arr_2_lvl_q_step = arr_2_lvl_q + if arr_2_lvl_tbl2[arr_2_lvl_q] == arr_2_lvl_i + arr_2_lvl_q_step = Finch.scansearch(arr_2_lvl_tbl2, arr_2_lvl_i + 1, arr_2_lvl_q, arr_2_lvl_q_stop - 1) + end + phase_stop_2 = min(phase_stop, arr_2_lvl_i) + if arr_2_lvl_i == phase_stop_2 + fmt_lvl_q = (1 - 1) * fmt_lvl.shape + phase_stop_2 + arr_2_lvl_q_2 = arr_2_lvl_q + if arr_2_lvl_q < arr_2_lvl_q_step + arr_2_lvl_i_stop_2 = arr_2_lvl_tbl1[arr_2_lvl_q_step - 1] + else + arr_2_lvl_i_stop_2 = 0 + end + phase_stop_3 = min(arr_2_lvl.shape[1], arr_2_lvl_i_stop_2) + if phase_stop_3 >= 1 + i = 1 + if arr_2_lvl_tbl1[arr_2_lvl_q] < 1 + arr_2_lvl_q_2 = Finch.scansearch(arr_2_lvl_tbl1, 1, arr_2_lvl_q, arr_2_lvl_q_step - 1) + end + while i <= phase_stop_3 + arr_2_lvl_i_2 = arr_2_lvl_tbl1[arr_2_lvl_q_2] + phase_stop_4 = min(phase_stop_3, arr_2_lvl_i_2) + if arr_2_lvl_i_2 == phase_stop_4 + arr_2_lvl_2_val = arr_2_lvl_val[arr_2_lvl_q_2] + fmt_lvl_2_key = (fmt_lvl_q, (phase_stop_4,)) + fmt_lvl_2_q = get(fmt_lvl_tbl, fmt_lvl_2_key, fmt_lvl_2_qos_fill + 1) + if fmt_lvl_2_q > fmt_lvl_2_qos_stop + fmt_lvl_2_qos_stop = max(fmt_lvl_2_qos_stop << 1, 1) + Finch.resize_if_smaller!(fmt_lvl_2_val, fmt_lvl_2_qos_stop) + Finch.fill_range!(fmt_lvl_2_val, 0.0, fmt_lvl_2_q, fmt_lvl_2_qos_stop) + end + fmt_lvl_2_val[fmt_lvl_2_q] = arr_2_lvl_2_val + fmt_lvl_2_val[fmt_lvl_2_q] + if fmt_lvl_2_q > fmt_lvl_2_qos_fill + fmt_lvl_2_qos_fill = fmt_lvl_2_q + fmt_lvl_tbl[fmt_lvl_2_key] = fmt_lvl_2_q + fmt_lvl_ptr[fmt_lvl_q + 1] += 1 + end + arr_2_lvl_q_2 += 1 + end + i = phase_stop_4 + 1 + end + end + arr_2_lvl_q = arr_2_lvl_q_step + end + j = phase_stop_2 + 1 + end + end + resize!(fmt_lvl_srt, length(fmt_lvl_tbl)) + copyto!(fmt_lvl_srt, pairs(fmt_lvl_tbl)) + sort!(fmt_lvl_srt, by = hashkeycmp) + for p = 2:fmt_lvl.shape + 1 + fmt_lvl_ptr[p] += fmt_lvl_ptr[p - 1] + end + qos = 1 * fmt_lvl.shape + resize!(fmt_lvl_ptr, qos + 1) + qos_2 = fmt_lvl_ptr[end] - 1 + resize!(fmt_lvl_srt, qos_2) + resize!(fmt_lvl_2_val, qos_2) + (fmt = Fiber((DenseLevel){Int64}((SparseHashLevel){1, Tuple{Int64}}(fmt_lvl_3, (fmt_lvl_2.shape[1],), fmt_lvl_ptr, fmt_lvl_tbl, fmt_lvl_srt), fmt_lvl.shape)),) +end diff --git "a/test/reference64/increment_to_10\303\22710 Fiber!(SparseHash{2}(Element(0.0))).jl" "b/test/reference64/increment_to_10\303\22710 Fiber!(SparseHash{2}(Element(0.0))).jl" new file mode 100644 index 000000000..0c3c45e92 --- /dev/null +++ "b/test/reference64/increment_to_10\303\22710 Fiber!(SparseHash{2}(Element(0.0))).jl" @@ -0,0 +1,94 @@ +begin + fmt_lvl = ex.body.body.lhs.tns.bind.lvl + fmt_lvl_qos_fill = length(fmt_lvl.tbl) + fmt_lvl_qos_stop = fmt_lvl_qos_fill + fmt_lvl_ptr = ex.body.body.lhs.tns.bind.lvl.ptr + fmt_lvl_tbl = ex.body.body.lhs.tns.bind.lvl.tbl + fmt_lvl_srt = ex.body.body.lhs.tns.bind.lvl.srt + fmt_lvl_2 = fmt_lvl.lvl + fmt_lvl_val = fmt_lvl.lvl.val + arr_2_lvl = ex.body.body.rhs.tns.bind.lvl + arr_2_lvl_ptr = ex.body.body.rhs.tns.bind.lvl.ptr + arr_2_lvl_tbl1 = ex.body.body.rhs.tns.bind.lvl.tbl[1] + arr_2_lvl_tbl2 = ex.body.body.rhs.tns.bind.lvl.tbl[2] + arr_2_lvl_val = arr_2_lvl.lvl.val + arr_2_lvl.shape[1] == fmt_lvl.shape[1] || throw(DimensionMismatch("mismatched dimension limits ($(arr_2_lvl.shape[1]) != $(fmt_lvl.shape[1]))")) + arr_2_lvl.shape[2] == fmt_lvl.shape[2] || throw(DimensionMismatch("mismatched dimension limits ($(arr_2_lvl.shape[2]) != $(fmt_lvl.shape[2]))")) + for fmt_lvl_p = 1:-1:1 + fmt_lvl_ptr[fmt_lvl_p + 1] = fmt_lvl_ptr[fmt_lvl_p + 1] - fmt_lvl_ptr[fmt_lvl_p] + end + fmt_lvl_ptr[1] = 1 + fmt_lvl_qos_fill = length(fmt_lvl_tbl) + arr_2_lvl_q = arr_2_lvl_ptr[1] + arr_2_lvl_q_stop = arr_2_lvl_ptr[1 + 1] + if arr_2_lvl_q < arr_2_lvl_q_stop + arr_2_lvl_i_stop = arr_2_lvl_tbl2[arr_2_lvl_q_stop - 1] + else + arr_2_lvl_i_stop = 0 + end + phase_stop = min(arr_2_lvl.shape[2], arr_2_lvl_i_stop) + if phase_stop >= 1 + j = 1 + if arr_2_lvl_tbl2[arr_2_lvl_q] < 1 + arr_2_lvl_q = Finch.scansearch(arr_2_lvl_tbl2, 1, arr_2_lvl_q, arr_2_lvl_q_stop - 1) + end + while j <= phase_stop + arr_2_lvl_i = arr_2_lvl_tbl2[arr_2_lvl_q] + arr_2_lvl_q_step = arr_2_lvl_q + if arr_2_lvl_tbl2[arr_2_lvl_q] == arr_2_lvl_i + arr_2_lvl_q_step = Finch.scansearch(arr_2_lvl_tbl2, arr_2_lvl_i + 1, arr_2_lvl_q, arr_2_lvl_q_stop - 1) + end + phase_stop_2 = min(phase_stop, arr_2_lvl_i) + if arr_2_lvl_i == phase_stop_2 + arr_2_lvl_q_2 = arr_2_lvl_q + if arr_2_lvl_q < arr_2_lvl_q_step + arr_2_lvl_i_stop_2 = arr_2_lvl_tbl1[arr_2_lvl_q_step - 1] + else + arr_2_lvl_i_stop_2 = 0 + end + phase_stop_3 = min(arr_2_lvl.shape[1], arr_2_lvl_i_stop_2) + if phase_stop_3 >= 1 + i = 1 + if arr_2_lvl_tbl1[arr_2_lvl_q] < 1 + arr_2_lvl_q_2 = Finch.scansearch(arr_2_lvl_tbl1, 1, arr_2_lvl_q, arr_2_lvl_q_step - 1) + end + while i <= phase_stop_3 + arr_2_lvl_i_2 = arr_2_lvl_tbl1[arr_2_lvl_q_2] + phase_stop_4 = min(phase_stop_3, arr_2_lvl_i_2) + if arr_2_lvl_i_2 == phase_stop_4 + arr_2_lvl_2_val = arr_2_lvl_val[arr_2_lvl_q_2] + fmt_lvl_key_2 = (1, (phase_stop_4, phase_stop_2)) + fmt_lvl_q_2 = get(fmt_lvl_tbl, fmt_lvl_key_2, fmt_lvl_qos_fill + 1) + if fmt_lvl_q_2 > fmt_lvl_qos_stop + fmt_lvl_qos_stop = max(fmt_lvl_qos_stop << 1, 1) + Finch.resize_if_smaller!(fmt_lvl_val, fmt_lvl_qos_stop) + Finch.fill_range!(fmt_lvl_val, 0.0, fmt_lvl_q_2, fmt_lvl_qos_stop) + end + fmt_lvl_val[fmt_lvl_q_2] = arr_2_lvl_2_val + fmt_lvl_val[fmt_lvl_q_2] + if fmt_lvl_q_2 > fmt_lvl_qos_fill + fmt_lvl_qos_fill = fmt_lvl_q_2 + fmt_lvl_tbl[fmt_lvl_key_2] = fmt_lvl_q_2 + fmt_lvl_ptr[1 + 1] += 1 + end + arr_2_lvl_q_2 += 1 + end + i = phase_stop_4 + 1 + end + end + arr_2_lvl_q = arr_2_lvl_q_step + end + j = phase_stop_2 + 1 + end + end + resize!(fmt_lvl_srt, length(fmt_lvl_tbl)) + copyto!(fmt_lvl_srt, pairs(fmt_lvl_tbl)) + sort!(fmt_lvl_srt, by = hashkeycmp) + for p = 2:1 + 1 + fmt_lvl_ptr[p] += fmt_lvl_ptr[p - 1] + end + resize!(fmt_lvl_ptr, 1 + 1) + qos = fmt_lvl_ptr[end] - 1 + resize!(fmt_lvl_srt, qos) + resize!(fmt_lvl_val, qos) + (fmt = Fiber((SparseHashLevel){2, Tuple{Int64, Int64}}(fmt_lvl_2, (fmt_lvl.shape[1], fmt_lvl.shape[2]), fmt_lvl_ptr, fmt_lvl_tbl, fmt_lvl_srt)),) +end diff --git "a/test/reference64/increment_to_5\303\2275 Fiber!(Dense(SparseByteMap(Element(0.0)))).jl" "b/test/reference64/increment_to_5\303\2275 Fiber!(Dense(SparseByteMap(Element(0.0)))).jl" new file mode 100644 index 000000000..fca916841 --- /dev/null +++ "b/test/reference64/increment_to_5\303\2275 Fiber!(Dense(SparseByteMap(Element(0.0)))).jl" @@ -0,0 +1,98 @@ +begin + fmt_lvl = ex.body.body.lhs.tns.bind.lvl + fmt_lvl_2 = fmt_lvl.lvl + fmt_lvl_ptr = fmt_lvl.lvl.ptr + fmt_lvl_tbl = fmt_lvl.lvl.tbl + fmt_lvl_srt = fmt_lvl.lvl.srt + fmt_lvl_2_qos_stop = (fmt_lvl_2_qos_fill = length(fmt_lvl_2.srt)) + fmt_lvl_3 = fmt_lvl_2.lvl + fmt_lvl_2_val = fmt_lvl_2.lvl.val + arr_2_lvl = ex.body.body.rhs.tns.bind.lvl + arr_2_lvl_ptr = ex.body.body.rhs.tns.bind.lvl.ptr + arr_2_lvl_tbl1 = ex.body.body.rhs.tns.bind.lvl.tbl[1] + arr_2_lvl_tbl2 = ex.body.body.rhs.tns.bind.lvl.tbl[2] + arr_2_lvl_val = arr_2_lvl.lvl.val + arr_2_lvl.shape[1] == fmt_lvl_2.shape || throw(DimensionMismatch("mismatched dimension limits ($(arr_2_lvl.shape[1]) != $(fmt_lvl_2.shape))")) + arr_2_lvl.shape[2] == fmt_lvl.shape || throw(DimensionMismatch("mismatched dimension limits ($(arr_2_lvl.shape[2]) != $(fmt_lvl.shape))")) + for fmt_lvl_2_p = 1:1 * fmt_lvl.shape + fmt_lvl_ptr[fmt_lvl_2_p] = fmt_lvl_ptr[fmt_lvl_2_p] - fmt_lvl_ptr[fmt_lvl_2_p + 1] + end + fmt_lvl_ptr[1] = 1 + arr_2_lvl_q = arr_2_lvl_ptr[1] + arr_2_lvl_q_stop = arr_2_lvl_ptr[1 + 1] + if arr_2_lvl_q < arr_2_lvl_q_stop + arr_2_lvl_i_stop = arr_2_lvl_tbl2[arr_2_lvl_q_stop - 1] + else + arr_2_lvl_i_stop = 0 + end + phase_stop = min(arr_2_lvl.shape[2], arr_2_lvl_i_stop) + if phase_stop >= 1 + j = 1 + if arr_2_lvl_tbl2[arr_2_lvl_q] < 1 + arr_2_lvl_q = Finch.scansearch(arr_2_lvl_tbl2, 1, arr_2_lvl_q, arr_2_lvl_q_stop - 1) + end + while j <= phase_stop + arr_2_lvl_i = arr_2_lvl_tbl2[arr_2_lvl_q] + arr_2_lvl_q_step = arr_2_lvl_q + if arr_2_lvl_tbl2[arr_2_lvl_q] == arr_2_lvl_i + arr_2_lvl_q_step = Finch.scansearch(arr_2_lvl_tbl2, arr_2_lvl_i + 1, arr_2_lvl_q, arr_2_lvl_q_stop - 1) + end + phase_stop_2 = min(phase_stop, arr_2_lvl_i) + if arr_2_lvl_i == phase_stop_2 + fmt_lvl_q = (1 - 1) * fmt_lvl.shape + phase_stop_2 + arr_2_lvl_q_2 = arr_2_lvl_q + if arr_2_lvl_q < arr_2_lvl_q_step + arr_2_lvl_i_stop_2 = arr_2_lvl_tbl1[arr_2_lvl_q_step - 1] + else + arr_2_lvl_i_stop_2 = 0 + end + phase_stop_3 = min(arr_2_lvl.shape[1], arr_2_lvl_i_stop_2) + if phase_stop_3 >= 1 + i = 1 + if arr_2_lvl_tbl1[arr_2_lvl_q] < 1 + arr_2_lvl_q_2 = Finch.scansearch(arr_2_lvl_tbl1, 1, arr_2_lvl_q, arr_2_lvl_q_step - 1) + end + while i <= phase_stop_3 + arr_2_lvl_i_2 = arr_2_lvl_tbl1[arr_2_lvl_q_2] + phase_stop_4 = min(phase_stop_3, arr_2_lvl_i_2) + if arr_2_lvl_i_2 == phase_stop_4 + arr_2_lvl_2_val = arr_2_lvl_val[arr_2_lvl_q_2] + fmt_lvl_2_q = (fmt_lvl_q - 1) * fmt_lvl_2.shape + phase_stop_4 + fmt_lvl_2_val[fmt_lvl_2_q] = arr_2_lvl_2_val + fmt_lvl_2_val[fmt_lvl_2_q] + if !(fmt_lvl_tbl[fmt_lvl_2_q]) + fmt_lvl_tbl[fmt_lvl_2_q] = true + fmt_lvl_2_qos_fill += 1 + if fmt_lvl_2_qos_fill > fmt_lvl_2_qos_stop + fmt_lvl_2_qos_stop = max(fmt_lvl_2_qos_stop << 1, 1) + Finch.resize_if_smaller!(fmt_lvl_srt, fmt_lvl_2_qos_stop) + end + fmt_lvl_srt[fmt_lvl_2_qos_fill] = (fmt_lvl_q, phase_stop_4) + end + arr_2_lvl_q_2 += 1 + end + i = phase_stop_4 + 1 + end + end + arr_2_lvl_q = arr_2_lvl_q_step + end + j = phase_stop_2 + 1 + end + end + sort!(view(fmt_lvl_srt, 1:fmt_lvl_2_qos_fill)) + fmt_lvl_2_p_prev = 0 + for fmt_lvl_2_r = 1:fmt_lvl_2_qos_fill + fmt_lvl_2_p_2 = first(fmt_lvl_srt[fmt_lvl_2_r]) + if fmt_lvl_2_p_2 != fmt_lvl_2_p_prev + fmt_lvl_ptr[fmt_lvl_2_p_prev + 1] = fmt_lvl_2_r + fmt_lvl_ptr[fmt_lvl_2_p_2] = fmt_lvl_2_r + end + fmt_lvl_2_p_prev = fmt_lvl_2_p_2 + end + fmt_lvl_ptr[fmt_lvl_2_p_2 + 1] = fmt_lvl_2_qos_fill + 1 + qos = 1 * fmt_lvl.shape + resize!(fmt_lvl_ptr, qos + 1) + resize!(fmt_lvl_tbl, qos * fmt_lvl_2.shape) + resize!(fmt_lvl_srt, fmt_lvl_2_qos_fill) + resize!(fmt_lvl_2_val, qos * fmt_lvl_2.shape) + (fmt = Fiber((DenseLevel){Int64}((SparseByteMapLevel){Int64}(fmt_lvl_3, fmt_lvl_2.shape, fmt_lvl_ptr, fmt_lvl_tbl, fmt_lvl_srt), fmt_lvl.shape)),) +end diff --git "a/test/reference64/increment_to_5\303\2275 Fiber!(Dense(SparseHash{1}(Element(0.0)))).jl" "b/test/reference64/increment_to_5\303\2275 Fiber!(Dense(SparseHash{1}(Element(0.0)))).jl" new file mode 100644 index 000000000..9f6370f84 --- /dev/null +++ "b/test/reference64/increment_to_5\303\2275 Fiber!(Dense(SparseHash{1}(Element(0.0)))).jl" @@ -0,0 +1,97 @@ +begin + fmt_lvl = ex.body.body.lhs.tns.bind.lvl + fmt_lvl_2 = fmt_lvl.lvl + fmt_lvl_2_qos_fill = length(fmt_lvl_2.tbl) + fmt_lvl_2_qos_stop = fmt_lvl_2_qos_fill + fmt_lvl_ptr = fmt_lvl.lvl.ptr + fmt_lvl_tbl = fmt_lvl.lvl.tbl + fmt_lvl_srt = fmt_lvl.lvl.srt + fmt_lvl_3 = fmt_lvl_2.lvl + fmt_lvl_2_val = fmt_lvl_2.lvl.val + arr_2_lvl = ex.body.body.rhs.tns.bind.lvl + arr_2_lvl_ptr = ex.body.body.rhs.tns.bind.lvl.ptr + arr_2_lvl_tbl1 = ex.body.body.rhs.tns.bind.lvl.tbl[1] + arr_2_lvl_tbl2 = ex.body.body.rhs.tns.bind.lvl.tbl[2] + arr_2_lvl_val = arr_2_lvl.lvl.val + arr_2_lvl.shape[1] == fmt_lvl_2.shape[1] || throw(DimensionMismatch("mismatched dimension limits ($(arr_2_lvl.shape[1]) != $(fmt_lvl_2.shape[1]))")) + arr_2_lvl.shape[2] == fmt_lvl.shape || throw(DimensionMismatch("mismatched dimension limits ($(arr_2_lvl.shape[2]) != $(fmt_lvl.shape))")) + for fmt_lvl_2_p = 1 * fmt_lvl.shape:-1:1 + fmt_lvl_ptr[fmt_lvl_2_p + 1] = fmt_lvl_ptr[fmt_lvl_2_p + 1] - fmt_lvl_ptr[fmt_lvl_2_p] + end + fmt_lvl_ptr[1] = 1 + fmt_lvl_2_qos_fill = length(fmt_lvl_tbl) + arr_2_lvl_q = arr_2_lvl_ptr[1] + arr_2_lvl_q_stop = arr_2_lvl_ptr[1 + 1] + if arr_2_lvl_q < arr_2_lvl_q_stop + arr_2_lvl_i_stop = arr_2_lvl_tbl2[arr_2_lvl_q_stop - 1] + else + arr_2_lvl_i_stop = 0 + end + phase_stop = min(arr_2_lvl.shape[2], arr_2_lvl_i_stop) + if phase_stop >= 1 + j = 1 + if arr_2_lvl_tbl2[arr_2_lvl_q] < 1 + arr_2_lvl_q = Finch.scansearch(arr_2_lvl_tbl2, 1, arr_2_lvl_q, arr_2_lvl_q_stop - 1) + end + while j <= phase_stop + arr_2_lvl_i = arr_2_lvl_tbl2[arr_2_lvl_q] + arr_2_lvl_q_step = arr_2_lvl_q + if arr_2_lvl_tbl2[arr_2_lvl_q] == arr_2_lvl_i + arr_2_lvl_q_step = Finch.scansearch(arr_2_lvl_tbl2, arr_2_lvl_i + 1, arr_2_lvl_q, arr_2_lvl_q_stop - 1) + end + phase_stop_2 = min(phase_stop, arr_2_lvl_i) + if arr_2_lvl_i == phase_stop_2 + fmt_lvl_q = (1 - 1) * fmt_lvl.shape + phase_stop_2 + arr_2_lvl_q_2 = arr_2_lvl_q + if arr_2_lvl_q < arr_2_lvl_q_step + arr_2_lvl_i_stop_2 = arr_2_lvl_tbl1[arr_2_lvl_q_step - 1] + else + arr_2_lvl_i_stop_2 = 0 + end + phase_stop_3 = min(arr_2_lvl.shape[1], arr_2_lvl_i_stop_2) + if phase_stop_3 >= 1 + i = 1 + if arr_2_lvl_tbl1[arr_2_lvl_q] < 1 + arr_2_lvl_q_2 = Finch.scansearch(arr_2_lvl_tbl1, 1, arr_2_lvl_q, arr_2_lvl_q_step - 1) + end + while i <= phase_stop_3 + arr_2_lvl_i_2 = arr_2_lvl_tbl1[arr_2_lvl_q_2] + phase_stop_4 = min(phase_stop_3, arr_2_lvl_i_2) + if arr_2_lvl_i_2 == phase_stop_4 + arr_2_lvl_2_val = arr_2_lvl_val[arr_2_lvl_q_2] + fmt_lvl_2_key = (fmt_lvl_q, (phase_stop_4,)) + fmt_lvl_2_q = get(fmt_lvl_tbl, fmt_lvl_2_key, fmt_lvl_2_qos_fill + 1) + if fmt_lvl_2_q > fmt_lvl_2_qos_stop + fmt_lvl_2_qos_stop = max(fmt_lvl_2_qos_stop << 1, 1) + Finch.resize_if_smaller!(fmt_lvl_2_val, fmt_lvl_2_qos_stop) + Finch.fill_range!(fmt_lvl_2_val, 0.0, fmt_lvl_2_q, fmt_lvl_2_qos_stop) + end + fmt_lvl_2_val[fmt_lvl_2_q] = arr_2_lvl_2_val + fmt_lvl_2_val[fmt_lvl_2_q] + if fmt_lvl_2_q > fmt_lvl_2_qos_fill + fmt_lvl_2_qos_fill = fmt_lvl_2_q + fmt_lvl_tbl[fmt_lvl_2_key] = fmt_lvl_2_q + fmt_lvl_ptr[fmt_lvl_q + 1] += 1 + end + arr_2_lvl_q_2 += 1 + end + i = phase_stop_4 + 1 + end + end + arr_2_lvl_q = arr_2_lvl_q_step + end + j = phase_stop_2 + 1 + end + end + resize!(fmt_lvl_srt, length(fmt_lvl_tbl)) + copyto!(fmt_lvl_srt, pairs(fmt_lvl_tbl)) + sort!(fmt_lvl_srt, by = hashkeycmp) + for p = 2:fmt_lvl.shape + 1 + fmt_lvl_ptr[p] += fmt_lvl_ptr[p - 1] + end + qos = 1 * fmt_lvl.shape + resize!(fmt_lvl_ptr, qos + 1) + qos_2 = fmt_lvl_ptr[end] - 1 + resize!(fmt_lvl_srt, qos_2) + resize!(fmt_lvl_2_val, qos_2) + (fmt = Fiber((DenseLevel){Int64}((SparseHashLevel){1, Tuple{Int64}}(fmt_lvl_3, (fmt_lvl_2.shape[1],), fmt_lvl_ptr, fmt_lvl_tbl, fmt_lvl_srt), fmt_lvl.shape)),) +end diff --git "a/test/reference64/increment_to_5\303\2275 Fiber!(SparseHash{2}(Element(0.0))).jl" "b/test/reference64/increment_to_5\303\2275 Fiber!(SparseHash{2}(Element(0.0))).jl" new file mode 100644 index 000000000..0c3c45e92 --- /dev/null +++ "b/test/reference64/increment_to_5\303\2275 Fiber!(SparseHash{2}(Element(0.0))).jl" @@ -0,0 +1,94 @@ +begin + fmt_lvl = ex.body.body.lhs.tns.bind.lvl + fmt_lvl_qos_fill = length(fmt_lvl.tbl) + fmt_lvl_qos_stop = fmt_lvl_qos_fill + fmt_lvl_ptr = ex.body.body.lhs.tns.bind.lvl.ptr + fmt_lvl_tbl = ex.body.body.lhs.tns.bind.lvl.tbl + fmt_lvl_srt = ex.body.body.lhs.tns.bind.lvl.srt + fmt_lvl_2 = fmt_lvl.lvl + fmt_lvl_val = fmt_lvl.lvl.val + arr_2_lvl = ex.body.body.rhs.tns.bind.lvl + arr_2_lvl_ptr = ex.body.body.rhs.tns.bind.lvl.ptr + arr_2_lvl_tbl1 = ex.body.body.rhs.tns.bind.lvl.tbl[1] + arr_2_lvl_tbl2 = ex.body.body.rhs.tns.bind.lvl.tbl[2] + arr_2_lvl_val = arr_2_lvl.lvl.val + arr_2_lvl.shape[1] == fmt_lvl.shape[1] || throw(DimensionMismatch("mismatched dimension limits ($(arr_2_lvl.shape[1]) != $(fmt_lvl.shape[1]))")) + arr_2_lvl.shape[2] == fmt_lvl.shape[2] || throw(DimensionMismatch("mismatched dimension limits ($(arr_2_lvl.shape[2]) != $(fmt_lvl.shape[2]))")) + for fmt_lvl_p = 1:-1:1 + fmt_lvl_ptr[fmt_lvl_p + 1] = fmt_lvl_ptr[fmt_lvl_p + 1] - fmt_lvl_ptr[fmt_lvl_p] + end + fmt_lvl_ptr[1] = 1 + fmt_lvl_qos_fill = length(fmt_lvl_tbl) + arr_2_lvl_q = arr_2_lvl_ptr[1] + arr_2_lvl_q_stop = arr_2_lvl_ptr[1 + 1] + if arr_2_lvl_q < arr_2_lvl_q_stop + arr_2_lvl_i_stop = arr_2_lvl_tbl2[arr_2_lvl_q_stop - 1] + else + arr_2_lvl_i_stop = 0 + end + phase_stop = min(arr_2_lvl.shape[2], arr_2_lvl_i_stop) + if phase_stop >= 1 + j = 1 + if arr_2_lvl_tbl2[arr_2_lvl_q] < 1 + arr_2_lvl_q = Finch.scansearch(arr_2_lvl_tbl2, 1, arr_2_lvl_q, arr_2_lvl_q_stop - 1) + end + while j <= phase_stop + arr_2_lvl_i = arr_2_lvl_tbl2[arr_2_lvl_q] + arr_2_lvl_q_step = arr_2_lvl_q + if arr_2_lvl_tbl2[arr_2_lvl_q] == arr_2_lvl_i + arr_2_lvl_q_step = Finch.scansearch(arr_2_lvl_tbl2, arr_2_lvl_i + 1, arr_2_lvl_q, arr_2_lvl_q_stop - 1) + end + phase_stop_2 = min(phase_stop, arr_2_lvl_i) + if arr_2_lvl_i == phase_stop_2 + arr_2_lvl_q_2 = arr_2_lvl_q + if arr_2_lvl_q < arr_2_lvl_q_step + arr_2_lvl_i_stop_2 = arr_2_lvl_tbl1[arr_2_lvl_q_step - 1] + else + arr_2_lvl_i_stop_2 = 0 + end + phase_stop_3 = min(arr_2_lvl.shape[1], arr_2_lvl_i_stop_2) + if phase_stop_3 >= 1 + i = 1 + if arr_2_lvl_tbl1[arr_2_lvl_q] < 1 + arr_2_lvl_q_2 = Finch.scansearch(arr_2_lvl_tbl1, 1, arr_2_lvl_q, arr_2_lvl_q_step - 1) + end + while i <= phase_stop_3 + arr_2_lvl_i_2 = arr_2_lvl_tbl1[arr_2_lvl_q_2] + phase_stop_4 = min(phase_stop_3, arr_2_lvl_i_2) + if arr_2_lvl_i_2 == phase_stop_4 + arr_2_lvl_2_val = arr_2_lvl_val[arr_2_lvl_q_2] + fmt_lvl_key_2 = (1, (phase_stop_4, phase_stop_2)) + fmt_lvl_q_2 = get(fmt_lvl_tbl, fmt_lvl_key_2, fmt_lvl_qos_fill + 1) + if fmt_lvl_q_2 > fmt_lvl_qos_stop + fmt_lvl_qos_stop = max(fmt_lvl_qos_stop << 1, 1) + Finch.resize_if_smaller!(fmt_lvl_val, fmt_lvl_qos_stop) + Finch.fill_range!(fmt_lvl_val, 0.0, fmt_lvl_q_2, fmt_lvl_qos_stop) + end + fmt_lvl_val[fmt_lvl_q_2] = arr_2_lvl_2_val + fmt_lvl_val[fmt_lvl_q_2] + if fmt_lvl_q_2 > fmt_lvl_qos_fill + fmt_lvl_qos_fill = fmt_lvl_q_2 + fmt_lvl_tbl[fmt_lvl_key_2] = fmt_lvl_q_2 + fmt_lvl_ptr[1 + 1] += 1 + end + arr_2_lvl_q_2 += 1 + end + i = phase_stop_4 + 1 + end + end + arr_2_lvl_q = arr_2_lvl_q_step + end + j = phase_stop_2 + 1 + end + end + resize!(fmt_lvl_srt, length(fmt_lvl_tbl)) + copyto!(fmt_lvl_srt, pairs(fmt_lvl_tbl)) + sort!(fmt_lvl_srt, by = hashkeycmp) + for p = 2:1 + 1 + fmt_lvl_ptr[p] += fmt_lvl_ptr[p - 1] + end + resize!(fmt_lvl_ptr, 1 + 1) + qos = fmt_lvl_ptr[end] - 1 + resize!(fmt_lvl_srt, qos) + resize!(fmt_lvl_val, qos) + (fmt = Fiber((SparseHashLevel){2, Tuple{Int64, Int64}}(fmt_lvl_2, (fmt_lvl.shape[1], fmt_lvl.shape[2]), fmt_lvl_ptr, fmt_lvl_tbl, fmt_lvl_srt)),) +end diff --git a/test/test_conversions.jl b/test/test_conversions.jl index db855476e..6325eb369 100644 --- a/test/test_conversions.jl +++ b/test/test_conversions.jl @@ -259,4 +259,29 @@ end end end -end + + for fmt in [ + Fiber!(SparseHash{2}(Element(0.0))) + Fiber!(Dense(SparseHash{1}(Element(0.0)))) + Fiber!(Dense(SparseByteMap(Element(0.0)))) + ] + arr_1 = fsprand((10, 10), 0.5) + fmt = copyto!(fmt, arr_1) + arr_2 = fsprand((10, 10), 0.5) + check_output("increment_to_$(summary(fmt)).jl", @finch_code begin + for j = _ + for i = _ + fmt[i, j] += arr_2[i, j] + end + end + end) + @finch begin + for j = _ + for i = _ + fmt[i, j] += arr_2[i, j] + end + end + end + @test fmt == arr_1 .+ arr_2 + end +end \ No newline at end of file