예제 #1
0
def memcpy(dst, src):
    assert (dst.flags['C_CONTIGUOUS'])
    assert (src.shape == dst.shape)
    dst_space = _string2space(_get_space(dst))
    src_space = _string2space(_get_space(src))
    count = dst.nbytes
    _check(
        _bf.bfMemcpy(dst.ctypes.data, dst_space, src.ctypes.data, src_space,
                     count))
    return dst
예제 #2
0
def memcpy2D(dst, src):
    assert (len(dst.shape) == 2)
    assert (src.shape == dst.shape)
    dst_space = _string2space(_get_space(dst))
    src_space = _string2space(_get_space(src))
    height, width = dst.shape
    width_bytes = width * dst.dtype.itemsize
    _check(
        _bf.bfMemcpy2D(dst.ctypes.data, dst.strides[0], dst_space,
                       src.ctypes.data, src.strides[0], src_space, width_bytes,
                       height))
예제 #3
0
 def init(self, coeffs, decim=1, space='cuda'):
     space = _string2space(space)
     psize = None
     _check(
         _bf.bfFirInit(self.obj,
                       asarray(coeffs).as_BFarray(), decim, space, 0,
                       psize))
예제 #4
0
def memset2D(dst, val=0):
    assert (len(dst.shape) == 2)
    space = _string2space(_get_space(dst))
    height, width = dst.shape
    width_bytes = width * dst.dtype.itemsize
    _check(
        _bf.bfMemset2D(dst.ctypes.data, dst.strides[0], space, val,
                       width_bytes, height))
예제 #5
0
 def __init__(self, space='system', name=None, core=None):
     if name is None:
         name = str(uuid4())
     name = _slugify(name)
     try:
         name = name.encode()
     except AttributeError:
         # Python2 catch
         pass
     space = _string2space(space)
     #self.obj = None
     #self.obj = _get(_bf.bfRingCreate(name=name, space=space), retarg=0)
     BifrostObject.__init__(self, _bf.bfRingCreate, _bf.bfRingDestroy, name,
                            space)
     if core is not None:
         try:
             _check(_bf.bfRingSetAffinity(self.obj, core))
         except RuntimeError:
             pass
예제 #6
0
 def __init__(self, space='system', name=None, owner=None, core=None):
     # If this is non-None, then the object is wrapping a base Ring instance
     self.base = None
     self.space = space
     if name is None:
         name = 'ring_%i' % Ring.instance_count
         Ring.instance_count += 1
     name = _slugify(name)
     try:
         name = name.encode()
     except AttributeError:
         # Python2 catch
         pass
     BifrostObject.__init__(self, _bf.bfRingCreate, _bf.bfRingDestroy, name,
                            _string2space(self.space))
     if core is not None:
         try:
             _check(_bf.bfRingSetAffinity(self.obj, core))
         except RuntimeError:
             pass
     self.owner = owner
     self.header_transform = None
예제 #7
0
def raw_free(ptr, space='auto'):
    _check(_bf.bfFree(ptr, _string2space(space)))
예제 #8
0
def raw_malloc(size, space):
    ptr = ctypes.c_void_p()
    _check(_bf.bfMalloc(ptr, size, _string2space(space)))
    return ptr.value
예제 #9
0
def memset(dst, val=0):
    assert (dst.flags['C_CONTIGUOUS'])
    space = _string2space(_get_space(dst))
    count = dst.nbytes
    _check(_bf.bfMemset(dst.ctypes.data, space, val, count))
예제 #10
0
 def init(self, nchan, max_delay, f0, df, exponent=-2.0, space='cuda'):
     space = _string2space(space)
     psize = None
     _check(
         _bf.bfFdmtInit(self.obj, nchan, max_delay, f0, df, exponent, space,
                        0, psize))