I am new to cuda programming in Visual C++. In EVERY example of dot product that I have seen, e.g.,
, NOWHERE in the code is the summation variable, in the example, dev_c, EXPLICITLY initialized to 0.
The OBVIOUS question is where is it being initialized to zero and where is such zero initialization covered in cuda documentation?
Indeed, when I run dot the first time, it works, as expected, but, if I run it a second time, on the same dev_c, the new answer is added to the old one. So, to get the correct answer the second time, I use cudaMemset(dev_c, 0, sizeof(int)). But, this is a time expensive operation. Please, show me a faster way, maybe, within the code of dot.