From dea95fe68edce9edfa6933d19a82bc83214156d8 Mon Sep 17 00:00:00 2001 From: Tom Deakin Date: Tue, 28 Jul 2015 12:06:21 +0100 Subject: [PATCH] Move common exceptions to common.h --- common.h | 17 +++++++++++++++++ cuda-stream.cu | 16 ---------------- ocl-stream.cpp | 16 ---------------- 3 files changed, 17 insertions(+), 32 deletions(-) diff --git a/common.h b/common.h index 8cd2156..864bcb6 100644 --- a/common.h +++ b/common.h @@ -14,6 +14,23 @@ extern bool useFloat; extern int deviceIndex; +// Exceptions +struct invaliddevice : public std::exception +{ + virtual const char * what () const throw () + { + return "Chosen device index is invalid"; + } +}; + +struct badntimes : public std::exception +{ + virtual const char * what () const throw () + { + return "Chosen number of times is invalid, must be >= 2"; + } +}; + template < typename T > void check_solution(void* a_in, void* b_in, void* c_in) { diff --git a/cuda-stream.cu b/cuda-stream.cu index 87981ec..9b06efd 100644 --- a/cuda-stream.cu +++ b/cuda-stream.cu @@ -11,22 +11,6 @@ std::string getDeviceName(int device); -struct invaliddevice : public std::exception -{ - virtual const char * what () const throw () - { - return "Chosen device index is invalid"; - } -}; - -struct badntimes : public std::exception -{ - virtual const char * what () const throw () - { - return "Chosen number of times is invalid, must be >= 2"; - } -}; - // Code to check CUDA errors void check_cuda_error(void) { diff --git a/ocl-stream.cpp b/ocl-stream.cpp index 5a0b6bc..54c7a5c 100644 --- a/ocl-stream.cpp +++ b/ocl-stream.cpp @@ -21,22 +21,6 @@ struct badfile : public std::exception } }; -struct invaliddevice : public std::exception -{ - virtual const char * what () const throw () - { - return "Chosen device index is invalid"; - } -}; - -struct badntimes : public std::exception -{ - virtual const char * what () const throw () - { - return "Chosen number of times is invalid, must be >= 2"; - } -}; - // Print error and exit void die(std::string msg, cl::Error& e)