mirror of
https://github.com/stevenrobertson/cuburn.git
synced 2025-02-05 11:40:04 -05:00
Add --sleep for slightly more usable system
This commit is contained in:
parent
e6e2c4a8d7
commit
14872ee6ed
@ -196,20 +196,22 @@ class Animation(object):
|
||||
finish the current task. Otherwise, this generator will yield ``None``
|
||||
until the GPU is finished, for filtering later.
|
||||
"""
|
||||
# Don't see this changing, but empirical tests could prove me wrong
|
||||
NRENDERERS = 2
|
||||
# TODO: under a slightly modified sequencing, certain buffers can be
|
||||
# shared (though this may be unimportant if a good AA technique which
|
||||
# doesn't require full SS can be found)
|
||||
rdrs = [_AnimRenderer(self) for i in range(NRENDERERS)]
|
||||
|
||||
# Zip up each genome with an alternating renderer, plus enough empty
|
||||
# genomes at the end to flush all pending tasks
|
||||
times = times if times is not None else [cp.time for cp in self.genomes]
|
||||
exttimes = chain(times, repeat(None, NRENDERERS))
|
||||
|
||||
if block:
|
||||
rdr = _AnimRenderer(self)
|
||||
for t in times:
|
||||
rdr.render(t)
|
||||
yield rdr.get_result()
|
||||
else:
|
||||
# TODO: share buffers.
|
||||
rdrs = [_AnimRenderer(self) for i in range(2)]
|
||||
|
||||
# Zip up each genome with an alternating renderer, plus 2 empty
|
||||
# genomes at the end to flush all pending tasks
|
||||
exttimes = times[:] + [None, None]
|
||||
for rdr, t in izip(cycle(rdrs), exttimes):
|
||||
if rdr.pending:
|
||||
if not block:
|
||||
while not rdr.done():
|
||||
yield None
|
||||
yield rdr.get_result()
|
||||
@ -236,6 +238,8 @@ class _AnimRenderer(object):
|
||||
|
||||
# Use synchronous launches
|
||||
sync = False
|
||||
# Delay this long between iterations (only active when sync is True)
|
||||
sleep = None
|
||||
|
||||
def __init__(self, anim):
|
||||
self.anim = anim
|
||||
@ -364,6 +368,9 @@ class _AnimRenderer(object):
|
||||
block=(32, 16, 1), grid=(len(block_times), 1),
|
||||
texrefs=[tref], stream=stream)
|
||||
|
||||
if self.sync and self.sleep:
|
||||
time.sleep(self.sleep)
|
||||
|
||||
# Now ensure all alt stream tasks are done before continuing main
|
||||
if not self.sync:
|
||||
self.stream.wait_for_event(cuda.Event().record(self.alt_stream))
|
||||
|
10
main.py
10
main.py
@ -110,7 +110,9 @@ def main(args):
|
||||
if (args.start is None or t >= args.start)
|
||||
and (args.end is None or t < args.end)]
|
||||
|
||||
render._AnimRenderer.sync = args.sync
|
||||
render._AnimRenderer.sync = args.sync or args.sleep
|
||||
if args.sleep:
|
||||
render._AnimRenderer.sleep = args.sleep / 1000.
|
||||
anim = render.Animation(genomes)
|
||||
if args.debug:
|
||||
anim.cmp_options.append('-G')
|
||||
@ -128,7 +130,6 @@ def main(args):
|
||||
|
||||
@window.event
|
||||
def on_draw():
|
||||
print 'redrawing'
|
||||
window.clear()
|
||||
image.texture.blit(0, 0)
|
||||
label.draw()
|
||||
@ -219,7 +220,10 @@ if __name__ == "__main__":
|
||||
help='Compile kernel with debugging enabled (implies --keep)')
|
||||
debug.add_argument('--sync', action='store_true', dest='sync',
|
||||
help='Use synchronous launches whenever possible')
|
||||
|
||||
parser.add_argument('--sleep', metavar='MSEC', type=int, dest='sleep',
|
||||
nargs='?', const='5',
|
||||
help='Sleep between invocations. Keeps a single-card system '
|
||||
'usable. Implies --sync.')
|
||||
args = parser.parse_args()
|
||||
|
||||
main(args)
|
||||
|
Loading…
Reference in New Issue
Block a user