Indexing of CUDA C files

73 views
Skip to first unread message

Alex Szakál

unread,
Jun 10, 2021, 9:31:47 AM6/10/21
to cmake4eclipse user mailing list
Hi,

Could anybody please give a short guide on how to configure an existing Cmake project which uses cuda?

The comilation works well, but the cuda specific variables/functions are marked as errors by the indexer. 

I found this issue: https://github.com/15knots/cmake4eclipse/issues/65 but I could not resolve my problem. I got the following error in the Problems->Warnings section: 

No parser for command '/usr/local/cuda-10.2/bin/nvcc -forward-unknown-to-host-compiler  -isystem=/usr/local/cuda-10.2/include -isystem=/usr/include/opencv4 -g --generate-code=arch=compute_30,code=[compute_30,sm_30] -std=c++14 -x cu -dc /home/szakal/eclipse-workspace/cs344/HWs/HW4/HW4.cu -o CMakeFiles/hw4.dir/HW4.cu.o'. Your workbench will not know all include paths and preprocessor defines.

In the Language Mappings section I set CUDA C for "Cuda C source file" and "Cuda Header Content Type". In the toolchain Editor I have the folloving entries selected: 
CMake driven Languages Proxy
NVCC Compiler
NVCC linker
Cross G++ Compiler
GCC C++ Linker

I have selected "NVCC Builtins provider" in the Providers tab and the CUDA C language appears with  "NVCC Builtins provider" entry in the Entries tab.

I used a freshly installed Eclipse 2021-03 (4.19.0) with cmake4eclipse installed from the marketplace. Nsight Plugin was installed from the CUDA Toolkit 10.2 distribution. I use Ubuntu 20.04.

Thank you for your help,
Best regards,
Alex





Martin Weber

unread,
Jun 12, 2021, 12:48:11 PM6/12/21
to cmake4ecl...@googlegroups.com
On Donnerstag, 10. Juni 2021 15:31:47 CEST Alex Szakál wrote:
> Hi,
>
> Could anybody please give a short guide on how to configure an existing
> Cmake project which uses cuda?

Have a look at the example project here <https://github.com/15knots/
cmake4eclipse-sample-projects/tree/master/cuda>

>
> The comilation works well, but the cuda specific variables/functions are
> marked as errors by the indexer.
>
> I found this issue: https://github.com/15knots/cmake4eclipse/issues/65 but
> I could not resolve my problem. I got the following error in the
> Problems->Warnings section:
>
> No parser for command '/usr/local/cuda-10.2/bin/nvcc
> -forward-unknown-to-host-compiler

What exactly is the name of the compiler executable you are using? The line
break makes it impossible to guess here.
Is it
'nvcc-forward-unknown-to-host-compiler'
or just
'nvcc' ?

> In the Language Mappings section I set CUDA C for "Cuda C source file" and
> "Cuda Header Content Type". In the toolchain Editor I have the folloving
> entries selected:
> CMake driven Languages Proxy

CMake driven Languages Proxy should be suffcient here.
> NVCC Compiler
> NVCC linker
> Cross G++ Compiler
> GCC C++ Linker

Martin

--
Cd wrttn wtht vwls s mch trsr.




Alex Szakál

unread,
Jun 14, 2021, 4:28:23 AM6/14/21
to Martin Weber, cmake4ecl...@googlegroups.com
Dear Martin,
Thank you for the suggestions. 

The name of the compiler is: /usr/local/cuda-10.2/bin/nvcc

I downloaded the sample project, imported in Eclipse but it marks the blockIdx.x and other cuda-specific variables as unknown. I changed the path of the CUDA compiler to the above metioned one and selected the option to use the cmake found in the path of the system (version 3.20). The project compiled and got the output:
Hello World!
Hello, hello World!
Hello World!

I get the following Warning in the "Problems" tab in the bottom of the Eclipse window:
"Description" column: No parser for command '/usr/local/cuda-10.2/bin/nvcc -forward-unknown-to-host-compiler -DMACRO_FROM_COMMANDLINE=2 -I/home/szakal/Asztal/cmake4eclipse-sample-projects-master/cuda/build/Debug/src -std=c++14 -x cu -c /home/szakal/Asztal/cmake4eclipse-sample-projects-master/cuda/src/hello-cuda.cu -o CMakeFiles/hello-cuda.dir/hello-cuda.cu.o'. Your workbench will not know all include paths and preprocessor defines.
"Resource" column: compile_commands.json
"Path" column: /cuda/build/Debug
"Location" column: de.marw.cmake.cdt.language.settings.providers.CompileCommandsJsonParser 
"Type" column: CMAKE_EXPORT_COMPILE_COMMANDS Parser Problem

Best regards,
Alex


--
You received this message because you are subscribed to the Google Groups "cmake4eclipse user mailing list" group.
To unsubscribe from this group and stop receiving emails from it, send an email to cmake4eclipse-u...@googlegroups.com.
To view this discussion on the web visit https://groups.google.com/d/msgid/cmake4eclipse-users/2075848.Icojqenx9y%40localhost.

Martin Weber

unread,
Jun 14, 2021, 10:14:08 AM6/14/21
to cmake4eclipse user mailing list
Maybe the 'CDT indexer support for NVidia CUDA compilers' plugin is not installed?
You can find it in the 'Install New Software...' menu.

Alex Szakál

unread,
Jun 14, 2021, 3:18:37 PM6/14/21
to Martin Weber, cmake4eclipse user mailing list
Dear Martin,

Thanks, you were right, the 'CDT Indexer support for NVidia CUDA compilers' was not installed. This solved the problem of the 'cuda' sample project, but I am still not able to import my existing cmake projects.

I copied the 'cuda' sample and manually deleted the .project and .cpoject files and .settings folder. I created a project using this folder with File->New..->Project wizard using the "C++ project" and "CUDA C/C++ project" options. I set the "NVCC Builtins Provider" and selected "Use global provider shared between projects" but it did not work.

The differences between the sample project and the newly created one:
1) In the .settings directory I don't have "org.eclipse.cdt.managedbuilder.core.prefs" and org.eclipse.ltk.core.refactoring.prefs files, only the language.settings.xml exist. The language.settings.xml is little bit different than the sample. My version:

<?xml version="1.0" encoding="UTF-8" standalone="no"?>
<project>
<configuration id="de.marw.cmake.cdt.lsp.config.debug.756640889" name="Debug">
<extension point="org.eclipse.cdt.core.LanguageSettingsProvider">
<provider-reference id="de.marw.cmake.cdt.language.settings.providers.CompileCommandsJsonParser" ref="shared-provider"/>
<provider-reference id="de.marw.cmake.cdt.language.settings.providers.BuiltinsCompileCommandsJsonParser" ref="shared-provider"/>
<provider-reference id="com.nvidia.cuda.toolchain.CUDACProvider" ref="shared-provider"/>
</extension>
</configuration>
</project>

2) The only difference in .project is that the following line was added to <natures>:
                           <nature>org.eclipse.cdt.core.ccnature</nature>

3) There are a lot of differences in the .cpoject file, but unfortunately I could got get a hint where to search for solution. My .cproject file:

