cdua.devices: remove redundant init-cuda calls

db4
Joe Groff 2010-05-07 17:16:28 -07:00
parent ec6c2ccc3e
commit a228e575a5
1 changed files with 0 additions and 8 deletions

View File

@ -7,11 +7,9 @@ sequences ;
IN: cuda.devices
: #cuda-devices ( -- n )
init-cuda
int <c-object> [ cuDeviceGetCount cuda-error ] keep *int ;
: n>cuda-device ( n -- device )
init-cuda
[ CUdevice <c-object> ] dip [ cuDeviceGet cuda-error ] 2keep drop *int ;
: enumerate-cuda-devices ( -- devices )
@ -21,7 +19,6 @@ IN: cuda.devices
[ enumerate-cuda-devices ] dip '[ <launcher> _ with-cuda ] each ; inline
: cuda-device-properties ( n -- properties )
init-cuda
[ CUdevprop <c-object> ] dip
[ cuDeviceGetProperties cuda-error ] 2keep drop
CUdevprop memory>struct ;
@ -30,31 +27,26 @@ IN: cuda.devices
enumerate-cuda-devices [ dup cuda-device-properties ] { } map>assoc ;
: cuda-device-name ( n -- string )
init-cuda
[ 256 [ <byte-array> ] keep ] dip
[ cuDeviceGetName cuda-error ]
[ 2drop utf8 alien>string ] 3bi ;
: cuda-device-capability ( n -- pair )
init-cuda
[ int <c-object> int <c-object> ] dip
[ cuDeviceComputeCapability cuda-error ]
[ drop [ *int ] bi@ ] 3bi 2array ;
: cuda-device-memory ( n -- bytes )
init-cuda
[ uint <c-object> ] dip
[ cuDeviceTotalMem cuda-error ]
[ drop *uint ] 2bi ;
: cuda-device-attribute ( attribute n -- n )
init-cuda
[ int <c-object> ] 2dip
[ cuDeviceGetAttribute cuda-error ]
[ 2drop *int ] 3bi ;
: cuda-device. ( n -- )
init-cuda
{
[ "Device: " write number>string print ]
[ "Name: " write cuda-device-name print ]