Exemplo n.º 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())
Exemplo n.º 2
0
import ThrustRTC as trtc



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

absolute_value = trtc.Functor( {}, ['x'], 
'''
         return x<(decltype(x))0 ? -x : x;
''')

print(trtc.Transform_Reduce(darr, absolute_value, trtc.DVInt32(0), trtc.Maximum()))
Exemplo n.º 3
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))
Exemplo n.º 4
0
import ThrustRTC as trtc

darr = trtc.device_vector_from_list([1, 0, 2, 2, 1, 3], 'int32_t')
trtc.Inclusive_Scan(darr, darr)
print (darr.to_host())

darr = trtc.device_vector_from_list([-5, 0, 2, -3, 2, 4, 0, -1, 2, 8], 'int32_t')
trtc.Inclusive_Scan(darr, darr, trtc.Maximum())
print (darr.to_host())

darr = trtc.device_vector_from_list([1, 0, 2, 2, 1, 3], 'int32_t')
trtc.Exclusive_Scan(darr, darr)
print (darr.to_host())

darr = trtc.device_vector_from_list([1, 0, 2, 2, 1, 3], 'int32_t')
trtc.Exclusive_Scan(darr, darr, trtc.DVInt32(4))
print (darr.to_host())

darr = trtc.device_vector_from_list([-5, 0, 2, -3, 2, 4, 0, -1, 2, 8], 'int32_t')
trtc.Exclusive_Scan(darr, darr, trtc.DVInt32(1), trtc.Maximum())
print (darr.to_host())