This is an automated email from the ASF dual-hosted git repository. kparzysz pushed a commit to branch main in repository https://gitbox.apache.org/repos/asf/tvm.git
The following commit(s) were added to refs/heads/main by this push: new 365fcc832d Use TVM log instead of hexagon_print (#11024) 365fcc832d is described below commit 365fcc832d1d5916947e50643f388b34194d44b7 Author: Mehrdad Hessar <mhes...@octoml.ai> AuthorDate: Fri Apr 15 14:43:39 2022 -0700 Use TVM log instead of hexagon_print (#11024) --- apps/hexagon_api/CMakeLists.txt | 1 + src/runtime/hexagon/hexagon/hexagon_buffer.cc | 15 ++----- src/runtime/hexagon/hexagon/hexagon_common.cc | 9 +--- .../hexagon/hexagon/hexagon_device_api_v2.cc | 4 -- src/runtime/hexagon/rpc/hexagon/rpc_server.cc | 48 ++++++++++------------ 5 files changed, 28 insertions(+), 49 deletions(-) diff --git a/apps/hexagon_api/CMakeLists.txt b/apps/hexagon_api/CMakeLists.txt index e983758ba3..6d9f04948a 100644 --- a/apps/hexagon_api/CMakeLists.txt +++ b/apps/hexagon_api/CMakeLists.txt @@ -105,6 +105,7 @@ ExternalProject_Add(hexagon_tvm_runtime_rpc "-DBUILD_STATIC_RUNTIME=ON" "-DCMAKE_BUILD_TYPE=${CMAKE_BUILD_TYPE}" "-DUSE_ALTERNATIVE_LINKER=OFF" + "-DUSE_CUSTOM_LOGGING=ON" INSTALL_COMMAND "" BUILD_ALWAYS ON ) diff --git a/src/runtime/hexagon/hexagon/hexagon_buffer.cc b/src/runtime/hexagon/hexagon/hexagon_buffer.cc index 53cf655595..cfe2b528bb 100644 --- a/src/runtime/hexagon/hexagon/hexagon_buffer.cc +++ b/src/runtime/hexagon/hexagon/hexagon_buffer.cc @@ -16,12 +16,6 @@ * specific language governing permissions and limitations * under the License. */ - -// TODO(csulivan,adstraw,kparzysz-quic) This should be set on a TVM-wide basis. -#if defined(__hexagon__) -#define TVM_LOG_CUSTOMIZE 1 -#endif - #include "hexagon_buffer.h" #include <tvm/runtime/module.h> @@ -92,19 +86,18 @@ struct VTCMAllocation : public Allocation { if (context_id_) { data_ = HAP_compute_res_attr_get_vtcm_ptr(&res_info); if (!data_) { - HEXAGON_PRINT(ERROR, "ERROR: Allocated VTCM ptr is null."); + LOG(ERROR) << "ERROR: Allocated VTCM ptr is null."; HEXAGON_SAFE_CALL(HAP_compute_res_release(context_id_)); return; } } else { - HEXAGON_PRINT(ERROR, "ERROR: Unable to acquire requeisted resource."); + LOG(ERROR) << "ERROR: Unable to acquire requeisted resource."; return; } - // HEXAGON_PRINT(ALWAYS, "VTCMAllocation() - Context ID: %u, VTCM ptr: %p", context_id_, data_); + // LOG(INFO) << "VTCMAllocation() - Context ID: " << context_id_ << ", VTCM ptr: " << data_; } ~VTCMAllocation() { - // HEXAGON_PRINT(ALWAYS, "~VTCMAllocation() - Context ID: %u, VTCM ptr: %p", context_id_, - // data_); + // LOG(INFO) << "~VTCMAllocation() - Context ID: " << context_id_ << ", VTCM ptr: " << data_; HEXAGON_SAFE_CALL(HAP_compute_res_release(context_id_)); data_ = nullptr; } diff --git a/src/runtime/hexagon/hexagon/hexagon_common.cc b/src/runtime/hexagon/hexagon/hexagon_common.cc index f7bd4ffda7..4fb2af8acd 100644 --- a/src/runtime/hexagon/hexagon/hexagon_common.cc +++ b/src/runtime/hexagon/hexagon/hexagon_common.cc @@ -20,11 +20,6 @@ /*! * \file hexagon_common.cc */ -// TODO(csulivan,adstraw,kparzysz-quic) This should be set on a TVM-wide basis. -#if defined(__hexagon__) -#define TVM_LOG_CUSTOMIZE 1 -#endif - #include "hexagon_common.h" #include <tvm/runtime/logging.h> @@ -80,10 +75,10 @@ std::vector<std::string> SplitString(const std::string& str, char delim) { return lines; } void HexagonLog(const std::string& file, int lineno, const std::string& message) { - HEXAGON_PRINT(ALWAYS, "%s:%d:", file.c_str(), lineno); + HEXAGON_PRINT(ALWAYS, "INFO: %s:%d:", file.c_str(), lineno); std::vector<std::string> err_lines = SplitString(message, '\n'); for (auto& line : err_lines) { - HEXAGON_PRINT(ALWAYS, "%s", line.c_str()); + HEXAGON_PRINT(ALWAYS, "INFO: %s", line.c_str()); } } } // namespace diff --git a/src/runtime/hexagon/hexagon/hexagon_device_api_v2.cc b/src/runtime/hexagon/hexagon/hexagon_device_api_v2.cc index ea1cf18f3c..3419c7e68b 100644 --- a/src/runtime/hexagon/hexagon/hexagon_device_api_v2.cc +++ b/src/runtime/hexagon/hexagon/hexagon_device_api_v2.cc @@ -20,10 +20,6 @@ /*! * \file hexagon_device_api_v2.cc */ -// TODO(csulivan,adstraw,kparzysz-quic) This should be set on a TVM-wide basis. -#if defined(__hexagon__) -#define TVM_LOG_CUSTOMIZE 1 -#endif #include "hexagon_device_api_v2.h" diff --git a/src/runtime/hexagon/rpc/hexagon/rpc_server.cc b/src/runtime/hexagon/rpc/hexagon/rpc_server.cc index d14b178cf7..f61b1b6b40 100644 --- a/src/runtime/hexagon/rpc/hexagon/rpc_server.cc +++ b/src/runtime/hexagon/rpc/hexagon/rpc_server.cc @@ -43,11 +43,6 @@ extern "C" { // TODO(mehrdadh): make this configurable. #define TVM_HEXAGON_RPC_BUFF_SIZE_BYTES 2 * 1024 * 1024 -// TODO(csulivan,adstraw,kparzysz-quic) This should be set on a TVM-wide basis. -#if defined(__hexagon__) -#define TVM_LOG_CUSTOMIZE 1 -#endif - namespace tvm { namespace runtime { namespace hexagon { @@ -69,23 +64,22 @@ class HexagonIOHandler { void MessageStart(size_t message_size_bytes) {} ssize_t PosixWrite(const uint8_t* buf, size_t write_len_bytes) { - HEXAGON_PRINT(ALWAYS, "INFO: HexagonIOHandler PosixWrite called, write_len_bytes(%d)", - write_len_bytes); + LOG(INFO) << "INFO: HexagonIOHandler PosixWrite called, write_len_bytes(" << write_len_bytes + << ")"; int32_t written_size = write_buffer_.sputn(reinterpret_cast<const char*>(buf), write_len_bytes); if (written_size != write_len_bytes) { - HEXAGON_PRINT(ALWAYS, "ERROR: written_size(%lld) != write_len_bytes(%d)"); + LOG(ERROR) << "written_size(" << written_size << ") != write_len_bytes(" << write_len_bytes + << ")"; } write_buffer_available_length_ += written_size; return (ssize_t)written_size; } - void MessageDone() { HEXAGON_PRINT(HIGH, "INFO: Message Done."); } + void MessageDone() { LOG(INFO) << "INFO: Message Done."; } ssize_t PosixRead(uint8_t* buf, size_t read_len_bytes) { - HEXAGON_PRINT( - ALWAYS, - "INFO: HexagonIOHandler PosixRead called, read_len_bytes(%d), read_buffer_index_(%d)", - read_len_bytes, read_buffer_index_); + LOG(INFO) << "INFO: HexagonIOHandler PosixRead called, read_len_bytes(" << read_len_bytes + << "), read_buffer_index_(" << read_buffer_index_ << ")"; uint32_t bytes_to_read = 0; if (read_buffer_index_ < read_len_bytes) { @@ -108,12 +102,12 @@ class HexagonIOHandler { * \return The status */ AEEResult SetReadBuffer(const uint8_t* data, size_t data_size_bytes) { - HEXAGON_PRINT(ALWAYS, - "INFO: HexagonIOHandler SetReadBuffer: data_size_bytes(%d), " - "read_buffer_index_(%d), read_buffer_size_bytes_(%d)", - data_size_bytes, read_buffer_index_, read_buffer_size_bytes_); + LOG(INFO) << "INFO: HexagonIOHandler SetReadBuffer: data_size_bytes(" << data_size_bytes + << "), read_buffer_index_(" << read_buffer_index_ << "), read_buffer_size_bytes_(" + << read_buffer_size_bytes_ << ")"; if (data_size_bytes > read_buffer_size_bytes_) { - HEXAGON_PRINT(ERROR, "ERROR: data_size_bytes(%d) > read_buffer_size_bytes_(%d)"); + LOG(ERROR) << "ERROR: data_size_bytes(" << data_size_bytes << ") > read_buffer_size_bytes_(" + << read_buffer_size_bytes_ << ")"; return AEE_EFAILED; } std::memcpy(reinterpret_cast<void*>(read_buffer_), reinterpret_cast<const void*>(data), @@ -130,8 +124,8 @@ class HexagonIOHandler { * \return The size of data that is read in bytes. */ int64_t ReadFromWriteBuffer(uint8_t* buf, size_t read_size_bytes) { - HEXAGON_PRINT(ALWAYS, "INFO: HexagonIOHandler ReadFromWriteBuffer called, read_size_bytes: %d", - read_size_bytes); + LOG(INFO) << "INFO: HexagonIOHandler ReadFromWriteBuffer called, read_size_bytes: " + << read_size_bytes; int64_t size = (int64_t)write_buffer_.sgetn(reinterpret_cast<char*>(buf), read_size_bytes); write_buffer_available_length_ -= size; @@ -142,7 +136,7 @@ class HexagonIOHandler { return size; } - void Close() { HEXAGON_PRINT(ALWAYS, "INFO: HexagonIOHandler Close called"); } + void Close() { LOG(INFO) << "INFO: HexagonIOHandler Close called"; } void Exit(int code) { exit(code); } @@ -218,7 +212,7 @@ void reset_device_api() { int __QAIC_HEADER(hexagon_rpc_open)(const char* uri, remote_handle64* handle) { *handle = static_cast<remote_handle64>(reinterpret_cast<uintptr_t>(malloc(1))); if (!*handle) { - HEXAGON_PRINT(ERROR, "%s: cannot allocate memory", __func__); + LOG(ERROR) << __func__ << ": cannot allocate memory"; return AEE_ENOMEMORY; } reset_device_api(); @@ -228,7 +222,7 @@ int __QAIC_HEADER(hexagon_rpc_open)(const char* uri, remote_handle64* handle) { } int __QAIC_HEADER(hexagon_rpc_close)(remote_handle64 handle) { - HEXAGON_PRINT(ALWAYS, "%s", __func__); + LOG(INFO) << __func__; if (handle) { free(reinterpret_cast<void*>(static_cast<uintptr_t>(handle))); } @@ -248,8 +242,8 @@ AEEResult __QAIC_HEADER(hexagon_rpc_send)(remote_handle64 _handle, const unsigne int64_t written_size = get_hexagon_rpc_server()->Write(reinterpret_cast<const uint8_t*>(data), static_cast<size_t>(dataLen)); if (written_size != dataLen) { - HEXAGON_PRINT(ERROR, "ERROR: hexagon_rpc_send failed, written_size (%d) != dataLen (%d)", - written_size, dataLen); + LOG(ERROR) << "ERROR: hexagon_rpc_send failed, written_size (" << written_size + << ") != dataLen (" << dataLen << ")"; return AEE_EFAILED; } return AEE_SUCCESS; @@ -272,8 +266,8 @@ AEEResult __QAIC_HEADER(hexagon_rpc_receive)(remote_handle64 _handle, unsigned c if (read_size == static_cast<int64_t>(bufLen)) { return AEE_SUCCESS; } else { - HEXAGON_PRINT(ERROR, "ERROR: RPC Server Read failed, read_size (%lld) != bufLen (%lld)", - read_size, static_cast<int64_t>(bufLen)); + LOG(ERROR) << "ERROR: RPC Server Read failed, read_size (" << read_size << ") != bufLen (" + << static_cast<int64_t>(bufLen) << ")"; return AEE_EFAILED; } }