Eclipse Plugin for CUDA and QT development

Hi,

we developed a plugin for Eclipse, which comortably allows CUDA and QT development. It provides three toolchains, which can be used to compile CUDA and/or QT sources.

Features include:

  • Error Parsing
  • Dependency Calculation
  • Automatic invocation of all tools

Check: http://www.ai3.uni-bayreuth.de/software/ec…udaqt/index.php

Thanks for your interest.

This is very interesting. Any chance that you have, or could develop, a similar product for PGI’s CudaFortran?

Thanks

MMB

The development of this plugin was a side effect of a research project at our chair at University of Bayreuth. Since we do not use Fortran at the moment, there is no need to develop such a plugin.

Apart from that, i think it could be done relatively easy to modify the plugin to fit in a CudaFortran environment. It is licensed under the Eclipse Puplic Licence 1.0 an therefore is open source. Perhaps you could try to modify it yourself.

The source code isn’t available at our homepage yet, but it will be in the future. If you need it now, I could send it to you.

daniel

Daniel, thanks for the offer. My e-mail address is m.bibby at comcast.net.

Thanks again,

MMB

I create a c++ project with cuda tool chain

but it always complain cannot find nvcc

did I miss something

can you provide about the enviroment setting or example

Of course, you have to install the CUDA tools (and optionally the SDK) before using the toolchain. Simply download it from the NVIDIA page and setup your environment correctly (e.g. add the path to nvcc to your $PATH variable).

Eclipse simply calls “nvcc” on the command line and therefore can’t find it, if it isn’t correctly installed.

Please check the CUDA documentation for further installation instructions.

thanks for your replay, I found that is PATH problem

I have some question, I use SDK matrixMUL example create a project

MaMUL -±- Default

               +-- make file .etc 

        +-- matrixMul.cu

±- matrixMul.h

        +-- matrixMul_gold.cpp

        +-- matrixMul_kernel.cu

it says cannot find matrixMul_kernel.cu

**** Build of configuration Default for project MaMUL ****

make all

Building file: …/matrixMul.cu

Invoking: CUDA NVCC Compiler

nvcc -c -I"/usr/share/cuda_sdk/C/common/inc" -I/usr/include -o “matrixMul.o” “…/matrixMul.cu” && \

echo -n 'matrixMul.d' ./ > 'matrixMul.d' && \

nvcc -M -I"/usr/share/cuda_sdk/C/common/inc" -I/usr/include   "../matrixMul.cu" >> 'matrixMul.d'

…/matrixMul.cu:34:31: error: matrixMul_kernel.cu: No such file or directory

make: *** [matrixMul.o] Error 255

First, delete the makefile(s) in your project that were shipped with the sample project of CUDA SDK. These example projects use some very complex makefiles to enable an easy build on EVERY system without any IDE. But the CUDA toolchain uses the so-called Managed Build System of Eclipse and therefore creates its own makefiles.

Your includes for nvcc are right. You simply could change the line

#include <matrixMul_kernel.cu>

to

#include "matrixMul_kernel.cu"

("" instead of <>) and it should find the file.

Aside from that you will get some new errors. This is, because for some reason you can’t include .cu-files in other .cu-files with the plugin.

The SDK examples behave in a strange way in that context. Because of the above noted needed usability of the examples on as many systems as possible, they are not very suitable for use in other build contexts and toolchains out of the box. They need some modification.

Back to the problem:

You can simply replace the inclusion of matrixMul_kernel.cu with a the inclusion of a header file and the forward declaration of the function “global void matrixMul(…)”.

So, add

#include "matrixMul.h"

to matrixMul.cu.

Now, delete (or comment) the line

#include "matrixMul_kernel.cu"

and replace it with:

__global__ void matrixMul(float* C, float* A, float* B, int wA, int wB);

These are the only changes in the code.

Additionally you need some libraries for this project:

Go the Properties page of the project and select “Libraries” in the “Settings” page of “C/C++ Build” under “C++ Linker”.

Now add “cudart” and “cutil” in the top box (“Libraries”) and “/usr/local/cuda/lib” and “<CUDA_SDK>/sdk/lib” in the bottom box (“Library search path”). Replace <CUDA_SDK> with your installation path of the CUDA SDK.

Now, it should compile successfully with the CUDA toolchain.

After this step what I get error is multiple defintion

I add -zmuldefs flag, and it seems work fine.

I didn’t know it’s a right way or not.

