1 ! Copyright (C) 2010 Doug Coleman.
2 ! See https://factorcode.org/license.txt for BSD license.
3 USING: alien.c-types cuda cuda.contexts cuda.devices
4 cuda.libraries cuda.memory cuda.syntax destructors io
5 io.encodings.string io.encodings.utf8 kernel math math.parser
7 IN: cuda.demos.hello-world
9 CUDA-LIBRARY: hello cuda32 "vocab:cuda/demos/hello-world/hello.ptx"
11 CUDA-FUNCTION: helloWorld ( char* string-ptr )
13 : cuda-hello-world ( -- )
17 context-device number>string
18 "CUDA device " ": " surround write
19 "Hello World!" utf8 encode [ - ] B{ } map-index-as host>device &cuda-free
20 [ { 2 1 } { 6 1 1 } <grid> helloWorld ]
21 [ 12 device>host >string print ] bi
23 ] with-each-cuda-device ;
25 MAIN: cuda-hello-world