]> gitweb.factorcode.org Git - factor.git/commitdiff
Compile the .cu file with a relative pathname instead of absolute
authorDoug Coleman <doug.coleman@gmail.com>
Fri, 23 Apr 2010 20:06:43 +0000 (15:06 -0500)
committerDoug Coleman <doug.coleman@gmail.com>
Fri, 23 Apr 2010 20:06:43 +0000 (15:06 -0500)
extra/cuda/nvcc/authors.txt [new file with mode: 0644]
extra/cuda/nvcc/nvcc.factor [new file with mode: 0644]

diff --git a/extra/cuda/nvcc/authors.txt b/extra/cuda/nvcc/authors.txt
new file mode 100644 (file)
index 0000000..7c1b2f2
--- /dev/null
@@ -0,0 +1 @@
+Doug Coleman
diff --git a/extra/cuda/nvcc/nvcc.factor b/extra/cuda/nvcc/nvcc.factor
new file mode 100644 (file)
index 0000000..c1e35c3
--- /dev/null
@@ -0,0 +1,31 @@
+! Copyright (C) 2010 Doug Coleman.
+! See http://factorcode.org/license.txt for BSD license.
+USING: arrays combinators.smart io.backend io.directories
+io.launcher io.pathnames kernel locals math sequences splitting
+system ;
+IN: cuda.nvcc
+
+HOOK: nvcc-path os ( -- path )
+
+M: object nvcc-path "nvcc" ;
+
+M: macosx nvcc-path "/usr/local/cuda/bin/nvcc" ;
+
+: cu>ptx ( path -- path' )
+    ".cu" ?tail drop ".ptx" append ;
+
+: nvcc-command ( path -- seq )
+    [
+        [ nvcc-path "--ptx" "-o" ] dip
+        [ cu>ptx ] [ file-name ] bi
+    ] output>array ;
+
+ERROR: nvcc-failed n path ;
+
+:: compile-cu ( path -- path' )
+    path normalize-path :> path2
+    path2 parent-directory [
+        path2 nvcc-command
+        run-process wait-for-process [ path2 nvcc-failed ] unless-zero
+        path2 cu>ptx
+    ] with-directory ;