can not get values from display memory

w have write a test program, but can not get the wright answer,

[codebox]

#include <stdio.h>

#include <cuda_runtime.h>

global void copy(float *gpudata, float *result)

{

for(int i = 0; i < 3; i++)

	result[i] = gpudata[i] + 5;

}

int main()

{

int count;

cudaGetDeviceCount(&count);

printf("count: %d\n", count);

cudaDeviceProp prop;

cudaError_t errtest = cudaGetDeviceProperties(&prop, 0);

if (errtest == cudaErrorInvalidDevice)

{

	printf("cudaErrorInvalidDevice\n");

}

printf("major: %d; minor: %d; name: %s\n", prop.major, prop.minor, prop.name);

printf("totalGlobalMem: %d", prop.totalGlobalMem);

cudaSetDevice(0);

float *gpudata, *result;

errtest = cudaMalloc((void **)&gpudata, sizeof(float) * 3);

if (errtest != cudaSuccess)

	printf("Error 1\n");

errtest = cudaMalloc((void **)&result, sizeof(float) * 3);

if (errtest != cudaSuccess)

	printf("Error 2\n");

float data[] ={10, 20, 30};



errtest = cudaMemcpy(gpudata, data, sizeof(float) * 3, cudaMemcpyHostToDevice);

if (errtest != cudaSuccess)

	printf("Error 3\n");

copy<<<1, 1, 0>>>(gpudata, result);

float res[3];

errtest = cudaMemcpy(res, result, sizeof(float) * 3, cudaMemcpyDeviceToHost);

if (errtest != cudaSuccess)

	printf("Error 4\n");

printf("\n%f, %f, %f", res[0], res[1], res[2]);

return 0;

}

[/codebox]

i get result:

count: 1

major: 1; minor: 1; name: GeForce 8400M GS

totalGlobalMem: 133890048

-0.000000, -0.000000, -0.000000

[… following up what we said on cuda@freenode … ]

This is really worth noting that this code is actually working (at least on my system) since i get

count: 1

major: 1; minor: 0; name: Quadro FX 4600

totalGlobalMem: 804585472

15.000000, 25.000000, 35.000000

Perhaps you should investigate to find what is wrong with your CUDA environment. you said on IRC that you are using windows and VS2005 while the SDK examples are working.

Just my 2 cents so that you can get helped more easily …

Cédric