! Copyright (C) 2010 Doug Coleman.
! See http://factorcode.org/license.txt for BSD license.
-USING: accessors alien alien.data alien.destructors assocs
-byte-arrays cuda.ffi cuda.utils destructors fry io.encodings.string
-io.encodings.utf8 kernel locals namespaces sequences strings ;
+USING: alien alien.c-types alien.data alien.destructors
+byte-arrays cuda cuda.ffi kernel math ;
QUALIFIED-WITH: alien.c-types c
IN: cuda.memory
: cuda-malloc ( n -- ptr )
- [ CUdeviceptr <c-object> ] dip
- '[ _ cuMemAlloc cuda-error ] keep
- c:*int ; inline
+ [ { CUdeviceptr } ] dip
+ '[ _ cuMemAlloc cuda-error ] with-out-parameters ; inline
: cuda-malloc-type ( n type -- ptr )
- heap-size * cuda-malloc ; inline
+ c:heap-size * cuda-malloc ; inline
: cuda-free ( ptr -- )
cuMemFree cuda-error ; inline
cuMemcpyDtoH cuda-error ; inline
: host>device ( data -- ptr )
- [ >c-ptr ] [ byte-length ] bi
+ binary-object
[ nip cuda-malloc dup ] [ memcpy-host>device ] 2bi ; inline
: device>host ( ptr len -- byte-array )