# Select device with maximum GFlops

**URL:** <https://forums.developer.nvidia.com/t/select-device-with-maximum-gflops/17260>\
**Category:** CUDA Programming and Performance\
**Created:** [June 18, 2010, 4:00pm UTC](https://forums.developer.nvidia.com/t/select-device-with-maximum-gflops/17260 "2010-06-18T16:00:31Z")\
**Posts on this page:** 3\
**Page:** 1

<div class="post-metadata">

**Author:** ![Kwyjibo2010](https://developer.download.nvidia.com/images/forums/profile-default-devtalk-84.png) [@Kwyjibo2010](https://forums.developer.nvidia.com/u/Kwyjibo2010)\
**Post date:** [June 18, 2010, 4:00pm UTC](https://forums.developer.nvidia.com/t/select-device-with-maximum-gflops/17260/1 "2010-06-18T16:00:31Z")

</div>

Hi,

I have written a function that selects the device with maximum theoretical GFlops throughput. I don’t know if my calculation is correct.

```auto
//Returns the device index of the device with the maximal theoretical

//throughput of floating point multiplies and adds. This number

//is estimated from different parameters and can be seen as a hint

//to choose the correct device. This function should be rewritten

//for devices more recent than GeForce GTX 480.

int deviceManager::getMaxGFLOPSDevice()

{

	//Query devices

	std::vector<cudaDeviceProp> devices;

	deviceQuery(devices);

	//Receive number of devices

	int devcount = getNumberOfDevices();

	//Calculate theoretical GFLOPs

	int flops = 0;

	int bestdevice = 0;

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

	{

		int tempflops = (devices[i].major == 1 ? 8 : 32) * \ //FMADs per clock cycle, taken from Programming Guide chapter 5.4.1

						(devices[i].major == 1 ? 1 : 2) * \ //Warps per multiprocessor

						 devices[i].multiProcessorCount * \

						 devices[i].clockRate;

		if (tempflops > flops)

		{

			flops = tempflops;

			bestdevice = i;

		}

	}

	//Return index of best device found

	return bestdevice;

}

```

Any suggestions?

Regards,

Kwyjibo

---

<div class="post-metadata">

**Author:** ![ddmk](https://developer.download.nvidia.com/images/forums/profile-default-devtalk-84.png) [@ddmk](https://forums.developer.nvidia.com/u/ddmk)\
**Post date:** [June 18, 2010, 6:11pm UTC](https://forums.developer.nvidia.com/t/select-device-with-maximum-gflops/17260/2 "2010-06-18T18:11:33Z")

</div>

> [@](#):
>
> For devices of compute capability 2.0, a multiprocessor consists of:
> 
> ï± 32 CUDA cores for integer and floating-point arithmetic operations,
> 
> …
> 
> ï± 2 warp schedulers.
> 
> …
> 
> A warp scheduler can issue an instruction to only half of the CUDA cores. To execute an instruction for all threads of a warp, a warp scheduler must therefore issue the instruction over:
> 
> ï± 2 clock cycles for an integer or floating-point arithmetic instruction

---

<div class="post-metadata">

**Author:** ![Kwyjibo2010](https://developer.download.nvidia.com/images/forums/profile-default-devtalk-84.png) [@Kwyjibo2010](https://forums.developer.nvidia.com/u/Kwyjibo2010)\
**Post date:** [June 18, 2010, 6:35pm UTC](https://forums.developer.nvidia.com/t/select-device-with-maximum-gflops/17260/3 "2010-06-18T18:35:05Z")

</div>

DO you have a source for that?
