PageRenderTime 25ms CodeModel.GetById 16ms app.highlight 5ms RepoModel.GetById 1ms app.codeStats 0ms

/extra/cuda/demos/hello-world/hello-world.factor

http://github.com/abeaumont/factor
Unknown | 26 lines | 21 code | 5 blank | 0 comment | 0 complexity | 40e5af34e21facae9bf8dc33038b4041 MD5 | raw file
 1! Copyright (C) 2010 Doug Coleman.
 2! See http://factorcode.org/license.txt for BSD license.
 3USING: accessors alien.c-types alien.strings byte-arrays cuda
 4cuda.contexts cuda.devices cuda.libraries cuda.memory cuda.syntax
 5destructors io io.encodings.string io.encodings.utf8 kernel locals
 6math math.parser namespaces sequences strings ;
 7IN: cuda.demos.hello-world
 8
 9CUDA-LIBRARY: hello cuda32 vocab:cuda/demos/hello-world/hello.ptx
10
11CUDA-FUNCTION: helloWorld ( char* string-ptr ) ;
12
13: cuda-hello-world ( -- )
14    init-cuda
15    [
16        [
17            context-device number>string
18            "CUDA device " ": " surround write
19            "Hello World!" >byte-array [ - ] map-index host>device &cuda-free
20
21            [ { 2 1 } { 6 1 1 } <grid> helloWorld ]
22            [ 12 device>host >string print ] bi
23        ] with-destructors
24    ] with-each-cuda-device ;
25
26MAIN: cuda-hello-world