Exemple #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
Exemple #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))
Exemple #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))
Exemple #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))
Exemple #5
0
	def __init__(self, space='system', name=None, owner=None):
		self.space = space
		if name is None:
			name = 'ring_%i' % Ring.instance_count
			Ring.instance_count += 1
		self.obj = _get(_bf.RingCreate(name=name, space=_string2space(self.space)), retarg=0)
		self.owner = owner
		self.header_transform = None
		# If this is non-None, then the object is wrapping a base Ring instance
		self.base = None
Exemple #6
0
 def __init__(self, space='system', name=None, core=None):
     if name is None:
         name = str(uuid4())
     name = _slugify(name)
     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
Exemple #7
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)
     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
Exemple #8
0
	def init(self, nchan, max_delay, f0, df, exponent=-2.0, space='cuda'):
		space = _string2space(space)
		psize = None
		_check( _bf.FdmtInit(self.obj, nchan, max_delay, f0, df, exponent, space, 0, psize) )
Exemple #9
0
def raw_free(ptr, space='auto'):
    _check(_bf.bfFree(ptr, _string2space(space)))
Exemple #10
0
def raw_malloc(size, space):
    ptr = ctypes.c_void_p()
    _check(_bf.bfMalloc(ptr, size, _string2space(space)))
    return ptr.value
Exemple #11
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))
Exemple #12
0
 def __init__(self, space='system', name=None):
     if name is None:
         name = str(uuid4())
     space = _string2space(space)
     #self.obj = None
     self.obj = _get(_bf.RingCreate(name=name, space=space), retarg=0)
Exemple #13
0
def raw_malloc(size, space):
    ptr = _get(_bf.Malloc(size=size, space=_string2space(space)), retarg=0)
    return ptr