mirror of
https://github.com/stevenrobertson/cuburn.git
synced 2025-02-05 11:40:04 -05:00
Hang on to old modules to avoid syncing
This commit is contained in:
parent
ed09cc6955
commit
5a91d9f96c
@ -194,11 +194,21 @@ class DevInfo(object):
|
|||||||
self.d_pal_array = cuda.Array(self.palette_surf_dsc)
|
self.d_pal_array = cuda.Array(self.palette_surf_dsc)
|
||||||
|
|
||||||
class Renderer(object):
|
class Renderer(object):
|
||||||
|
# Unloading a module triggers a context sync. To keep the renderer
|
||||||
|
# asynchronous, and avoid expensive CPU polling, this hangs on to
|
||||||
|
# a number of (relatively small) CUDA modules and flushes them together.
|
||||||
|
MAX_MODREFS = 20
|
||||||
|
_modrefs = []
|
||||||
|
|
||||||
def __init__(self, gnm):
|
def __init__(self, gnm):
|
||||||
self.packer, self.lib = iter.mkiterlib(gnm)
|
self.packer, self.lib = iter.mkiterlib(gnm)
|
||||||
cubin = util.compile('iter', assemble_code(self.lib))
|
cubin = util.compile('iter', assemble_code(self.lib))
|
||||||
self.mod = cuda.module_from_buffer(cubin)
|
self.mod = cuda.module_from_buffer(cubin)
|
||||||
|
|
||||||
|
if len(self._modrefs) > self.MAX_MODREFS:
|
||||||
|
del self._modrefs[:]
|
||||||
|
self._modrefs.append(self.mod)
|
||||||
|
|
||||||
# TODO: make these customizable
|
# TODO: make these customizable
|
||||||
self.filts = [ filters.Bilateral()
|
self.filts = [ filters.Bilateral()
|
||||||
, filters.Logscale()
|
, filters.Logscale()
|
||||||
|
Loading…
Reference in New Issue
Block a user