예제 #1
0
	def to_host(self, begin = 0, end = -1):
		elem_cls = self.name_elem_cls()
		if elem_cls=='int8_t':
			nptype = np.int8
		elif elem_cls=='uint8_t':
			nptype = np.uint8
		elif elem_cls=='int16_t':
			nptype = np.int16
		elif elem_cls=='uint16_t':
			nptype = np.uint16
		elif elem_cls=='int32_t':
			nptype = np.int32
		elif elem_cls=='uint32_t':
			nptype = np.uint32
		elif elem_cls=='int64_t':
			nptype = np.int64
		elif elem_cls=='uint64_t':
			nptype = np.uint64
		elif elem_cls=='float':
			nptype = np.float32
		elif elem_cls=='double':
			nptype = np.float64
		elif elem_cls=='bool':
			nptype = np.bool
		if end == -1:
			end = self.size()
		ret = np.empty(end - begin, dtype=nptype)
		native.n_dvvector_to_host(self.m_cptr, ret.__array_interface__['data'][0], begin, end)
		return ret
예제 #2
0
def Sequence(vec, value_init=None, value_step=None):
    cptr_init = None
    if value_init != None:
        cptr_init = value_init.m_cptr
    cptr_step = None
    if value_step != None:
        cptr_step = value_step.m_cptr
    native.n_sequence(vec.m_cptr, cptr_init, cptr_step)
예제 #3
0
def Sort(
    vec,
    comp=None,
):
    cptr_comp = None
    if comp != None:
        cptr_comp = comp.m_cptr
    native.n_sort(vec.m_cptr, cptr_comp)
예제 #4
0
def Adjacent_Difference(vec_in, vec_out, binary_op=None):
    cptr_binary_op = None
    if binary_op != None:
        cptr_binary_op = binary_op.m_cptr
    native.n_adjacent_difference(
        vec_in.m_cptr,
        vec_out.m_cptr,
        cptr_binary_op,
    )
예제 #5
0
def Exclusive_Scan(vec_in, vec_out, value_init=None, binary_op=None):
    cptr_init = None
    if value_init != None:
        cptr_init = value_init.m_cptr
    cptr_binary_op = None
    if binary_op != None:
        cptr_binary_op = binary_op.m_cptr
    native.n_exclusive_scan(vec_in.m_cptr, vec_out.m_cptr, cptr_init,
                            cptr_binary_op)
예제 #6
0
def Inclusive_Scan_By_Key(vec_key,
                          vec_value,
                          vec_out,
                          binary_pred=None,
                          binary_op=None):
    cptr_binary_pred = None
    if binary_pred != None:
        cptr_binary_pred = binary_pred.m_cptr
    cptr_binary_op = None
    if binary_op != None:
        cptr_binary_op = binary_op.m_cptr
    native.n_inclusive_scan_by_key(vec_key.m_cptr, vec_value.m_cptr,
                                   vec_out.m_cptr, cptr_binary_pred,
                                   cptr_binary_op)
예제 #7
0
	def __init__(self, nbarr):
		self.nbarr = nbarr
		if nbarr.dtype == np.int8:
			elem_cls = 'int8_t'
		elif nbarr.dtype == np.uint8:
			elem_cls = 'uint8_t'
		elif nbarr.dtype == np.int16:
			elem_cls = 'int16_t'
		elif nbarr.dtype == np.uint16:
			elem_cls = 'uint16_t'
		elif nbarr.dtype == np.int32:
			elem_cls = 'int32_t'
		elif nbarr.dtype == np.uint32:
			elem_cls = 'uint32_t'		
		elif nbarr.dtype == np.int64:
			elem_cls = 'int64_t'
		elif nbarr.dtype == np.uint64:
			elem_cls = 'uint64_t'	
		elif nbarr.dtype == np.int64:
			elem_cls = 'int64_t'
		elif nbarr.dtype == np.uint64:
			elem_cls = 'uint64_t'	
		elif nbarr.dtype == np.float32:
			elem_cls = 'float'
		elif nbarr.dtype == np.float64:
			elem_cls = 'double'
		elif nbarr.dtype == np.bool:
			elem_cls = 'bool'
		size = nbarr.size
		ptr_device_data = nbarr.device_ctypes_pointer.value
		self.m_cptr = native.n_dvvectoradaptor_create(elem_cls, size, ptr_device_data)
예제 #8
0
def Exclusive_Scan_By_Key(vec_key,
                          vec_value,
                          vec_out,
                          value_init=None,
                          binary_pred=None,
                          binary_op=None):
    cptr_init = None
    if value_init != None:
        cptr_init = value_init.m_cptr
    cptr_binary_pred = None
    if binary_pred != None:
        cptr_binary_pred = binary_pred.m_cptr
    cptr_binary_op = None
    if binary_op != None:
        cptr_binary_op = binary_op.m_cptr
    native.n_exclusive_scan_by_key(vec_key.m_cptr, vec_value.m_cptr,
                                   vec_out.m_cptr, cptr_init, cptr_binary_pred,
                                   cptr_binary_op)
