From 63f32fcb5179d70fe20435302a39c0d7f7a51455 Mon Sep 17 00:00:00 2001 From: Ruyman Reyes Date: Wed, 2 May 2018 15:21:41 +0100 Subject: [PATCH] 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. --- OCLStream.cpp | 2 ++ SYCLStream.cpp | 2 +- 2 files changed, 3 insertions(+), 1 deletion(-) diff --git a/OCLStream.cpp b/OCLStream.cpp index 7bc5a78..4d6e85a 100644 --- a/OCLStream.cpp +++ b/OCLStream.cpp @@ -186,6 +186,8 @@ OCLStream::~OCLStream() delete mul_kernel; delete add_kernel; delete triad_kernel; + + devices.clear(); } template diff --git a/SYCLStream.cpp b/SYCLStream.cpp index ea9c55f..171c9f7 100644 --- a/SYCLStream.cpp +++ b/SYCLStream.cpp @@ -94,6 +94,7 @@ SYCLStream::~SYCLStream() delete p; delete queue; + devices.clear(); } template @@ -322,7 +323,6 @@ std::string getDeviceDriver(const int device) return driver; } - // TODO: Fix kernel names to allow multiple template specializations template class SYCLStream; template class SYCLStream;