Closed abelsiqueira closed 2 years ago
Looks to me like you are not linking the cudawrappers library.
The Makefile that I used to compile the vector_add example is:
LIBS = -L../../build/ -lcuda -lnvrtc
CUDA_WRAPPER_INCLUDE = -I../../
CUDA_WRAPPER_LIB = -Wl,-rpath=../../build/ -lcu
all: vector_add
vector_add: vector_add.cc vector_add_kernel.cu
g++ $(LIBS) $(CUDA_WRAPPER_LIB) vector_add.cc $(CUDA_WRAPPER_INCLUDE) -o vector_add
clean:
rm vector_add
Looks to me like you are not linking the cudawrappers library.
I added the source files explicitly (See my command nvcc cu/*.cc ...
) to remove CMake from the issue, so there is no library to be linked, but the cudawrappers information is there.
But your answer showed me the solution. Apparently, the .cu
is not necessary but it needs to be in the same folder.
This works now:
nvcc ../../cu/*.cc vector_add.cc -o vector_add -I../../ -lcuda -lnvrtc
gpurun vector_add
@benvanwerkhoven, do you know the proper way of handling the issue of having .cu
in the same folder?
That's the thing with runtime compilation. The cu file contains the kernel code, which is read in at run time and compiled by the runtime compiler. The running application needs to have a path to this file containing the kernel code. It needs to know where this file is. There are several ways in which you could make known to your application where the kernel codes are, but it's ultimately up to the application developer to decide how to organize these source files.
One trick that is used in the Tensor-core Correlator is to embed the kernel source code as a string, as you can see here: https://git.astron.nl/RD/tensor-core-correlator/-/blob/master/libtcc/Correlator.cc#L82
I seem to remember some people achieved this inclusion of a file's contents as a string in some way using the C preprocessor and C++ R raw strings, but I can't seem to find any examples looking for this right now.
Seems to suggest that it can't be done this way in C++. I do seem to remember seeing this trick being used somewhere at some point in the past. Well anyway, there are other options as well.
fixed in #123
I have reached a point of being able to compile the example (#123), but when I try to run it on DAS-5, I get
So I went back to version 0.1.0 and tried to compile the code before any of the major changes, but I still get the same error. Maybe someone with more C++ experience can help out? cc. @benvanwerkhoven @isazi @csbnw @john-romein @svlugt
Steps to reproduce on DAS-5, no CMake, no new changes: