diff --git a/cmake/modules/Hexagon.cmake b/cmake/modules/Hexagon.cmake index eb3ad1f5ae4a..10e8d825c52d 100644 --- a/cmake/modules/Hexagon.cmake +++ b/cmake/modules/Hexagon.cmake @@ -73,12 +73,12 @@ endif() if(USE_HEXAGON_DEVICE STREQUAL "${PICK_SIM}") find_hexagon_toolchain() message(STATUS "Hexagon toolchain: ${HEXAGON_TOOLCHAIN}") - file(GLOB RUNTIME_HEXAGON_SIM_SRCS src/runtime/hexagon/sim/*.cc) + file(GLOB RUNTIME_HEXAGON_SIM_SRCS src/runtime/hexagon/android/sim/*.cc) include_directories(SYSTEM "${HEXAGON_TOOLCHAIN}/include/iss") link_directories("${HEXAGON_TOOLCHAIN}/lib/iss") list(APPEND TVM_RUNTIME_LINKER_LIBS "-lwrapper") ExternalProject_Add(sim_dev - SOURCE_DIR "${CMAKE_SOURCE_DIR}/src/runtime/hexagon/sim/driver" + SOURCE_DIR "${CMAKE_SOURCE_DIR}/src/runtime/hexagon/android/sim/driver" CMAKE_ARGS "-DCMAKE_C_COMPILER=${HEXAGON_TOOLCHAIN}/bin/hexagon-clang" "-DCMAKE_CXX_COMPILER=${HEXAGON_TOOLCHAIN}/bin/hexagon-clang++" @@ -88,7 +88,7 @@ if(USE_HEXAGON_DEVICE STREQUAL "${PICK_SIM}") elseif(USE_HEXAGON_DEVICE STREQUAL "${PICK_HW}") find_hexagon_sdk_root("${USE_HEXAGON_SDK}" "${USE_HEXAGON_ARCH}") find_hexagon_toolchain() - file(GLOB RUNTIME_HEXAGON_DEVICE_SRCS src/runtime/hexagon/target/*.cc) + file(GLOB RUNTIME_HEXAGON_DEVICE_SRCS src/runtime/hexagon/android/target/*.cc) include_directories(SYSTEM ${HEXAGON_SDK_INCLUDES} @@ -102,7 +102,10 @@ elseif(USE_HEXAGON_DEVICE STREQUAL "${PICK_HW}") endif() endif() -file(GLOB RUNTIME_HEXAGON_SRCS src/runtime/hexagon/*.cc) +if(BUILD_FOR_HEXAGON AND USE_HEXAGON_DEVICE STREQUAL "${PICK_NONE}") + file(GLOB RUNTIME_HEXAGON_SRCS src/runtime/hexagon/hexagon/*.cc) +else() + file(GLOB RUNTIME_HEXAGON_SRCS src/runtime/hexagon/android/*.cc) +endif() list(APPEND RUNTIME_SRCS ${RUNTIME_HEXAGON_SRCS} ${RUNTIME_HEXAGON_SIM_SRCS} ${RUNTIME_HEXAGON_DEVICE_SRCS}) - diff --git a/src/runtime/hexagon/android/hexagon_device.h b/src/runtime/hexagon/android/hexagon_device.h new file mode 100644 index 000000000000..552b8f971369 --- /dev/null +++ b/src/runtime/hexagon/android/hexagon_device.h @@ -0,0 +1,135 @@ +/* + * Licensed to the Apache Software Foundation (ASF) under one + * or more contributor license agreements. See the NOTICE file + * distributed with this work for additional information + * regarding copyright ownership. The ASF licenses this file + * to you under the Apache License, Version 2.0 (the + * "License"); you may not use this file except in compliance + * with the License. You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, + * software distributed under the License is distributed on an + * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY + * KIND, either express or implied. See the License for the + * specific language governing permissions and limitations + * under the License. + */ + +#ifndef TVM_RUNTIME_HEXAGON_ANDROID_HEXAGON_DEVICE_H_ +#define TVM_RUNTIME_HEXAGON_ANDROID_HEXAGON_DEVICE_H_ + +#include +#include + +#include +#include + +#include "../../meta_data.h" + +namespace tvm { +namespace runtime { +namespace hexagon { + +/*! + * \brief Low-level interface for communicating with Hexagon devices. + */ +class Device { + public: + /*! + * \brief Allocate memory on device. + * \param size Requested size. + * \param align Requested alignment. + * \return Pointer (local to the device) of the allocated memory, + * or nullptr if allocation failed. + */ + virtual void* Alloc(unsigned size, unsigned align) = 0; + /*! + * \brief Release allocated memory on device. + * \param ptr Pointer to memory previously allocated by \ref Alloc. + */ + virtual void Free(void* ptr) = 0; + /*! + * \brief Allocate VTCM memory on device. + * \param size Requested size. + * \param align Requested alignment. + * \return Pointer (local to the device) of the allocated memory, + * or nullptr if allocation failed. + */ + virtual void* AllocVtcm(unsigned size, unsigned align) = 0; + /*! + * \brief Release allocated VTCM memory on device. + * \param ptr Pointer to memory previously allocated by \ref AllocVtcm. + */ + virtual void FreeVtcm(void* ptr) = 0; + /*! + * \brief Copy a block of data on device to another location on the device. + * \param dst Pointer (local to device) to the destination buffer. + * \param src Pointer (local to device) of the source buffer. + * \param len Number of bytes to copy. + */ + virtual void CopyDeviceToDevice(void* dst, const void* src, unsigned len) = 0; + /*! + * \brief Copy a block of data from device to host. + * \param host_dst Pointer (local to host) to the destination buffer. + * \param src Pointer (local to device) to the source buffer. + * \param len Number of bytes to copy. + */ + virtual void CopyDeviceToHost(void* host_dst, const void* src, unsigned len) = 0; + /*! + * \brief Copy a block of data from host to device. + * \param dst Pointer (local to device) to the destination buffer. + * \param host_src Pointer (local to host) to the source buffer. + * \param len Number of bytes to copy. + */ + virtual void CopyHostToDevice(void* dst, const void* host_src, unsigned len) = 0; + /*! + * \brief Load a module (typically a shared library) into device. + * \param data Name of the shared library. + * \param fmt Format of the library (currently ignored). + * \return Pointer to the loaded module. + * \note Currently only one module can be loaded at any given time. + */ + virtual void* Load(const std::string& data, const std::string& fmt) = 0; + /*! + * \brief Unload a module from device. + * \param mod Pointer to a loaded module returned by \ref Load. + */ + virtual void Unload(void* mod) = 0; + /*! + * \brief Find the address of an object in the currently loaded module. + * \param sym Name of the object. + * \return Address of the located object, or nullptr if object was + * not found. + */ + virtual void* Resolve(const std::string& sym) = 0; + /*! + * \brief Invoke a function on device with given arguments. + * \param func Address (local to device) of the function to call. + * \param scalar Pointer to an array of 32-bit values that will be + * passed via consecutive registers: r0..r5. This array + * includes dummy values for skipped registers. + * \param sc_num Number of values in the "scalar" array. + * \param stack Pointer to an array of 32-bit values that will be + * passed on the stack. This array includes dummy values + * for padding. + * \param st_num Number of values in the "stack" array. + */ + virtual void Call(void* func, uint32_t* scalar, unsigned sc_num, uint32_t* stack, + unsigned st_num) = 0; + + virtual ~Device() = 0; + + static std::shared_ptr Global(); + static bool ValidateDeviceId(decltype(DLDevice::device_id) device_id) { + // Only supporting a single device for now. + return device_id == 0; + } +}; + +} // namespace hexagon + +} // namespace runtime +} // namespace tvm +#endif // TVM_RUNTIME_HEXAGON_ANDROID_HEXAGON_DEVICE_H_ diff --git a/src/runtime/hexagon/hexagon_device_api.cc b/src/runtime/hexagon/android/hexagon_device_api.cc similarity index 99% rename from src/runtime/hexagon/hexagon_device_api.cc rename to src/runtime/hexagon/android/hexagon_device_api.cc index a07a7c683026..ec50b4bf93a5 100644 --- a/src/runtime/hexagon/hexagon_device_api.cc +++ b/src/runtime/hexagon/android/hexagon_device_api.cc @@ -24,7 +24,7 @@ #include #include -#include "hexagon_module.h" +#include "hexagon_device.h" namespace tvm { namespace runtime { diff --git a/src/runtime/hexagon/hexagon_module.cc b/src/runtime/hexagon/android/hexagon_module.cc similarity index 99% rename from src/runtime/hexagon/hexagon_module.cc rename to src/runtime/hexagon/android/hexagon_module.cc index 41aa5855ceeb..e386daf7dc7c 100644 --- a/src/runtime/hexagon/hexagon_module.cc +++ b/src/runtime/hexagon/android/hexagon_module.cc @@ -17,7 +17,7 @@ * under the License. */ -#include "hexagon_module.h" +#include "../hexagon_module.h" #ifdef __ANDROID__ #include @@ -31,8 +31,8 @@ #include #include -#include "../file_utils.h" -#include "../meta_data.h" +#include "../../file_utils.h" +#include "hexagon_device.h" namespace tvm { namespace runtime { diff --git a/src/runtime/hexagon/hexagon_posix.cc b/src/runtime/hexagon/android/hexagon_posix.cc similarity index 100% rename from src/runtime/hexagon/hexagon_posix.cc rename to src/runtime/hexagon/android/hexagon_posix.cc diff --git a/src/runtime/hexagon/sim/driver/CMakeLists.txt b/src/runtime/hexagon/android/sim/driver/CMakeLists.txt similarity index 95% rename from src/runtime/hexagon/sim/driver/CMakeLists.txt rename to src/runtime/hexagon/android/sim/driver/CMakeLists.txt index dbac99534383..ddcec9169211 100644 --- a/src/runtime/hexagon/sim/driver/CMakeLists.txt +++ b/src/runtime/hexagon/android/sim/driver/CMakeLists.txt @@ -61,10 +61,10 @@ add_executable(sim_dev ${SOURCE_FILES}) target_include_directories(sim_dev PUBLIC "." PUBLIC ".." - PUBLIC "../../../../../include" + PUBLIC "../../../../../../include" ) target_include_directories(sim_dev SYSTEM - PUBLIC "../../../../../3rdparty/dlpack/include" + PUBLIC "../../../../../../3rdparty/dlpack/include" ) target_link_libraries(sim_dev "-ldl") diff --git a/src/runtime/hexagon/sim/driver/README.md b/src/runtime/hexagon/android/sim/driver/README.md similarity index 100% rename from src/runtime/hexagon/sim/driver/README.md rename to src/runtime/hexagon/android/sim/driver/README.md diff --git a/src/runtime/hexagon/sim/driver/fake_pthread.cc b/src/runtime/hexagon/android/sim/driver/fake_pthread.cc similarity index 100% rename from src/runtime/hexagon/sim/driver/fake_pthread.cc rename to src/runtime/hexagon/android/sim/driver/fake_pthread.cc diff --git a/src/runtime/hexagon/sim/driver/pthread.h b/src/runtime/hexagon/android/sim/driver/pthread.h similarity index 94% rename from src/runtime/hexagon/sim/driver/pthread.h rename to src/runtime/hexagon/android/sim/driver/pthread.h index 7ec74b4f99f5..b4d559c44f8e 100644 --- a/src/runtime/hexagon/sim/driver/pthread.h +++ b/src/runtime/hexagon/android/sim/driver/pthread.h @@ -17,8 +17,8 @@ * under the License. */ -#ifndef TVM_RUNTIME_HEXAGON_SIM_DRIVER_PTHREAD_H_ -#define TVM_RUNTIME_HEXAGON_SIM_DRIVER_PTHREAD_H_ +#ifndef TVM_RUNTIME_HEXAGON_ANDROID_SIM_DRIVER_PTHREAD_H_ +#define TVM_RUNTIME_HEXAGON_ANDROID_SIM_DRIVER_PTHREAD_H_ #define _PROVIDE_POSIX_TIME_DECLS 1 #include @@ -89,4 +89,4 @@ pthread_t pthread_self(void); } #endif -#endif // TVM_RUNTIME_HEXAGON_SIM_DRIVER_PTHREAD_H_ +#endif // TVM_RUNTIME_HEXAGON_ANDROID_SIM_DRIVER_PTHREAD_H_ diff --git a/src/runtime/hexagon/sim/driver/sched.h b/src/runtime/hexagon/android/sim/driver/sched.h similarity index 84% rename from src/runtime/hexagon/sim/driver/sched.h rename to src/runtime/hexagon/android/sim/driver/sched.h index cc63630f2072..621ef218b795 100644 --- a/src/runtime/hexagon/sim/driver/sched.h +++ b/src/runtime/hexagon/android/sim/driver/sched.h @@ -17,8 +17,8 @@ * under the License. */ -#ifndef TVM_RUNTIME_HEXAGON_SIM_DRIVER_SCHED_H_ -#define TVM_RUNTIME_HEXAGON_SIM_DRIVER_SCHED_H_ +#ifndef TVM_RUNTIME_HEXAGON_ANDROID_SIM_DRIVER_SCHED_H_ +#define TVM_RUNTIME_HEXAGON_ANDROID_SIM_DRIVER_SCHED_H_ #ifdef __cplusplus extern "C" { @@ -28,4 +28,4 @@ int sched_yield(void); } #endif -#endif // TVM_RUNTIME_HEXAGON_SIM_DRIVER_SCHED_H_ +#endif // TVM_RUNTIME_HEXAGON_ANDROID_SIM_DRIVER_SCHED_H_ diff --git a/src/runtime/hexagon/sim/driver/sim_device.cc b/src/runtime/hexagon/android/sim/driver/sim_device.cc similarity index 100% rename from src/runtime/hexagon/sim/driver/sim_device.cc rename to src/runtime/hexagon/android/sim/driver/sim_device.cc diff --git a/src/runtime/hexagon/sim/hexagon_device_sim.cc b/src/runtime/hexagon/android/sim/hexagon_device_sim.cc similarity index 99% rename from src/runtime/hexagon/sim/hexagon_device_sim.cc rename to src/runtime/hexagon/android/sim/hexagon_device_sim.cc index 14ab4c30e2f2..250259832597 100644 --- a/src/runtime/hexagon/sim/hexagon_device_sim.cc +++ b/src/runtime/hexagon/android/sim/hexagon_device_sim.cc @@ -32,7 +32,7 @@ #include #include -#include "../hexagon_module.h" +#include "../hexagon_device.h" #include "HexagonWrapper.h" #include "hexagon_sim_proto.h" @@ -121,7 +121,7 @@ struct non_const_str { ICHECK_EQ(pointers_.size(), 1); return pointers_[0]; } - operator char* *() { return pointers_.data(); } + operator char**() { return pointers_.data(); } private: std::vector pointers_; diff --git a/src/runtime/hexagon/sim/hexagon_sim_proto.h b/src/runtime/hexagon/android/sim/hexagon_sim_proto.h similarity index 90% rename from src/runtime/hexagon/sim/hexagon_sim_proto.h rename to src/runtime/hexagon/android/sim/hexagon_sim_proto.h index 2a41536037df..888752623262 100644 --- a/src/runtime/hexagon/sim/hexagon_sim_proto.h +++ b/src/runtime/hexagon/android/sim/hexagon_sim_proto.h @@ -17,8 +17,8 @@ * under the License. */ -#ifndef TVM_RUNTIME_HEXAGON_SIM_HEXAGON_SIM_PROTO_H_ -#define TVM_RUNTIME_HEXAGON_SIM_HEXAGON_SIM_PROTO_H_ +#ifndef TVM_RUNTIME_HEXAGON_ANDROID_SIM_HEXAGON_SIM_PROTO_H_ +#define TVM_RUNTIME_HEXAGON_ANDROID_SIM_HEXAGON_SIM_PROTO_H_ // Protocol: @@ -70,4 +70,4 @@ struct MsgCall { uint32_t data[]; // 12 } __attribute__((packed)); -#endif // TVM_RUNTIME_HEXAGON_SIM_HEXAGON_SIM_PROTO_H_ +#endif // TVM_RUNTIME_HEXAGON_ANDROID_SIM_HEXAGON_SIM_PROTO_H_ diff --git a/src/runtime/hexagon/target/fastrpc/CMakeLists.txt b/src/runtime/hexagon/android/target/fastrpc/CMakeLists.txt similarity index 100% rename from src/runtime/hexagon/target/fastrpc/CMakeLists.txt rename to src/runtime/hexagon/android/target/fastrpc/CMakeLists.txt diff --git a/src/runtime/hexagon/target/fastrpc/README.md b/src/runtime/hexagon/android/target/fastrpc/README.md similarity index 100% rename from src/runtime/hexagon/target/fastrpc/README.md rename to src/runtime/hexagon/android/target/fastrpc/README.md diff --git a/src/runtime/hexagon/target/fastrpc/include/tvm_remote.idl b/src/runtime/hexagon/android/target/fastrpc/include/tvm_remote.idl similarity index 100% rename from src/runtime/hexagon/target/fastrpc/include/tvm_remote.idl rename to src/runtime/hexagon/android/target/fastrpc/include/tvm_remote.idl diff --git a/src/runtime/hexagon/target/fastrpc/include/tvm_remote_nd.idl b/src/runtime/hexagon/android/target/fastrpc/include/tvm_remote_nd.idl similarity index 100% rename from src/runtime/hexagon/target/fastrpc/include/tvm_remote_nd.idl rename to src/runtime/hexagon/android/target/fastrpc/include/tvm_remote_nd.idl diff --git a/src/runtime/hexagon/target/fastrpc/src/tvm_hvx.cc b/src/runtime/hexagon/android/target/fastrpc/src/tvm_hvx.cc similarity index 100% rename from src/runtime/hexagon/target/fastrpc/src/tvm_hvx.cc rename to src/runtime/hexagon/android/target/fastrpc/src/tvm_hvx.cc diff --git a/src/runtime/hexagon/target/fastrpc/src/tvm_hvx.h b/src/runtime/hexagon/android/target/fastrpc/src/tvm_hvx.h similarity index 95% rename from src/runtime/hexagon/target/fastrpc/src/tvm_hvx.h rename to src/runtime/hexagon/android/target/fastrpc/src/tvm_hvx.h index 2fe947574bbb..3d14252ad648 100644 --- a/src/runtime/hexagon/target/fastrpc/src/tvm_hvx.h +++ b/src/runtime/hexagon/android/target/fastrpc/src/tvm_hvx.h @@ -17,8 +17,8 @@ * under the License. */ -#ifndef TVM_RUNTIME_HEXAGON_TARGET_FASTRPC_SRC_TVM_HVX_H_ -#define TVM_RUNTIME_HEXAGON_TARGET_FASTRPC_SRC_TVM_HVX_H_ +#ifndef TVM_RUNTIME_HEXAGON_ANDROID_TARGET_FASTRPC_SRC_TVM_HVX_H_ +#define TVM_RUNTIME_HEXAGON_ANDROID_TARGET_FASTRPC_SRC_TVM_HVX_H_ // Utility providing functions for accessing the Hexagon Vector Extensions // (HVX) hardware. @@ -150,4 +150,4 @@ int cleanup_mt_job(const config_t* hvx_config); } // namespace hvx -#endif // TVM_RUNTIME_HEXAGON_TARGET_FASTRPC_SRC_TVM_HVX_H_ +#endif // TVM_RUNTIME_HEXAGON_ANDROID_TARGET_FASTRPC_SRC_TVM_HVX_H_ diff --git a/src/runtime/hexagon/target/fastrpc/src/tvm_remote_imp.cc b/src/runtime/hexagon/android/target/fastrpc/src/tvm_remote_imp.cc similarity index 100% rename from src/runtime/hexagon/target/fastrpc/src/tvm_remote_imp.cc rename to src/runtime/hexagon/android/target/fastrpc/src/tvm_remote_imp.cc diff --git a/src/runtime/hexagon/target/fastrpc/src/tvm_remote_nd_imp.cc b/src/runtime/hexagon/android/target/fastrpc/src/tvm_remote_nd_imp.cc similarity index 100% rename from src/runtime/hexagon/target/fastrpc/src/tvm_remote_nd_imp.cc rename to src/runtime/hexagon/android/target/fastrpc/src/tvm_remote_nd_imp.cc diff --git a/src/runtime/hexagon/target/fastrpc/src/tvm_wrap_pthread.cc b/src/runtime/hexagon/android/target/fastrpc/src/tvm_wrap_pthread.cc similarity index 100% rename from src/runtime/hexagon/target/fastrpc/src/tvm_wrap_pthread.cc rename to src/runtime/hexagon/android/target/fastrpc/src/tvm_wrap_pthread.cc diff --git a/src/runtime/hexagon/target/hexagon_device_target.cc b/src/runtime/hexagon/android/target/hexagon_device_target.cc similarity index 99% rename from src/runtime/hexagon/target/hexagon_device_target.cc rename to src/runtime/hexagon/android/target/hexagon_device_target.cc index ee326ca0b159..a542c5a3e3a2 100644 --- a/src/runtime/hexagon/target/hexagon_device_target.cc +++ b/src/runtime/hexagon/android/target/hexagon_device_target.cc @@ -27,7 +27,7 @@ #include #include -#include "../hexagon_module.h" +#include "../hexagon_device.h" #include "AEEStdErr.h" #include "fastrpc/include/tvm_remote.h" #include "hexagon_dsprpcapi.h" diff --git a/src/runtime/hexagon/target/hexagon_dsprpcapi.cc b/src/runtime/hexagon/android/target/hexagon_dsprpcapi.cc similarity index 100% rename from src/runtime/hexagon/target/hexagon_dsprpcapi.cc rename to src/runtime/hexagon/android/target/hexagon_dsprpcapi.cc diff --git a/src/runtime/hexagon/target/hexagon_dsprpcapi.h b/src/runtime/hexagon/android/target/hexagon_dsprpcapi.h similarity index 96% rename from src/runtime/hexagon/target/hexagon_dsprpcapi.h rename to src/runtime/hexagon/android/target/hexagon_dsprpcapi.h index e4711e3da584..a3d186e302e3 100644 --- a/src/runtime/hexagon/target/hexagon_dsprpcapi.h +++ b/src/runtime/hexagon/android/target/hexagon_dsprpcapi.h @@ -17,8 +17,8 @@ * under the License. */ -#ifndef TVM_RUNTIME_HEXAGON_TARGET_HEXAGON_DSPRPCAPI_H_ -#define TVM_RUNTIME_HEXAGON_TARGET_HEXAGON_DSPRPCAPI_H_ +#ifndef TVM_RUNTIME_HEXAGON_ANDROID_TARGET_HEXAGON_DSPRPCAPI_H_ +#define TVM_RUNTIME_HEXAGON_ANDROID_TARGET_HEXAGON_DSPRPCAPI_H_ #ifdef __ANDROID__ #include @@ -189,4 +189,4 @@ class DspRpcAPI { } // namespace tvm #endif // __ANDROID__ -#endif // TVM_RUNTIME_HEXAGON_TARGET_HEXAGON_DSPRPCAPI_H_ +#endif // TVM_RUNTIME_HEXAGON_ANDROID_TARGET_HEXAGON_DSPRPCAPI_H_ diff --git a/src/runtime/hexagon/target/hexagon_stubapi.cc b/src/runtime/hexagon/android/target/hexagon_stubapi.cc similarity index 100% rename from src/runtime/hexagon/target/hexagon_stubapi.cc rename to src/runtime/hexagon/android/target/hexagon_stubapi.cc diff --git a/src/runtime/hexagon/target/hexagon_stubapi.h b/src/runtime/hexagon/android/target/hexagon_stubapi.h similarity index 98% rename from src/runtime/hexagon/target/hexagon_stubapi.h rename to src/runtime/hexagon/android/target/hexagon_stubapi.h index fba22b10247c..feb329f5cef2 100644 --- a/src/runtime/hexagon/target/hexagon_stubapi.h +++ b/src/runtime/hexagon/android/target/hexagon_stubapi.h @@ -17,8 +17,8 @@ * under the License. */ -#ifndef TVM_RUNTIME_HEXAGON_TARGET_HEXAGON_STUBAPI_H_ -#define TVM_RUNTIME_HEXAGON_TARGET_HEXAGON_STUBAPI_H_ +#ifndef TVM_RUNTIME_HEXAGON_ANDROID_TARGET_HEXAGON_STUBAPI_H_ +#define TVM_RUNTIME_HEXAGON_ANDROID_TARGET_HEXAGON_STUBAPI_H_ #ifdef __ANDROID__ #include @@ -312,4 +312,4 @@ class StubAPI { } // namespace tvm #endif // __ANDROID__ -#endif // TVM_RUNTIME_HEXAGON_TARGET_HEXAGON_STUBAPI_H_ +#endif // TVM_RUNTIME_HEXAGON_ANDROID_TARGET_HEXAGON_STUBAPI_H_ diff --git a/src/runtime/hexagon/target/hexagon_target_log.h b/src/runtime/hexagon/android/target/hexagon_target_log.h similarity index 87% rename from src/runtime/hexagon/target/hexagon_target_log.h rename to src/runtime/hexagon/android/target/hexagon_target_log.h index c7684fc56197..f8ba6a74e3b9 100644 --- a/src/runtime/hexagon/target/hexagon_target_log.h +++ b/src/runtime/hexagon/android/target/hexagon_target_log.h @@ -17,8 +17,8 @@ * under the License. */ -#ifndef TVM_RUNTIME_HEXAGON_TARGET_HEXAGON_TARGET_LOG_H_ -#define TVM_RUNTIME_HEXAGON_TARGET_HEXAGON_TARGET_LOG_H_ +#ifndef TVM_RUNTIME_HEXAGON_ANDROID_TARGET_HEXAGON_TARGET_LOG_H_ +#define TVM_RUNTIME_HEXAGON_ANDROID_TARGET_HEXAGON_TARGET_LOG_H_ #ifdef __ANDROID__ #include @@ -31,4 +31,4 @@ #define TVM_LOGF(...) __android_log_print(ANDROID_LOG_FATAL, "TVM", ##__VA_ARGS__) #endif // __ANDROID__ -#endif // TVM_RUNTIME_HEXAGON_TARGET_HEXAGON_TARGET_LOG_H_ +#endif // TVM_RUNTIME_HEXAGON_ANDROID_TARGET_HEXAGON_TARGET_LOG_H_ diff --git a/src/runtime/hexagon/hexagon_module.h b/src/runtime/hexagon/hexagon_module.h index 1288b933410c..887d9bb30ecb 100644 --- a/src/runtime/hexagon/hexagon_module.h +++ b/src/runtime/hexagon/hexagon_module.h @@ -50,107 +50,6 @@ Module HexagonModuleCreate(std::string data, std::string fmt, std::unordered_map fmap, std::string asm_str, std::string obj_str, std::string ir_str, std::string bc_str, const std::set& packed_c_abi); - -namespace hexagon { - -/*! - * \brief Low-level interface for communicating with Hexagon devices. - */ -class Device { - public: - /*! - * \brief Allocate memory on device. - * \param size Requested size. - * \param align Requested alignment. - * \return Pointer (local to the device) of the allocated memory, - * or nullptr if allocation failed. - */ - virtual void* Alloc(unsigned size, unsigned align) = 0; - /*! - * \brief Release allocated memory on device. - * \param ptr Pointer to memory previously allocated by \ref Alloc. - */ - virtual void Free(void* ptr) = 0; - /*! - * \brief Allocate VTCM memory on device. - * \param size Requested size. - * \param align Requested alignment. - * \return Pointer (local to the device) of the allocated memory, - * or nullptr if allocation failed. - */ - virtual void* AllocVtcm(unsigned size, unsigned align) = 0; - /*! - * \brief Release allocated VTCM memory on device. - * \param ptr Pointer to memory previously allocated by \ref AllocVtcm. - */ - virtual void FreeVtcm(void* ptr) = 0; - /*! - * \brief Copy a block of data on device to another location on the device. - * \param dst Pointer (local to device) to the destination buffer. - * \param src Pointer (local to device) of the source buffer. - * \param len Number of bytes to copy. - */ - virtual void CopyDeviceToDevice(void* dst, const void* src, unsigned len) = 0; - /*! - * \brief Copy a block of data from device to host. - * \param host_dst Pointer (local to host) to the destination buffer. - * \param src Pointer (local to device) to the source buffer. - * \param len Number of bytes to copy. - */ - virtual void CopyDeviceToHost(void* host_dst, const void* src, unsigned len) = 0; - /*! - * \brief Copy a block of data from host to device. - * \param dst Pointer (local to device) to the destination buffer. - * \param host_src Pointer (local to host) to the source buffer. - * \param len Number of bytes to copy. - */ - virtual void CopyHostToDevice(void* dst, const void* host_src, unsigned len) = 0; - /*! - * \brief Load a module (typically a shared library) into device. - * \param data Name of the shared library. - * \param fmt Format of the library (currently ignored). - * \return Pointer to the loaded module. - * \note Currently only one module can be loaded at any given time. - */ - virtual void* Load(const std::string& data, const std::string& fmt) = 0; - /*! - * \brief Unload a module from device. - * \param mod Pointer to a loaded module returned by \ref Load. - */ - virtual void Unload(void* mod) = 0; - /*! - * \brief Find the address of an object in the currently loaded module. - * \param sym Name of the object. - * \return Address of the located object, or nullptr if object was - * not found. - */ - virtual void* Resolve(const std::string& sym) = 0; - /*! - * \brief Invoke a function on device with given arguments. - * \param func Address (local to device) of the function to call. - * \param scalar Pointer to an array of 32-bit values that will be - * passed via consecutive registers: r0..r5. This array - * includes dummy values for skipped registers. - * \param sc_num Number of values in the "scalar" array. - * \param stack Pointer to an array of 32-bit values that will be - * passed on the stack. This array includes dummy values - * for padding. - * \param st_num Number of values in the "stack" array. - */ - virtual void Call(void* func, uint32_t* scalar, unsigned sc_num, uint32_t* stack, - unsigned st_num) = 0; - - virtual ~Device() = 0; - - static std::shared_ptr Global(); - static bool ValidateDeviceId(decltype(DLDevice::device_id) device_id) { - // Only supporting a single device for now. - return device_id == 0; - } -}; - -} // namespace hexagon - } // namespace runtime } // namespace tvm #endif // TVM_RUNTIME_HEXAGON_HEXAGON_MODULE_H_