@@ -78,10 +78,13 @@ endif()
7878#
7979# USE_HEXAGON_RPC:
8080# - When building for Hexagon, this will build the Hexagon endpoint of the
81- # RPC server: the FastRPC skel library (with TVM runtime built into it).
81+ # RPC server: the FastRPC skel library (with TVM runtime built into it),
82+ # and the standalone RPC server for simulator.
8283# - When building for Android, this will build the (intermediary) RPC server,
8384# including the "stub" code for the FastRPC implementation of the RPC
8485# channel.
86+ # - When building for x86, this will build the host-side code that instan-
87+ # tiates the simulator.
8588
8689if (NOT BUILD_FOR_HEXAGON AND NOT BUILD_FOR_ANDROID)
8790 set (BUILD_FOR_HOST TRUE )
@@ -116,6 +119,15 @@ function(add_android_paths)
116119 link_directories (${HEXAGON_REMOTE_ROOT} )
117120endfunction ()
118121
122+ function (add_hexagon_wrapper_paths )
123+ if (NOT DEFINED HEXAGON_TOOLCHAIN)
124+ message (FATAL_ERROR "This function must be called after find_hexagon_toolchain" )
125+ endif ()
126+ include_directories (SYSTEM
127+ "${HEXAGON_TOOLCHAIN} /include/iss"
128+ )
129+ link_directories ("${HEXAGON_TOOLCHAIN} /lib/iss" )
130+ endfunction ()
119131
120132# Common sources for TVM runtime with Hexagon support
121133file_glob_append (RUNTIME_HEXAGON_COMMON_SRCS
@@ -148,12 +160,11 @@ if(USE_HEXAGON_DEVICE)
148160 invalid_device_value_for ("host" )
149161 endif ()
150162 find_hexagon_toolchain ()
163+ add_hexagon_wrapper_paths ()
151164 file_glob_append (RUNTIME_HEXAGON_SRCS
152165 "${TVMRT_SOURCE_DIR } /hexagon/android/*.cc"
153166 "${TVMRT_SOURCE_DIR } /hexagon/android/sim/*.cc"
154167 )
155- include_directories (SYSTEM "${HEXAGON_TOOLCHAIN} /include/iss" )
156- link_directories ("${HEXAGON_TOOLCHAIN} /lib/iss" )
157168 list (APPEND TVM_RUNTIME_LINKER_LIBS "-lwrapper" )
158169
159170 ExternalProject_Add (sim_dev
@@ -245,6 +256,23 @@ if(USE_HEXAGON_RPC)
245256 target_include_directories (hexagon_rpc_skel
246257 SYSTEM PRIVATE "${TVMRT_SOURCE_DIR } /hexagon/rpc"
247258 )
259+ # Add the simulator-specific RPC code into a shared library to be
260+ # executed via run_main_on_sim.
261+ add_library (hexagon_rpc_sim SHARED
262+ "${TVMRT_SOURCE_DIR } /hexagon/rpc/simulator/rpc_server.cc"
263+ )
264+ target_link_libraries (hexagon_rpc_sim
265+ -Wl,--whole-archive tvm_runtime -Wl,--no-whole-archive
266+ )
267+
268+ elseif (BUILD_FOR_HOST)
269+ find_hexagon_toolchain ()
270+ add_hexagon_wrapper_paths ()
271+ file_glob_append (RUNTIME_HEXAGON_SRCS
272+ "${TVMRT_SOURCE_DIR } /hexagon/host/*.cc"
273+ "${TVMRT_SOURCE_DIR } /hexagon/rpc/simulator/session.cc"
274+ )
275+ list (APPEND TVM_RUNTIME_LINKER_LIBS "-lwrapper" )
248276 endif ()
249277endif () # USE_HEXAGON_RPC
250278
0 commit comments