Hi,
I recently started coding in CUDA 4.2 on Ubuntu 12.04 and I have a problem - when compiling my kernel to PTX with the command below:
nvcc -arch="compute_20" -code="sm_20" -I"/home/maciej/NVIDIA_GPU_Computing_SDK/C/common/inc" -I"/usr/local/cuda/include" -I"/home/maciej/Projekty/CIRT/src" -maxrregcount=0 -m 64 -ptx code.cu -o code.ptx
I get following error:
/home/maciej/Projekty/CIRT/src/cirt_programs.cu(437): error: no operator "-" matches these operands
operand types are: - float3
/home/maciej/Projekty/CIRT/src/cirt_programs.cu(453): error: no operator "-" matches these operands
operand types are: - float3
2 errors detected in the compilation of "/tmp/tmpxft_00001bfa_00000000-4_ptPrimary.cpp4.ii".
Any tips/links to existing topics?
MK
P.S.
The code the error is refering to is likewise:
inline __device__ float ray2Plane(const float4 c, const float4 norm, float4 *hb) {
float3 N = make_float3(norm.x, norm.y, norm.z);
float3 D = make_float3(raydir().x, raydir().y, raydir().z);
float3 E = make_float3(rayori().x, rayori().y, rayori().z);
float3 Q = make_float3(c.x, c.y, c.z);
float num = dot(N, -(Q - E));// this line...
float denom = dot(-D, N);
float t = -1.0f;
if (denom > 0.0f) t = num / denom;
return t;
}
Is this a case that I need to first do the substraction into a variable and then change it’s sign? The same code on Windows 7 x64 compiles to PTX without errors.
MK
Ok I solved it myself :D
Indeed was there a problem with the ‘-’ before the innermost parenthesis, containing substraction of two float3 vectors. I simply swaped them and voila! No more problems.
Thanks,
MK