From 77b5dc3b5609c12797f5b35c621c7dd23fe1dccf Mon Sep 17 00:00:00 2001 From: Fabian schuetze Date: Tue, 16 Apr 2024 16:30:02 +0200 Subject: [PATCH 1/3] forward hvx_128 instruction target --- apps/blur/Makefile | 2 +- apps/blur/halide_blur_generator.cpp | 2 -- 2 files changed, 1 insertion(+), 3 deletions(-) diff --git a/apps/blur/Makefile b/apps/blur/Makefile index d23d5608f6f9..a953edc5a0ef 100644 --- a/apps/blur/Makefile +++ b/apps/blur/Makefile @@ -11,7 +11,7 @@ $(GENERATOR_BIN)/halide_blur.generator: halide_blur_generator.cpp $(GENERATOR_DE $(BIN)/%/halide_blur.a: $(GENERATOR_BIN)/halide_blur.generator @mkdir -p $(@D) - $^ -g halide_blur -e $(GENERATOR_OUTPUTS) -o $(@D) target=$* + $^ -g halide_blur -e $(GENERATOR_OUTPUTS) -o $(@D) target=$(HL_TARGET) # g++ on OS X might actually be system clang without openmp CXX_VERSION=$(shell $(CXX) --version) diff --git a/apps/blur/halide_blur_generator.cpp b/apps/blur/halide_blur_generator.cpp index c3fd5009689e..30205f6ace49 100644 --- a/apps/blur/halide_blur_generator.cpp +++ b/apps/blur/halide_blur_generator.cpp @@ -86,8 +86,6 @@ class HalideBlur : public Halide::Generator { const int vector_size = 128; blur_y.compute_root() - .hexagon() - .prefetch(input, y, y, 2) .split(y, y, yi, 128) .parallel(y) .vectorize(x, vector_size * 2); From 1092532916f55be0f00e2d76f8adfd2f09af7edf Mon Sep 17 00:00:00 2001 From: Fabian schuetze Date: Sat, 20 Apr 2024 15:24:36 +0200 Subject: [PATCH 2/3] use HL_TARGET as generator, and expand Makefile definitions --- apps/blur/Makefile | 2 +- apps/blur/adb_run_on_device.sh | 23 ++++++++++------------- apps/support/Makefile.inc | 8 ++++++++ 3 files changed, 19 insertions(+), 14 deletions(-) diff --git a/apps/blur/Makefile b/apps/blur/Makefile index a953edc5a0ef..d23d5608f6f9 100644 --- a/apps/blur/Makefile +++ b/apps/blur/Makefile @@ -11,7 +11,7 @@ $(GENERATOR_BIN)/halide_blur.generator: halide_blur_generator.cpp $(GENERATOR_DE $(BIN)/%/halide_blur.a: $(GENERATOR_BIN)/halide_blur.generator @mkdir -p $(@D) - $^ -g halide_blur -e $(GENERATOR_OUTPUTS) -o $(@D) target=$(HL_TARGET) + $^ -g halide_blur -e $(GENERATOR_OUTPUTS) -o $(@D) target=$* # g++ on OS X might actually be system clang without openmp CXX_VERSION=$(shell $(CXX) --version) diff --git a/apps/blur/adb_run_on_device.sh b/apps/blur/adb_run_on_device.sh index 9f6cf392a529..ce319a1433c3 100755 --- a/apps/blur/adb_run_on_device.sh +++ b/apps/blur/adb_run_on_device.sh @@ -10,27 +10,24 @@ DEVICE_ENV="LD_LIBRARY_PATH=${DEVICE_PATH}:/vendor/lib64 ADSP_LIBRARY_PATH=\"${D HEXAGON_RUNTIME_PATH=../../src/runtime/hexagon_remote BIN=bin -#TODO: It would be nice to just use HL_TARGET, but that means one -#cannot enable extra target features without jumping through hoops. If -#we had a way to extra the 'base target' from an HL_TARGET environment -#variable... -APP_TARGET=arm-64-android - # Build the app. -make bin/${APP_TARGET}/test +make bin/${HL_TARGET}/test # Make a folder on device for the app and our dependencies. adb shell mkdir -p ${DEVICE_PATH} # Push the Hexagon runtime to $DEVICE_PATH. -adb push ${HEXAGON_RUNTIME_PATH}/bin/${APP_TARGET}/libhalide_hexagon_host.so ${DEVICE_PATH} -adb push ${HEXAGON_RUNTIME_PATH}/bin/v60/signed_by_debug/libhalide_hexagon_remote_skel.so ${DEVICE_PATH} +if [[ "$HL_TARGET" == *"-hvx"* ]]; then + RUNTIME=${HL_TARGET%%-hvx*} + adb push ${HEXAGON_RUNTIME_PATH}/bin/${RUNTIME}/libhalide_hexagon_host.so ${DEVICE_PATH} + adb push ${HEXAGON_RUNTIME_PATH}/bin/v60/signed_by_debug/libhalide_hexagon_remote_skel.so ${DEVICE_PATH} -# If there's a testsig installed in the usual location, copy it to -# $DEVICE_PATH so it is visible to our modified $ASDP_LIBRARY_PATH. -adb shell cp /system/lib/rfsa/adsp/testsig* ${DEVICE_PATH} > /dev/null || true + # If there's a testsig installed in the usual location, copy it to + # $DEVICE_PATH so it is visible to our modified $ASDP_LIBRARY_PATH. + adb shell cp /system/lib/rfsa/adsp/testsig* ${DEVICE_PATH} > /dev/null || true +fi # Push and run the app! -adb push ${BIN}/${APP_TARGET}/test ${DEVICE_PATH} +adb push ${BIN}/${HL_TARGET}/test ${DEVICE_PATH} adb shell chmod +x ${DEVICE_PATH}/test adb shell ${DEVICE_ENV} ${DEVICE_PATH}/test diff --git a/apps/support/Makefile.inc b/apps/support/Makefile.inc index 0611a6806c6e..754d9d0a0125 100644 --- a/apps/support/Makefile.inc +++ b/apps/support/Makefile.inc @@ -122,6 +122,8 @@ CXX-host-hvx ?= $(CXX) CXX-hexagon-32-qurt-hvx ?= hexagon-clang++ CXX-arm-64-android ?= ${ANDROID_NDK_ROOT}/toolchains/llvm/prebuilt/${ANDROID_NDK_HOST_PLATFORM}-x86_64/bin/aarch64-linux-android${ANDROID_API_VERSION}-clang++ CXX-arm-64-android-arm_dot_prod ?= $(CXX-arm-64-android) +CXX-arm-64-android-hvx ?= $(CXX-arm-64-android) +CXX-arm-64-android-hvx_128 ?= $(CXX-arm-64-android) CXX-arm-32-android ?= ${ANDROID_NDK_ROOT}/toolchains/llvm/prebuilt/${ANDROID_NDK_HOST_PLATFORM}-x86_64/bin/armv7a-linux-androideabi${ANDROID_API_VERSION}-clang++ CXX-arm-64-profile-android ?= $(CXX-arm-64-android) CXX-arm-32-profile-android ?= $(CXX-arm-32-android) @@ -132,6 +134,8 @@ CXXFLAGS-host-cuda ?= $(CXXFLAGS) CXXFLAGS-host-metal ?= $(CXXFLAGS) CXXFLAGS-arm-64-android ?= $(CXXFLAGS) CXXFLAGS-arm-64-android-arm_dot_prod ?= $(CXXFLAGS-arm-64-android) +CXXFLAGS-arm-64-android-hvx ?= $(CXXFLAGS-arm-64-android) +CXXFLAGS-arm-64-android-hvx_128 ?= $(CXXFLAGS-arm-64-android) CXXFLAGS-hexagon-32-qurt-hvx ?= -mv65 $(CXXFLAGS) -I$(HEXAGON_SDK_ROOT)/rtos/qurt/computev65/include/qurt -I$(HEXAGON_SDK_ROOT)/rtos/qurt/computev65/include/posix CXXFLAGS-arm-32-android ?= $(CXXFLAGS) @@ -144,6 +148,8 @@ AR-host-hvx ?= $(AR) AR-hexagon-32-qurt-hvx ?= ar AR-arm-64-android ?= ${ANDROID_NDK_ROOT}/toolchains/llvm/prebuilt/${ANDROID_NDK_HOST_PLATFORM}-x86_64/bin/llvm-ar AR-arm-64-android-arm_dot_prod ?= $(AR-arm-64-android) +AR-arm-64-android-hvx ?= $(AR-arm-64-android) +AR-arm-64-android-hvx_128 ?= $(AR-arm-64-android) AR-arm-32-android ?= ${ANDROID_NDK_ROOT}/toolchains/llvm/prebuilt/${ANDROID_NDK_HOST_PLATFORM}-x86_64/bin/armv7a-linux-androideabi-ar AR-arm-64-profile-android ?= $(AR-arm-64-android) AR-arm-32-profile-android ?= $(AR-arm-32-android) @@ -158,6 +164,8 @@ LDFLAGS-hexagon-32-qurt-hvx = # of deployment. (Despite the name, this applies to libc++, not libstdc++) LDFLAGS-arm-64-android ?= -llog -fPIE -pie -static-libstdc++ LDFLAGS-arm-64-android-arm_dot_prod ?= $(LDFLAGS-arm-64-android) +LDFLAGS-arm-64-android-hvx ?= $(LDFLAGS-arm-64-android) +LDFLAGS-arm-64-android-hvx_128 ?= $(LDFLAGS-arm-64-android) LDFLAGS-arm-32-android ?= -llog -fPIE -pie -static-libstdc++ # Put HL_TARGET variants of all of these last, to avoid conflict with the android variants From 1fc214a8a573f10c062f6b9935c43ec45b781710 Mon Sep 17 00:00:00 2001 From: Fabian schuetze Date: Sat, 20 Apr 2024 15:39:55 +0200 Subject: [PATCH 3/3] restore hexagon directive --- apps/blur/halide_blur_generator.cpp | 2 ++ 1 file changed, 2 insertions(+) diff --git a/apps/blur/halide_blur_generator.cpp b/apps/blur/halide_blur_generator.cpp index 30205f6ace49..c3fd5009689e 100644 --- a/apps/blur/halide_blur_generator.cpp +++ b/apps/blur/halide_blur_generator.cpp @@ -86,6 +86,8 @@ class HalideBlur : public Halide::Generator { const int vector_size = 128; blur_y.compute_root() + .hexagon() + .prefetch(input, y, y, 2) .split(y, y, yi, 128) .parallel(y) .vectorize(x, vector_size * 2);