it’s work

thanks for your help

I can’t start my eclipse IDE any more since your last update

  1. May 2010:
    • Solved: The plugin sometimes generated “null” strings while compiling, resulting in nvcc fatal errors.

Eclipse just crashes in the startup process without an error message. Is this a known issue?
I was using the Version pre 21. Apr 2010 on my gentoo linux box yust fine.

Greets Janick

This is new to me. We only changed some lines of code of the dependency calculator in the last release. This code gets executed not before a build process with .cu files is invoked. So I think this change isn’t able to crash Eclipse during startup.

You could try starting Eclipse with the -clean argument to wipe clean caches for bundle dependency resolution and extension registry data.

I know of working copies of the plugin on different machines and different distributions. Does Eclipse output some further information on the console during startup?

I’m sorry, but I figured out that my exlise starup problems were related to my distro and not to your plugin, it is still working great, thanks for the update =)

Greets Janick

I’m sorry, but I figured out that my exlise starup problems were related to my distro and not to your plugin, it is still working great, thanks for the update =)

Greets Janick

Hello, and thank you very much for developing this CUDA C plugin for eclipse!

First of all let me say that I am completely new with cuda. I’ve been programming cpp for quite a while, but with eclipse, all I did was to write my code and header files, and everything else was done for me. aka, I’ve never been bothered with makefiles etc. (and maybe its time). So, feel free -and please do- correct anything mis-stated below!

I’ve installed the plugin as described in the first post, i’ve added to my project a .cu file with the following simple code i found in a tutorial:

[codebox]

#include “assert.h”

int main(void)

{

float *a_h, *b_h; // host data

float *a_d, *b_d; // device data

int N = 14, nBytes, i ;

nBytes = N*sizeof(float);

a_h = (float *)malloc(nBytes);

b_h = (float *)malloc(nBytes);

cudaMalloc((void **) &a_d, nBytes);

cudaMalloc((void **) &b_d, nBytes);

for (i=0; i<N; i++) a_h[i] = 100.f + i;

cudaMemcpy(a_d, a_h, nBytes, cudaMemcpyHostToDevice);

cudaMemcpy(b_d, a_d, nBytes, cudaMemcpyDeviceToDevice);

cudaMemcpy(b_h, b_d, nBytes, cudaMemcpyDeviceToHost);

for (i=0; i< N; i++) assert( a_h[i] == b_h[i] );

free(a_h); free(b_h); cudaFree(a_d); cudaFree(b_d);

return 0;

}

[/codebox]

giving the built all command, i get the following errors (i give just the highlights in order not to take much space)

[codebox]./cu_memtrans.o: In function `__sti____cudaRegisterAll_43_tmpxft_00001916_00000000_4_m

emtrans_cpp1_ii_main()’:

tmpxft_00001916_00000000-1_memtrans.cudafe1.cpp:(.text+0xa24f): undefined reference to `__cudaRegisterFatBinary’

./cu_memtrans.o: In function `__ftexfetch(void const*, float4, int)’:

tmpxft_00001916_00000000-1_memtrans.cudafe1.cpp:(.text+0xc1e3): undefined reference to `__cudaTextureFetch’

./cu_memtrans.o: In function `__utexfetch(void const*, float4, int)’:

undefined reference to `__cudaSynchronizeThreads’

undefined reference to `__cudaMutexOperation’

…[/codebox]

and also (after that):

[codebox]tmpxft_00001916_00000000-1_memtrans.cudafe1.cpp:(.text+0x10721): undefined reference to `cudaMalloc’

tmpxft_00001916_00000000-1_memtrans.cudafe1.cpp:(.text+0x10730): undefined reference to `cudaMalloc’

tmpxft_00001916_00000000-1_memtrans.cudafe1.cpp:(.text+0x1077f): undefined reference to `cudaMemcpy’

tmpxft_00001916_00000000-1_memtrans.cudafe1.cpp:(.text+0x10797): undefined reference to `cudaMemcpy’

tmpxft_00001916_00000000-1_memtrans.cudafe1.cpp:(.text+0x107af): undefined reference to `cudaMemcpy’

tmpxft_00001916_00000000-1_memtrans.cudafe1.cpp:(.text+0x1082c): undefined reference to `cudaFree’

tmpxft_00001916_00000000-1_memtrans.cudafe1.cpp:(.text+0x10835): undefined reference to `cudaFree’[/codebox]

do note that compiling this same file from console with

