Exemple #1
0
 def __call__(self, queue, nd, *args):
     assert sum(signature) == len(args)
     dda_args = []
     for i,a in enumerate(args):
         if i < signature[0]:
             dda_args.append(dda.dda(a.block, dda.sync_in))
         elif i < signature[1]:
             dda_args.append(dda.dda(a.block, dda.sync_inout))
         else:
             dda_args.append(dda.dda(a.block, dda.sync_out))
     bufs = [data.buf() for data in dda_args]
     self.kernel(queue, nd, *bufs)
     for d in dda_args:
         d.sync_out()
Exemple #2
0
 def __call__(self, queue, nd, *args):
     assert sum(signature) == len(args)
     dda_args = []
     for i, a in enumerate(args):
         if i < signature[0]:
             dda_args.append(dda.dda(a.block, dda.sync_in))
         elif i < signature[1]:
             dda_args.append(dda.dda(a.block, dda.sync_inout))
         else:
             dda_args.append(dda.dda(a.block, dda.sync_out))
     bufs = [data.buf() for data in dda_args]
     self.kernel(queue, nd, *bufs)
     for d in dda_args:
         d.sync_out()
Exemple #3
0
inbuf = cl.buffer(cxt, 32)
outbuf = cl.buffer(cxt, 32)
queue = cl.default_queue()
queue.write(input, inbuf)
kernel(queue, 32, inbuf, outbuf)
output = queue.read_string(outbuf, len(input))

# ...finally test that the output is equal to the input
assert input == output
print 'copying string PASSED'

# Now try a copy operation on vectors
v1 = vector(array=numpy.arange(16, dtype=numpy.float32))
v2 = vector(length=16, dtype=numpy.float32)
v1_data = dda.dda(v1.block, dda.sync_in)
v2_data = dda.dda(v2.block, dda.sync_out)
kernel(queue, 32, v1_data.buf(), v2_data.buf())
# force the data back to the host
v2_data.sync_out();
assert v1 == v2
print 'copying buffers PASSED'

# now do the same using the wrapper
kernel = wrap(program.create_kernel("copy"), (1,0,1))
v2 = vector(length=16, dtype=numpy.float32)
v3 = vector(length=16, dtype=numpy.float32)
v1[:] = 1.
logging.info('copying v1->v2')
kernel(queue, 32, v1, v2)
logging.info('copying v2->v3')
Exemple #4
0
inbuf = cl.buffer(cxt, 32)
outbuf = cl.buffer(cxt, 32)
queue = cl.default_queue()
queue.write(input, inbuf)
kernel(queue, 32, inbuf, outbuf)
output = queue.read_string(outbuf, len(input))

# ...finally test that the output is equal to the input
assert input == output
print 'copying string PASSED'

# Now try a copy operation on vectors
v1 = vector(array=numpy.arange(16, dtype=numpy.float32))
v2 = vector(length=16, dtype=numpy.float32)
v1_data = dda.dda(v1.block, dda.sync_in)
v2_data = dda.dda(v2.block, dda.sync_out)
kernel(queue, 32, v1_data.buf(), v2_data.buf())
# force the data back to the host
v2_data.sync_out()
assert v1 == v2
print 'copying buffers PASSED'

# now do the same using the wrapper
kernel = wrap(program.create_kernel("copy"), (1, 0, 1))
v2 = vector(length=16, dtype=numpy.float32)
v3 = vector(length=16, dtype=numpy.float32)
v1[:] = 1.
logging.info('copying v1->v2')
kernel(queue, 32, v1, v2)
logging.info('copying v2->v3')