From 63f32fcb5179d70fe20435302a39c0d7f7a51455 Mon Sep 17 00:00:00 2001 From: Ruyman Reyes Date: Wed, 2 May 2018 15:21:41 +0100 Subject: [PATCH 1/2] 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; From 8920cfd633e3677192c385ed7c7d4fda314f327d Mon Sep 17 00:00:00 2001 From: Ruyman Reyes Date: Wed, 2 May 2018 15:22:20 +0100 Subject: [PATCH 2/2] Split compilation lines for SYCL Stream The Makefile for SYCL Stream compilation is now split with individual lines for each file. This facilitates identifying compile time errors and avoids warnings on unused symbols. --- SYCL.make | 14 ++++++++++---- 1 file changed, 10 insertions(+), 4 deletions(-) diff --git a/SYCL.make b/SYCL.make index f3c5c80..3572681 100644 --- a/SYCL.make +++ b/SYCL.make @@ -1,12 +1,18 @@ COMPUTECPP_FLAGS = $(shell $(COMPUTECPP_PACKAGE_ROOT_DIR)/bin/computecpp_info --dump-device-compiler-flags) -sycl-stream: main.cpp SYCLStream.cpp SYCLStream.sycl - $(CXX) -O3 -std=c++11 -DSYCL main.cpp SYCLStream.cpp -I$(COMPUTECPP_PACKAGE_ROOT_DIR)/include -include SYCLStream.sycl $(EXTRA_FLAGS) -L$(COMPUTECPP_PACKAGE_ROOT_DIR)/lib -lComputeCpp -lOpenCL -Wl,--rpath=$(COMPUTECPP_PACKAGE_ROOT_DIR)/lib/ -o $@ +sycl-stream: main.o SYCLStream.o SYCLStream.sycl + $(CXX) -O3 -std=c++11 -DSYCL main.o SYCLStream.o $(EXTRA_FLAGS) -L$(COMPUTECPP_PACKAGE_ROOT_DIR)/lib -lComputeCpp -lOpenCL -Wl,--rpath=$(COMPUTECPP_PACKAGE_ROOT_DIR)/lib/ -o $@ + +main.o: main.cpp + $(CXX) -O3 -std=c++11 -DSYCL main.cpp -c -I$(COMPUTECPP_PACKAGE_ROOT_DIR)/include $(EXTRA_FLAGS) -o $@ + +SYCLStream.o: SYCLStream.cpp SYCLStream.sycl + $(CXX) -O3 -std=c++11 -DSYCL SYCLStream.cpp -c -I$(COMPUTECPP_PACKAGE_ROOT_DIR)/include -include SYCLStream.sycl $(EXTRA_FLAGS) -o $@ SYCLStream.sycl: SYCLStream.cpp - $(COMPUTECPP_PACKAGE_ROOT_DIR)/bin/compute++ SYCLStream.cpp $(COMPUTECPP_FLAGS) -c -I$(COMPUTECPP_PACKAGE_ROOT_DIR)/include -o $@ + $(COMPUTECPP_PACKAGE_ROOT_DIR)/bin/compute++ -DSYCL SYCLStream.cpp $(COMPUTECPP_FLAGS) -c -I$(COMPUTECPP_PACKAGE_ROOT_DIR)/include -o $@ .PHONY: clean clean: - rm -f sycl-stream SYCLStream.sycl SYCLStream.bc + rm -f sycl-stream SYCLStream.sycl main.o SYCLStream.o