Skip to content

Commit 26cf77c

Browse files
committed
[Hexagon] Add support for v75
Add support for executing v75 (Snapdragon 8 gen 3). This PR just adds the support, but to build and execute for v75, the Hexagon SDK used should be 5.4+.
1 parent 4a5e22e commit 26cf77c

File tree

8 files changed

+36
-19
lines changed

8 files changed

+36
-19
lines changed

apps/hexagon_launcher/README.md

Lines changed: 8 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -43,10 +43,10 @@ Create a subdirectory for the build files, and run `cmake` with the
4343
following variables set:
4444

4545
```
46-
cmake -DCMAKE_C_COMPILER=/path/to/hexagon-clang \
47-
-DCMAKE_CXX_COMPILER=/path/to/hexagon-clang++ \
48-
-DUSE_HEXAGON_ARCH=v65|v66|v68|v69|v73 \
49-
-DUSE_HEXAGON_SDK=/path/to/hexagon/SDK \
46+
cmake -DCMAKE_C_COMPILER=/path/to/hexagon-clang \
47+
-DCMAKE_CXX_COMPILER=/path/to/hexagon-clang++ \
48+
-DUSE_HEXAGON_ARCH=v65|v66|v68|v69|v73|v75 \
49+
-DUSE_HEXAGON_SDK=/path/to/hexagon/SDK \
5050
/path/to/apps/hexagon_launcher/cmake/hexagon
5151
```
5252

@@ -60,10 +60,10 @@ the TVM runtime for Hexagon will be built as a part of the process.
6060

6161
```
6262
cmake -DCMAKE_TOOLCHAIN_FILE=/path/to/android-ndk/build/cmake/android.toolchain.cmake \
63-
-DANDROID_ABI=arm64-v8a \
64-
-DANDROID_PLATFORM=android-28 \
65-
-DUSE_HEXAGON_SDK=/p/Hexagon_SDK/4.3.0.0 \
66-
-DUSE_HEXAGON_ARCH=v65|v66|v68|v69|v73 \
63+
-DANDROID_ABI=arm64-v8a \
64+
-DANDROID_PLATFORM=android-28 \
65+
-DUSE_HEXAGON_SDK=/p/Hexagon_SDK/4.3.0.0 \
66+
-DUSE_HEXAGON_ARCH=v65|v66|v68|v69|v73|v75 \
6767
/path/to/apps/hexagon_launcher/cmake/android
6868
```
6969

cmake/config.cmake

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -367,7 +367,7 @@ set(USE_HEXAGON_RPC OFF)
367367
# compiling _by_ TVM). This applies to components like the TVM runtime, but is
368368
# also used to select correct include/library paths from the Hexagon SDK when
369369
# building runtime for Android.
370-
# Valid values are v65, v66, v68, v69, v73.
370+
# Valid values are v65, v66, v68, v69, v73, v75.
371371
set(USE_HEXAGON_ARCH "v68")
372372

373373
# Whether use MRVL codegen

