[Campaign-news] New k-centers
Marc Sosnick
marcsosnick at mac.com
Thu Feb 11 17:37:28 PST 2010
Kai:
>> For your example, the kcenterGPU.cu file should not be included,
>> but rather linked in during the link phase, and instead a
>> kcenterGPU.h file included in the users' projects.
>
> Hi Marc,
>
> That all sounds good and I am looking forward to talking more about
> this tomorrow.
>
> I just have a quick remark to the last bit of your email. I am not
> sure that using an extra .h file is even possible. Do you have an
> example? For all I know, it is not supported that kernels be split
> into a header and a source code file (e.g. keywords like __global__
> are not supported in a separate header declaration). The .cu in
> principle IS the .h file containing both declaration and
> definition. It does work for your timing object, since you are not
> actually implementing GPU kernels, but I would be (very positively!)
> surprised if this would work for kcentersGPU. If you have a
> solution I am very eager to hear about it.
>
It actually works like a charm. All the .h file does is have forward
declarations of functions that allows the compiler to continue
compiling. The compiler essentially says "here's where this function
call goes, let's wait to the linker to put the address in." NVCC
precompiles the .cu file, then gcc links the .o file in which contains
the actual definition of the function. So, all the .h file contains
is essentially the line that you're using now (for example):
void kcentersGPU(int N, int K, float *data, int *assignments,
float *distances, float *generators, int seed);
Pretty cool, eh?
Marc
More information about the Campaign-news
mailing list