CoffeeBeforeArch/cuda_programming

example vectorAdd c is zero after adding

Ziaeemehr opened this issue · 2 comments

I am using

nvcc: NVIDIA (R) Cuda compiler driver
Copyright (c) 2005-2019 NVIDIA Corporation
Built on Sun_Jul_28_19:07:16_PDT_2019
Cuda compilation tools, release 10.1, V10.1.243

running the example return :

vectorAdd.cu:24: void verify_result(std::vector<int>&, std::vector<int>&, std::vector<int>&): Assertion `c[i] == a[i] + b[i]' failed.
[1]    49753 abort (core dumped)  ./prog

if I print few first elements of a, b, c after running kernel and copy data from device to host it returns all elements of c is zero.

what was the fix ?

@alxndrTL @Ziaeemehr I seem to be facing the same issue. What is the fix?

Update:

the problem relates to the architecture which one can find https://arnon.dk/matching-sm-architectures-arch-and-gencode-for-various-nvidia-cards/

and then compile with it in my case nvcc -arch=sm_86 -o vector_add add.cu worked