MCPcopy Create free account
hub / github.com/MeshInspector/MeshLib / getDeviceInfo

Function getDeviceInfo

source/MRCuda/MRCudaBasic.cpp:16–44  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

14{
15
16Expected<DeviceInfo> getDeviceInfo()
17{
18 DeviceInfo res;
19 CUDA_RETURN_UNEXPECTED( cudaDriverGetVersion( &res.driverVersion ) );
20 if ( res.driverVersion <= 0 )
21 return MR::unexpected( "NVIDIA GPU error: no CUDA driver found" );
22
23 {
24 int n = 0;
25 auto code = cudaGetDeviceCount( &n );
26 if ( code != cudaSuccess || n <= 0 )
27 {
28 auto err = ( code != cudaSuccess ) ? MR::Cuda::getError( code ) : "NVIDIA GPU error: no capable device found";
29 err += fmt::format( ", CUDA driver {}.{}", res.driverVersion / 1000, ( res.driverVersion % 1000 ) / 10 );
30 return MR::unexpected( err );
31 }
32 }
33
34 CUDA_RETURN_UNEXPECTED( cudaRuntimeGetVersion( &res.runtimeVersion ) );
35
36 cudaDeviceProp prop;
37 CUDA_RETURN_UNEXPECTED( cudaGetDeviceProperties( &prop, 0 ) );
38 res.computeMajor = prop.major;
39 res.computeMinor = prop.minor;
40 res.totalGlobalMem = prop.totalGlobalMem;
41 res.name = prop.name;
42
43 return res;
44}
45
46bool DeviceInfo::fitForComputations() const
47{

Callers 2

mainFunction · 0.85
isCudaAvailableFunction · 0.85

Calls 2

getErrorFunction · 0.85
unexpectedFunction · 0.50

Tested by 1

mainFunction · 0.68