Skip to content

Commit fbdda4d

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

2 files changed

Lines changed: 24 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: 22 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -788,6 +788,28 @@ 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,
800+
is_input=True, is_output=False),
801+
lp.GlobalArg("output", np.uint8, shape=lp.auto, is_input=False,
802+
is_output=True)],
803+
target=lp.ISPCTarget(), assumptions="1<K")
804+
805+
knl = lp.split_iname(knl, "k", 8, inner_tag="l.0")
806+
knl = lp.set_temporary_address_space(knl, "b", "private")
807+
808+
cg_result = lp.generate_code_v2(knl)
809+
810+
print(cg_result.device_code())
811+
812+
791813
if __name__ == "__main__":
792814
if len(sys.argv) > 1:
793815
exec(sys.argv[1])

0 commit comments

Comments
 (0)