Hello,
I have: Windows 8 x64, CUDA 9.0, NVIDIA GT620M and Visual Studio Community 2017.
I copied the easy code from the book into my program:
#include “stdafx.h”
#include <cuda_runtime.h>
global void add(int a, int b, int *c)
{
*c = a + b;
}
int main()
{
int c;
int *dev_c;
cudaMalloc((void**)&dev_c, sizeof(int));
add<<<1, 1>>>(2, 7, dev_c);
cudaMemcpy(&c,
dev_c,
sizeof(int),
cudaMemcpyDeviceToHost);
printf("2 + 7 = %d\n", c);
cudaFree(dev_c);
return 0;
}
The program compiles correctly but the result is always:
2 + 7 = 0
Why not 9? Where could be the problem?
Regards