def TestSynIterInc(): SIZE = 64 # build and run the kernel prgm = env.Program() code = prgm.get_stream() code.add(ptx.dcl_output(reg.o0, USAGE=ptx.usage.pos)) ones = prgm.acquire_register((1, 1, 1, 1)) counter = prgm.acquire_register() code.add(ptx.mov(counter, ones)) for i in syn_iter(code, 4, step=1, mode=INC): code.add(ptx.iadd(counter, counter, ones)) code.add(ptx.mov(reg.o0, counter.x)) domain = (0, 0, SIZE, SIZE) proc = env.Processor(0) ext_output=proc.alloc_remote('i', 1, SIZE) prgm.set_binding(reg.o0, ext_output) prgm.add(code) proc.execute(prgm, domain) passed = True for i in xrange(0, SIZE): if ext_output[i] != 5: passed = False print "Passed == ", passed proc.free(ext_output) return
def TestSynIterInc(): SIZE = 64 # build and run the kernel prgm = env.Program() code = prgm.get_stream() code.add(ptx.dcl_output(reg.o0, USAGE=ptx.usage.pos)) ones = prgm.acquire_register((1, 1, 1, 1)) counter = prgm.acquire_register() code.add(ptx.mov(counter, ones)) for i in syn_iter(code, 4, step=1, mode=INC): code.add(ptx.iadd(counter, counter, ones)) code.add(ptx.mov(reg.o0, counter.x)) domain = (0, 0, SIZE, SIZE) proc = env.Processor(0) ext_output = proc.alloc_remote('i', 1, SIZE) prgm.set_binding(reg.o0, ext_output) prgm.add(code) proc.execute(prgm, domain) passed = True for i in xrange(0, SIZE): if ext_output[i] != 5: passed = False print "Passed == ", passed proc.free(ext_output) return
def TestSynIterIncFloatExtStopExtStart(): SIZE = 64 # build and run the kernel prgm = env.Program() code = prgm.get_stream() code.add(ptx.dcl_output(reg.o0, USAGE=ptx.usage.pos)) ones = prgm.acquire_register((1, 1, 1, 1)) counter = prgm.acquire_register() code.add(ptx.mov(counter, ones)) stop = prgm.acquire_register((4.0, 4.0, 4.0, 4.0)) start = prgm.acquire_register((2.0, 2.0, 2.0, 2.0)) step = prgm.acquire_register((1.0, 1.0, 1.0, 1.0)) fiter = syn_iter_float(code, stop, step=step, mode=INC) fiter.set_start_reg(start) for i in fiter: code.add(ptx.iadd(counter, counter, ones)) code.add(ptx.mov(reg.o0, counter.x)) domain = (0, 0, SIZE, SIZE) proc = env.Processor(0) ext_output=proc.alloc_remote('i', 1, SIZE, 1) prgm.set_binding(reg.o0, ext_output) prgm.add(code) proc.execute(prgm, domain) passed = True for i in xrange(0, SIZE): if ext_output[i] != 3: passed = False print "Passed == ", passed proc.free(ext_output) return
def TestSynIterIncFloatExtStopExtStart(): SIZE = 64 # build and run the kernel prgm = env.Program() code = prgm.get_stream() code.add(ptx.dcl_output(reg.o0, USAGE=ptx.usage.pos)) ones = prgm.acquire_register((1, 1, 1, 1)) counter = prgm.acquire_register() code.add(ptx.mov(counter, ones)) stop = prgm.acquire_register((4.0, 4.0, 4.0, 4.0)) start = prgm.acquire_register((2.0, 2.0, 2.0, 2.0)) step = prgm.acquire_register((1.0, 1.0, 1.0, 1.0)) fiter = syn_iter_float(code, stop, step=step, mode=INC) fiter.set_start_reg(start) for i in fiter: code.add(ptx.iadd(counter, counter, ones)) code.add(ptx.mov(reg.o0, counter.x)) domain = (0, 0, SIZE, SIZE) proc = env.Processor(0) ext_output = proc.alloc_remote('i', 1, SIZE, 1) prgm.set_binding(reg.o0, ext_output) prgm.add(code) proc.execute(prgm, domain) passed = True for i in xrange(0, SIZE): if ext_output[i] != 3: passed = False print "Passed == ", passed proc.free(ext_output) return