Move 'mktref' to util

This commit is contained in:
Steven Robertson 2017-04-24 16:38:39 -07:00
parent bdcaca1f97
commit 6bf428caee
2 changed files with 8 additions and 8 deletions

View File

@ -52,6 +52,13 @@ def launch2(name, mod, stream, dim, *args, **kwargs):
block, grid = (32, 8, 1), (dim.astride / 32, dim.ah / 8) block, grid = (32, 8, 1), (dim.astride / 32, dim.ah / 8)
launch(name, mod, stream, block, grid, *args, **kwargs) 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): def crep(s):
"""Multiline literal escape for inline PTX assembly.""" """Multiline literal escape for inline PTX assembly."""
if isinstance(s, unicode): if isinstance(s, unicode):

View File

@ -6,7 +6,7 @@ import pycuda.compiler
from pycuda.gpuarray import vec from pycuda.gpuarray import vec
import code.filters 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): def set_blur_width(mod, pool, stdev=1, stream=None):
coefs = pool.allocate((7,), f32) 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') ptr, size = mod.get_global('gauss_coefs')
cuda.memcpy_htod_async(ptr, coefs, stream) 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): def mkdsc(dim, ch):
return argset(cuda.ArrayDescriptor(), height=dim.ah, return argset(cuda.ArrayDescriptor(), height=dim.ah,
width=dim.astride, num_channels=ch, width=dim.astride, num_channels=ch,