Manually clearing the global device vector

The vector of devices is a global object, which destruction order is
undefined. In some platforms, the OpenCL library has been unloaded
before this destructor is hit, which causes a segmentation fault after
the program ends.  By clearing the global vector of devices on
destruction of the OpenCL and SYCL Stream benchmarks we avoid the
problem.
This commit is contained in:
Ruyman Reyes 2018-05-02 15:21:41 +01:00
parent 54fc326097
commit 63f32fcb51
2 changed files with 3 additions and 1 deletions

View File

@ -186,6 +186,8 @@ OCLStream<T>::~OCLStream()
delete mul_kernel; delete mul_kernel;
delete add_kernel; delete add_kernel;
delete triad_kernel; delete triad_kernel;
devices.clear();
} }
template <class T> template <class T>

View File

@ -94,6 +94,7 @@ SYCLStream<T>::~SYCLStream()
delete p; delete p;
delete queue; delete queue;
devices.clear();
} }
template <class T> template <class T>
@ -322,7 +323,6 @@ std::string getDeviceDriver(const int device)
return driver; return driver;
} }
// TODO: Fix kernel names to allow multiple template specializations // TODO: Fix kernel names to allow multiple template specializations
template class SYCLStream<float>; template class SYCLStream<float>;
template class SYCLStream<double>; template class SYCLStream<double>;