Exemplo n.º 1
0
import ThrustRTC as trtc

darr = trtc.device_vector('int32_t', 10)

trtc.Sequence(darr)
trtc.Tabulate(darr, trtc.Negate())
print(darr.to_host())
Exemplo n.º 2
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())
Exemplo n.º 3
0
import ThrustRTC as trtc



negate = trtc.Functor( {}, ['x'],
'''
         return -x;
''')


darr = trtc.device_vector('int32_t', 10)
trtc.Transform(trtc.DVCounter(trtc.DVInt32(5), 10), darr, trtc.Negate())
print (darr.to_host())
Exemplo n.º 4
0
import ThrustRTC as trtc

dinput = trtc.device_vector_from_list([3, 7, 2, 5], 'int32_t')
doutput = trtc.device_vector('int32_t', 4)

dreverse = trtc.DVReverse(dinput)

trtc.Transform(dreverse, doutput, trtc.Negate())
print(doutput.to_host())
Exemplo n.º 5
0
import ThrustRTC as trtc

is_odd = trtc.Functor({}, ['x'], '''
         return x % 2;
''')

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

darr_in1 = trtc.device_vector_from_list([-5, 0, 2, 3, 2, 4], 'int32_t')
darr_in2 = trtc.device_vector_from_list([3, 6, -2, 1, 2, 3], 'int32_t')
darr_out = trtc.device_vector('int32_t', 6)
trtc.Transform_Binary(darr_in1, darr_in2, darr_out, trtc.Plus())
print(darr_out.to_host())

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

darr_data = trtc.device_vector_from_list([-5, 0, 2, -3, 2, 4, 0, -1, 2, 8],
                                         'int32_t')
darr_stencil = trtc.device_vector_from_list([1, 0, 1, 0, 1, 0, 1, 0, 1, 0],
                                            'int32_t')
trtc.Transform_If_Stencil(darr_data, darr_stencil, darr_data, trtc.Negate(),
                          trtc.Identity())
print(darr_data.to_host())

darr_in1 = trtc.device_vector_from_list([-5, 0, 2, 3, 2, 4], 'int32_t')
Exemplo n.º 6
0
import ThrustRTC as trtc

square_root = trtc.Functor({}, ['x'], '''
         return sqrtf(x);
''')

dvalues = trtc.device_vector_from_list([1.0, 4.0, 9.0, 16.0], 'float')
doutput = trtc.device_vector('float', 4)

dtrans = trtc.DVTransform(dvalues, 'float', square_root)

trtc.Transform(dtrans, doutput, trtc.Negate())
print(doutput.to_host())
Exemplo n.º 7
0
import ThrustRTC as trtc

trtc.Set_Verbose()

trtc.Transform(trtc.DVCounter(trtc.DVInt32(5), 10), trtc.DVDiscard("int32_t"),
               trtc.Negate())
Exemplo n.º 8
0
import ThrustRTC as trtc

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

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