From: Wathsala Vithanage <wathsala.vithanage@arm.com>
To: Wathsala Vithanage <wathsala.vithanage@arm.com>,
Bruce Richardson <bruce.richardson@intel.com>
Cc: dev@dpdk.org, nd@arm.com, thomas@monjalon.net,
honnappa.nagarahalli@arm.com,
Dhruv Tripathi <dhruv.tripathi@arm.com>
Subject: [PATCH v3 1/2] config/arm: strict use of -mcpu for supported CPUs
Date: Fri, 29 Nov 2024 23:47:25 +0000 [thread overview]
Message-ID: <20241129234726.1570765-1-wathsala.vithanage@arm.com> (raw)
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_<soc_name> is
introduced and referenced in the mcpu field in the part number
dictionary of the part_number_config dictionary. The definition of the
mcpu_<soc_name> must be provided in the mcpu_defs dictionary.
Each mcpu_<soc_name> 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 <wathsala.vithanage@arm.com>
Reviewed-by: Dhruv Tripathi <dhruv.tripathi@arm.com>
---
config/arm/meson.build | 193 +++++++++++++++++------------------------
1 file changed, 80 insertions(+), 113 deletions(-)
diff --git a/config/arm/meson.build b/config/arm/meson.build
index 55be7c8711..9ed36d9907 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,15 +158,11 @@ implementer_cavium = {
'flags': flags_part_number_thunderx
},
'0xa3': {
- 'march': 'armv8-a',
- 'march_features': ['crc', 'crypto'],
- 'mcpu': 'thunderxt83',
+ 'mcpu': 'mcpu_thunderxt83',
'flags': flags_part_number_thunderx
},
'0xaf': {
- 'march': 'armv8.1-a',
- 'march_features': ['crc', 'crypto'],
- 'mcpu': 'thunderx2t99',
+ 'mcpu': 'mcpu_thunderx2t99',
'flags': [
['RTE_MACHINE', '"thunderx2"'],
['RTE_ARM_FEATURE_ATOMICS', true],
@@ -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,45 @@ 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'],
+ }
+ 'mcpu_thunderx2t99': {
+ 'march': 'armv8.1-a',
+ 'march_extensions': ['crc', 'crypto']
+ },
+ 'mcpu_thunderxt83': {
+ 'march': 'armv8-a',
+ 'march_extensions': ['crc', 'crypto']
+ },
+}
+
'''
Start of SoCs list
generic: Generic un-optimized build for armv8 aarch64 execution mode.
@@ -851,82 +854,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.43.0
next reply other threads:[~2024-11-29 23:47 UTC|newest]
Thread overview: 2+ messages / expand[flat|nested] mbox.gz Atom feed top
2024-11-29 23:47 Wathsala Vithanage [this message]
2024-11-29 23:47 ` [PATCH v3 2/2] config/arm: sort SOCs alphabetically Wathsala Vithanage
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=20241129234726.1570765-1-wathsala.vithanage@arm.com \
--to=wathsala.vithanage@arm.com \
--cc=bruce.richardson@intel.com \
--cc=dev@dpdk.org \
--cc=dhruv.tripathi@arm.com \
--cc=honnappa.nagarahalli@arm.com \
--cc=nd@arm.com \
--cc=thomas@monjalon.net \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).