예제 #9
0
def Unique_By_Key_Copy(keys_in,
                       values_in,
                       keys_out,
                       values_out,
                       binary_pred=None):
    cptr_binary_pred = None
    if binary_pred != None:
        cptr_binary_pred = binary_pred.m_cptr
    return native.n_unique_by_key_copy(keys_in.m_cptr, values_in.m_cptr,
                                       keys_out.m_cptr, values_out.m_cptr,
                                       cptr_binary_pred)
예제 #10
0
def Unique_By_Key(keys, values, binary_pred=None):
    cptr_binary_pred = None
    if binary_pred != None:
        cptr_binary_pred = binary_pred.m_cptr
    return native.n_unique_by_key(keys.m_cptr, values.m_cptr, cptr_binary_pred)
예제 #11
0
def Transform_Binary_If_Stencil(vec_in1, vec_in2, vec_stencil, vec_out, op,
                                pred):
    native.n_transform_binary_if_stencil(vec_in1.m_cptr, vec_in2.m_cptr,
                                         vec_stencil.m_cptr, vec_out.m_cptr,
                                         op.m_cptr, pred.m_cptr)
예제 #12
0
def Unique(vec, binary_pred=None):
    cptr_binary_pred = None
    if binary_pred != None:
        cptr_binary_pred = binary_pred.m_cptr
    return native.n_unique(vec.m_cptr, cptr_binary_pred)
예제 #13
0
def Unique_Copy(vec_in, vec_out, binary_pred=None):
    cptr_binary_pred = None
    if binary_pred != None:
        cptr_binary_pred = binary_pred.m_cptr
    return native.n_unique_copy(vec_in.m_cptr, vec_out.m_cptr,
                                cptr_binary_pred)
예제 #14
0
def Copy_If(vec_in, vec_out, pred):
    return native.n_copy_if(vec_in.m_cptr, vec_out.m_cptr, pred.m_cptr)
예제 #15
0
def Remove_Copy_If_Stencil(vec_in, stencil, vec_out, pred):
    return native.n_remove_copy_if_stencil(vec_in.m_cptr, stencil.m_cptr,
                                           vec_out.m_cptr, pred.m_cptr)
예제 #16
0
def Remove_Copy_If(vec_in, vec_out, pred):
    return native.n_remove_copy_if(vec_in.m_cptr, vec_out.m_cptr, pred.m_cptr)
예제 #17
0
def Remove_If_Stencil(vec, stencil, pred):
    return native.n_remove_if_stencil(vec.m_cptr, stencil.m_cptr, pred.m_cptr)
예제 #18
0
def Partition_Copy_Stencil(vec_in, stencil, vec_true, vec_false, pred):
    return native.n_partition_copy_stencil(vec_in.m_cptr, stencil.m_cptr,
                                           vec_true.m_cptr, vec_false.m_cptr,
                                           pred.m_cptr)
예제 #19
0
def Transform_Binary(vec_in1, vec_in2, vec_out, op):
    native.n_transform_binary(vec_in1.m_cptr, vec_in2.m_cptr, vec_out.m_cptr,
                              op.m_cptr)
예제 #20
0
def Partition_Stencil(vec, stencil, pred):
    return native.n_partition_stencil(vec.m_cptr, stencil.m_cptr, pred.m_cptr)
예제 #21
0
def Copy_If_Stencil(vec_in, vec_stencil, vec_out, pred):
    return native.n_copy_if_stencil(vec_in.m_cptr, vec_stencil.m_cptr,
                                    vec_out.m_cptr, pred.m_cptr)
예제 #22
0
def For_Each(vec, f):
    native.n_for_each(vec.m_cptr, f.m_cptr)
예제 #23
0
def Transform_If_Stencil(vec_in, vec_stencil, vec_out, op, pred):
    native.n_transform_if_stencil(vec_in.m_cptr, vec_stencil.m_cptr,
                                  vec_out.m_cptr, op.m_cptr, pred.m_cptr)
예제 #24
0
def Transform_If(vec_in, vec_out, op, pred):
    native.n_transform_if(vec_in.m_cptr, vec_out.m_cptr, op.m_cptr,
                          pred.m_cptr)
예제 #25
0
def Partition(vec, pred):
    return native.n_partition(vec.m_cptr, pred.m_cptr)
예제 #26
0
def Remove(vec, value):
    return native.n_remove(vec.m_cptr, value.m_cptr)
예제 #27
0
def Partition_Copy(vec_in, vec_true, vec_false, pred):
    return native.n_partition_copy(vec_in.m_cptr, vec_true.m_cptr,
                                   vec_false.m_cptr, pred.m_cptr)
예제 #28
0
def Remove_Copy(vec_in, vec_out, value):
    return native.n_remove_copy(vec_in.m_cptr, vec_out.m_cptr, value.m_cptr)
예제 #29
0
 def __init__(self, elem_map):
     self.m_elem_map = elem_map
     self.m_cptr = native.n_dvtuple_create([
         (param_name, elem.m_cptr) for param_name, elem in elem_map.items()
     ])
예제 #30
0
def Remove_If(vec, pred):
    return native.n_remove_if(vec.m_cptr, pred.m_cptr)