Add basic support for CUDA parsing
Concern Raised64d7d49ed3a2

Authored by qi437103 on Mar 6 2017, 10:47 PM.

Description

Add basic support for CUDA parsing

Summary:
Mostly based on Kevin's D4930 for OpenCL parsing.
LLVM has CUDA support since 3.9 [1], though not really good :/
Also added configuration UI for CUDA and OpenCL parser arguments.

[1] http://releases.llvm.org/3.9.1/docs/CompileCudaWithLLVM.html

Test Plan: Tested locally with a small CUDA project. It still can't parse perfectly, but at least won't mark everything as error. The language standard settings not actually work though.

Reviewers: mwolff, KDevelop, kfunk

Reviewed By: KDevelop, kfunk

Subscribers: kfunk, kdevelop-devel

Differential Revision: https://phabricator.kde.org/D5072

Details

Auditors
kfunk
Committed
qi437103Mar 17 2017, 7:33 PM
Reviewer
KDevelop
Differential Revision
D5072: Add basic support for CUDA parsing
Parents
R32:0214cd649275: Merge remote-tracking branch 'origin/5.1'
Branches
Unknown
Tags
Unknown
kfunk raised a concern with this commit.Mar 19 2017, 3:12 PM
kfunk added a subscriber: kfunk.

Breaks unit tests:

QDEBUG : TestFiles::testFiles(cuda.cu) test_files-clang(19662)/default: ?[31m?[34mTestFiles::testFiles(89)?[0m: "Error: Unknown type name '__device__' in /home/kfunk/devel/src/kf5/kdevelop/languages/clang/tests/files/cuda.cu:[(13,0),(13,10)]: <no explanation> (found by Semantic analysis)"
QDEBUG : TestFiles::testFiles(cuda.cu) test_files-clang(19662)/default: ?[31m?[34mTestFiles::testFiles(89)?[0m: "Error: Expected identifier or '(' in /home/kfunk/devel/src/kf5/kdevelop/languages/clang/tests/files/cuda.cu:[(13,11),(13,16)]: <no explanation> (found by Semantic analysis)"
QDEBUG : TestFiles::testFiles(cuda.cu) test_files-clang(19662)/default: ?[31m?[34mTestFiles::testFiles(89)?[0m: "Error: Unknown type name '__device__' in /home/kfunk/devel/src/kf5/kdevelop/languages/clang/tests/files/cuda.cu:[(19,0),(19,10)]: <no explanation> (found by Semantic analysis)"
QDEBUG : TestFiles::testFiles(cuda.cu) test_files-clang(19662)/default: ?[31m?[34mTestFiles::testFiles(89)?[0m: "Error: Expected identifier or '(' in /home/kfunk/devel/src/kf5/kdevelop/languages/clang/tests/files/cuda.cu:[(19,11),(19,15)]: <no explanation> (found by Semantic analysis)"
QDEBUG : TestFiles::testFiles(cuda.cu) test_files-clang(19662)/default: ?[31m?[34mTestFiles::testFiles(89)?[0m: "Error: Unknown type name '__device__' in /home/kfunk/devel/src/kf5/kdevelop/languages/clang/tests/files/cuda.cu:[(28,0),(28,10)]: <no explanation> (found by Semantic analysis)"
QDEBUG : TestFiles::testFiles(cuda.cu) test_files-clang(19662)/default: ?[31m?[34mTestFiles::testFiles(89)?[0m: "Error: Expected ';' after top level declarator in /home/kfunk/devel/src/kf5/kdevelop/languages/clang/tests/files/cuda.cu:[(28,18),(28,30)]: <no explanation> (found by Semantic analysis)"
FAIL!  : TestFiles::testFiles(cuda.cu) 'top->problems().isEmpty()' returned FALSE. ()
   Loc: [/home/kfunk/devel/src/kf5/kdevelop/languages/clang/tests/test_files.cpp(93)]

I can't compile the test file either, even when using Clang 4.0. What's wrong?

This commit now has outstanding concerns.Mar 19 2017, 3:12 PM

Hmm, I can compile fine with nvcc from CUDA 8.0, despite a few warnings about uninitialized variables.

Clang must be provided with a CUDA installation to be able to compile the file.

Clang 3.9 doesn't work with CUDA 8.0 (latest supported version is 7.5) so I haven't tested that.

Clang 4.0 works fine. But it won't automatically link to Cuda runtime libraries. So you have to pass in extra arguments:

clang++ --cuda-path=/opt/cuda cuda.cu -L/opt/cuda/lib64 -lcudart_static -pthread -ldl -lrt

I didn't realize test files will be compiled... Perhaps it relates to how those files are compiled?

A bit more investigation shows that both clang and nvcc implicitly add many headers when compiling the file. And our parser doesn't do that, thus the error.

I've created a task about what need to be done: T5733. But I still don't have enough knowledge about the parser to work on it.

Actually I had a hard time reading the relevant code... @kfunk, could you give me some pointers on where should I start with the parser code?