How to use the desert.helpers.load_kernel function in desert

To help you get started, we’ve selected a few desert examples, based on popular ways it is used in public projects.

Secure your code as it's written. Use Snyk Code to scan source code in minutes - no build needed - and fix issues immediately.

github inconvergent / desert / desert / primitives.py View on Github external
subs={'_THREADS_': THREADS}
    )

_cuda_sample_circle = load_kernel(
    pkg_resources.resource_filename('desert', 'cuda/circle.cu'),
    'circle',
    subs={'_THREADS_': THREADS}
    )

_cuda_sample_stroke = load_kernel(
    pkg_resources.resource_filename('desert', 'cuda/stroke.cu'),
    'stroke',
    subs={'_THREADS_': THREADS}
    )

_cuda_sample_bzspl = load_kernel(
    pkg_resources.resource_filename('desert', 'cuda/bzspl.cu'),
    'bzspl',
    subs={'_THREADS_': THREADS}
    )

def add_noise(f):
  @wraps(f)
  def inside(*args, **kwargs):
    res = f(*args, **kwargs)
    self = args[0]
    if self.noise is not None:
      rad = npfloat(self.noise)
      ng = res.shape[0]
      xy = zeros((ng, 2), npfloat)
      mid = zeros((1, 2), npfloat)
      _cuda_sample_circle(npint(ng),
github inconvergent / desert / desert / primitives.py View on Github external
RGEN = Rgen(offset=0)



THREADS = int(getenv('THREADS', 512))
TWOPI = 2.0*PI


_cuda_sample_box = load_kernel(
    pkg_resources.resource_filename('desert', 'cuda/box.cu'),
    'box',
    subs={'_THREADS_': THREADS}
    )

_cuda_sample_circle = load_kernel(
    pkg_resources.resource_filename('desert', 'cuda/circle.cu'),
    'circle',
    subs={'_THREADS_': THREADS}
    )

_cuda_sample_stroke = load_kernel(
    pkg_resources.resource_filename('desert', 'cuda/stroke.cu'),
    'stroke',
    subs={'_THREADS_': THREADS}
    )

_cuda_sample_bzspl = load_kernel(
    pkg_resources.resource_filename('desert', 'cuda/bzspl.cu'),
    'bzspl',
    subs={'_THREADS_': THREADS}
    )
github inconvergent / desert / desert / desert.py View on Github external
assert self.gsamples >= 5000, 'you must set gsamples to at least 5000.'

    self.cuda_agg = load_kernel(
         pkg_resources.resource_filename('desert', 'cuda/agg.cu'),
        'agg',
        subs={'_THREADS_': THREADS}
        )

    self.cuda_agg_bin = load_kernel(
         pkg_resources.resource_filename('desert', 'cuda/agg_bin.cu'),
        'agg_bin',
        subs={'_THREADS_': THREADS}
        )

    self.cuda_dot = load_kernel(
         pkg_resources.resource_filename('desert', 'cuda/dot.cu'),
        'dot',
        subs={'_THREADS_': THREADS}
        )

    self.fig = None
    if show:
      self.fig = plt.figure()
      self.fig.patch.set_facecolor('gray')

    self._updated = False
    self.verbose = verbose

    self.fg = None
    self.bg = None
github inconvergent / desert / desert / primitives.py View on Github external
TWOPI = 2.0*PI


_cuda_sample_box = load_kernel(
    pkg_resources.resource_filename('desert', 'cuda/box.cu'),
    'box',
    subs={'_THREADS_': THREADS}
    )

_cuda_sample_circle = load_kernel(
    pkg_resources.resource_filename('desert', 'cuda/circle.cu'),
    'circle',
    subs={'_THREADS_': THREADS}
    )

_cuda_sample_stroke = load_kernel(
    pkg_resources.resource_filename('desert', 'cuda/stroke.cu'),
    'stroke',
    subs={'_THREADS_': THREADS}
    )

_cuda_sample_bzspl = load_kernel(
    pkg_resources.resource_filename('desert', 'cuda/bzspl.cu'),
    'bzspl',
    subs={'_THREADS_': THREADS}
    )

def add_noise(f):
  @wraps(f)
  def inside(*args, **kwargs):
    res = f(*args, **kwargs)
    self = args[0]
github inconvergent / desert / desert / desert.py View on Github external
def __init__(self, imsize, show=True,
               gsamples=1000000, verbose=False):
    self.imsize = imsize
    self.imsize2 = imsize*imsize
    self.img = zeros((self.imsize2, 4), npfloat)

    self._img = cuda.mem_alloc(self.img.nbytes)
    self.gsamples = gsamples

    assert self.gsamples >= 5000, 'you must set gsamples to at least 5000.'

    self.cuda_agg = load_kernel(
         pkg_resources.resource_filename('desert', 'cuda/agg.cu'),
        'agg',
        subs={'_THREADS_': THREADS}
        )

    self.cuda_agg_bin = load_kernel(
         pkg_resources.resource_filename('desert', 'cuda/agg_bin.cu'),
        'agg_bin',
        subs={'_THREADS_': THREADS}
        )

    self.cuda_dot = load_kernel(
         pkg_resources.resource_filename('desert', 'cuda/dot.cu'),
        'dot',
        subs={'_THREADS_': THREADS}
        )
github inconvergent / desert / desert / desert.py View on Github external
self.imsize = imsize
    self.imsize2 = imsize*imsize
    self.img = zeros((self.imsize2, 4), npfloat)

    self._img = cuda.mem_alloc(self.img.nbytes)
    self.gsamples = gsamples

    assert self.gsamples >= 5000, 'you must set gsamples to at least 5000.'

    self.cuda_agg = load_kernel(
         pkg_resources.resource_filename('desert', 'cuda/agg.cu'),
        'agg',
        subs={'_THREADS_': THREADS}
        )

    self.cuda_agg_bin = load_kernel(
         pkg_resources.resource_filename('desert', 'cuda/agg_bin.cu'),
        'agg_bin',
        subs={'_THREADS_': THREADS}
        )

    self.cuda_dot = load_kernel(
         pkg_resources.resource_filename('desert', 'cuda/dot.cu'),
        'dot',
        subs={'_THREADS_': THREADS}
        )

    self.fig = None
    if show:
      self.fig = plt.figure()
      self.fig.patch.set_facecolor('gray')
github inconvergent / desert / desert / primitives.py View on Github external
from .helpers import is_verbose
from .helpers import json_array
from .helpers import load_kernel
from .helpers import pfloat

from .color import Rgba

RGEN = Rgen(offset=0)



THREADS = int(getenv('THREADS', 512))
TWOPI = 2.0*PI


_cuda_sample_box = load_kernel(
    pkg_resources.resource_filename('desert', 'cuda/box.cu'),
    'box',
    subs={'_THREADS_': THREADS}
    )

_cuda_sample_circle = load_kernel(
    pkg_resources.resource_filename('desert', 'cuda/circle.cu'),
    'circle',
    subs={'_THREADS_': THREADS}
    )

_cuda_sample_stroke = load_kernel(
    pkg_resources.resource_filename('desert', 'cuda/stroke.cu'),
    'stroke',
    subs={'_THREADS_': THREADS}
    )