Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 1 addition & 0 deletions apps/hexagon_api/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -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
)
Expand Down
15 changes: 4 additions & 11 deletions src/runtime/hexagon/hexagon/hexagon_buffer.cc
Original file line number Diff line number Diff line change
Expand Up @@ -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>
Expand Down Expand Up @@ -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;
}
Expand Down
9 changes: 2 additions & 7 deletions src/runtime/hexagon/hexagon/hexagon_common.cc
Original file line number Diff line number Diff line change
Expand Up @@ -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>
Expand Down Expand Up @@ -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
Expand Down
4 changes: 0 additions & 4 deletions src/runtime/hexagon/hexagon/hexagon_device_api_v2.cc
Original file line number Diff line number Diff line change
Expand Up @@ -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"

Expand Down
48 changes: 21 additions & 27 deletions src/runtime/hexagon/rpc/hexagon/rpc_server.cc
Original file line number Diff line number Diff line change
Expand Up @@ -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 {
Expand All @@ -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) {
Expand All @@ -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),
Expand All @@ -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;

Expand All @@ -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); }

Expand Down Expand Up @@ -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();
Expand All @@ -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)));
}
Expand All @@ -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;
Expand All @@ -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;
}
}
Expand Down