From 6bf428caee3ec49023d26a3200c0506a1838846d Mon Sep 17 00:00:00 2001 From: Steven Robertson Date: Mon, 24 Apr 2017 16:38:39 -0700 Subject: [PATCH] Move 'mktref' to util --- cuburn/code/util.py | 7 +++++++ cuburn/filters.py | 9 +-------- 2 files changed, 8 insertions(+), 8 deletions(-) diff --git a/cuburn/code/util.py b/cuburn/code/util.py index 67f802d..0456db2 100644 --- a/cuburn/code/util.py +++ b/cuburn/code/util.py @@ -52,6 +52,13 @@ def launch2(name, mod, stream, dim, *args, **kwargs): block, grid = (32, 8, 1), (dim.astride / 32, dim.ah / 8) launch(name, mod, stream, block, grid, *args, **kwargs) +def mktref(mod, n): + tref = mod.get_texref(n) + tref.set_filter_mode(cuda.filter_mode.POINT) + tref.set_address_mode(0, cuda.address_mode.WRAP) + tref.set_address_mode(1, cuda.address_mode.WRAP) + return tref + def crep(s): """Multiline literal escape for inline PTX assembly.""" if isinstance(s, unicode): diff --git a/cuburn/filters.py b/cuburn/filters.py index 80a8ccb..b3698a4 100644 --- a/cuburn/filters.py +++ b/cuburn/filters.py @@ -6,7 +6,7 @@ import pycuda.compiler from pycuda.gpuarray import vec import code.filters -from code.util import ClsMod, argset, launch2 +from code.util import ClsMod, argset, launch2, mktref def set_blur_width(mod, pool, stdev=1, stream=None): coefs = pool.allocate((7,), f32) @@ -15,13 +15,6 @@ def set_blur_width(mod, pool, stdev=1, stream=None): ptr, size = mod.get_global('gauss_coefs') cuda.memcpy_htod_async(ptr, coefs, stream) -def mktref(mod, n): - tref = mod.get_texref(n) - tref.set_filter_mode(cuda.filter_mode.POINT) - tref.set_address_mode(0, cuda.address_mode.WRAP) - tref.set_address_mode(1, cuda.address_mode.WRAP) - return tref - def mkdsc(dim, ch): return argset(cuda.ArrayDescriptor(), height=dim.ah, width=dim.astride, num_channels=ch,