diff --git a/extra/cuda/cuda.factor b/extra/cuda/cuda.factor index 9c9b74a9bb..d4202ba665 100644 --- a/extra/cuda/cuda.factor +++ b/extra/cuda/cuda.factor @@ -19,7 +19,7 @@ TUPLE: launcher swap >>device ; inline TUPLE: function-launcher -dim-block dim-grid shared-size stream ; +dim-grid dim-block shared-size stream ; : with-cuda-context ( flags device quot -- ) H{ } clone cuda-modules set-global @@ -48,16 +48,23 @@ dim-block dim-grid shared-size stream ; { [ dup a:void* = ] [ drop 4 [ cuda-int* ] ] } } cond ; + + : run-function-launcher ( function-launcher function -- ) swap { - [ dim-block>> first3 function-block-shape* ] + [ dim-block>> block-dim function-block-shape* ] [ shared-size>> function-shared-size* ] [ dim-grid>> [ launch-function* ] [ - first2 launch-function-grid* + grid-dim launch-function-grid* ] if-empty ] } 2cleave ; diff --git a/extra/cuda/demos/hello-world/hello-world.factor b/extra/cuda/demos/hello-world/hello-world.factor index 1c9b8a51f7..5db01e412a 100644 --- a/extra/cuda/demos/hello-world/hello-world.factor +++ b/extra/cuda/demos/hello-world/hello-world.factor @@ -17,7 +17,7 @@ CUDA-FUNCTION: helloWorld ( char* string-ptr ) ; "CUDA device " ": " surround write "Hello World!" >byte-array [ - ] map-index host>device &cuda-free - [ { 6 1 1 } { 2 1 } 2<<< helloWorld ] + [ { 2 1 } { 6 1 1 } 2<<< helloWorld ] [ 12 device>host >string print ] bi ] with-destructors ] with-each-cuda-device ; diff --git a/extra/cuda/syntax/syntax.factor b/extra/cuda/syntax/syntax.factor index 4e15fa383e..237a87f900 100644 --- a/extra/cuda/syntax/syntax.factor +++ b/extra/cuda/syntax/syntax.factor @@ -13,11 +13,11 @@ SYNTAX: CUDA-FUNCTION: scan [ create-in current-cuda-library get ] [ ] bi ";" scan-c-args drop define-cuda-word ; -: 2<<< ( dim-block dim-grid -- function-launcher ) +: 2<<< ( dim-grid dim-block -- function-launcher ) 0 f function-launcher boa ; inline -: 3<<< ( dim-block dim-grid shared-size -- function-launcher ) +: 3<<< ( dim-grid dim-block shared-size -- function-launcher ) f function-launcher boa ; inline -: 4<<< ( dim-block dim-grid shared-size stream -- function-launcher ) +: 4<<< ( dim-grid dim-block shared-size stream -- function-launcher ) function-launcher boa ; inline