Added get_num_devices()

This commit is contained in:
Davis King 2016-04-16 21:12:31 -04:00
parent 603d474352
commit 2703a72dfe
2 changed files with 14 additions and 0 deletions

View File

@ -27,6 +27,14 @@ namespace dlib
return dev; return dev;
} }
int get_num_devices (
)
{
int num_devices;
CHECK_CUDA(cudaGetDeviceCount(&num_devices));
return num_devices;
}
// ----------------------------------------------------------------------------------- // -----------------------------------------------------------------------------------
__global__ void _cuda_multiply1(float* d, const float* s1, const float* s2, size_t n) __global__ void _cuda_multiply1(float* d, const float* s1, const float* s2, size_t n)

View File

@ -22,6 +22,9 @@ namespace dlib
int get_device ( int get_device (
); );
int get_num_devices (
);
// ----------------------------------------------------------------------------------- // -----------------------------------------------------------------------------------
void multiply ( void multiply (
@ -165,6 +168,9 @@ namespace dlib
inline int get_device ( inline int get_device (
){ return 0; } ){ return 0; }
int get_num_devices (
) { return 1; }
#endif // DLIB_USE_CUDA #endif // DLIB_USE_CUDA
} }