     grid boa ; inline
 
 <PRIVATE
-: block-dim ( block -- x y z )
-    dup sequence? [ 3 1 pad-tail first3 ] [ 1 1 ] if ; inline
-: grid-dim ( block -- x y )
-    dup sequence? [ 2 1 pad-tail first2 ] [ 1 ] if ; inline
+GENERIC: block-dim ( block-size -- x y z ) foldable
+M: integer block-dim 1 1 ; inline
+M: sequence block-dim
+    dup length {
+        { 0 [ drop 1 1 1 ] }
+        { 1 [ first 1 1 ] }
+        { 2 [ first2 1 ] }
+        [ drop first3 ]
+    } case ; inline
+
+GENERIC: grid-dim ( grid-size -- x y ) foldable
+M: integer grid-dim 1 ; inline
+M: sequence grid-dim
+    dup length {
+        { 0 [ drop 1 1 ] }
+        { 1 [ first 1 ] }
+        [ drop first2 ]
+    } case ; inline
 PRIVATE>
 
 : load-module ( path -- module )

    cuFuncSetSharedSize cuda-error ; inline

TUPLE: grid
dim-grid dim-block shared-size stream ;

: <grid> ( dim-grid dim-block -- grid )
    0 f grid boa ; inline

            [ grid-dim launch-function-grid ]
            [ launch-function ] if*
        ]
    } 2cleave ; inline

<PRIVATE
: make-param-buffer ( function size -- buffer size )
