From f0a7f039bdf98e74a957f4866f2e70c8658d427c Mon Sep 17 00:00:00 2001 From: Joe Groff Date: Thu, 20 May 2010 14:51:47 -0700 Subject: [PATCH] cuda.libraries: rename "function-launcher" to "grid", 2<<< to , 3<<< to , 4<<< to --- extra/cuda/demos/hello-world/hello-world.factor | 8 ++++---- extra/cuda/demos/prefix-sum/prefix-sum.factor | 2 +- extra/cuda/devices/devices.factor | 4 ++-- extra/cuda/libraries/libraries.factor | 17 +++++++++++++---- extra/cuda/syntax/syntax.factor | 8 -------- 5 files changed, 20 insertions(+), 19 deletions(-) diff --git a/extra/cuda/demos/hello-world/hello-world.factor b/extra/cuda/demos/hello-world/hello-world.factor index 4c2f68f011..dae6ce83d6 100644 --- a/extra/cuda/demos/hello-world/hello-world.factor +++ b/extra/cuda/demos/hello-world/hello-world.factor @@ -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 } helloWorld ] [ 12 device>host >string print ] bi ] with-destructors ] with-each-cuda-device ; diff --git a/extra/cuda/demos/prefix-sum/prefix-sum.factor b/extra/cuda/demos/prefix-sum/prefix-sum.factor index badd7d905d..aedc9aa095 100644 --- a/extra/cuda/demos/prefix-sum/prefix-sum.factor +++ b/extra/cuda/demos/prefix-sum/prefix-sum.factor @@ -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 prefix_sum_block ] with-cuda-context ; MAIN: cuda-prefix-sum diff --git a/extra/cuda/devices/devices.factor b/extra/cuda/devices/devices.factor index 594e894ce1..4e7a50e6f2 100644 --- a/extra/cuda/devices/devices.factor +++ b/extra/cuda/devices/devices.factor @@ -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) ; inline diff --git a/extra/cuda/libraries/libraries.factor b/extra/cuda/libraries/libraries.factor index 768c4e2ee1..91c715b4c1 100644 --- a/extra/cuda/libraries/libraries.factor +++ b/extra/cuda/libraries/libraries.factor @@ -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 ; +: ( dim-grid dim-block -- grid ) + 0 f grid boa ; inline + +: ( dim-grid dim-block shared-size -- grid ) + f grid boa ; inline + +: ( 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 ; diff --git a/extra/cuda/syntax/syntax.factor b/extra/cuda/syntax/syntax.factor index 8f74c63243..0e2dafc790 100644 --- a/extra/cuda/syntax/syntax.factor +++ b/extra/cuda/syntax/syntax.factor @@ -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