]> gitweb.factorcode.org Git - factor.git/blobdiff - extra/cuda/memory/memory.factor
factor: trim using lists
[factor.git] / extra / cuda / memory / memory.factor
index f3c452093a7ea044e2e2d6e732c82406698bd527..92cb9dec31ca452e815f13e06baaae1f6e8083f8 100644 (file)
@@ -1,16 +1,13 @@
 ! 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 cuda.ffi destructors fry io.encodings.string
-io.encodings.utf8 kernel locals math 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 )
     c:heap-size * cuda-malloc ; inline
@@ -45,7 +42,7 @@ DESTRUCTOR: cuda-free
     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 )