Skip to content
test_loopy.py 28 KiB
Newer Older
    for k in lp.generate_loop_schedules(knl):
        assert k.temporary_variables["a"].shape == (16,)
def test_write_parameter(ctx_factory):
    dtype = np.float32
    ctx = ctx_factory()

    knl = lp.make_kernel(ctx.devices[0], [
            "{[i,j]: 0<=i,j<n }",
            ],
            """
                a = sum((i,j), i*j)
                b = sum(i, sum(j, i*j))
                n = 15
                """,
            [
                lp.GlobalArg("a", dtype, shape=()),
                lp.GlobalArg("b", dtype, shape=()),
                lp.ValueArg("n", np.int32, approximately=1000),
                ],
            assumptions="n>=1")

    try:
        lp.CompiledKernel(ctx, knl).get_code()
    except RuntimeError, e:
        assert "may not be written" in str(e)
        pass # expected!
    else:
        assert False # expecting an error




if __name__ == "__main__":
    import sys
    if len(sys.argv) > 1:
        exec(sys.argv[1])
    else:
        from py.test.cmdline import main
        main([__file__])