Пример #1
0
        def sum_pair(data_out, data_in, idx, length):
            perm_in = trtc.DVPermutation(data_in, idx)

            loop = trtc.For(['arr_in', 'arr_out'], "i",
                            "arr_out[i] = arr_in[2 * i] + arr_in[2 * i + 1];")

            loop.launch_n(length // 2, [perm_in, data_out])
Пример #2
0
 def sort_pair(data_out, data_in, is_first_in_pair, idx, length):
     # note: silently assumes that data_out is not permuted (i.e. not part of state)
     perm_in = trtc.DVPermutation(data_in, idx)
     trtc.Fill(data_out, trtc.DVDouble(0))
     if length > 1:
         AlgorithmicStepMethods.__sort_pair_body.launch_n(
             length - 1, [data_out, perm_in, is_first_in_pair])
Пример #3
0
 def amax(row, idx, length):
     perm_in = trtc.DVPermutation(row, idx)
     index = trtc.Max_Element(perm_in.range(0, length))
     row_idx = idx.get(index)
     result = row.get(row_idx)
     return result
Пример #4
0
 def find_pairs(cell_start, is_first_in_pair, cell_id, idx, length):
     perm_cell_id = trtc.DVPermutation(cell_id, idx)
     if length > 1:
         AlgorithmicStepMethods.__find_pairs_body.launch_n(
             length - 1, [cell_start, perm_cell_id, is_first_in_pair])
Пример #5
0
 def amin(row, idx):
     perm_in = trtc.DVPermutation(row.data, idx.data)
     index = trtc.Min_Element(perm_in.range(0, len(row)))
     row_idx = idx[index]
     result = row[row_idx]
     return result
Пример #6
0
import ThrustRTC as trtc

dvalues = trtc.device_vector_from_list(
    [10.0, 20.0, 30.0, 40.0, 50.0, 60.0, 70.0, 80.0], 'float')
dindices = trtc.device_vector_from_list([2, 6, 1, 3], 'int32_t')
doutput = trtc.device_vector('float', 4)

perm = trtc.DVPermutation(dvalues, dindices)

trtc.Transform(perm, doutput, trtc.Negate())
print(doutput.to_host())