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

Scale, Product Array Combinator #349

Merged
merged 10 commits into from
Dec 20, 2023
Merged
Changes from 1 commit
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
145 changes: 82 additions & 63 deletions test/reference64/continuous_2d_intersect.txt

Large diffs are not rendered by default.

86 changes: 49 additions & 37 deletions test/reference64/continuous_2d_intersect_counting.txt
Original file line number Diff line number Diff line change
@@ -7,85 +7,97 @@ julia> @finch_code begin
quote
s = (ex.bodies[1]).tns.bind
x_lvl = ((ex.bodies[2]).body.body.rhs.args[1]).tns.bind.lvl
x_lvl_ptr = x_lvl.ptr
x_lvl_left = x_lvl.left
x_lvl_right = x_lvl.right
x_lvl_2 = x_lvl.lvl
x_lvl_3 = x_lvl_2.lvl
x_lvl_ptr_2 = x_lvl_2.ptr
x_lvl_left_2 = x_lvl_2.left
x_lvl_right_2 = x_lvl_2.right
x_lvl_2_val = x_lvl_2.lvl.val
y_lvl = ((ex.bodies[2]).body.body.rhs.args[2]).tns.bind.lvl
y_lvl_ptr = y_lvl.ptr
y_lvl_left = y_lvl.left
y_lvl_right = y_lvl.right
y_lvl_2 = y_lvl.lvl
y_lvl_3 = y_lvl_2.lvl
y_lvl_ptr_2 = y_lvl_2.ptr
y_lvl_left_2 = y_lvl_2.left
y_lvl_right_2 = y_lvl_2.right
y_lvl_2_val = y_lvl_2.lvl.val
y_lvl_2.shape == x_lvl_2.shape || throw(DimensionMismatch("mismatched dimension limits ($(y_lvl_2.shape) != $(x_lvl_2.shape))"))
y_lvl.shape == x_lvl.shape || throw(DimensionMismatch("mismatched dimension limits ($(y_lvl.shape) != $(x_lvl.shape))"))
s_val = 0
y_lvl_q = y_lvl.ptr[1]
y_lvl_q_stop = y_lvl.ptr[1 + 1]
y_lvl_q = y_lvl_ptr[1]
y_lvl_q_stop = y_lvl_ptr[1 + 1]
if y_lvl_q < y_lvl_q_stop
y_lvl_i_end = y_lvl.right[y_lvl_q_stop - 1]
y_lvl_i_end = y_lvl_right[y_lvl_q_stop - 1]
else
y_lvl_i_end = 0.0f0
end
x_lvl_q = x_lvl.ptr[1]
x_lvl_q_stop = x_lvl.ptr[1 + 1]
x_lvl_q = x_lvl_ptr[1]
x_lvl_q_stop = x_lvl_ptr[1 + 1]
if x_lvl_q < x_lvl_q_stop
x_lvl_i_end = x_lvl.right[x_lvl_q_stop - 1]
x_lvl_i_end = x_lvl_right[x_lvl_q_stop - 1]
else
x_lvl_i_end = 0.0f0
end
phase_stop = min(y_lvl.shape, y_lvl_i_end, x_lvl_i_end)
if phase_stop >= limit(1.0)
i = limit(1.0)
if y_lvl.right[y_lvl_q] < limit(1.0)
y_lvl_q = Finch.scansearch(y_lvl.right, limit(1.0), y_lvl_q, y_lvl_q_stop - 1)
if y_lvl_right[y_lvl_q] < limit(1.0)
y_lvl_q = Finch.scansearch(y_lvl_right, limit(1.0), y_lvl_q, y_lvl_q_stop - 1)
end
if x_lvl.right[x_lvl_q] < limit(1.0)
x_lvl_q = Finch.scansearch(x_lvl.right, limit(1.0), x_lvl_q, x_lvl_q_stop - 1)
if x_lvl_right[x_lvl_q] < limit(1.0)
x_lvl_q = Finch.scansearch(x_lvl_right, limit(1.0), x_lvl_q, x_lvl_q_stop - 1)
end
while i <= phase_stop
y_lvl_i_start = y_lvl.left[y_lvl_q]
y_lvl_i_stop = y_lvl.right[y_lvl_q]
x_lvl_i_start = x_lvl.left[x_lvl_q]
x_lvl_i_stop = x_lvl.right[x_lvl_q]
y_lvl_i_start = y_lvl_left[y_lvl_q]
y_lvl_i_stop = y_lvl_right[y_lvl_q]
x_lvl_i_start = x_lvl_left[x_lvl_q]
x_lvl_i_stop = x_lvl_right[x_lvl_q]
phase_start_2 = i
phase_stop_2 = min(x_lvl_i_stop, phase_stop, y_lvl_i_stop)
phase_start_6 = max(phase_start_2, y_lvl_i_start, x_lvl_i_start)
if phase_stop_2 >= phase_start_6
cond_5 = -phase_start_6 + phase_stop_2 == 0
if cond_5
x_lvl_2_q_2 = x_lvl_2.ptr[x_lvl_q]
x_lvl_2_q_stop_2 = x_lvl_2.ptr[x_lvl_q + 1]
cond = -phase_start_6 + phase_stop_2 == 0
if cond
x_lvl_2_q_2 = x_lvl_ptr_2[x_lvl_q]
x_lvl_2_q_stop_2 = x_lvl_ptr_2[x_lvl_q + 1]
if x_lvl_2_q_2 < x_lvl_2_q_stop_2
x_lvl_2_i_end_2 = x_lvl_2.right[x_lvl_2_q_stop_2 - 1]
x_lvl_2_i_end_2 = x_lvl_right_2[x_lvl_2_q_stop_2 - 1]
else
x_lvl_2_i_end_2 = 0.0f0
end
y_lvl_2_q_2 = y_lvl_2.ptr[y_lvl_q]
y_lvl_2_q_stop_2 = y_lvl_2.ptr[y_lvl_q + 1]
y_lvl_2_q_2 = y_lvl_ptr_2[y_lvl_q]
y_lvl_2_q_stop_2 = y_lvl_ptr_2[y_lvl_q + 1]
if y_lvl_2_q_2 < y_lvl_2_q_stop_2
y_lvl_2_i_end_2 = y_lvl_2.right[y_lvl_2_q_stop_2 - 1]
y_lvl_2_i_end_2 = y_lvl_right_2[y_lvl_2_q_stop_2 - 1]
else
y_lvl_2_i_end_2 = 0.0f0
end
phase_stop_7 = min(y_lvl_2.shape, x_lvl_2_i_end_2, y_lvl_2_i_end_2)
if phase_stop_7 >= limit(1.0)
j = limit(1.0)
if x_lvl_2.right[x_lvl_2_q_2] < limit(1.0)
x_lvl_2_q_2 = Finch.scansearch(x_lvl_2.right, limit(1.0), x_lvl_2_q_2, x_lvl_2_q_stop_2 - 1)
if x_lvl_right_2[x_lvl_2_q_2] < limit(1.0)
x_lvl_2_q_2 = Finch.scansearch(x_lvl_right_2, limit(1.0), x_lvl_2_q_2, x_lvl_2_q_stop_2 - 1)
end
if y_lvl_2.right[y_lvl_2_q_2] < limit(1.0)
y_lvl_2_q_2 = Finch.scansearch(y_lvl_2.right, limit(1.0), y_lvl_2_q_2, y_lvl_2_q_stop_2 - 1)
if y_lvl_right_2[y_lvl_2_q_2] < limit(1.0)
y_lvl_2_q_2 = Finch.scansearch(y_lvl_right_2, limit(1.0), y_lvl_2_q_2, y_lvl_2_q_stop_2 - 1)
end
while j <= phase_stop_7
x_lvl_2_i_start_2 = x_lvl_2.left[x_lvl_2_q_2]
x_lvl_2_i_stop_2 = x_lvl_2.right[x_lvl_2_q_2]
y_lvl_2_i_start_2 = y_lvl_2.left[y_lvl_2_q_2]
y_lvl_2_i_stop_2 = y_lvl_2.right[y_lvl_2_q_2]
x_lvl_2_i_start_2 = x_lvl_left_2[x_lvl_2_q_2]
x_lvl_2_i_stop_2 = x_lvl_right_2[x_lvl_2_q_2]
y_lvl_2_i_start_2 = y_lvl_left_2[y_lvl_2_q_2]
y_lvl_2_i_stop_2 = y_lvl_right_2[y_lvl_2_q_2]
phase_start_8 = j
phase_stop_8 = min(y_lvl_2_i_stop_2, phase_stop_7, x_lvl_2_i_stop_2)
phase_start_12 = max(phase_start_8, x_lvl_2_i_start_2, y_lvl_2_i_start_2)
if phase_stop_8 >= phase_start_12
y_lvl_3_val_3 = y_lvl_3.val[y_lvl_2_q_2]
x_lvl_3_val_3 = x_lvl_3.val[x_lvl_2_q_2]
cond_9 = -phase_start_12 + phase_stop_8 == 0
if cond_9
s_val = s_val + x_lvl_3_val_3 * y_lvl_3_val_3
y_lvl_3_val_2 = y_lvl_2_val[y_lvl_2_q_2]
x_lvl_3_val_2 = x_lvl_2_val[x_lvl_2_q_2]
cond_2 = -phase_start_12 + phase_stop_8 == 0
if cond_2
s_val = s_val + x_lvl_3_val_2 * y_lvl_3_val_2
end
end
x_lvl_2_q_2 += phase_stop_8 == x_lvl_2_i_stop_2
78 changes: 45 additions & 33 deletions test/reference64/continuous_2d_intersect_lebesgue.txt
Original file line number Diff line number Diff line change
@@ -7,81 +7,93 @@ julia> @finch_code begin
quote
s = (ex.bodies[1]).tns.bind
x_lvl = (((ex.bodies[2]).body.body.rhs.args[1]).args[1]).tns.bind.lvl
x_lvl_ptr = x_lvl.ptr
x_lvl_left = x_lvl.left
x_lvl_right = x_lvl.right
x_lvl_2 = x_lvl.lvl
x_lvl_3 = x_lvl_2.lvl
x_lvl_ptr_2 = x_lvl_2.ptr
x_lvl_left_2 = x_lvl_2.left
x_lvl_right_2 = x_lvl_2.right
x_lvl_2_val = x_lvl_2.lvl.val
y_lvl = (((ex.bodies[2]).body.body.rhs.args[1]).args[2]).tns.bind.lvl
y_lvl_ptr = y_lvl.ptr
y_lvl_left = y_lvl.left
y_lvl_right = y_lvl.right
y_lvl_2 = y_lvl.lvl
y_lvl_3 = y_lvl_2.lvl
y_lvl_ptr_2 = y_lvl_2.ptr
y_lvl_left_2 = y_lvl_2.left
y_lvl_right_2 = y_lvl_2.right
y_lvl_2_val = y_lvl_2.lvl.val
y_lvl_2.shape == x_lvl_2.shape || throw(DimensionMismatch("mismatched dimension limits ($(y_lvl_2.shape) != $(x_lvl_2.shape))"))
y_lvl.shape == x_lvl.shape || throw(DimensionMismatch("mismatched dimension limits ($(y_lvl.shape) != $(x_lvl.shape))"))
s_val = 0
y_lvl_q = y_lvl.ptr[1]
y_lvl_q_stop = y_lvl.ptr[1 + 1]
y_lvl_q = y_lvl_ptr[1]
y_lvl_q_stop = y_lvl_ptr[1 + 1]
if y_lvl_q < y_lvl_q_stop
y_lvl_i_end = y_lvl.right[y_lvl_q_stop - 1]
y_lvl_i_end = y_lvl_right[y_lvl_q_stop - 1]
else
y_lvl_i_end = 0.0f0
end
x_lvl_q = x_lvl.ptr[1]
x_lvl_q_stop = x_lvl.ptr[1 + 1]
x_lvl_q = x_lvl_ptr[1]
x_lvl_q_stop = x_lvl_ptr[1 + 1]
if x_lvl_q < x_lvl_q_stop
x_lvl_i_end = x_lvl.right[x_lvl_q_stop - 1]
x_lvl_i_end = x_lvl_right[x_lvl_q_stop - 1]
else
x_lvl_i_end = 0.0f0
end
phase_stop = min(y_lvl.shape, y_lvl_i_end, x_lvl_i_end)
if phase_stop >= limit(1.0)
i = limit(1.0)
if y_lvl.right[y_lvl_q] < limit(1.0)
y_lvl_q = Finch.scansearch(y_lvl.right, limit(1.0), y_lvl_q, y_lvl_q_stop - 1)
if y_lvl_right[y_lvl_q] < limit(1.0)
y_lvl_q = Finch.scansearch(y_lvl_right, limit(1.0), y_lvl_q, y_lvl_q_stop - 1)
end
if x_lvl.right[x_lvl_q] < limit(1.0)
x_lvl_q = Finch.scansearch(x_lvl.right, limit(1.0), x_lvl_q, x_lvl_q_stop - 1)
if x_lvl_right[x_lvl_q] < limit(1.0)
x_lvl_q = Finch.scansearch(x_lvl_right, limit(1.0), x_lvl_q, x_lvl_q_stop - 1)
end
while i <= phase_stop
y_lvl_i_start = y_lvl.left[y_lvl_q]
y_lvl_i_stop = y_lvl.right[y_lvl_q]
x_lvl_i_start = x_lvl.left[x_lvl_q]
x_lvl_i_stop = x_lvl.right[x_lvl_q]
y_lvl_i_start = y_lvl_left[y_lvl_q]
y_lvl_i_stop = y_lvl_right[y_lvl_q]
x_lvl_i_start = x_lvl_left[x_lvl_q]
x_lvl_i_stop = x_lvl_right[x_lvl_q]
phase_start_2 = i
phase_stop_2 = min(x_lvl_i_stop, phase_stop, y_lvl_i_stop)
phase_start_6 = max(phase_start_2, y_lvl_i_start, x_lvl_i_start)
if phase_stop_2 >= phase_start_6
y_lvl_2_q_2 = y_lvl_2.ptr[y_lvl_q]
y_lvl_2_q_stop_2 = y_lvl_2.ptr[y_lvl_q + 1]
y_lvl_2_q_2 = y_lvl_ptr_2[y_lvl_q]
y_lvl_2_q_stop_2 = y_lvl_ptr_2[y_lvl_q + 1]
if y_lvl_2_q_2 < y_lvl_2_q_stop_2
y_lvl_2_i_end_2 = y_lvl_2.right[y_lvl_2_q_stop_2 - 1]
y_lvl_2_i_end_2 = y_lvl_right_2[y_lvl_2_q_stop_2 - 1]
else
y_lvl_2_i_end_2 = 0.0f0
end
x_lvl_2_q_2 = x_lvl_2.ptr[x_lvl_q]
x_lvl_2_q_stop_2 = x_lvl_2.ptr[x_lvl_q + 1]
x_lvl_2_q_2 = x_lvl_ptr_2[x_lvl_q]
x_lvl_2_q_stop_2 = x_lvl_ptr_2[x_lvl_q + 1]
if x_lvl_2_q_2 < x_lvl_2_q_stop_2
x_lvl_2_i_end_2 = x_lvl_2.right[x_lvl_2_q_stop_2 - 1]
x_lvl_2_i_end_2 = x_lvl_right_2[x_lvl_2_q_stop_2 - 1]
else
x_lvl_2_i_end_2 = 0.0f0
end
phase_stop_7 = min(y_lvl_2.shape, y_lvl_2_i_end_2, x_lvl_2_i_end_2)
if phase_stop_7 >= limit(1.0)
j = limit(1.0)
if y_lvl_2.right[y_lvl_2_q_2] < limit(1.0)
y_lvl_2_q_2 = Finch.scansearch(y_lvl_2.right, limit(1.0), y_lvl_2_q_2, y_lvl_2_q_stop_2 - 1)
if y_lvl_right_2[y_lvl_2_q_2] < limit(1.0)
y_lvl_2_q_2 = Finch.scansearch(y_lvl_right_2, limit(1.0), y_lvl_2_q_2, y_lvl_2_q_stop_2 - 1)
end
if x_lvl_2.right[x_lvl_2_q_2] < limit(1.0)
x_lvl_2_q_2 = Finch.scansearch(x_lvl_2.right, limit(1.0), x_lvl_2_q_2, x_lvl_2_q_stop_2 - 1)
if x_lvl_right_2[x_lvl_2_q_2] < limit(1.0)
x_lvl_2_q_2 = Finch.scansearch(x_lvl_right_2, limit(1.0), x_lvl_2_q_2, x_lvl_2_q_stop_2 - 1)
end
while j <= phase_stop_7
y_lvl_2_i_start_2 = y_lvl_2.left[y_lvl_2_q_2]
y_lvl_2_i_stop_2 = y_lvl_2.right[y_lvl_2_q_2]
x_lvl_2_i_start_2 = x_lvl_2.left[x_lvl_2_q_2]
x_lvl_2_i_stop_2 = x_lvl_2.right[x_lvl_2_q_2]
y_lvl_2_i_start_2 = y_lvl_left_2[y_lvl_2_q_2]
y_lvl_2_i_stop_2 = y_lvl_right_2[y_lvl_2_q_2]
x_lvl_2_i_start_2 = x_lvl_left_2[x_lvl_2_q_2]
x_lvl_2_i_stop_2 = x_lvl_right_2[x_lvl_2_q_2]
phase_start_8 = j
phase_stop_8 = min(x_lvl_2_i_stop_2, phase_stop_7, y_lvl_2_i_stop_2)
phase_start_12 = max(phase_start_8, y_lvl_2_i_start_2, x_lvl_2_i_start_2)
if phase_stop_8 >= phase_start_12
y_lvl_3_val_3 = y_lvl_3.val[y_lvl_2_q_2]
x_lvl_3_val_3 = x_lvl_3.val[x_lvl_2_q_2]
s_val = s_val + drop_eps(-phase_start_6 + phase_stop_2) * drop_eps(-phase_start_12 + phase_stop_8) * y_lvl_3_val_3 * x_lvl_3_val_3
y_lvl_3_val_2 = y_lvl_2_val[y_lvl_2_q_2]
x_lvl_3_val_2 = x_lvl_2_val[x_lvl_2_q_2]
s_val = s_val + drop_eps(-phase_start_6 + phase_stop_2) * drop_eps(-phase_start_12 + phase_stop_8) * y_lvl_3_val_2 * x_lvl_3_val_2
end
y_lvl_2_q_2 += phase_stop_8 == y_lvl_2_i_stop_2
x_lvl_2_q_2 += phase_stop_8 == x_lvl_2_i_stop_2
Loading