I have a kernel that I developed under OS X that I am now in the process of porting to NVIDIA’s platform on Windows (7, 64-bit). I’ve been receiving build errors related to logical operations on integer vector types that according to the spec should be OK. For example,
[codebox]float4 smoothpart(float4 x, float4 degree) {
x *= degree;
float4 temp = exp(-1.f/(0.5f + x));
float4 result = temp/(temp + exp(-1.f/(0.5f - x)));
int4 test = (x >= -0.5f && x <= 0.5f);
temp = x < -0.5f ? : (float4) 0.f : (float4) 1.f;
return test ? result : temp;
}
[/codebox]
compiles fine under OS X, but elicits the following errors when I try to compile under Windows (my card is an NVIDIA GT 330M; I have CUDA Toolkit 3.1 installed and my driver version is 257.21):
[codebox]:194: error: invalid operands to binary expression (‘int attribute((ext_vector_type(4)))’ and ‘int attribute((ext_vector_type(4)))’)
int4 test = (x >= -0.5f && x <= 0.5f);
~~~~~~~~~~ ^ ~~~~~~~~~
:195: error: used type ‘int attribute((ext_vector_type(4)))’ where arithmetic or pointer type is required
temp = x < -0.5f ? : (float4) 0.f : (float4) 1.f;
^
:196: error: used type ‘int4’ where arithmetic or pointer type is required
return test ? result : temp;
^
[/codebox]
According to the spec, logical operators such as && should work for non-float vector types (on a component by component basis, see section 6.3 g), and the ternary operator should also work for vector types (section 6.3 i). Am I missing something? Does anyone know why this code fails to compile?