Queue memoization for test suite
Setting up the queue takes time, and the test suite is already slow -- it would be a big advantage not to have to execute get_queue
every time.
We can't do a one-time memoization, as the ctx_factory
can vary. I wonder if we could use ctx_factory.__str__()
, something like this:
_QUEUES = {}
def get_queue(ctx_factory):
id = ctx_factory.__str__()
if not id in _QUEUES:
add_queue(ctx_factory)
return _QUEUES[id]
def add_queue(ctx_factory):
id = ctx_factory.__str__()
ctx = ctx_factory()
_QUEUES[id] = cl.CommandQueue(ctx)
Edited by Timothy Smith