cmake/modules/HexagonSDK.cmake

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -109,11 +109,12 @@ function(_get_hexagon_sdk_property_impl
109109
set(_hexarch_dir_v68 "computev68")
110110
set(_hexarch_dir_v69 "computev69")
111111
set(_hexarch_dir_v73 "computev73")
112+
set(_hexarch_dir_v75 "computev75")
112113
set(_hexarch_dir_str "_hexarch_dir_${_hexagon_arch}")
113114
set(_hexarch_dir "${${_hexarch_dir_str}}")
114115

115116
if(NOT _hexarch_dir)
116-
message(SEND_ERROR "Please set Hexagon architecture to one of v65, v66, v68, v69, v73")
117+
message(SEND_ERROR "Please set Hexagon architecture to one of v65, v66, v68, v69, v73, v75")
117118
endif()
118119

119120
if(_property STREQUAL "VERSION")
@@ -160,6 +161,9 @@ function(_get_hexagon_sdk_property_impl
160161
elseif(_property STREQUAL "QURT_INCLUDE")
161162
# Set the Hexagon arch directory for runtime linker.
162163
set(_rtld_dir "hexagon_toolv84_${_hexagon_arch}")
164+
if(_hexagon_arch STREQUAL "v75")
165+
set(_rtld_dir "hexagon_toolv87_v75") # Use hexagon_toolv87_v75 for v75
166+
endif()
163167
if(_hexagon_arch STREQUAL "v69")
164168
set(_rtld_dir "hexagon_toolv84_v68") # Use hexagon_toolv84_v68 for v69
165169
endif()

python/tvm/contrib/hexagon/session.py

Lines changed: 10 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -286,7 +286,9 @@ def get_graph_debug_executor(
286286
graph_json, graph_debug_mod, self.device, dump_root=str(dump_root)
287287
)
288288

289-
def get_executor_from_factory(self, module: Union[ExecutorFactoryModule, relax.Executable]):
289+
def get_executor_from_factory(
290+
self, module: Union[ExecutorFactoryModule, relax.Executable], hexagon_arch: str = "v68"
291+
):
290292
"""Create a local GraphModule which consumes a remote libmod.
291293
292294
Parameters
@@ -296,13 +298,15 @@ def get_executor_from_factory(self, module: Union[ExecutorFactoryModule, relax.E
296298
297299
The module to upload to the remote
298300
session and load.
301+
hexagon_arch : str
302+
The hexagon arch to be used
299303
"""
300304
if isinstance(module, AOTExecutorFactoryModule):
301305
return self._aot_executor_from_factory(module)
302306
if isinstance(module, GraphExecutorFactoryModule):
303307
return self._graph_executor_from_factory(module)
304308
if isinstance(module, relax.Executable):
305-
return self._relax_vm_executable_executor(module)
309+
return self._relax_vm_executable_executor(module, hexagon_arch=hexagon_arch)
306310

307311
raise TypeError(f"Unsupported executor type: {type(module)}")
308312

@@ -354,7 +358,7 @@ def _graph_executor_from_factory(
354358
"""
355359
return self.get_graph_executor(module.get_graph_json(), module.get_lib())
356360

357-
def _relax_vm_executable_executor(self, vm_exec: relax.Executable):
361+
def _relax_vm_executable_executor(self, vm_exec: relax.Executable, hexagon_arch: str):
358362
"""Create a local TVM module which consumes a remote vm executable.
359363
360364
Paramters
@@ -363,7 +367,8 @@ def _relax_vm_executable_executor(self, vm_exec: relax.Executable):
363367
vm_exec : relax.Executable
364368
The Relax VM Executable to upload to the remote and load. This will typically be the
365369
output of `relax.build`.
366-
370+
hexagon_arch : str
371+
The hexagon arch to be used
367372
Returns
368373
-------
369374
TVMModule :
@@ -377,7 +382,7 @@ def _relax_vm_executable_executor(self, vm_exec: relax.Executable):
377382
vm_exec.mod.export_library(
378383
path_exec,
379384
fcompile=hexagon.create_aot_shared,
380-
hexagon_arch="v68",
385+
hexagon_arch=hexagon_arch,
381386
)
382387

383388
path = self.upload(path_exec, "exec.so")

python/tvm/target/target.py

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -715,7 +715,7 @@ def get_arch_version(cpu_ver):
715715
return int(m.group(1))
716716

717717
# Check for valid codegen cpu
718-
valid_hex = ["v65", "v66", "v67", "v67t", "v68", "v69", "v71", "v73"]
718+
valid_hex = ["v65", "v66", "v67", "v67t", "v68", "v69", "v71", "v73", "v75"]
719719
try:
720720
cpu_ver = cpu_ver[cpu_ver.index("v") :].lower()
721721
assert cpu_ver in valid_hex
@@ -731,6 +731,7 @@ def get_vtcm_capacity(cpu_ver):
731731
"v68": 4 * one_mb,
732732
"v69": 8 * one_mb,
733733
"v73": 8 * one_mb,
734+
"v75": 8 * one_mb,
734735
}
735736
return default_vtcm_sizes.get(cpu_ver, 0)
736737

src/runtime/hexagon/README.md

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -54,7 +54,7 @@ ANDROID_ABI=aarch64-v8a
5454
ANDROID_PLATFORM=android-28
5555
CMAKE_TOOLCHAIN_FILE=/path/to/android-ndk/build/cmake/android.toolchain.cmake
5656
USE_HEXAGON=ON
57-
USE_HEXAGON_ARCH=v65|v66|v68|v69|v73
57+
USE_HEXAGON_ARCH=v65|v66|v68|v69|v73|v75
5858
USE_HEXAGON_SDK=/path/to/sdk
5959
```
6060

@@ -63,7 +63,7 @@ Building for Hexagon requires setting the C/C++ compiler to `hexagon-clang/++`:
6363
CMAKE_C_COMPILER=hexagon-clang
6464
CMAKE_CXX_COMPILER=hexagon-clang++
6565
USE_HEXAGON=ON
66-
USE_HEXAGON_ARCH=v65|v66|v68|v69|v73
66+
USE_HEXAGON_ARCH=v65|v66|v68|v69|v73|v75
6767
USE_HEXAGON_SDK=/path/to/sdk
6868
USE_RPC=OFF
6969
USE_LIBBACKTRACE=OFF

src/runtime/hexagon/rpc/simulator/session.cc

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -457,6 +457,10 @@ std::string SimulatorRPCChannel::Cpu_::str() const {
457457
#ifdef HEX_CPU_ID_V73NA_1
458458
case HEX_CPU_V73:
459459
return "v73";
460+
#endif
461+
#ifdef HEX_CPU_ID_V75NA_1
462+
case HEX_CPU_V75:
463+
return "v75";
460464
#endif
461465
default:
462466
break;
@@ -574,6 +578,9 @@ std::optional<HEXAPI_Cpu> SimulatorRPCChannel::GetCPU(const detail::MaybeString&
574578
#endif
575579
#ifdef HEX_CPU_ID_V73NA_1
576580
.Case("v73", HEX_CPU_V73)
581+
#endif
582+
#ifdef HEX_CPU_ID_V75NA_1
583+
.Case("v75", HEX_CPU_V75)
577584
#endif
578585
.Default(std::nullopt);
579586
}

tests/python/contrib/test_hexagon/README.md

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -49,7 +49,7 @@ cd build
4949
cmake -DANDROID_ABI=arm64-v8a \
5050
-DANDROID_PLATFORM=android-28 \
5151
-DUSE_ANDROID_TOOLCHAIN="path to `android-ndk/build/cmake/android.toolchain.cmake` file" \
52-
-DUSE_HEXAGON_ARCH=v65|v66|v68|v69|v73 \
52+
-DUSE_HEXAGON_ARCH=v65|v66|v68|v69|v73|v75 \
5353
-DUSE_HEXAGON_SDK="path to Hexagon SDK" \
5454
-DUSE_HEXAGON_TOOLCHAIN="path to Hexagon toolchain `Tools` sub-directory which explained above" \
5555
-DUSE_OUTPUT_BINARY_DIR="path to `build/hexagon_api_output` which is a sub-directory of `tvm`" ..

0 commit comments

Comments
 (0)