-device=n option doesn't work on simpleAtomics or simpleAtomicIntrinsics example

The simpleAtomics and simpleAtomicIntrinsics examples don’t call the CUT_DEVICE_INIT function, so they don’t support the -device=n flag. They always try to use my first cuda GPU. (I have two cuda cards in my computer). Also, they don’t properly search for a 1.1 capable device.

Fixed code for runTest() in simpleAtomicIntrinsics.cu


runTest( int argc, char **argv)


	int deviceCount;


	if (deviceCount == 0) {

		fprintf(stderr, "cutil error: no devices supporting CUDA.\n");



	cudaDeviceProp deviceProp;

	deviceProp.major = 1;

	deviceProp.minor = 1;

	int dev = -1;

	// Get device number from command line

	cutGetCmdLineArgumenti(argc, (const char **) argv, "device", &dev);

	if(dev == -1) {

		// If no command line arg, try to automatically find a 1.1 device

		CUDA_SAFE_CALL(cudaChooseDevice(&dev, &deviceProp));


	if (dev > deviceCount-1) dev = deviceCount - 1;

	CUDA_SAFE_CALL(cudaGetDeviceProperties(&deviceProp, dev));

	if(deviceProp.major > 1 || deviceProp.minor > 0)


		printf("Using Device %d: \"%s\"\n", dev, deviceProp.name);





		printf("There is no device supporting CUDA compute capability 1.1.\n");

		printf("TEST PASSED");

		CUT_EXIT(argc, argv);


Thanks, it looks like this has already been fixed in the 2.1 SDK.