From 8323332838df0d92a23caaca577b27b1e9901bd9 Mon Sep 17 00:00:00 2001 From: Doug Coleman Date: Fri, 23 Apr 2010 15:06:43 -0500 Subject: [PATCH] Compile the .cu file with a relative pathname instead of absolute --- extra/cuda/nvcc/authors.txt | 1 + extra/cuda/nvcc/nvcc.factor | 31 +++++++++++++++++++++++++++++++ 2 files changed, 32 insertions(+) create mode 100644 extra/cuda/nvcc/authors.txt create mode 100644 extra/cuda/nvcc/nvcc.factor diff --git a/extra/cuda/nvcc/authors.txt b/extra/cuda/nvcc/authors.txt new file mode 100644 index 0000000000..7c1b2f2279 --- /dev/null +++ b/extra/cuda/nvcc/authors.txt @@ -0,0 +1 @@ +Doug Coleman diff --git a/extra/cuda/nvcc/nvcc.factor b/extra/cuda/nvcc/nvcc.factor new file mode 100644 index 0000000000..c1e35c32ca --- /dev/null +++ b/extra/cuda/nvcc/nvcc.factor @@ -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 ;