ComputeLibrary icon indicating copy to clipboard operation
ComputeLibrary copied to clipboard

how to support sve in ndk

Open xxxxxxLD opened this issue 3 years ago • 4 comments

In linux system,I try to use Android.mk to compile an executable file including SVE intrinsics, which is supported in armv8.2, and the system config as follows:

  1. TARGET_ARCH=arm64;
  2. TARGET_ARCH_VARIANT=armv8-2a;
  3. TARGET_CPU_VARIANT=cortex-a76
  4. TARGET_2ND_ARCH=arm;
  5. TARGET_2ND_ARCH_VARIANT=armv8-2a
  6. TARGET_2ND_CPU_VARIANT=cortex-a55
  7. HOST_ARCH=x86_64
  8. HSOT_2ND_ARCH=x86
  9. HSOT_OS=linux

And the Android.mk is

LOCAL_PATH:= $(call my-dir)
ROOT_DIR := $(LOCAL_PATH)/..
include $(CLEAR_VARS)
LOCAL_MODULE:= SVE_test
LOCAL_SRC_FILES := $(ROOT_DIR)/Project1/main.cpp
LOCAL_CFLAGS := -O3 -ffast-math -DNDK -D_GNU_SOURCE -D__ARM_FEATURE_SVE -D__LITTLE_ENDIAN
LOCAL_CFLAGS += -mfloat-abi=softfp -mfpu=neon -msve-vector-bits=256
LOCAL_LDLIBS  += -lc -ldl -lm -lz -llog -fPIE
APP_CPPFLAGS  +=-std=c++11

ifeq($(TARGET_ARCH_ABI), arm64-v8a)
LOCAL_ARM_NEON:=true
endif

LOCAL_PROPRIETARY_MODULE := TRUE
include $(BUILD_EXECUTABLE)

But some errors I met, it shows that error in backend:don't know how to legalize this scalable vector size. How to solve this problem?

xxxxxxLD avatar Jul 21 '22 06:07 xxxxxxLD

Hi @xdliangdi

Could you please share the complete error you get and the version of the NDK you're using?

morgolock avatar Jul 25 '22 09:07 morgolock

Hi @xdliangdi

Could you please share the complete error you get and the version of the NDK you're using?

The error writes fatal error:error in backend:Don't know how to legalize this scalable vector type. I compiler SVE instrinsics using Android compiler system not NDK, and how to compiler SVE code in Android system?

xxxxxxLD avatar Jul 26 '22 07:07 xxxxxxLD

Hi @xdliangdi

Could you please share the complete error you get and the version of the NDK you're using?

The error writes fatal error:error in backend:Don't know how to legalize this scalable vector type. I compiler SVE instrinsics using Android compiler system not NDK, and how to compiler SVE code in Android system?

xxxxxxLD avatar Jul 26 '22 07:07 xxxxxxLD

Hi @xdliangdi

What version of NDK are you using?

The error shows that your compiler does not support SVE, this could be either because the NDK you use is too old or the TARGET_ARCH_VARIANT is missing sve. For example when I build ACL with sve enabled the scons generates the following -march=armv8.2-a+sve+fp16+dotprod

I build ACL with the following command: user@host:~/work/acl/ComputeLibrary$ PATH=$PATH:../../toolchains/android-ndk-r23-beta5/toolchains/llvm/prebuilt/linux-x86_64/bin/ scons arch=arm64-v8.2-a-sve neon=1 opencl=0 embed_kernels=1 extra_cxx_flags="-fPIC" benchmark_tests=0 validation_tests=0 os=android Werror=0 toolchain_prefix=aarch64-linux-android29- -j16

Hope this helps.

morgolock avatar Aug 01 '22 16:08 morgolock

这是来自QQ邮箱的假期自动回复邮件。   您好,我最近正在休假中,无法亲自回复您的邮件。我将在假期结束后,尽快给您回复。

zhangqicai avatar Aug 30 '22 15:08 zhangqicai