Я свел это к простому примеру, демонстрирующему такое поведение.
Это уже находится в состоянии отчета об ошибке. Тем не менее, я подключаю его здесь, поскольку этот сайт становится все более надежным источником ошибок и исправлений. Поэтому я постоянно обновляю эту страницу.
Код:
Код: Выделить всё
#include"stdio.h"
#define PETE_DEVICE __device__
template class ILattice;
template class IScalar;
template struct AddILattice {};
template
PETE_DEVICE
void printType() {
printf("%s\n",__PRETTY_FUNCTION__);
}
template class IScalar {
T F;
};
template class ILattice {
T F[N];
};
template
struct AddILattice {
typedef ILattice< T , N > Type_t;
};
#define IL 16
__global__ void kernel()
{
printf("IL=%d\n",IL); // Here IL==16
typedef typename AddILattice::Type_t Tnew;
// This still works fine. Output:
// void printType() [with T = ILattice]
//
printType();
// Now problems begin: Output:
// T=4 Tnew=0 IL=64
// Here IL should still be 16
// sizeof(Tnew) should be 16*sizeof(float)
//
printf("T=%d Tnew=%d IL=%d\n",sizeof(IScalar ),sizeof(Tnew),IL);
}
int main()
{
dim3 blocksPerGrid( 1 , 1 , 1 );
dim3 threadsPerBlock( 1 , 1, 1);
kernel>( );
cudaDeviceSynchronize();
cudaError_t kernel_call = cudaGetLastError();
printf("call: %s\n",cudaGetErrorString(kernel_call));
}
Подробнее здесь: https://stackoverflow.com/questions/104 ... rait-types