8
8
//
9
9
// ===----------------------------------------------------------------------===//
10
10
#include " common.hpp"
11
+ #include " logger/ur_logger.hpp"
11
12
12
13
#include < sstream>
13
14
@@ -54,35 +55,34 @@ void checkErrorUR(amd_comgr_status_t Result, const char *Function, int Line,
54
55
return ;
55
56
}
56
57
57
- if (std::getenv (" SYCL_PI_SUPPRESS_ERROR_MESSAGE" ) == nullptr ||
58
- std::getenv (" UR_SUPPRESS_ERROR_MESSAGE" ) == nullptr ) {
59
- const char *ErrorString = nullptr ;
60
- const char *ErrorName = nullptr ;
61
- switch (Result) {
62
- case AMD_COMGR_STATUS_ERROR:
63
- ErrorName = " AMD_COMGR_STATUS_ERROR" ;
64
- ErrorString = " Generic error" ;
65
- break ;
66
- case AMD_COMGR_STATUS_ERROR_INVALID_ARGUMENT:
67
- ErrorName = " AMD_COMGR_STATUS_ERROR_INVALID_ARGUMENT" ;
68
- ErrorString =
69
- " One of the actual arguments does not meet a precondition stated in "
70
- " the documentation of the corresponding formal argument." ;
71
- break ;
72
- case AMD_COMGR_STATUS_ERROR_OUT_OF_RESOURCES:
73
- ErrorName = " AMD_COMGR_STATUS_ERROR_OUT_OF_RESOURCES" ;
74
- ErrorString = " Failed to allocate the necessary resources" ;
75
- break ;
76
- default :
77
- break ;
78
- }
79
- std::cerr << " \n UR HIP ERROR:"
80
- << " \n\t Value: " << Result
81
- << " \n\t Name: " << ErrorName
82
- << " \n\t Description: " << ErrorString
83
- << " \n\t Function: " << Function
84
- << " \n\t Source Location: " << File << " :" << Line << " \n\n " ;
58
+ const char *ErrorString = nullptr ;
59
+ const char *ErrorName = nullptr ;
60
+ switch (Result) {
61
+ case AMD_COMGR_STATUS_ERROR:
62
+ ErrorName = " AMD_COMGR_STATUS_ERROR" ;
63
+ ErrorString = " Generic error" ;
64
+ break ;
65
+ case AMD_COMGR_STATUS_ERROR_INVALID_ARGUMENT:
66
+ ErrorName = " AMD_COMGR_STATUS_ERROR_INVALID_ARGUMENT" ;
67
+ ErrorString =
68
+ " One of the actual arguments does not meet a precondition stated in "
69
+ " the documentation of the corresponding formal argument." ;
70
+ break ;
71
+ case AMD_COMGR_STATUS_ERROR_OUT_OF_RESOURCES:
72
+ ErrorName = " AMD_COMGR_STATUS_ERROR_OUT_OF_RESOURCES" ;
73
+ ErrorString = " Failed to allocate the necessary resources" ;
74
+ break ;
75
+ default :
76
+ break ;
85
77
}
78
+ std::stringstream SS;
79
+ SS << " \n UR HIP ERROR:"
80
+ << " \n\t Value: " << Result
81
+ << " \n\t Name: " << ErrorName
82
+ << " \n\t Description: " << ErrorString
83
+ << " \n\t Function: " << Function << " \n\t Source Location: " << File
84
+ << " :" << Line << " \n " ;
85
+ logger::error (" {}" , SS.str ());
86
86
87
87
if (std::getenv (" PI_HIP_ABORT" ) != nullptr ||
88
88
std::getenv (" UR_HIP_ABORT" ) != nullptr ) {
@@ -99,19 +99,17 @@ void checkErrorUR(hipError_t Result, const char *Function, int Line,
99
99
return ;
100
100
}
101
101
102
- if (std::getenv (" SYCL_PI_SUPPRESS_ERROR_MESSAGE" ) == nullptr ||
103
- std::getenv (" UR_SUPPRESS_ERROR_MESSAGE" ) == nullptr ) {
104
- const char *ErrorString = nullptr ;
105
- const char *ErrorName = nullptr ;
106
- ErrorName = hipGetErrorName (Result);
107
- ErrorString = hipGetErrorString (Result);
108
- std::cerr << " \n UR HIP ERROR:"
109
- << " \n\t Value: " << Result
110
- << " \n\t Name: " << ErrorName
111
- << " \n\t Description: " << ErrorString
112
- << " \n\t Function: " << Function
113
- << " \n\t Source Location: " << File << " :" << Line << " \n\n " ;
114
- }
102
+ const char *ErrorString = hipGetErrorString (Result);
103
+ const char *ErrorName = hipGetErrorName (Result);
104
+
105
+ std::stringstream SS;
106
+ SS << " \n UR HIP ERROR:"
107
+ << " \n\t Value: " << Result
108
+ << " \n\t Name: " << ErrorName
109
+ << " \n\t Description: " << ErrorString
110
+ << " \n\t Function: " << Function << " \n\t Source Location: " << File
111
+ << " :" << Line << " \n " ;
112
+ logger::error (" {}" , SS.str ());
115
113
116
114
if (std::getenv (" PI_HIP_ABORT" ) != nullptr ||
117
115
std::getenv (" UR_HIP_ABORT" ) != nullptr ) {
@@ -127,13 +125,11 @@ void checkErrorUR(ur_result_t Result, const char *Function, int Line,
127
125
return ;
128
126
}
129
127
130
- if (std::getenv (" SYCL_PI_SUPPRESS_ERROR_MESSAGE" ) == nullptr ||
131
- std::getenv (" UR_SUPPRESS_ERROR_MESSAGE" ) == nullptr ) {
132
- std::cerr << " \n UR HIP ERROR:"
133
- << " \n\t Value: " << Result
134
- << " \n\t Function: " << Function
135
- << " \n\t Source Location: " << File << " :" << Line << " \n\n " ;
136
- }
128
+ std::stringstream SS;
129
+ SS << " \n UR HIP ERROR:"
130
+ << " \n\t Value: " << Result << " \n\t Function: " << Function
131
+ << " \n\t Source Location: " << File << " :" << Line << " \n " ;
132
+ logger::error (" {}" , SS.str ());
137
133
138
134
if (std::getenv (" PI_HIP_ABORT" ) != nullptr ||
139
135
std::getenv (" UR_HIP_ABORT" ) != nullptr ) {
@@ -157,7 +153,7 @@ hipError_t getHipVersionString(std::string &Version) {
157
153
}
158
154
159
155
void detail::ur::die (const char *pMessage) {
160
- std::cerr << " ur_die: " << pMessage << ' \n ' ;
156
+ logger::always ( " ur_die: {} " , pMessage) ;
161
157
std::terminate ();
162
158
}
163
159
@@ -166,10 +162,6 @@ void detail::ur::assertion(bool Condition, const char *pMessage) {
166
162
die (pMessage);
167
163
}
168
164
169
- void detail::ur::hipPrint (const char *pMessage) {
170
- std::cerr << " ur_print: " << pMessage << ' \n ' ;
171
- }
172
-
173
165
// Global variables for UR_RESULT_ADAPTER_SPECIFIC_ERROR
174
166
thread_local ur_result_t ErrorMessageCode = UR_RESULT_SUCCESS;
175
167
thread_local char ErrorMessage[MaxMessageSize];
0 commit comments