aboutsummaryrefslogtreecommitdiff
path: root/SConstruct
diff options
context:
space:
mode:
authorMotti Gondabi <motti.gondabi@arm.com>2021-11-09 15:47:17 +0200
committerMotti Gondabi <motti.gondabi@arm.com>2021-12-14 06:22:48 +0000
commit6f3a9f5f4ef6ec7aa8e91df3c1f373d95931dd7b (patch)
tree68a880e4eda9b5b33d324f7f2d66ee48954ba693 /SConstruct
parent30124354c6848c49f9740d1944d2445782255a85 (diff)
downloadComputeLibrary-6f3a9f5f4ef6ec7aa8e91df3c1f373d95931dd7b.tar.gz
Add Multi ISA support for SCons build System (part #1)
- Enhance the SCons build system to support V8 SVE/SVE2 achitecture in a single binary - Add additional filedefs.json to include build definitions Resolves: COMPMID-4921 Signed-off-by: Motti Gondabi <motti.gondabi@arm.com> Change-Id: Ie3c0ef444303270ba560ca3f43c6e22d50b86679 Reviewed-on: https://review.mlplatform.org/c/ml/ComputeLibrary/+/6689 Tested-by: Arm Jenkins <bsgcomp@arm.com> Reviewed-by: Giorgio Arena <giorgio.arena@arm.com> Comments-Addressed: Arm Jenkins <bsgcomp@arm.com>
Diffstat (limited to 'SConstruct')
-rw-r--r--SConstruct95
1 files changed, 52 insertions, 43 deletions
diff --git a/SConstruct b/SConstruct
index 400228c71a..2a8403f8ce 100644
--- a/SConstruct
+++ b/SConstruct
@@ -99,7 +99,7 @@ vars.AddVariables(
BoolVariable("examples", "Build example programs", True),
BoolVariable("gemm_tuner", "Build gemm_tuner programs", True),
BoolVariable("Werror", "Enable/disable the -Werror compilation flag", True),
- BoolVariable("fat_binary", "Build fat binary version of library. Note works only for armv8.2-a", False),
+ BoolVariable("multi_isa", "Build Multi ISA binary version of library. Note works only for armv8.2-a", False),
BoolVariable("standalone", "Builds the tests as standalone executables, links statically with libgcc, libstdc++ and libarm_compute", False),
BoolVariable("opencl", "Enable OpenCL support", True),
BoolVariable("neon", "Enable Arm® Neon™ support", False),
@@ -250,40 +250,63 @@ if 'v7a' in env['estate'] and env['estate'] == '64':
# Add architecture specific flags
prefix = ""
-if 'v7a' in env['arch']:
- env.Append(CXXFLAGS = ['-march=armv7-a', '-mthumb', '-mfpu=neon'])
- if (env['os'] == 'android' or env['os'] == 'tizen') and not 'hf' in env['arch']:
- env.Append(CXXFLAGS = ['-mfloat-abi=softfp'])
- else:
- env.Append(CXXFLAGS = ['-mfloat-abi=hard'])
-elif 'v8' in env['arch']:
- if 'sve2' in env['arch']:
- env.Append(CXXFLAGS = ['-march=armv8.2-a+sve2+fp16+dotprod'])
- env.Append(CPPDEFINES = ['ARM_COMPUTE_ENABLE_SVE2'])
- elif 'sve' in env['arch']:
- env.Append(CXXFLAGS = ['-march=armv8.2-a+sve+fp16+dotprod'])
- elif 'armv8r64' in env['arch']:
- env.Append(CXXFLAGS = ['-march=armv8.4-a'])
- elif 'v8.' in env['arch']:
- env.Append(CXXFLAGS = ['-march=armv8.2-a+fp16']) # explicitly enable fp16 extension otherwise __ARM_FEATURE_FP16_VECTOR_ARITHMETIC is undefined
- else:
- env.Append(CXXFLAGS = ['-march=armv8-a'])
+if env['multi_isa']:
+ # assert arch version is v8
+ if 'v8' not in env['arch']:
+ print("Currently Multi ISA binary is only supported for arm v8 family")
+ Exit(1)
if 'v8.6-a' in env['arch']:
- env.Append(CPPDEFINES = ['ARM_COMPUTE_ENABLE_I8MM', 'ARM_COMPUTE_ENABLE_BF16'])
if "disable_mmla_fp" not in env['custom_options']:
env.Append(CPPDEFINES = ['ARM_COMPUTE_ENABLE_SVEF32MM'])
- if 'v8.' in env['arch']:
- env.Append(CPPDEFINES = ['ARM_COMPUTE_ENABLE_FP16'])
-elif 'x86' in env['arch']:
- if env['estate'] == '32':
- env.Append(CCFLAGS = ['-m32'])
- env.Append(LINKFLAGS = ['-m32'])
+else: # NONE "multi_isa" builds
+
+ if 'sve' in env['arch']:
+ env.Append(CPPDEFINES = ['ENABLE_SVE', 'ARM_COMPUTE_ENABLE_SVE'])
+ if 'sve2' in env['arch']:
+ env.Append(CPPDEFINES = ['ARM_COMPUTE_ENABLE_SVE2'])
else:
- env.Append(CXXFLAGS = ['-fPIC'])
- env.Append(CCFLAGS = ['-m64'])
- env.Append(LINKFLAGS = ['-m64'])
+ # FIXME: The NEON flags should be always defined for CPU.
+ # however, build fails when SVE/SVE2 & NEON flags
+ # defined together.
+ env.Append(CPPDEFINES = ['ENABLE_NEON', 'ARM_COMPUTE_ENABLE_NEON'])
+
+
+ if 'v7a' in env['arch']:
+ env.Append(CXXFLAGS = ['-march=armv7-a', '-mthumb', '-mfpu=neon'])
+ if (env['os'] == 'android' or env['os'] == 'tizen') and not 'hf' in env['arch']:
+ env.Append(CXXFLAGS = ['-mfloat-abi=softfp'])
+ else:
+ env.Append(CXXFLAGS = ['-mfloat-abi=hard'])
+ elif 'v8' in env['arch']:
+ # Preserve the V8 archs for non-multi-ISA variants
+ if 'sve2' in env['arch']:
+ env.Append(CXXFLAGS = ['-march=armv8.2-a+sve2+fp16+dotprod'])
+ elif 'sve' in env['arch']:
+ env.Append(CXXFLAGS = ['-march=armv8.2-a+sve+fp16+dotprod'])
+ elif 'armv8r64' in env['arch']:
+ env.Append(CXXFLAGS = ['-march=armv8.4-a'])
+ elif 'v8.' in env['arch']:
+ env.Append(CXXFLAGS = ['-march=armv8.2-a+fp16']) # explicitly enable fp16 extension otherwise __ARM_FEATURE_FP16_VECTOR_ARITHMETIC is undefined
+ else:
+ env.Append(CXXFLAGS = ['-march=armv8-a'])
+
+ if 'v8.6-a' in env['arch']:
+ env.Append(CPPDEFINES = ['ARM_COMPUTE_ENABLE_I8MM', 'ARM_COMPUTE_ENABLE_BF16'])
+ if "disable_mmla_fp" not in env['custom_options']:
+ env.Append(CPPDEFINES = ['ARM_COMPUTE_ENABLE_SVEF32MM'])
+ if 'v8.' in env['arch']:
+ env.Append(CPPDEFINES = ['ARM_COMPUTE_ENABLE_FP16'])
+
+ elif 'x86' in env['arch']:
+ if env['estate'] == '32':
+ env.Append(CCFLAGS = ['-m32'])
+ env.Append(LINKFLAGS = ['-m32'])
+ else:
+ env.Append(CXXFLAGS = ['-fPIC'])
+ env.Append(CCFLAGS = ['-m64'])
+ env.Append(LINKFLAGS = ['-m64'])
# Define toolchain
prefix = ""
@@ -307,11 +330,6 @@ if 'x86' not in env['arch']:
elif env['os'] == 'tizen':
prefix = "aarch64-tizen-linux-gnu-"
-if 'sve' in env['arch']:
- env.Append(CXXFLAGS = ['-DENABLE_SVE', '-DARM_COMPUTE_ENABLE_SVE'])
-else:
- env.Append(CXXFLAGS = ['-DENABLE_NEON', '-DARM_COMPUTE_ENABLE_NEON'])
-
if env['build'] == 'native':
prefix = ""
@@ -355,15 +373,6 @@ if not GetOption("help"):
if not version_at_least(compiler_ver, '7.0.0') and env['os'] == 'bare_metal':
env.Append(LINKFLAGS = ['-fstack-protector-strong'])
-if env['fat_binary']:
- if env['arch'] != 'armv8.2-a':
- print("Currently fat binary is only supported with armv8.2-a")
- Exit(1)
- env.Append(CXXFLAGS = ['-DENABLE_NEON', '-DARM_COMPUTE_ENABLE_NEON',
- '-DENABLE_SVE', '-DARM_COMPUTE_ENABLE_SVE',
- '-DARM_COMPUTE_ENABLE_FP16', '-DARM_COMPUTE_ENABLE_BF16',
- '-DARM_COMPUTE_ENABLE_I8MM', '-DARM_COMPUTE_ENABLE_SVEF32MM'])
-
if env['high_priority'] and env['build_config']:
print("The high priority library cannot be built in conjuction with a user-specified build configuration")
Exit(1)