From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: from mails.dpdk.org (mails.dpdk.org [217.70.189.124]) by inbox.dpdk.org (Postfix) with ESMTP id 0211D45C05; Tue, 29 Oct 2024 02:59:58 +0100 (CET) Received: from mails.dpdk.org (localhost [127.0.0.1]) by mails.dpdk.org (Postfix) with ESMTP id 89AE44014F; Tue, 29 Oct 2024 02:59:58 +0100 (CET) Received: from foss.arm.com (foss.arm.com [217.140.110.172]) by mails.dpdk.org (Postfix) with ESMTP id A962B4014F for ; Tue, 29 Oct 2024 02:59:56 +0100 (CET) Received: from usa-sjc-imap-foss1.foss.arm.com (unknown [10.121.207.14]) by usa-sjc-mx-foss1.foss.arm.com (Postfix) with ESMTP id 613CE13D5; Mon, 28 Oct 2024 19:00:25 -0700 (PDT) Received: from ampere-altra-2-1.usa.Arm.com (ampere-altra-2-1.usa.arm.com [10.118.91.158]) by usa-sjc-imap-foss1.foss.arm.com (Postfix) with ESMTPA id 9433C3F66E; Mon, 28 Oct 2024 18:59:55 -0700 (PDT) From: Wathsala Vithanage To: Wathsala Vithanage , Bruce Richardson Cc: nd@arm.com, dev@dpdk.org, honnappa.nagarahalli@arm.com, Dhruv Tripathi Subject: [PATCH v2 1/2] config/arm: strict use of -mcpu for supported CPUs Date: Tue, 29 Oct 2024 01:59:45 +0000 Message-Id: <20241029015946.998124-1-wathsala.vithanage@arm.com> X-Mailer: git-send-email 2.34.1 In-Reply-To: <20241028233139.922029-1-wathsala.vithanage@arm.com> References: <20241028233139.922029-1-wathsala.vithanage@arm.com> MIME-Version: 1.0 Content-Transfer-Encoding: 8bit X-BeenThere: dev@dpdk.org X-Mailman-Version: 2.1.29 Precedence: list List-Id: DPDK patches and discussions List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: dev-bounces@dpdk.org Arm recommends using -mcpu over -march and march-extensions when the compiler supports the target CPU (neoverse-n1 etc.). Arm build so far has been an amalgam of -mcpu and -march. When march is in use, it has been the case so far to silently fall back to a downgraded march when the compiler does not support the requested march. This is unnecessary and confusing to an end user who could be building DPDK with a particular ISA version and performance expectations in mind. This patch aims to rectify both the above issues. For part numbers that has a corresponding -mcpu, this patch removes all references to march and march_features from meson.build. For those SOCs that do not have a corresponding -mcpu, a pseudo cpu name in the format mcpu_ is introduced and referenced in the mcpu field in the part number dictionary of the part_number_config dictionary. The definition of the mcpu_ must be provided in the mcpu_defs dictionary. Each mcpu_ dictionary in the mcpu_defs have a march field and a march_extensions field to construct the optimal compiler setting for an SOC that has no corresponding -mcpu value. This patch alters the behavior of the build system such that it will no longer silently fall back to an older ISA version, it will only perform what's specified in the build dictionaries, if the compiler does not support the specified configuration it will fail with an error message. How to add a new SOC to the build system with these changes? If compiler supports mcpu follow the usual practice but without march and march_features fields in the part number dictionary. If mcpu is not available or buggy (misses certain features) for some reason follow the same process but set mcpu field to a string in the form 'mcpu_foo' (pseudo mcpu mentioned earlier). Then in the mcpu_defs dictionary add mcpu_foo dictionary as shown. 'mcpu_foo': { 'march': 'armv8.2-a', 'march_extensions': [rcpc] } march_extensions is a comma separated list of march extensions supported by the compiler such as sve, crypto etc. Empty match_extensions allowed as use of such extensions are optional. Signed-off-by: Wathsala Vithanage Reviewed-by: Dhruv Tripathi --- config/arm/meson.build | 181 ++++++++++++++++------------------------- 1 file changed, 70 insertions(+), 111 deletions(-) diff --git a/config/arm/meson.build b/config/arm/meson.build index 55be7c8711..85ec6c0228 100644 --- a/config/arm/meson.build +++ b/config/arm/meson.build @@ -39,14 +39,11 @@ implementer_generic = { ], 'part_number_config': { 'generic': { - 'march': 'armv8-a', - 'march_features': ['crc'], + 'mcpu': 'mcpu_generic', 'compiler_options': ['-moutline-atomics'] }, 'generic_aarch32': { - 'march': 'armv8-a', - 'force_march': true, - 'march_features': ['simd'], + 'mcpu': 'mcpu_generic_aarch32', 'compiler_options': ['-mfpu=auto'], 'flags': [ ['RTE_ARCH_ARM_NEON_MEMCPY', false], @@ -69,8 +66,6 @@ part_number_config_arm = { '0xd0a': {'mcpu': 'cortex-a75'}, '0xd0b': {'mcpu': 'cortex-a76'}, '0xd0c': { - 'march': 'armv8.2-a', - 'march_features': ['crypto', 'rcpc'], 'mcpu': 'neoverse-n1', 'flags': [ ['RTE_MACHINE', '"neoverse-n1"'], @@ -81,8 +76,6 @@ part_number_config_arm = { ] }, '0xd40': { - 'march': 'armv8.4-a', - 'march_features': ['sve'], 'mcpu': 'neoverse-v1', 'flags': [ ['RTE_MACHINE', '"neoverse-v1"'], @@ -94,9 +87,6 @@ part_number_config_arm = { 'march': 'armv8.4-a', }, '0xd49': { - 'march': 'armv9-a', - 'march_features': ['sve2'], - 'fallback_march': 'armv8.5-a', 'mcpu': 'neoverse-n2', 'flags': [ ['RTE_MACHINE', '"neoverse-n2"'], @@ -106,10 +96,7 @@ part_number_config_arm = { ] }, '0xd4f': { - 'march': 'armv9-a', - 'march_features': ['sve2'], 'mcpu' : 'neoverse-v2', - 'fallback_march': 'armv8.5-a', 'flags': [ ['RTE_MACHINE', '"neoverse-v2"'], ['RTE_ARM_FEATURE_ATOMICS', true], @@ -171,14 +158,10 @@ implementer_cavium = { 'flags': flags_part_number_thunderx }, '0xa3': { - 'march': 'armv8-a', - 'march_features': ['crc', 'crypto'], 'mcpu': 'thunderxt83', 'flags': flags_part_number_thunderx }, '0xaf': { - 'march': 'armv8.1-a', - 'march_features': ['crc', 'crypto'], 'mcpu': 'thunderx2t99', 'flags': [ ['RTE_MACHINE', '"thunderx2"'], @@ -189,8 +172,6 @@ implementer_cavium = { ] }, '0xb2': { - 'march': 'armv8.2-a', - 'march_features': ['crc', 'crypto', 'lse'], 'mcpu': 'octeontx2', 'flags': [ ['RTE_MACHINE', '"cn9k"'], @@ -212,8 +193,6 @@ implementer_ampere = { ], 'part_number_config': { '0x0': { - 'march': 'armv8-a', - 'march_features': ['crc', 'crypto'], 'mcpu': 'emag', 'flags': [ ['RTE_MACHINE', '"eMAG"'], @@ -222,8 +201,6 @@ implementer_ampere = { ] }, '0xac3': { - 'march': 'armv8.6-a', - 'march_features': ['crc', 'crypto'], 'mcpu': 'ampere1', 'flags': [ ['RTE_MACHINE', '"AmpereOne"'], @@ -232,8 +209,6 @@ implementer_ampere = { ] }, '0xac4': { - 'march': 'armv8.6-a', - 'march_features': ['crc', 'crypto'], 'mcpu': 'ampere1a', 'flags': [ ['RTE_MACHINE', '"AmpereOneAC04"'], @@ -252,8 +227,6 @@ implementer_hisilicon = { ], 'part_number_config': { '0xd01': { - 'march': 'armv8.2-a', - 'march_features': ['crypto'], 'mcpu': 'tsv110', 'flags': [ ['RTE_MACHINE', '"Kunpeng 920"'], @@ -263,8 +236,7 @@ implementer_hisilicon = { ] }, '0xd02': { - 'march': 'armv8.2-a', - 'march_features': ['crypto', 'sve'], + 'mcpu': 'mcpu_kunpeng930', 'flags': [ ['RTE_MACHINE', '"Kunpeng 930"'], ['RTE_ARM_FEATURE_ATOMICS', true], @@ -273,8 +245,7 @@ implementer_hisilicon = { ] }, '0xd03': { - 'march': 'armv8.5-a', - 'march_features': ['crypto', 'sve'], + 'mcpu': 'mcpu_hip10', 'flags': [ ['RTE_MACHINE', '"hip10"'], ['RTE_ARM_FEATURE_ATOMICS', true], @@ -321,16 +292,14 @@ implementer_phytium = { ], 'part_number_config': { '0x662': { - 'march': 'armv8-a', - 'march_features': ['crc'], + 'mcpu': 'mcpu_ft2000plus', 'flags': [ ['RTE_MAX_LCORE', 64], ['RTE_MAX_NUMA_NODES', 8] - ] + ] }, - '0x663': { - 'march': 'armv8-a', - 'march_features': ['crc'], + '0x663': { + 'mcpu': 'mcpu_tys2500', 'flags': [ ['RTE_MAX_LCORE', 256], ['RTE_MAX_NUMA_NODES', 32] @@ -349,13 +318,8 @@ implementer_qualcomm = { ['RTE_MAX_NUMA_NODES', 1] ], 'part_number_config': { - '0x800': { - 'march': 'armv8-a', - 'march_features': ['crc'] - }, '0xc00': { - 'march': 'armv8-a', - 'march_features': ['crc'] + 'mcpu': 'mcpu_centriq2400' } } } @@ -659,6 +623,37 @@ soc_v2 = { 'numa': true } +mcpu_defs = { + 'mcpu_kunpeng930': { + 'march': 'armv8.2-a', + 'march_extensions': ['crypto', 'sve'] + }, + 'mcpu_hip10': { + 'march': 'armv8.5-a', + 'march_extensions': ['crypto', 'sve'] + }, + 'mcpu_ft2000plus': { + 'march': 'armv8-a', + 'march_extensions': ['crc'] + }, + 'mcpu_tys2500': { + 'march': 'armv8-a', + 'march_extensions': ['crc'] + }, + 'mcpu_centriq2400': { + 'march': 'armv8-a', + 'march_extensions': ['crc'] + }, + 'mcpu_generic': { + 'march': 'armv8-a', + 'march_extensions': ['crc'], + }, + 'mcpu_generic_aarch32': { + 'march': 'armv8-a', + 'march_extensions': ['simd'], + } +} + ''' Start of SoCs list generic: Generic un-optimized build for armv8 aarch64 execution mode. @@ -851,82 +846,46 @@ if update_flags dpdk_flags = flags_common + implementer_config['flags'] + part_number_config.get('flags', []) + soc_flags machine_args = [] # Clear previous machine args - - march_features = [] - if part_number_config.has_key('march_features') - march_features += part_number_config['march_features'] - endif - if soc_config.has_key('extra_march_features') - march_features += soc_config['extra_march_features'] + mcpu = part_number_config.get('mcpu', '') + if mcpu == '' + error('No suitable Arm mcpu name or custom mcpu definition object found.') endif - candidate_mcpu = '' - candidate_march = '' + if mcpu.contains('mcpu_') + mcpu_def = mcpu_defs.get(mcpu, {}) + if mcpu_def.keys().length() == 0 + error('Custom mcpu definition @0@ is not found.'.format(mcpu)) + endif - if (part_number_config.has_key('mcpu') and - cc.has_argument('-mcpu=' + part_number_config['mcpu'])) - candidate_mcpu = '-mcpu=' + part_number_config['mcpu'] - foreach feature: march_features - if cc.has_argument('+'.join([candidate_mcpu, feature])) - candidate_mcpu = '+'.join([candidate_mcpu, feature]) - else - warning('The compiler does not support feature @0@' - .format(feature)) - endif - endforeach - machine_args += candidate_mcpu - elif part_number_config.has_key('march') - # probe supported archs and their features - if part_number_config.get('force_march', false) - candidate_march = part_number_config['march'] - else - supported_marchs = ['armv9-a', 'armv8.7-a', 'armv8.6-a', 'armv8.5-a', 'armv8.4-a', 'armv8.3-a', - 'armv8.2-a', 'armv8.1-a', 'armv8-a'] - check_compiler_support = false - foreach supported_march: supported_marchs - if supported_march == part_number_config['march'] - # start checking from this version downwards - check_compiler_support = true - endif - if (check_compiler_support and - cc.has_argument('-march=' + supported_march)) - candidate_march = supported_march - # highest supported march version found - break - endif - endforeach - if (part_number_config.has_key('fallback_march') and - candidate_march != part_number_config['march'] and - cc.has_argument('-march=' + part_number_config['fallback_march'])) - candidate_march = part_number_config['fallback_march'] - endif + march = mcpu_def.get('march', '') + if march == '' + error(('march not specified in the custom mcpu definition.' + .format(march))) endif + march = '-march=' + march - if candidate_march != part_number_config['march'] - warning('Configuration march version is @0@, not supported.' - .format(part_number_config['march'])) - if candidate_march != '' - warning('Using march version @0@.'.format(candidate_march)) - endif + if not cc.has_argument(march) + error('Compiler does not support @0@.'.format(march)) endif - if candidate_march != '' - candidate_march = '-march=' + candidate_march - foreach feature: march_features - if cc.has_argument('+'.join([candidate_march, feature])) - candidate_march = '+'.join([candidate_march, feature]) - else - warning('The compiler does not support feature @0@' - .format(feature)) - endif - endforeach - machine_args += candidate_march + march_exts = mcpu_def.get('march_extensions', []) + foreach ext: march_exts + if cc.has_argument('+'.join([march, ext])) + march = '+'.join([march, ext]) + else + error('Compiler does not support march extension @0@.'.format(ext)) + endif + endforeach + machine_args += march + else + candidate_mcpu = '-mcpu=' + mcpu + if (cc.has_argument(candidate_mcpu)) + machine_args += candidate_mcpu + else + error('Compiler does not support -mcpu=@0@.'.format(mcpu)) endif endif - if candidate_mcpu == '' and candidate_march == '' - error('No suitable ARM march/mcpu version found.') - endif # apply supported compiler options if part_number_config.has_key('compiler_options') -- 2.34.1