<?xml version="1.0" encoding="UTF-8" standalone="no"?>
<?fileVersion 4.0.0?><cproject storage_type_id="org.eclipse.cdt.core.XmlProjectDescriptionStorage">
<storageModule moduleId="org.eclipse.cdt.core.settings">
<cconfiguration id="de.marw.cmake.cdt.lsp.config.debug.756640889">
<storageModule buildSystemId="org.eclipse.cdt.managedbuilder.core.configurationDataProvider" id="de.marw.cmake.cdt.lsp.config.debug.756640889" moduleId="org.eclipse.cdt.core.settings" name="Debug">
<externalSettings/>
<extensions>
<extension id="org.eclipse.cdt.core.MachO64" point="org.eclipse.cdt.core.BinaryParser"/>
<extension id="org.eclipse.cdt.core.Cygwin_PE" point="org.eclipse.cdt.core.BinaryParser"/>
<extension id="org.eclipse.cdt.core.PE" point="org.eclipse.cdt.core.BinaryParser"/>
<extension id="org.eclipse.cdt.core.GNU_ELF" point="org.eclipse.cdt.core.BinaryParser"/>
<extension id="org.eclipse.cdt.core.ELF" point="org.eclipse.cdt.core.BinaryParser"/>
<extension id="org.eclipse.cdt.core.GASErrorParser" point="org.eclipse.cdt.core.ErrorParser"/>
<extension id="org.eclipse.cdt.core.GmakeErrorParser" point="org.eclipse.cdt.core.ErrorParser"/>
<extension id="com.nvidia.cuda.toolchain.nvccErrorParser" point="org.eclipse.cdt.core.ErrorParser"/>
<extension id="org.eclipse.cdt.core.GLDErrorParser" point="org.eclipse.cdt.core.ErrorParser"/>
<extension id="org.eclipse.cdt.core.MakeErrorParser" point="org.eclipse.cdt.core.ErrorParser"/>
<extension id="org.eclipse.cdt.core.VCErrorParser" point="org.eclipse.cdt.core.ErrorParser"/>
<extension id="org.eclipse.cdt.core.CWDLocator" point="org.eclipse.cdt.core.ErrorParser"/>
<extension id="org.eclipse.cdt.autotools.core.ErrorParser" point="org.eclipse.cdt.core.ErrorParser"/>
<extension id="org.eclipse.cdt.core.GCCErrorParser" point="org.eclipse.cdt.core.ErrorParser"/>
</extensions>
</storageModule>
<storageModule moduleId="cdtBuildSystem" version="4.0.0">
<configuration artifactName="${ProjName}" buildArtefactType="de.marw.cmake.cdt.lsp.buildArtefactType.cmake" buildProperties="org.eclipse.cdt.build.core.buildArtefactType=de.marw.cmake.cdt.lsp.buildArtefactType.cmake,org.eclipse.cdt.build.core.buildType=org.eclipse.cdt.build.core.buildType.debug" description="" id="de.marw.cmake.cdt.lsp.config.debug.756640889" name="Debug" parent="de.marw.cmake.cdt.lsp.config.debug">
<folderInfo id="de.marw.cmake.cdt.lsp.config.debug.756640889." name="/" resourcePath="">
<toolChain id="de.marw.cmake.cdt.lsp.config.debug.toolChain.493506659" name="CMake driven" superClass="de.marw.cmake.cdt.lsp.config.debug.toolChain">
<targetPlatform id="de.marw.cmake.cdt.lsp.targetPlatform.cmake.1780142765" name="Any Platform" superClass="de.marw.cmake.cdt.lsp.targetPlatform.cmake"/>
<builder buildPath="/cudaOwn7/build/Debug" id="de.marw.cmake.cdt.lsp.builder.portable.1898439034" managedBuildOn="true" name="CMake Builder.Debug" superClass="de.marw.cmake.cdt.lsp.builder.portable"/>
<tool id="de.marw.cmake.cdt.lsp.toolchain.tool.dummy.1632927808" name="CMake driven Languages Proxy" superClass="de.marw.cmake.cdt.lsp.toolchain.tool.dummy"/>
</toolChain>
</folderInfo>
</configuration>
</storageModule>
<storageModule moduleId="org.eclipse.cdt.core.externalSettings"/>
</cconfiguration>
</storageModule>
<storageModule moduleId="cdtBuildSystem" version="4.0.0">
<project id="cudaOwn7.de.marw.cmake.cdt.lsp.projectType.1828026222" name="CMake driven" projectType="de.marw.cmake.cdt.lsp.projectType"/>
</storageModule>
<storageModule moduleId="scannerConfiguration">
<autodiscovery enabled="true" problemReportingEnabled="true" selectedProfileId=""/>
</storageModule>
<storageModule moduleId="org.eclipse.cdt.core.LanguageSettingsProviders"/>
<storageModule moduleId="refreshScope"/>
</cproject> 

Thank you for your help,
Best regards,
Alex


