Sprinkle init-cuda everywhere you could conceivably need it!
parent
6809ac0855
commit
8d76f2e612
|
@ -34,6 +34,7 @@ dim-block dim-grid shared-size stream ;
|
||||||
'[ cuda-context set _ call ] with-cuda-context ; inline
|
'[ cuda-context set _ call ] with-cuda-context ; inline
|
||||||
|
|
||||||
: with-cuda ( launcher quot -- )
|
: with-cuda ( launcher quot -- )
|
||||||
|
init-cuda
|
||||||
[ H{ } clone cuda-memory-hashtable ] 2dip '[
|
[ H{ } clone cuda-memory-hashtable ] 2dip '[
|
||||||
_
|
_
|
||||||
[ cuda-launcher set ]
|
[ cuda-launcher set ]
|
||||||
|
@ -84,5 +85,3 @@ MACRO: cuda-arguments ( c-types -- quot: ( args... function -- ) )
|
||||||
]
|
]
|
||||||
[ 2nip \ function-launcher suffix a:void function-effect ]
|
[ 2nip \ function-launcher suffix a:void function-effect ]
|
||||||
3bi define-declared ;
|
3bi define-declared ;
|
||||||
|
|
||||||
[ init-cuda ] "cuda-init" add-startup-hook
|
|
||||||
|
|
|
@ -7,9 +7,11 @@ sequences ;
|
||||||
IN: cuda.devices
|
IN: cuda.devices
|
||||||
|
|
||||||
: #cuda-devices ( -- n )
|
: #cuda-devices ( -- n )
|
||||||
|
init-cuda
|
||||||
int <c-object> [ cuDeviceGetCount cuda-error ] keep *int ;
|
int <c-object> [ cuDeviceGetCount cuda-error ] keep *int ;
|
||||||
|
|
||||||
: n>cuda-device ( n -- device )
|
: n>cuda-device ( n -- device )
|
||||||
|
init-cuda
|
||||||
[ CUdevice <c-object> ] dip [ cuDeviceGet cuda-error ] 2keep drop *int ;
|
[ CUdevice <c-object> ] dip [ cuDeviceGet cuda-error ] 2keep drop *int ;
|
||||||
|
|
||||||
: enumerate-cuda-devices ( -- devices )
|
: enumerate-cuda-devices ( -- devices )
|
||||||
|
@ -27,16 +29,19 @@ IN: cuda.devices
|
||||||
enumerate-cuda-devices [ dup cuda-device-properties ] { } map>assoc ;
|
enumerate-cuda-devices [ dup cuda-device-properties ] { } map>assoc ;
|
||||||
|
|
||||||
: cuda-device-name ( n -- string )
|
: cuda-device-name ( n -- string )
|
||||||
|
init-cuda
|
||||||
[ 256 [ <byte-array> ] keep ] dip
|
[ 256 [ <byte-array> ] keep ] dip
|
||||||
[ cuDeviceGetName cuda-error ]
|
[ cuDeviceGetName cuda-error ]
|
||||||
[ 2drop utf8 alien>string ] 3bi ;
|
[ 2drop utf8 alien>string ] 3bi ;
|
||||||
|
|
||||||
: cuda-device-capability ( n -- pair )
|
: cuda-device-capability ( n -- pair )
|
||||||
|
init-cuda
|
||||||
[ int <c-object> int <c-object> ] dip
|
[ int <c-object> int <c-object> ] dip
|
||||||
[ cuDeviceComputeCapability cuda-error ]
|
[ cuDeviceComputeCapability cuda-error ]
|
||||||
[ drop [ *int ] bi@ ] 3bi 2array ;
|
[ drop [ *int ] bi@ ] 3bi 2array ;
|
||||||
|
|
||||||
: cuda-device-memory ( n -- bytes )
|
: cuda-device-memory ( n -- bytes )
|
||||||
|
init-cuda
|
||||||
[ uint <c-object> ] dip
|
[ uint <c-object> ] dip
|
||||||
[ cuDeviceTotalMem cuda-error ]
|
[ cuDeviceTotalMem cuda-error ]
|
||||||
[ drop *uint ] 2bi ;
|
[ drop *uint ] 2bi ;
|
||||||
|
@ -47,6 +52,7 @@ IN: cuda.devices
|
||||||
[ 2drop *int ] 3bi ;
|
[ 2drop *int ] 3bi ;
|
||||||
|
|
||||||
: cuda-device. ( n -- )
|
: cuda-device. ( n -- )
|
||||||
|
init-cuda
|
||||||
{
|
{
|
||||||
[ "Device: " write number>string print ]
|
[ "Device: " write number>string print ]
|
||||||
[ "Name: " write cuda-device-name print ]
|
[ "Name: " write cuda-device-name print ]
|
||||||
|
@ -64,6 +70,7 @@ IN: cuda.devices
|
||||||
} cleave ;
|
} cleave ;
|
||||||
|
|
||||||
: cuda. ( -- )
|
: cuda. ( -- )
|
||||||
|
init-cuda
|
||||||
"CUDA Version: " write cuda-version number>string print nl
|
"CUDA Version: " write cuda-version number>string print nl
|
||||||
#cuda-devices iota [ nl ] [ cuda-device. ] interleave ;
|
#cuda-devices iota [ nl ] [ cuda-device. ] interleave ;
|
||||||
|
|
||||||
|
|
|
@ -460,4 +460,3 @@ FUNCTION: CUresult cuGraphicsMapResources ( uint count, CUgraphicsResource* reso
|
||||||
FUNCTION: CUresult cuGraphicsUnmapResources ( uint count, CUgraphicsResource* resources, CUstream hStream ) ;
|
FUNCTION: CUresult cuGraphicsUnmapResources ( uint count, CUgraphicsResource* resources, CUstream hStream ) ;
|
||||||
|
|
||||||
FUNCTION: CUresult cuGetExportTable ( void** ppExportTable, CUuuid* pExportTableId ) ;
|
FUNCTION: CUresult cuGetExportTable ( void** ppExportTable, CUuuid* pExportTableId ) ;
|
||||||
|
|
||||||
|
|
Loading…
Reference in New Issue