Eclipse Plugin for CUDA and QT development
  1 / 6    
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: [url="http://www.ai3.uni-bayreuth.de/software/eclipsecudaqt/index.php"]http://www.ai3.uni-bayreuth.de/software/ec...udaqt/index.php[/url]

Thanks for your interest.
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.

#1
Posted 02/23/2010 11:22 AM   
[quote name='daniel.s' post='1006564' date='Feb 23 2010, 06:22 AM']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: [url="http://www.ai3.uni-bayreuth.de/software/eclipsecudaqt/index.php"]http://www.ai3.uni-bayreuth.de/software/ec...udaqt/index.php[/url]

Thanks for your interest.[/quote]
This is very interesting. Any chance that you have, or could develop, a similar product for PGI's CudaFortran?

Thanks

MMB
[quote name='daniel.s' post='1006564' date='Feb 23 2010, 06:22 AM']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

#2
Posted 02/27/2010 03:34 PM   
[quote name='MMB' post='1009010' date='Feb 27 2010, 04:34 PM']This is very interesting. Any chance that you have, or could develop, a similar product for PGI's CudaFortran?

Thanks

MMB[/quote]

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
[quote name='MMB' post='1009010' date='Feb 27 2010, 04:34 PM']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

#3
Posted 02/28/2010 10:39 AM   
[quote name='daniel.s' post='1009412' date='Feb 28 2010, 05:39 AM']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[/quote]
Daniel, thanks for the offer. My e-mail address is m.bibby at comcast.net.

Thanks again,

MMB
[quote name='daniel.s' post='1009412' date='Feb 28 2010, 05:39 AM']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

#4
Posted 03/02/2010 05:03 PM   
[quote name='daniel.s' post='1006564' date='Feb 23 2010, 07:22 PM']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: [url="http://www.ai3.uni-bayreuth.de/software/eclipsecudaqt/index.php"]http://www.ai3.uni-bayreuth.de/software/ec...udaqt/index.php[/url]

Thanks for your interest.[/quote]


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
[quote name='daniel.s' post='1006564' date='Feb 23 2010, 07:22 PM']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.





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

#5
Posted 03/03/2010 02:27 PM   
[quote name='tonyhcc' post='1011497' date='Mar 3 2010, 03:27 PM']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[/quote]

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.
[quote name='tonyhcc' post='1011497' date='Mar 3 2010, 03:27 PM']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.

#6
Posted 03/03/2010 06:09 PM   
[quote name='daniel.s' post='1011642' date='Mar 4 2010, 02:09 AM']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.[/quote]

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
[quote name='daniel.s' post='1011642' date='Mar 4 2010, 02:09 AM']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

#7
Posted 03/04/2010 07:29 AM   
[quote name='tonyhcc' post='1012099' date='Mar 4 2010, 08:29 AM']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[/quote]

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
[code]#include <matrixMul_kernel.cu>[/code]
to
[code]#include "matrixMul_kernel.cu"[/code]
("" 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 [code]#include "matrixMul.h"[/code] to matrixMul.cu.

Now, delete (or comment) the line
[code]#include "matrixMul_kernel.cu"[/code]
and replace it with:
[code]__global__ void matrixMul(float* C, float* A, float* B, int wA, int wB);[/code]

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.
[quote name='tonyhcc' post='1012099' date='Mar 4 2010, 08:29 AM']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.

#8
Posted 03/04/2010 10:50 AM   
[quote][code]#include <matrixMul_kernel.cu>[/code]
to
[code]#include "matrixMul_kernel.cu"[/code]
("" instead of <>) and it should find the file.[/quote]
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.

[quote]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
[code]#include "matrixMul.h" to matrixMul.cu.[/code]

Now, delete (or comment) the line
[code]#include "matrixMul_kernel.cu"[/code]
and replace it with:
CODE
__global__ void matrixMul(float* C, float* A, float* B, int wA, int wB);[/quote]
it's work
thanks for your help
#include <matrixMul_kernel.cu>


to

#include "matrixMul_kernel.cu"


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


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.



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:

CODE

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


it's work

thanks for your help

#9
Posted 03/04/2010 11:21 AM   
I can't start my eclipse IDE any more since your last update

18. 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
I can't start my eclipse IDE any more since your last update



18. 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

#10
Posted 05/21/2010 12:34 PM   
[quote name='ph03' post='1059332' date='May 21 2010, 01:34 PM']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.[/quote]

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?
[quote name='ph03' post='1059332' date='May 21 2010, 01:34 PM']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.



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?

#11
Posted 05/21/2010 04:39 PM   
[quote name='daniel.s' post='1059415' date='May 21 2010, 05:39 PM']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?[/quote]

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
[quote name='daniel.s' post='1059415' date='May 21 2010, 05:39 PM']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

#12
Posted 05/24/2010 10:25 AM   
[quote name='daniel.s' post='1059415' date='May 21 2010, 05:39 PM']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?[/quote]

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
[quote name='daniel.s' post='1059415' date='May 21 2010, 05:39 PM']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

#13
Posted 05/24/2010 10:25 AM   
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! :-)
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! :-)

#14
Posted 05/28/2010 09:33 AM   
[quote name='eotakos' post='1063708' date='May 28 2010, 10:33 AM']giving the built all command, i get the following errors (i give just the highlights in order not to take much space)
[code]./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'

....[/code]


and also (after that):

[code]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'[/code][/quote]


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.

[quote]do note that compiling this same file from console with
[code]nvcc bla.cu -o b.out[/code]
everything works just file (at least it seams so).[/quote]

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...).

[quote]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-[/quote]

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 =)

[quote]p.s. sorry - I don't know why my code-boxes are so huge! :-)[/quote]

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
[quote name='eotakos' post='1063708' date='May 28 2010, 10:33 AM']giving the built all command, i get the following errors (i give just the highlights in order not to take much space)

./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'



....






and also (after that):



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'






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.



do note that compiling this same file from console with

nvcc bla.cu -o b.out


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




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...).



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-




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 =)



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




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

#15
Posted 05/28/2010 04:39 PM   
  1 / 6    
Scroll To Top