Hello! I have some strange problems with definition of constants in CUDA. I posted this in another thread recently, but now the problem is more isolated so I thought a new thread would be best.
I have a single main.cu file, and this compiles fine:
__device__ __constant__ float d_some_constant = 1.0;
__global__ void kernel(float* time)
{
time[threadIdx.x] += d_some_constant;
}
int main()
{
return 0;
}
However, the following does NOT work:
const float some_constant = 1.0;
__device__ __constant__ float d_some_constant = some_constant;
__global__ void kernel(float* time)
{
time[threadIdx.x] += d_some_constant;
}
int main()
{
return 0;
}
The build log looks like this:
Build Log
Build started: Project: cuda_template, Configuration: Debug|x64
Command Lines
Creating temporary file “d:\Kod\Projects\cuda_template\cuda_template\x64\Debug\BAT00000E19685500.bat” with contents
[
@echo off
nvcc.exe -ccbin “C:\Program Files (x86)\Microsoft Visual Studio 8\VC\bin” -c -Xcompiler "/EHsc /W3 /nologo /Wp64 /O2 /Zi /MT " -o Debug\main.obj main.cu
if errorlevel 1 goto VCReportError
goto VCEnd
:VCReportError
echo Project : error PRJ0019: A tool returned an error code from “Compiling…”
exit 1
:VCEnd
]
Creating command line “d:\Kod\Projects\cuda_template\cuda_template\x64\Debug\BAT00000E19685500.bat”
Output Window
Compiling…
main.cu
main.cu(3): error: can’t generate code for non empty constructors or destructors on device
1 error detected in the compilation of “C:/Users/Victor/AppData/Local/Temp/tmpxft_0000074c_00000000-6_main.cpp1.ii”.
Project : error PRJ0019: A tool returned an error code from “Compiling…”
Results
Build log was saved at “file://d:\Kod\Projects\cuda_template\cuda_template\x64\Debug\BuildLog.htm”
cuda_template - 2 error(s), 0 warning(s)
Any ideas? I have friends that can compile the same code without any problems, and I have not found any other strange behaviour in my CUDA compiling yet!