[cfe-dev] [llvm-dev] Using Clang Tools on CUDA Programs

Izzat El Hajj via cfe-dev cfe-dev at lists.llvm.org
Tue Dec 22 16:56:14 PST 2015


Thanks Justin! This is very helpful!

-Izzat


On Tue, Dec 22, 2015 at 5:03 PM, Justin Lebar <jlebar at google.com> wrote:

> When the clang driver is handed a .cu file, it compiles that file more
> than once, to build the host code and the device code.  clang-check
> can't handle this, thus the error "expected exactly one compiler job".
> I expect it's a similar situation to if you asked clang-check to check
> two .cpp files at once.
>
> To make this work you'd need to teach clang-check to handle this case
> properly, or you'd need to convince the clang driver to invoke the
> compiler only once (for just the host, or just the device).  The
> relevant flags to clang proper are --cuda-device-only or
> --cuda-host-only; I don't know offhand how to make those interact with
> clang-check.
>
> Good luck,
> -Justin
>
> On Tue, Dec 22, 2015 at 10:45 AM, Jingyue Wu via llvm-dev
> <llvm-dev at lists.llvm.org> wrote:
> > +cfe-dev
> >
> > On Mon, Dec 21, 2015 at 10:07 AM, Izzat El Hajj via llvm-dev
> > <llvm-dev at lists.llvm.org> wrote:
> >>
> >> Hello,
> >>
> >> I'm not sure if this is the right place to post this question. If not, I
> >> apologize and would appreciate if you redirect me.
> >>
> >> I recently built and installed llvm/clang in order to build a CUDA
> >> source-to-source translator using Clang. I followed these instructions:
> >> http://clang.llvm.org/docs/LibASTMatchersTutorial.html.
> >>
> >> The built-in tools (like clang-check) work fine on C/C++ programs, but
> >> they don't work on CUDA. If I execute the following command (regardless
> of
> >> what kernel.cu contains) I get the error shown:
> >>
> >> $ clang-check kernel.cu --
> >>
> >> error: unable to handle compilation, expected exactly one compiler job
> in
> >> ' "/usr/local/bin/clang-check" "-cc1" "-triple" "nvptx64-nvidia-cuda"
> >> "-aux-triple" "x86_64-unknown-linux-gnu" "-fcuda-target-overloads"
> >> "-fcuda-disable-target-call-checks" "-fsyntax-only" "-disable-free"
> >> "-main-file-name" "kernel.cu" "-mrelocation-model" "static"
> "-mthread-model"
> >> "posix" "-mdisable-fp-elim" "-fmath-errno" "-no-integrated-as"
> >> "-mconstructor-aliases" "-fcuda-is-device" "-mlink-cuda-bitcode"
> >> "/usr/local/cuda/nvvm/libdevice/libdevice.compute_20.10.bc"
> >> "-target-feature" "+ptx42" "-target-cpu" "sm_20" "-dwarf-column-info"
> >> "-resource-dir" "/usr/local/bin/../lib/clang/3.8.0" "-internal-isystem"
> >> "/usr/lib/gcc/x86_64-linux-gnu/4.8/../../../../include/c++/4.8"
> >> "-internal-isystem"
> >>
> "/usr/lib/gcc/x86_64-linux-gnu/4.8/../../../../include/x86_64-linux-gnu/c++/4.8"
> >> "-internal-isystem"
> >>
> "/usr/lib/gcc/x86_64-linux-gnu/4.8/../../../../include/x86_64-linux-gnu/c++/4.8"
> >> "-internal-isystem"
> >> "/usr/lib/gcc/x86_64-linux-gnu/4.8/../../../../include/c++/4.8/backward"
> >> "-internal-isystem" "/usr/local/include" "-internal-isystem"
> >> "/usr/local/bin/../lib/clang/3.8.0/include" "-internal-externc-isystem"
> >> "/include" "-internal-externc-isystem" "/usr/include"
> "-internal-isystem"
> >> "/usr/lib/gcc/x86_64-linux-gnu/4.8/../../../../include/c++/4.8"
> >> "-internal-isystem"
> >>
> "/usr/lib/gcc/x86_64-linux-gnu/4.8/../../../../include/x86_64-linux-gnu/c++/4.8"
> >> "-internal-isystem"
> >>
> "/usr/lib/gcc/x86_64-linux-gnu/4.8/../../../../include/x86_64-linux-gnu/c++/4.8"
> >> "-internal-isystem"
> >> "/usr/lib/gcc/x86_64-linux-gnu/4.8/../../../../include/c++/4.8/backward"
> >> "-internal-isystem" "/usr/local/cuda/include" "-include"
> >> "__clang_cuda_runtime_wrapper.h" "-fdeprecated-macro"
> >> "-fno-dwarf-directory-asm" "-fdebug-compilation-dir" "/<path>/test"
> >> "-ferror-limit" "19" "-fmessage-length" "192" "-fobjc-runtime=gcc"
> >> "-fcxx-exceptions" "-fexceptions" "-fdiagnostics-show-option"
> >> "-fcolor-diagnostics" "-x" "cuda" "/<path>/test/kernel.cu";
> >> "/usr/local/bin/clang-check" "-cc1" "-triple" "x86_64-unknown-linux-gnu"
> >> "-aux-triple" "nvptx64-nvidia-cuda" "-fcuda-target-overloads"
> >> "-fcuda-disable-target-call-checks" "-fsyntax-only" "-disable-free"
> >> "-main-file-name" "kernel.cu" "-mrelocation-model" "static"
> "-mthread-model"
> >> "posix" "-mdisable-fp-elim" "-fmath-errno" "-masm-verbose"
> >> "-mconstructor-aliases" "-munwind-tables" "-fuse-init-array"
> "-target-cpu"
> >> "x86-64" "-dwarf-column-info" "-resource-dir"
> >> "/usr/local/bin/../lib/clang/3.8.0" "-internal-isystem"
> >> "/usr/lib/gcc/x86_64-linux-gnu/4.8/../../../../include/c++/4.8"
> >> "-internal-isystem"
> >>
> "/usr/lib/gcc/x86_64-linux-gnu/4.8/../../../../include/x86_64-linux-gnu/c++/4.8"
> >> "-internal-isystem"
> >>
> "/usr/lib/gcc/x86_64-linux-gnu/4.8/../../../../include/x86_64-linux-gnu/c++/4.8"
> >> "-internal-isystem"
> >> "/usr/lib/gcc/x86_64-linux-gnu/4.8/../../../../include/c++/4.8/backward"
> >> "-internal-isystem" "/usr/local/include" "-internal-isystem"
> >> "/usr/local/bin/../lib/clang/3.8.0/include" "-internal-externc-isystem"
> >> "/usr/include/x86_64-linux-gnu" "-internal-externc-isystem" "/include"
> >> "-internal-externc-isystem" "/usr/include" "-internal-isystem"
> >> "/usr/local/cuda/include" "-include" "__clang_cuda_runtime_wrapper.h"
> >> "-fdeprecated-macro" "-fdebug-compilation-dir" "/<path>/test"
> >> "-ferror-limit" "19" "-fmessage-length" "192" "-fobjc-runtime=gcc"
> >> "-fcxx-exceptions" "-fexceptions" "-fdiagnostics-show-option"
> >> "-fcolor-diagnostics" "-x" "cuda" "/<path>/test/kernel.cu"; '
> >> Error while processing /<path>/test/kernel.cu.
> >>
> >>
> >> I searched thoroughly online before posting here but could not find
> >> relevant answers. Any help would be appreciated.
> >>
> >> Thanks!
> >>
> >> -Izzat
> >>
> >>
> >>
> >> _______________________________________________
> >> LLVM Developers mailing list
> >> llvm-dev at lists.llvm.org
> >> http://lists.llvm.org/cgi-bin/mailman/listinfo/llvm-dev
> >>
> >
> >
> > _______________________________________________
> > LLVM Developers mailing list
> > llvm-dev at lists.llvm.org
> > http://lists.llvm.org/cgi-bin/mailman/listinfo/llvm-dev
> >
>
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.llvm.org/pipermail/cfe-dev/attachments/20151222/34f0f166/attachment.html>


More information about the cfe-dev mailing list