cancel
Showing results for 
Search instead for 
Did you mean: 

Archives Discussions

tgreen
Journeyman III

Largest component in vector

I am wondering if in opencl there is an operator to get the maximal component of a vector, so max([1,2,3]) would then return 3 and max([4,3,2]) would return 4 etc.

For collision detection I wanted to make an initial broadphase step before the more costly calculations. In this broadphase step I wanted to simply see what the maximal separation along x,y,z was and then see what the objects velocity along that axis was to see if a collision pair would have any chance of touching during a timestep. For this it seemed like a simple fast solution to get the maximal vector component, and I was expecting this to be supported untill reading the specs which seem to only work with two arguments.

0 Likes
1 Solution
LeeHowes
Staff

I'd have to check the spec too to see if there is one. Likely you're right.

Having said that, you're not going to gain much anyway realistically. The modern GPU architectures will linearise the short vectors in a single lane of the larger SIMD vector anyway and do the operation sequentially whatever code you write. That kind of operation might gain on an SSE mapping (if there is such an operation).

View solution in original post

0 Likes
2 Replies
LeeHowes
Staff

I'd have to check the spec too to see if there is one. Likely you're right.

Having said that, you're not going to gain much anyway realistically. The modern GPU architectures will linearise the short vectors in a single lane of the larger SIMD vector anyway and do the operation sequentially whatever code you write. That kind of operation might gain on an SSE mapping (if there is such an operation).

0 Likes

Thanks for the confirmation.

0 Likes