88//
99// ===----------------------------------------------------------------------===//
1010#include " common.hpp"
11+ #include " logger/ur_logger.hpp"
1112
1213#include < sstream>
1314
@@ -54,35 +55,34 @@ void checkErrorUR(amd_comgr_status_t Result, const char *Function, int Line,
5455 return ;
5556 }
5657
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 ;
8577 }
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 ());
8686
8787 if (std::getenv (" PI_HIP_ABORT" ) != nullptr ||
8888 std::getenv (" UR_HIP_ABORT" ) != nullptr ) {
@@ -99,19 +99,17 @@ void checkErrorUR(hipError_t Result, const char *Function, int Line,
9999 return ;
100100 }
101101
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 ());
115113
116114 if (std::getenv (" PI_HIP_ABORT" ) != nullptr ||
117115 std::getenv (" UR_HIP_ABORT" ) != nullptr ) {
@@ -127,13 +125,11 @@ void checkErrorUR(ur_result_t Result, const char *Function, int Line,
127125 return ;
128126 }
129127
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 ());
137133
138134 if (std::getenv (" PI_HIP_ABORT" ) != nullptr ||
139135 std::getenv (" UR_HIP_ABORT" ) != nullptr ) {
@@ -157,7 +153,7 @@ hipError_t getHipVersionString(std::string &Version) {
157153}
158154
159155void detail::ur::die (const char *pMessage) {
160- std::cerr << " ur_die: " << pMessage << ' \n ' ;
156+ logger::always ( " ur_die: {} " , pMessage) ;
161157 std::terminate ();
162158}
163159
@@ -166,10 +162,6 @@ void detail::ur::assertion(bool Condition, const char *pMessage) {
166162 die (pMessage);
167163}
168164
169- void detail::ur::hipPrint (const char *pMessage) {
170- std::cerr << " ur_print: " << pMessage << ' \n ' ;
171- }
172-
173165// Global variables for UR_RESULT_ADAPTER_SPECIFIC_ERROR
174166thread_local ur_result_t ErrorMessageCode = UR_RESULT_SUCCESS;
175167thread_local char ErrorMessage[MaxMessageSize];
0 commit comments