You received this message because you are subscribed to a topic in the Google Groups "cmake4eclipse user mailing list" group.
To unsubscribe from this topic, visit https://groups.google.com/d/topic/cmake4eclipse-users/GlbfLHf7m2U/unsubscribe.
To unsubscribe from this group and all its topics, send an email to cmake4eclipse-u...@googlegroups.com.
To view this discussion on the web visit https://groups.google.com/d/msgid/cmake4eclipse-users/CANo-CZG8rTmFDiTmsHSBRTVTXtcCNVgM5i_SyvaEkpuef0wt5A%40mail.gmail.com.

Martin Weber

unread,
Jun 14, 2021, 4:24:21 PM6/14/21
to Alex Szakál, cmake4eclipse user mailing list
On Montag, 14. Juni 2021 21:18:24 CEST Alex Szakál wrote:
> Dear Martin,
>
> Thanks, you were right, the 'CDT Indexer support for NVidia CUDA compilers'
> was not installed. This solved the problem of the 'cuda' sample project,
> but I am still not able to import my existing cmake projects.
>
> I copied the 'cuda' sample and manually deleted the .project and
> .cpoject files and .settings folder. I created a project using this folder
> with File->New..->Project wizard using the "C++ project" and "CUDA C/C++
> project" options. I set the "NVCC Builtins Provider" and selected "Use
> global provider shared between projects" but it did not work.
>
> The differences between the sample project and the newly created one:
> 1) In the .settings directory I don't have
> "org.eclipse.cdt.managedbuilder.core.prefs" and
> org.eclipse.ltk.core.refactoring.prefs files, only the

Should not matter.

> language.settings.xml exist. The language.settings.xml is little bit
> different than the sample. My version:
>
> <?xml version="1.0" encoding="UTF-8" standalone="no"?>
> <project>
> <configuration id="de.marw.cmake.cdt.lsp.config.debug.756640889"

Apart from the '756640889' your settings.xml looks the one in the example
project. That '756640889' is a CDT internal, unique ID. You will find that ID
in your .cproject, too.

>
> 2) The only difference in .project is that the following line was added to
> <natures>:
> <nature>org.eclipse.cdt.core.ccnature</nature>
That's the nature for projects with C++ code. Fine.

>
> 3) There are a lot of differences in the .cpoject file, but unfortunately I
> could got get a hint where to search for solution. My .cproject file:
...
> <toolChain id="de.marw.cmake.cdt.lsp.config.debug.toolChain.493506659"
> name="CMake driven"
...
> name="CMake driven Languages Proxy"

Looks good to me.

So what exactly does not work with the projects you created? Do they build? Or
do you still get the 'No parser for commmand' message?

Alex Szakál

unread,
Jun 15, 2021, 6:39:21 AM6/15/21
to Martin Weber, cmake4eclipse user mailing list
Dear Martin,

The projects build and run well but the Cuda-specific variables and functions (e.g. __syncthreads() and blockDim.x) are marked as errors. I don't get the 'No parser for command' message since I installed the "CDT Indexer support..." and the cuda variables are detected in the sample project. The problem arises if I make a new project, even with the source code of the sample project.

I found a small difference between your cuda sample project and mine: In the Indexer page in the Preferences window my project has an extra field named "Build configuration for the indexer" and your project does not have this field. This field is present always, even if the project has only one build configuration. Otherwise, the preferences of the two projects look the same. 

Thank you for your help,
Best regards,
Alex

--
You received this message because you are subscribed to the Google Groups "cmake4eclipse user mailing list" group.
To unsubscribe from this group and stop receiving emails from it, send an email to cmake4eclipse-u...@googlegroups.com.

Martin Weber

unread,
Jun 15, 2021, 4:27:48 PM6/15/21
to Alex Szakál, cmake4eclipse user mailing list
On Dienstag, 15. Juni 2021 12:39:09 CEST Alex Szakál wrote:
> Dear Martin,
>
> The projects build and run well but the Cuda-specific variables and
> functions (e.g. __syncthreads() and blockDim.x) are marked as errors. I

I guess these should come from a header file that does not get indexed. No
idea here.

...
> I found a small difference between your cuda sample project and mine: In
> the Indexer page in the Preferences window my project has an extra field
> named "Build configuration for the indexer" and your project does not have

My version of Eclipse *does* show that input fields even for my sample
project. It is set to 'use active build configuration'.
Reply all
Reply to author
Forward
0 new messages