NVCC templates support

Hello,

overloaded template functions don’t compile.

Example, when i compile :

//… a lot of code …

template< typename ScanType >
static global void CUDA_Scan(ScanType* array, ScanType* ret)
{
//… code …
}

template< typename ScanType >
static global void CUDA_Scan(ScanType* array, ScanType* blockSums, ScanType* ret)
{
//… code …
}

//… a lot of code …

I obtain :

StreamScan.cu:224: erreur: «CUDA_Scan" was not declared in this scope
StreamScan.cu:224: erreur: expected primary-expression before «>" token
StreamScan.cu:224: erreur: expected primary-expression before «)" token
StreamScan.cu:232: erreur: expected primary-expression before «>" token
StreamScan.cu:232: erreur: expected primary-expression before «)" token
StreamScan.cu:238: erreur: expected primary-expression before «>" token
StreamScan.cu:238: erreur: expected primary-expression before «)" token
StreamScan.cu:247: erreur: expected primary-expression before «>" token
StreamScan.cu:247: erreur: expected primary-expression before «)" token
StreamScan.cu:259: erreur: «CUDA_Scan" was not declared in this scope
StreamScan.cu:259: erreur: expected primary-expression before «>" token
StreamScan.cu:259: erreur: expected primary-expression before «)" token

However, when i rename the two CUDA_Scan functions and compile :

//… a lot of code …

template< typename ScanType >
static global void CUDA_Scan1(ScanType* array, ScanType* ret)
{
//… code …
}

template< typename ScanType >
static global void CUDA_Scan2(ScanType* array, ScanType* blockSums, ScanType* ret)
{
//… code …
}

//… a lot of code …

It compiles fine.

I use CUDA 2.1 and the NVidia driver 180.44 on Ubuntu.

Thanks

Anyone can reproduce this bug ?

Hi!

C actually does not support overloading.

Regards

Navier

Damn ! >.<

Agreed ^^

w8ing for c++ support

I found overloaded functions in cutil_math.h (SDK). So, there is a bug ! It isn’t a stupid C lack. :rolleyes:

what about

template

class foo {

global static void bar(T *, int) { }

global static void bar(T *, int, int) { }

};

foo<my_very_own_data_type>::bar( … )

a bit more verbose though

i have made the experience that compiler errors are best worked around by

changing the code somehow without changing its functionality and i was lucky

with that strategy half a dozen times.