def OclSimulator(model): ctx = cl.create_some_context() name = ctx.devices[0].name return (name, sim_ocl.Simulator(model, ctx))
def OclSimulator(model): ctx = cl.create_some_context() return sim_ocl.Simulator(model, ctx, profiling=True)
def OclSimulator(*args, **kwargs): return sim_ocl.Simulator(*args, context=ctx, **kwargs)
import nengo_ocl from nengo_ocl.tricky_imports import unittest from nengo_ocl import sim_ocl from nengo_ocl import ast_conversion from nengo_ocl.plan import Plan import pyopencl as cl model = nengo.Model("Dummy") model.prep_for_simulation(model, 0.001) ctx = cl.create_some_context() if 1: sim = sim_ocl.Simulator(ctx, model, profiling=True) t0 = time.time() # sim.run(0.2) # sim.run(10.0) sim.run(9.9985) t1 = time.time() print "Done in %s seconds" % (t1 - t0) t = sim.probe_outputs[sim.model.probed[sim.model.t]] t_diff = np.diff(t, axis=0) print "t: %f, %f" % (len(t) * sim.model.dt, t[-1]) print "t_diff: mean %s, std %s, min %s, max %s" % ( t_diff.mean(), t_diff.std(), t_diff.min(), t_diff.max())
def Simulator(self, *args, **kwargs): rval = sim_ocl.Simulator(ctx, *args, **kwargs) rval.alloc_all() rval.plan_all() return rval
def Ocl2Simulator(*args, **kwargs): kwargs['context'] = ctx return sim_ocl.Simulator(*args, **kwargs)