No vector addition operator? getting arror when adding 2 float4 values


	sum = i1 + i2;

where sum, i1, i2 are float4 type leads to error:

error: no operator “+” matches these operands
1> operand types are: float4 + float4

Why could it be ???


error: no instance of overloaded function “max” matches the argument list
1> argument types are: (float4, float4)

em… that’s a surprise for me. Maybe you just have to do the addition on each element.

Yes, you have to define your own operator or use elementwise addition, as hyqneuron wrote. The compiler is still good enough to optimize necessary memory accesses into 256-bit loads and stores.

Elementwise addition works OK of course, I rewrote that kernel to use it, but… honestly it looks odd, too odd if you recall that it’s not CUDA 1.0 alpha, but CUDA 3.2 release…

To have vector type and not to have basic operations on it… weird!

Moreover, I think I’ve seen addition for float4 type somewhere in CUDA samples. Interesting, will that sample compile?..

I tought something wrong with my CUDA setup, but if it’s lack of vector addition indeed…

The header file cutil_math.h in the SDK has most vector operations you might want.

Thanks! Will try… but why not in CUDA toolkit? Why not as part of CUDA C/C++ language but as some additions ?