]> gitweb.factorcode.org Git - factor.git/blob - extra/cuda/demos/hello-world/hello-world.factor
Switch to https urls
[factor.git] / extra / cuda / demos / hello-world / hello-world.factor
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
6 sequences strings ;
7 IN: cuda.demos.hello-world
8
9 CUDA-LIBRARY: hello cuda32 "vocab:cuda/demos/hello-world/hello.ptx"
10
11 CUDA-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!" 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
22         ] with-destructors
23     ] with-each-cuda-device ;
24
25 MAIN: cuda-hello-world