HCC
HCC is a single-source, C/C++ compiler for heterogeneous computing. It's optimized with HSA (http://www.hsafoundation.com/).
kalmar_exception.h
1 //===----------------------------------------------------------------------===//
2 //
3 // This file is distributed under the University of Illinois Open Source
4 // License. See LICENSE.TXT for details.
5 //
6 //===----------------------------------------------------------------------===//
7 
8 #pragma once
9 
10 #include <string>
11 #include <exception>
12 
13 namespace Kalmar {
14 
15 #ifndef E_FAIL
16 #define E_FAIL 0x80004005
17 #endif
18 
19 static const char *__errorMsg_UnsupportedAccelerator = "concurrency::parallel_for_each is not supported on the selected accelerator \"CPU accelerator\".";
20 
21 typedef int HRESULT;
22 class runtime_exception : public std::exception
23 {
24 public:
25  runtime_exception(const char * message, HRESULT hresult) throw() : _M_msg(message), err_code(hresult) {}
26  explicit runtime_exception(HRESULT hresult) throw() : err_code(hresult) {}
27  runtime_exception(const runtime_exception& other) throw() : _M_msg(other.what()), err_code(other.err_code) {}
28  runtime_exception& operator=(const runtime_exception& other) throw() {
29  _M_msg = *(other.what());
30  err_code = other.err_code;
31  return *this;
32  }
33  virtual ~runtime_exception() throw() {}
34  virtual const char* what() const throw() {return _M_msg.c_str();}
35  HRESULT get_error_code() const {return err_code;}
36 
37 private:
38  std::string _M_msg;
39  HRESULT err_code;
40 };
41 
43 {
44 public:
45  explicit invalid_compute_domain (const char * message) throw()
46  : runtime_exception(message, E_FAIL) {}
47  invalid_compute_domain() throw()
48  : runtime_exception(E_FAIL) {}
49 };
50 
52 {
53 public:
54  explicit accelerator_view_removed (const char * message, HRESULT view_removed_reason) throw()
55  : runtime_exception(message, view_removed_reason) {}
56  accelerator_view_removed(HRESULT view_removed_reason) throw()
57  : runtime_exception(view_removed_reason) {}
58  HRESULT get_view_removed_reason() const throw() { return get_error_code(); }
59 };
60 
61 } // namespace Kalmar
62 
Definition: kalmar_exception.h:51
namespace for internal classes of Kalmar compiler / runtime
Definition: hc.hpp:42
Definition: kalmar_exception.h:22
Definition: kalmar_exception.h:42