cudaMemcpy gives all zeroes?

[font=“Times New Roman”]I’m probably missing something simple, because I can’t believe this “bug” would be in a production release.

The following code was adapted directly from the Programmer’s Guide (shorts instead of floats is all):
[/font]
/* minitest.cu
*/

#include <stdio.h>
#include <stdlib.h>
#include <cuda.h>
#include “symbolic_constants.h”

int main (int argc , char* argv )
{
int hPopulation = NUM_AGENTS;
int hGridSize = GRID_SIZE;
short* agentX;
short* hShort;
short* hNew;

// seed rng
srand((unsigned int) 21397);

// use the GTX470
cudaSetDevice(0);

// set up agent list
// allocate device memory
cudaMalloc((void**)&agentX,hPopulation*sizeof(short));

// allocate temp arrays
hShort = (short*) malloc(hPopulation*sizeof(short));
hNew = (short*) malloc(hPopulation*sizeof(short));

// fill temp arrays with random numbers and copy to device
for (int i = 0; i < hPopulation; i++) {
	hShort[i] = rand() % hGridSize;
}

cudaMemcpy(agentX,hShort,hPopulation*sizeof(short),cudaMemcpyHostToDevice);
memcpy(hNew,hShort,hPopulation*sizeof(short));

// do something with it here

// clean up
cudaFree(agentX);
cudaFree(hShort);

return EXIT_SUCCESS ;

}

[font=“Times New Roman”]The symbolic constants file just defines NUM_AGENTS and GRID_SIZE. The memcpy works as expected, but in the cuda-gdb debugger (on Ubuntu 10.10), the cudaMemcpy yields all zeroes. Please point out my mistake, 'cause I just don’t get it!

Thanks!

CRF[/font]