helo
Im very very new to cuda
I wrote a very simple cuda program:
// moveArrays.cu
//
// demonstrates CUDA interface to data allocation on device (GPU)
// and data movement between host (CPU) and device.
#include <stdio.h>
#include <assert.h>
#include <cuda.h>
int main(void)
{
float *a_h, *b_h; // pointers to host memory
float *a_d, *b_d; // pointers to device memory
int N = 14;
int i;
// allocate arrays on host
a_h = (float *)malloc(sizeof(float)*N);
b_h = (float *)malloc(sizeof(float)*N);
// allocate arrays on device
cudaMalloc((void **) &a_d, sizeof(float)*N);
cudaMalloc((void **) &b_d, sizeof(float)*N);
// initialize host data
for (i=0; i<N; i++) {
a_h[i] = 10.f+i;
b_h[i] = 0.f;
}
// send data from host to device: a_h to a_d
cudaMemcpy(a_d, a_h, sizeof(float)*N, cudaMemcpyHostToDevice);
// copy data within device: a_d to b_d
cudaMemcpy(b_d, a_d, sizeof(float)*N, cudaMemcpyDeviceToDevice);
// retrieve data from device: b_d to b_h
cudaMemcpy(b_h, a_d, sizeof(float)*N, cudaMemcpyDeviceToHost);
// check result
for (i=0; i<N; i++)
printf(“a_h=%f, b_h=%f\r\n”, a_h[i], b_h[i]);
// cleanup
free(a_h); free(b_h);
cudaFree(a_d); cudaFree(b_d);
}
when i run it in emualtion mode i get - ok:
a_h=10.000000, b_h=10.000000
a_h=11.000000, b_h=11.000000
a_h=12.000000, b_h=12.000000
a_h=13.000000, b_h=13.000000
a_h=14.000000, b_h=14.000000
a_h=15.000000, b_h=15.000000
a_h=16.000000, b_h=16.000000
a_h=17.000000, b_h=17.000000
a_h=18.000000, b_h=18.000000
a_h=19.000000, b_h=19.000000
a_h=20.000000, b_h=20.000000
a_h=21.000000, b_h=21.000000
a_h=22.000000, b_h=22.000000
a_h=23.000000, b_h=23.000000
and when not emulation i get
a_h=10.000000, b_h=0.000000
a_h=11.000000, b_h=0.000000
a_h=12.000000, b_h=0.000000
a_h=13.000000, b_h=0.000000
a_h=14.000000, b_h=0.000000
a_h=15.000000, b_h=0.000000
a_h=16.000000, b_h=0.000000
a_h=17.000000, b_h=0.000000
a_h=18.000000, b_h=0.000000
a_h=19.000000, b_h=0.000000
a_h=20.000000, b_h=0.000000
a_h=21.000000, b_h=0.000000
a_h=22.000000, b_h=0.000000
a_h=23.000000, b_h=0.000000
that is not correct
why is that ?
what am i doing wong?
thanks and sorry for the stpid question…
I use cuda 2.2
i installefd the sdk the toolkit and the driver
i have GF 6200 le ver 185.85