Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion include/itkCudaUtil.h
Original file line number Diff line number Diff line change
Expand Up @@ -55,7 +55,7 @@ GetCudaComputeCapability(int device);
int
CudaGetAvailableDevices(std::vector<cudaDeviceProp> & devices);

/** Get the device that has the maximum FLOPS in the current context */
/** Get the device that has the maximum FLOPS in the current context. The result is cached for future calls. */
int
CudaGetMaxFlopsDev();

Expand Down
15 changes: 12 additions & 3 deletions src/itkCudaUtil.cxx
Original file line number Diff line number Diff line change
Expand Up @@ -69,18 +69,19 @@ CudaGetAvailableDevices(std::vector<cudaDeviceProp> & devices)
}

//
// Get the device that has the maximum FLOPS
// Compute the device that has the maximum FLOPS
//
int
CudaGetMaxFlopsDev()
ComputeMaxFlopsDevice()
{
std::vector<cudaDeviceProp> devices;
int numAvailableDevices = CudaGetAvailableDevices(devices);

if (numAvailableDevices == 0)
{

return -1;
}

int max_flops = 0;
int max_flops_device = 0;
for (int i = 0; i < numAvailableDevices; ++i)
Expand All @@ -98,6 +99,14 @@ CudaGetMaxFlopsDev()
return max_flops_device;
}

int
CudaGetMaxFlopsDev()
{
static const int max_flops_device = ComputeMaxFlopsDevice();

return max_flops_device;
}


std::pair<int, int>
GetCudaComputeCapability(int device)
Expand Down
Loading