Select fastest device.
This commit is contained in:
@ -149,7 +149,37 @@ int nv::cuda::deviceCount()
|
||||
}
|
||||
#endif
|
||||
return 0;
|
||||
}
|
||||
}
|
||||
|
||||
int nv::cuda::getFastestDevice()
|
||||
{
|
||||
const int device_count = deviceCount();
|
||||
|
||||
int max_gflops_device = 0;
|
||||
int max_gflops = 0;
|
||||
|
||||
int current_device = 0;
|
||||
while (current_device < device_count)
|
||||
{
|
||||
cudaDeviceProp device_properties;
|
||||
cudaGetDeviceProperties(&device_properties, current_device);
|
||||
int gflops = device_properties.multiProcessorCount * device_properties.clockRate;
|
||||
|
||||
if (device_properties.major != -1 && device_properties.minor != -1)
|
||||
{
|
||||
if( gflops > max_gflops )
|
||||
{
|
||||
max_gflops = gflops;
|
||||
max_gflops_device = current_device;
|
||||
}
|
||||
}
|
||||
|
||||
current_device++;
|
||||
}
|
||||
|
||||
return max_gflops_device;
|
||||
}
|
||||
|
||||
|
||||
/// Activate the given devices.
|
||||
bool nv::cuda::setDevice(int i)
|
||||
|
@ -30,7 +30,8 @@ namespace nv
|
||||
namespace cuda
|
||||
{
|
||||
bool isHardwarePresent();
|
||||
int deviceCount();
|
||||
int deviceCount();
|
||||
int getFastestDevice();
|
||||
bool setDevice(int i);
|
||||
};
|
||||
|
||||
|
Reference in New Issue
Block a user