Strange cudaMemcpyFromSymbol bug

Hi,

I am trying to copy two values (an x-shift, and a y-shift) into constant memory using the following code:

__constant__ int c_xShift;

__constant__ int c_yShift;

__host__ bool SetShiftSizes(int x_shift, int y_shift)

{

	int testRet;

	int xShift = x_shift;

	int yShift = y_shift;

	int* src = &xShift;

	checkError( cudaMemcpyToSymbol("c_xShift", src, sizeof(int) ) );

	checkError( cudaMemcpyFromSymbol(&testRet, "c_xShift", sizeof(int)) );

	if(testRet != *src)

		return false;

	src = &yShift;

	checkError( cudaMemcpyToSymbol("c_yShift", src, sizeof(int) ) );

	checkError( cudaMemcpyFromSymbol(&testRet, "c_yShift", sizeof(int)) );

	if(testRet != *src)

		return false;

	return true;

}

I am getting an error on the second cudaMemcpyFromSymbol (irregardless of which order the two memory copies are performed in). If the value of yShift is less than 32, the error is ‘cudaInvalidSymbol’. If the value of yShift is greater than 32, the error is ‘cudaErrorUnknown’. The code works if the value of yShift is 32.

Any help on this is appreciated, thanks.

Probably you put wrong quotes. Does you compiler give you some warnings about characters?
Try to use just cudaMemcpyToSymbol(c_yShift, src, …), the same syntax in the others cudaMemcpy… calls.