Dot product

The dot product between two vectors is an important mathematical operation. It will also explain one important concept in CUDA programming that is called reduction operation. The dot product between two vectors can be defined as follows:

(x1,x1,x3) . (y1,y2,y3) = x1y1 + x2y2 +x3y3

Now, if you see this operation, it is very similar to an element-wise addition operation on vectors. Instead of addition, you have to perform element-wise multiplication. All threads also have to keep running the sum of multiplication they have performed because all individual multiplications need to be summed up to get a final answer of the dot product. The answer of the dot product will be a single number. This operation where the final answer is the ...

Get Hands-On GPU-Accelerated Computer Vision with OpenCV and CUDA now with O’Reilly online learning.

O’Reilly members experience live online training, plus books, videos, and digital content from 200+ publishers.