]> gitweb.factorcode.org Git - factor.git/commitdiff
cuda.libraries: rename "function-launcher" to "grid", 2<<< to <grid>, 3<<< to <grid...
authorJoe Groff <arcata@gmail.com>
Thu, 20 May 2010 21:51:47 +0000 (14:51 -0700)
committerJoe Groff <arcata@gmail.com>
Thu, 20 May 2010 21:59:27 +0000 (14:59 -0700)
extra/cuda/demos/hello-world/hello-world.factor
extra/cuda/demos/prefix-sum/prefix-sum.factor
extra/cuda/devices/devices.factor
extra/cuda/libraries/libraries.factor
extra/cuda/syntax/syntax.factor

index 4c2f68f01133a95c5c01e63db2cea25e4d793303..dae6ce83d6671b15238138fc9a2cb44f9d600f77 100644 (file)
@@ -1,9 +1,9 @@
 ! Copyright (C) 2010 Doug Coleman.
 ! See http://factorcode.org/license.txt for BSD license.
 USING: accessors alien.c-types alien.strings byte-arrays cuda
-cuda.contexts cuda.devices cuda.memory cuda.syntax destructors
-io io.encodings.string io.encodings.utf8 kernel locals math
-math.parser namespaces sequences strings ;
+cuda.contexts cuda.devices cuda.libraries cuda.memory cuda.syntax
+destructors io io.encodings.string io.encodings.utf8 kernel locals
+math math.parser namespaces sequences strings ;
 IN: cuda.demos.hello-world
 
 CUDA-LIBRARY: hello vocab:cuda/demos/hello-world/hello.ptx
@@ -18,7 +18,7 @@ CUDA-FUNCTION: helloWorld ( char* string-ptr ) ;
             "CUDA device " ": " surround write
             "Hello World!" >byte-array [ - ] map-index host>device &cuda-free
 
-            [ { 2 1 } { 6 1 1 } 2<<< helloWorld ]
+            [ { 2 1 } { 6 1 1 } <grid> helloWorld ]
             [ 12 device>host >string print ] bi
         ] with-destructors
     ] with-each-cuda-device ;
index badd7d905d6cf75aedd8645756f8b204f9d5cad5..aedc9aa095bcd218d4d61d0404cb38129661beaa 100644 (file)
@@ -10,7 +10,7 @@ CUDA-FUNCTION: prefix_sum_block ( uint* in, uint* out, uint n ) ;
 :: cuda-prefix-sum ( -- )
     init-cuda
     0 0 [
-        ! { 1 1 1 } { 2 1 } 0 3<<< prefix_sum_block
+        ! { 1 1 1 } { 2 1 } 0 <grid-shared> prefix_sum_block
     ] with-cuda-context ;
 
 MAIN: cuda-prefix-sum
index 594e894ce138ea1b5c031ddb1e182270aa51ecf5..4e7a50e6f20e4b81e12c7745de488b14da9e1ae7 100644 (file)
@@ -2,7 +2,7 @@
 ! 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.syntax fry io io.encodings.utf8
+cuda.contexts cuda.ffi cuda.libraries fry io io.encodings.utf8
 kernel locals math math.order math.parser namespaces
 prettyprint sequences ;
 IN: cuda.devices
@@ -87,4 +87,4 @@ IN: cuda.devices
 : distribute-jobs ( job-count per-job-shared -- launcher )
     context-device-properties
     [ sharedMemPerBlock>> ] [ maxThreadsPerBlock>> ] bi
-    (distribute-jobs) 3<<< ; inline
+    (distribute-jobs) <grid-shared> ; inline
index 768c4e2ee1f538b6ea45bce56eb2af2cc6975cf3..91c715b4c1162fab4e527ac016175f0aad144bf4 100644 (file)
@@ -65,9 +65,18 @@ SYMBOL: current-cuda-library
     [ cuda-function get ] dip
     cuFuncSetSharedSize cuda-error ; inline
 
-TUPLE: function-launcher
+TUPLE: grid
 dim-grid dim-block shared-size stream ;
 
+: <grid> ( dim-grid dim-block -- grid )
+    0 f grid boa ; inline
+
+: <grid-shared> ( dim-grid dim-block shared-size -- grid )
+    f grid boa ; inline
+
+: <grid-shared-stream> ( dim-grid dim-block shared-size stream -- grid )
+    grid boa ; inline
+
 : c-type>cuda-setter ( c-type -- n cuda-type )
     {
         { [ dup c:int = ] [ drop 4 [ cuda-int* ] ] }
@@ -109,7 +118,7 @@ ERROR: no-cuda-library name ;
 
 : launch-function ( -- ) cuda-function get cuLaunch cuda-error ; inline
 
-: run-function-launcher ( function-launcher function -- )
+: run-grid ( grid function -- )
     swap
     {
         [ dim-block>> block-dim function-block-shape* ]
@@ -151,10 +160,10 @@ MACRO: cuda-arguments ( c-types -- quot: ( args... function -- ) )
         '[
             _ _ cached-function
             [ nip _ cuda-arguments ]
-            [ run-function-launcher ] 2bi
+            [ run-grid ] 2bi
         ]
     ]
-    [ 2nip \ function-launcher suffix c:void function-effect ]
+    [ 2nip \ grid suffix c:void function-effect ]
     3bi define-declared ;
 
 TUPLE: cuda-library name path handle ;
index 8f74c632433b3a088f92b0d545759f47f615eb3a..0e2dafc7902c86225fa385a03ba26b90bff1d317 100644 (file)
@@ -13,11 +13,3 @@ SYNTAX: CUDA-FUNCTION:
     scan [ create-in current-cuda-library get ] [ ] bi
     ";" scan-c-args drop define-cuda-word ;
 
-: 2<<< ( dim-grid dim-block -- function-launcher )
-    0 f function-launcher boa ; inline
-
-: 3<<< ( dim-grid dim-block shared-size -- function-launcher )
-    f function-launcher boa ; inline
-
-: 4<<< ( dim-grid dim-block shared-size stream -- function-launcher )
-    function-launcher boa ; inline