[codebox]nvcc bla.cu -o b.out[/codebox]

everything works just file (at least it seams so).

Also, I don’t know if this makes any difference, I’m running eclipse on Ubuntu linux.

Another thing I’d like to ask -even if it is kind of “out of topic”-… I read in a thread that the c part of the code has to be in a c/cpp file, whereas the cuda part of the code has to be in a .cu file. The thing is that I’ve been reading the programming guide, and this isn’t stated anywhere, and also all the sample code files from the SDK are .cpp files! -please do comment on that too if you can-

Thank you very much in advance for any answers.

p.s. sorry - I don’t know why my code-boxes are so huge! :-)

These “undefined reference to…” errors alway come from the linker and mostly indicate that it can’t find some libraries that it needs.

For your code this would be the “cudart” library, which is needed for almost every CUDA project. Please follow my instructions in post #8 of this thread to tell the linker where it is. (If you use a 64bit system please replace /usr/local/cuda/lib with /usr/local/cuda/lib64).

After that, the build process should run without any errors.

The plugin uses nvcc ONLY to compile .cu files to object files (.o) in order to make an incremental build possible. This is done with the -c flag of nvcc. The linking is done by gcc/g++ as in every normal c/c++ application.

If nvcc is invoked like above it handles the linking step by itself and somehow includes the right libs automatically (I think…).

I do not know which SDK samples you have but I see .cu files in every sample project of SDK versions 2.2, 2.3 and 3.0.

In order to use the Eclipse plugin every piece of code that uses CUDA constructs (things ike global, shared_, <<<dimGrid, dimBlock>>>, kernel and device function and variable declarations and definitions, kernel calls, etc.) has to be in a .cu file since only these are passed to nvcc. The gcc/g++ can’t handle these constructs. Hint: To call a kernel from a cpp/c file write a wrapper function in your .cu file which calls the kernel and doesn’t use CUDA constructs in its own signature.

Aside from that it’s not a very good idea to try to compile SDK samples with your own (or Eclipse generated) makefiles as you can see in this thread. This is a pain =)

I think you have to use the “code” tag instead of “codebox”.

I hope this helps… If you have any further questions feel free to ask.

Daniel

With your instructions I got to built and run my project successfully, so thank you very much for your prompt reply! It has been really helpful!

Something that caught my attention is that the .cu file when compiled with nvcc from the command line directly, it wouldn’t give the output of a “cout” command that I included, while when complided through your eclipse plugin, it worked like a charm! I guess it is the incremental built and the linking by gcc that you mentioned…

After reading your reply, I remembered this part from the programming guide that says “the runtime is implemented in the cudart dynamic library…” so I figure it has to be included in every cuda project… What I can’t seem to find is a reference, that indicates which .h files should be included in order for a cuda function to work. For the time, I’ve only found math_functions.h and device_functions.h in the programming guide, and it isn’t very clear (at least for me) which functions these headers define.

Thank you for that too, I seem to understand now the structure a cuda project should have.

question: Supposedly I have completed a project of mine with all the .cu , .cpp and header files, and I want to run it on another computer. Is it enough to transfer all the files of the project and execute the makefile? (assuming that cuda is installed in the same directories, the other computer runs on linux also etc.) or I should install eclipse and the pluggin on the other computer too (which should definitely work, but I’d rather have this option as an alternative).

You are so right about that! I was just focused on the device-query project (which I was interested in) which only has a .cpp and a makefile in it’s /src/ folder :-)

Thank you again very much for your time!

Mostly, including cutil_inline.h from the SDK include dir will do it. Check it out to see which functions it defines. It includes some other headers, too.

I did not try this before but in theory this should work. After generating the makefiles Eclipse also just calls “make all”.

Would be nice if you could tell me if it worked or not when you try it. I’m also interested in this…

Sincerely,

Daniel

Will sure do! I’ll post back when I’ve put together some code and tried the transition…

Thanks again

Hello,

Nice work, we start using it and is very usefull.

We notice some problems with dependencies files:

for a xxx.cu file CU_DEPS is set to xxx.d

while nvcc generates a cu_xxx.d files

I see on your web page that a similar problem has been solved for .o files

A+

Thomas

Hello Thomas,

in what way is this a problem? Are you experiencing some wrong compilation behavior?

As far as I see, the incremental build of .cu files works correctly in the current release. Am I wrong?

Please give me some details…

Greetings,

Daniel