Merge topic 'safe-cuda-runtime-config'
f42f59d68 Fix crash when CUDA device is disabled Acked-by: Kitware Robot <kwrobot@kitware.com> Acked-by: Gunther Weber <ghweber@lbl.gov> Merge-request: !3216
This commit is contained in:
commit
f2b73fe2e4
7
docs/changelog/safe-cuda-runtime-config.md
Normal file
7
docs/changelog/safe-cuda-runtime-config.md
Normal file
@ -0,0 +1,7 @@
|
|||||||
|
# Fix crash when CUDA device is disabled
|
||||||
|
|
||||||
|
There was an issue where if VTK-m was compiled with CUDA support but then
|
||||||
|
run on a computer where no CUDA device was available, an inappropriate
|
||||||
|
exception was thrown (instead of just disabling the device). The
|
||||||
|
initialization code should now properly check for the existance of a CUDA
|
||||||
|
device.
|
@ -10,6 +10,7 @@
|
|||||||
#ifndef vtk_m_cont_cuda_internal_RuntimeDeviceConfigurationCuda_h
|
#ifndef vtk_m_cont_cuda_internal_RuntimeDeviceConfigurationCuda_h
|
||||||
#define vtk_m_cont_cuda_internal_RuntimeDeviceConfigurationCuda_h
|
#define vtk_m_cont_cuda_internal_RuntimeDeviceConfigurationCuda_h
|
||||||
|
|
||||||
|
#include <vtkm/cont/cuda/internal/DeviceAdapterRuntimeDetectorCuda.h>
|
||||||
#include <vtkm/cont/cuda/internal/DeviceAdapterTagCuda.h>
|
#include <vtkm/cont/cuda/internal/DeviceAdapterTagCuda.h>
|
||||||
#include <vtkm/cont/internal/RuntimeDeviceConfiguration.h>
|
#include <vtkm/cont/internal/RuntimeDeviceConfiguration.h>
|
||||||
|
|
||||||
@ -36,13 +37,28 @@ class RuntimeDeviceConfiguration<vtkm::cont::DeviceAdapterTagCuda>
|
|||||||
public:
|
public:
|
||||||
RuntimeDeviceConfiguration<vtkm::cont::DeviceAdapterTagCuda>()
|
RuntimeDeviceConfiguration<vtkm::cont::DeviceAdapterTagCuda>()
|
||||||
{
|
{
|
||||||
int tmp;
|
this->CudaDeviceCount = 0;
|
||||||
VTKM_CUDA_CALL(cudaGetDeviceCount(&tmp));
|
this->CudaProp.clear();
|
||||||
this->CudaDeviceCount = tmp;
|
vtkm::cont::DeviceAdapterRuntimeDetector<vtkm::cont::DeviceAdapterTagCuda> detector;
|
||||||
this->CudaProp.resize(this->CudaDeviceCount);
|
if (detector.Exists())
|
||||||
for (int i = 0; i < this->CudaDeviceCount; ++i)
|
|
||||||
{
|
{
|
||||||
VTKM_CUDA_CALL(cudaGetDeviceProperties(&this->CudaProp[i], i));
|
try
|
||||||
|
{
|
||||||
|
int tmp;
|
||||||
|
VTKM_CUDA_CALL(cudaGetDeviceCount(&tmp));
|
||||||
|
this->CudaDeviceCount = tmp;
|
||||||
|
this->CudaProp.resize(this->CudaDeviceCount);
|
||||||
|
for (int i = 0; i < this->CudaDeviceCount; ++i)
|
||||||
|
{
|
||||||
|
VTKM_CUDA_CALL(cudaGetDeviceProperties(&this->CudaProp[i], i));
|
||||||
|
}
|
||||||
|
}
|
||||||
|
catch (...)
|
||||||
|
{
|
||||||
|
VTKM_LOG_F(vtkm::cont::LogLevel::Error,
|
||||||
|
"Error retrieving CUDA device information. Disabling.");
|
||||||
|
this->CudaDeviceCount = 0;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
Loading…
Reference in New Issue
Block a user