Proper CUDA handling
AbandonedPublic

Authored by kossebau on Mar 28 2017, 4:36 AM.

Details

Reviewers
mwolff
kfunk
qi437103
Group Reviewers
KDevelop
Summary

See T5733

  • Add configuration UI for CUDA PATH
  • Add CUDA auto detection by nvcc path
  • Fix typos in config dialog signal connection
  • Make CUDA and OpenCL parsing honor parser argument settings
  • Skip unit test for .cu files if no CUDA found

Correct persistent OpenCL and CUDA settings

Auto completion when typing:

Auto completion of kernel calls:

Auto completion of API calls:

Config dialog:

Known limitation

  • The colorful highlight is only available when cuda_runtime.h is explicitly included. Otherwise, there's no syntax highlight for cuda builtin types/variables/apis. However, the auto completion still works with correct information, though the API function signatures seems to be incomplete.
  • KDevelop currently is built against Clang 3.9, which only supports CUDA 7.5. To get CUDA 8.0 support, it need to be compiled against Clang 4.0
Test Plan

unit test passes. Also manually tested. See screenshots.

Diff Detail

Repository
R32 KDevelop
Branch
cuda-parsing
Lint
No Linters Available
Unit
No Unit Test Coverage
qi437103 created this revision.Mar 28 2017, 4:36 AM
Restricted Application added a subscriber: kdevelop-devel. · View Herald TranscriptMar 28 2017, 4:36 AM
qi437103 edited the summary of this revision. (Show Details)Mar 28 2017, 4:40 AM
qi437103 added a reviewer: KDevelop.
qi437103 edited the summary of this revision. (Show Details)
qi437103 edited the summary of this revision. (Show Details)
qi437103 edited the summary of this revision. (Show Details)
mwolff edited edge metadata.Mar 28 2017, 9:07 AM

the screenshot shows "c++11" as Cuda C profile - is that correct?

languages/plugins/custom-definesandincludes/compilerprovider/settingsmanager.h
45

why do we need three args for cuda now? why can't this be one like the other languages?

languages/plugins/custom-definesandincludes/definesandincludesmanager.cpp
118

this looks fishy. at least add some comments please

i.e. why is going two dirs up from nvcc the right cuda-path? that looks pretty arbitrary

languages/plugins/custom-definesandincludes/kcm_widget/parserwidget.ui
365

This is the installation *path*, not the flags, no?

qi437103 updated this revision to Diff 12934.Mar 28 2017, 6:14 PM
  • Make the cuda config dialog less confusing
  • Add comments explaining how cuda auto detection works

CUDA is compatible with both C and C++. But clang only accepts c++11 etc for -std. For example, with c11, clang says

error: invalid argument '-std=c11' not allowed with 'CUDA'
languages/plugins/custom-definesandincludes/compilerprovider/settingsmanager.h
45

Because I can't find a way to combine the --cuda-path=/some/path flag into cudaArguments and then reliably distinguish between auto detection and manually set path. Also, when using language profiles other than custom, the line edit is disabled with default arguments, so we need separate line edit for cuda path anyway.

But I agree that this doesn't feel good. Any suggestions are welcomed.

languages/plugins/custom-definesandincludes/definesandincludesmanager.cpp
118

Cuda is usually installed in a single folder with fixed structure, i.e. path to nvcc is /path/to/cuda/bin/nvcc. That's why two cdUp. I'll add comments here.

languages/plugins/custom-definesandincludes/kcm_widget/parserwidget.ui
365

It is flag. I was thinking this can give the user the ability to specify path using --cuda-path=/pat/to/cuda, or -nocudainc -nocudalib if they want, or completely nothing.

But this seems to be confusing, and probably no one will want to leave this completely empty, as clang won't work at all. I'll change it to path and match the auto detection behavior:

If auto detect failed, or user specified empty path, use -nocudainc -nocudalib,
otherwise use --cuda-path=/path/to/cuda

I think you are still abusing the code architecture for compiler support here.

  • the auto-detected nvcc path should be used in a default compiler provider for cuda
  • it can then be cloned and custom args can be added
  • or one adds a completely new cuda compiler with custom clang args

i.e. only add parserArgumentsCuda, move the auto-detection + path stuff to a compiler provider or what it is again. I haven't had a look at the code. if you have trouble with this tell me and I'll have a closer look at the code and try to make it work the way I imagine it for this

mwolff requested changes to this revision.Mar 29 2017, 9:19 PM
This revision now requires changes to proceed.Mar 29 2017, 9:19 PM
qi437103 added a comment.EditedMar 30 2017, 12:21 AM

Yeah I still don't understand the overall design well. Here's my understanding, please correct me if I'm wrong

  • The constructor of ParserSessionData is the final place where arguments are assembled. It adds various include and define flags. Before this
  • argsForSession adds language specific flags in addition to those stored in ParserSettings, which is a QString.
  • ParserSettings comes from ClangParsingEnvironment, which is set in the constructor of ClangParserJob. The value is from ClangSettingsManager::parserSettings, which
  • Delegates the call to DefinesAndIncludesManager::parserArguments.
  • In DefinesAndIncludesManager::parserArguments, the arguments are computed by argumentsForPath, which basically returns corresponding string in ParserArguments
  • And ParserArguments comes from the configuration file, which can be set by user using config dialog

I can add nvcc (CUDA) to the compiler provider as a GccLikeCompiler, and do path detection there. But I'm not clear about how that information can be used in the above process. In DefinesAndIncludesManager::parserArguments, should I use findConfigForItem(...).compiler->path() to get the path to nvcc and add proper --cuda-path there?

However the compiler is set for the whole project (at the right bottom corner of the config dialog if I understand correctly), while what we want here is actually per file type compiler.

Will close next week given no-one has cared for > 2 years.

kossebau commandeered this revision.Jul 15 2019, 6:23 PM
kossebau added a reviewer: qi437103.
kossebau abandoned this revision.Jul 15 2019, 6:27 PM

Closing due to lack of further interest by anyone for long time