Beispiel #1
0
 def coalescence(n, volume, idx, length, intensive, extensive, gamma, healthy, adaptive, subs, adaptive_memory):
     idx_length = trtc.DVInt64(len(idx))
     intensive_length = trtc.DVInt64(len(intensive))
     extensive_length = trtc.DVInt64(len(extensive))
     adaptive_device = trtc.DVBool(adaptive)
     subs_device = trtc.DVInt64(subs)
     AlgorithmicMethods.__coalescence_body.launch_n(length - 1,
         [n.data, volume.data, idx.data, idx_length, intensive.data, intensive_length, extensive.data, extensive_length, gamma.data, healthy.data, adaptive_device, subs_device, adaptive_memory.data])
     return trtc.Reduce(adaptive_memory.data.range(0, length-1), trtc.DVInt64(0), trtc.Maximum())
Beispiel #2
0
 def __equip(data, shape):
     data.shape = shape
     data.get = lambda index: trtc.Reduce(data.range(index, index + 1))
Beispiel #3
0
 def get(index):
     return trtc.Reduce(data.range(index, index + 1))
Beispiel #4
0
import ThrustRTC as trtc



darr = trtc.device_vector_from_list([1, 0, 2, 2, 1, 3], 'int32_t')
print(trtc.Reduce(darr))
print(trtc.Reduce(darr, trtc.DVInt32(1)))
print(trtc.Reduce(darr, trtc.DVInt32(-1), trtc.Maximum()))

d_keys_in = trtc.device_vector_from_list([1, 3, 3, 3, 2, 2, 1], 'int32_t')
d_value_in = trtc.device_vector_from_list([9, 8, 7, 6, 5, 4, 3], 'int32_t')

d_keys_out = trtc.device_vector('int32_t', 7)
d_values_out = trtc.device_vector('int32_t', 7)

count = trtc.Reduce_By_Key(d_keys_in, d_value_in, d_keys_out, d_values_out)
print (d_keys_out.to_host(0, count))
print (d_values_out.to_host(0, count))

count = trtc.Reduce_By_Key(d_keys_in, d_value_in, d_keys_out, d_values_out, trtc.EqualTo())
print (d_keys_out.to_host(0, count))
print (d_values_out.to_host(0, count))

count = trtc.Reduce_By_Key(d_keys_in, d_value_in, d_keys_out, d_values_out, trtc.EqualTo(), trtc.Plus())
print (d_keys_out.to_host(0, count))
print (d_values_out.to_host(0, count))