Skip to content

Commit ff234b3

Browse files
committed
Fix, test private vars in ispc (closes gh-763)
1 parent 609e143 commit ff234b3

2 files changed

Lines changed: 22 additions & 1 deletion

File tree

‎loopy/target/ispc.py‎

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -93,7 +93,8 @@ def map_variable(self, expr, type_context):
9393
# FIXME: This is a pretty coarse way of deciding what
9494
# private temporaries get duplicated. Refine? (See also
9595
# below in decl generation)
96-
gsize, lsize = self.kernel.get_grid_size_upper_bounds_as_exprs()
96+
_gsize, lsize = self.kernel.get_grid_size_upper_bounds_as_exprs(
97+
self.codegen_state.callables_table)
9798
if lsize:
9899
return expr[var("programIndex")]
99100
else:

‎test/test_target.py‎

Lines changed: 20 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -788,6 +788,26 @@ def test_no_uint_in_cuda_code():
788788
assert "uint" not in lp.generate_code_v2(knl).device_code()
789789

790790

791+
def test_ispc_private_var():
792+
# https://github.com/inducer/loopy/issues/763
793+
knl = lp.make_kernel(
794+
"{ [k]: 0<=k<K }",
795+
"""
796+
<float32> b = 6.0 * float_pos[k]
797+
output[k] = 2.0 * b
798+
""", [lp.ValueArg("K", is_input=True),
799+
lp.GlobalArg("float_pos", np.float32, shape=lp.auto, is_input=True, is_output=False),
800+
lp.GlobalArg("output", np.uint8, shape=lp.auto, is_input=False, is_output=True)],
801+
target=lp.ISPCTarget(), assumptions='1<K')
802+
803+
knl = lp.split_iname(knl, "k", 8, inner_tag="l.0")
804+
knl = lp.set_temporary_address_space(knl, "b", "private")
805+
806+
cg_result = lp.generate_code_v2(knl)
807+
808+
print(cg_result.device_code())
809+
810+
791811
if __name__ == "__main__":
792812
if len(sys.argv) > 1:
793813
exec(sys.argv[1])

0 commit comments

Comments
 (0)