]> gitweb.factorcode.org Git - factor.git/blobdiff - extra/cuda/devices/devices.factor
factor: trim using lists
[factor.git] / extra / cuda / devices / devices.factor
index dc69946648dc5f9618d5b8d11a4aea88d1c8c3ea..ac3bfdec85b0705b2c246523d6fe8bafa8eea1a1 100644 (file)
@@ -1,10 +1,9 @@
 ! Copyright (C) 2010 Doug Coleman.
 ! See http://factorcode.org/license.txt for BSD license.
 USING: accessors alien.c-types alien.data alien.strings arrays
-assocs byte-arrays classes.struct combinators cuda
-cuda.contexts cuda.ffi cuda.libraries fry io io.encodings.utf8
-kernel locals math math.order math.parser namespaces
-prettyprint sequences ;
+assocs byte-arrays combinators cuda cuda.contexts cuda.ffi
+cuda.libraries io io.encodings.utf8 kernel math math.order
+math.parser prettyprint sequences splitting ;
 IN: cuda.devices
 
 : #cuda-devices ( -- n )
@@ -20,8 +19,8 @@ IN: cuda.devices
     [ enumerate-cuda-devices ] dip '[ 0 _ with-cuda-context ] each ; inline
 
 : cuda-device-properties ( n -- properties )
-    [ CUdevprop <struct> ] dip
-    [ cuDeviceGetProperties cuda-error ] 2keep drop ;
+    [ CUdevprop new ] dip
+    [ cuDeviceGetProperties cuda-error ] keepd ;
 
 : cuda-devices ( -- assoc )
     enumerate-cuda-devices [ dup cuda-device-properties ] { } map>assoc ;
@@ -37,8 +36,8 @@ IN: cuda.devices
     2array ;
 
 : cuda-device-memory ( n -- bytes )
-    [ { uint } ] dip
-    '[ _ cuDeviceTotalMem cuda-error ] with-out-parameters ;
+    [ { ulonglong } ] dip
+    '[ _ cuDeviceTotalMem_v2 cuda-error ] with-out-parameters ;
 
 : cuda-device-attribute ( attribute n -- n )
     [ { int } ] 2dip
@@ -51,7 +50,7 @@ IN: cuda.devices
         [ "Memory: " write cuda-device-memory number>string print ]
         [
             "Capability: " write
-            cuda-device-capability [ number>string ] map " " join print
+            cuda-device-capability [ number>string ] map join-words print
         ]
         [ "Properties: " write cuda-device-properties . ]
         [
@@ -61,6 +60,10 @@ IN: cuda.devices
         ]
     } cleave ;
 
+: cuda-devices. ( -- )
+    init-cuda
+    enumerate-cuda-devices [ cuda-device. ] each ;
+
 : cuda. ( -- )
     init-cuda
     "CUDA Version: " write cuda-version number>string print nl