float4 and possible out of range?

Suppose I were to create a memory buffer for only 17 * sizeof(float) bytes and access this buffer in the kernel through a __global float4 pointer. Can I read from and write to the fifth and last float4, or do these actions result in some out of range faults? What are the initial values for the .yzw swizzles, if it’s a valid read operation?

Suppose I were to create a memory buffer for only 17 * sizeof(float) bytes and access this buffer in the kernel through a __global float4 pointer.

That’s problematic since the beginning. The __global float4 pointer can only read from memory addresses that are aligned to a float4. See section 6.1.5.

Can I read from and write to the fifth and last float4

Behavior is undefined for out-of-bounds memory accesses. It could page fault, it could start playing a tune through your speakers, or it could do anything else.

add 3 more elements as 0.0 … prob solved… 8) :lol:

Not quite true for all cases, for example when one of the increments is negative and the other is positive. In that example you‘d have to pad the beginning on the negative increment vector. Also, the proper padding value depends on the problem/algorithm.

Anyways, padding works if you control the entire program but if you want to make a kernel library it would be best to avoid additional constraints on vector lengths.

watever … :mrgreen: :evil: