def setUpModule(): global ca DEVICE_TYPE_ATTR = os.environ.get('DEVICE_TYPE', 'DEFAULT') DEVICE_TYPE = getattr(cl.Device, DEVICE_TYPE_ATTR) ca = CLArrayContext(device_type=DEVICE_TYPE) print ca.devices
def main(): ca = CLArrayContext() a = ca.empty([1], ctype='f') foo = Foo(10., 2.) objects(ca, a, foo) print "compiled result: ", a.item().value print "python result: ", foo.bar()
def main(): ca = CLArrayContext(device_type=cl.Device.GPU) size = 8 device_input = ca.arange(size) output = ca.add.reduce(device_input) print output.item() with output.map() as view: print "device sum", np.asarray(view).item()
''' Created on Dec 15, 2011 @author: sean ''' import opencl as cl from clyther.array import CLArrayContext #Always have to create a context. ca = CLArrayContext() #can print the current devices print ca.devices #Create an array a = ca.arange(12) print a #map is the same as a memory map with a.map() as arr: print arr #can clice b = a[1::2] with b.map() as arr: print arr #ufuncs c = a + 1