mux85

problem with 3-component vector

Discussion created by mux85 on Aug 12, 2010
Latest reply on Aug 12, 2010 by MicahVillmow

Hi, I'm developing an opencl image progessing application.

With opencl 1.0 i was passing the image to my kernel as an array of byte (host-side) and using it inside the kernel as an array of structure defined by me (3 uchar elements).

Now i've update to stream sdk 2.2 and i wanted to use one of the new opencl 1.1 features, a 3-component vector type. i relplaced my structure with uchar3. now the entire program crashes.

i think that it might depend on the fact that uchar3 is memorized as 4 bytes. in the array i pass to the kernel every 3 bytes represent a pixel (rgb) and so i think the 1 byte in 4 is "lost" in the 4-th byte of the uchar3. the crash is probably causad by the fact that after a certain number of pixels the program access some memory it shouldn't (it reads 4 bytes for every pixel insted of 3 so it goes out of the array boundaries at some point).

is there a way to solve this problem? is it better to go back to my 3 byte structure (performance-wise)?

Outcomes