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
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))
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))
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))
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
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
def raw_free(ptr, space='auto'): _check(_bf.bfFree(ptr, _string2space(space)))
def raw_malloc(size, space): ptr = ctypes.c_void_p() _check(_bf.bfMalloc(ptr, size, _string2space(space))) return ptr.value
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))
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))