Sprinkle init-cuda everywhere you could conceivably need it!

db4
Doug Coleman 2010-04-23 23:17:47 -05:00
parent 6809ac0855
commit 8d76f2e612
3 changed files with 8 additions and 3 deletions

View File

@ -34,6 +34,7 @@ dim-block dim-grid shared-size stream ;
'[ cuda-context set _ call ] with-cuda-context ; inline
: with-cuda ( launcher quot -- )
init-cuda
[ H{ } clone cuda-memory-hashtable ] 2dip '[
_
[ cuda-launcher set ]
@ -84,5 +85,3 @@ MACRO: cuda-arguments ( c-types -- quot: ( args... function -- ) )
]
[ 2nip \ function-launcher suffix a:void function-effect ]
3bi define-declared ;
[ init-cuda ] "cuda-init" add-startup-hook

View File

@ -7,9 +7,11 @@ 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 )
@ -27,16 +29,19 @@ 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 ;
@ -47,6 +52,7 @@ IN: cuda.devices
[ 2drop *int ] 3bi ;
: cuda-device. ( n -- )
init-cuda
{
[ "Device: " write number>string print ]
[ "Name: " write cuda-device-name print ]
@ -64,6 +70,7 @@ IN: cuda.devices
} cleave ;
: cuda. ( -- )
init-cuda
"CUDA Version: " write cuda-version number>string print nl
#cuda-devices iota [ nl ] [ cuda-device. ] interleave ;

View File

@ -460,4 +460,3 @@ FUNCTION: CUresult cuGraphicsMapResources ( uint count, CUgraphicsResource* reso
FUNCTION: CUresult cuGraphicsUnmapResources ( uint count, CUgraphicsResource* resources, CUstream hStream ) ;
FUNCTION: CUresult cuGetExportTable ( void** ppExportTable, CUuuid* pExportTableId ) ;