build: enable to build on power10 or newer for ppc
PATCH 1/1 build: enable to build on power10 or newer for ppc
A older version of complier would fail to generate code for new Power CPUs when it uses "-mcpu=native" argument.
This patch will test if the compiler supports the current Power CPU type then proceeds with "-mcpu=native" argument, else it tries with older type. Limit to two older CPU type levels.
--- config/ppc/check_cpu_platform.sh | 2 ++ config/ppc/meson.build | 40 +++++++++++++++++++++++++------- 2 files changed, 34 insertions(+), 8 deletions(-) create mode 100644 config/ppc/check_cpu_platform.sh
config/ppc/check_cpu_platform.sh new file +2 -0
@@ -0,0 +1,2 @@ +#! /bin/sh +LD_SHOW_AUXV=1 /bin/true | awk '/AT_PLATFORM/ {print $2}'|sed 's/\power//'
config/ppc/meson.build +32 -8
@@ -7,16 +7,40 @@ endif dpdk_conf.set('RTE_ARCH', 'ppc_64') dpdk_conf.set('RTE_ARCH_PPC_64', 1) -# RHEL 7.x uses gcc 4.8.X which doesn't generate code for Power 9 CPUs, -# though it will detect a Power 9 CPU when the "-mcpu=native" argument -# is used, resulting in a build failure. -power9_supported = cc.has_argument('-mcpu=power9') -if not power9_supported - cpu_instruction_set = 'power8' - machine_args = ['-mcpu=power8', '-mtune=power8'] - dpdk_conf.set('RTE_MACHINE','power8') +# Checking compiler for supporting Power CPU platform +# For newer Power(N) System that current gcc may not supoort it yet, +# it falls back and try N-1 and N-2 +check_cpu = find_program(join_paths(meson.current_source_dir(), + 'check_cpu_platform.sh')) + +target_cpu = run_command(check_cpu.path()).stdout().strip() + +cpu_int = target_cpu.to_int() +cpu_flag = '-mcpu=power@0@' +tune_flag = '-mtune=power@0@' +machine_type = 'power@0@' +debug = 'configure the compiler to build DPDK for POWER@0@ platform' + +if cc.has_argument(cpu_flag.format(cpu_int)) + + # target system cpu is supported by the compiler, use '-mcpu=native' + message(debug.format(target_cpu+'_native')) + machine_args = ['-mcpu=native'] + dpdk_conf.set('RTE_MACHINE',machine_type.format(cpu_int)) +elif cc.has_argument(cpu_flag.format(cpu_int-1)) + message(debug.format(cpu_int-1)) + machine_args = [cpu_flag.format(cpu_int-1),tune_flag.format(cpu_int-1)] + dpdk_conf.set('RTE_MACHINE',machine_type.format(cpu_int-1)) +elif cc.has_argument(cpu_flag.format(cpu_int-2)) + message(debug.format(cpu_int-2)) + machine_args = [cpu_flag.format(cpu_int-2),tune_flag.format(cpu_int-2)] + dpdk_conf.set('RTE_MACHINE',machine_type.format(cpu_int-2)) +else + error('The compiler does not support POWER@0@ platform' .format(cpu_int)) endif + + # Certain POWER9 systems can scale as high as 1536 LCORES, but setting such a # high value can waste memory, cause timeouts in time limited autotests, and is # unlikely to be used in many production situations. Similarly, keeping the
Signature · 1 line
2.17.1
Quoted 2 lines · Thinh Tran
A older version of complier would fail to generate code for new Power
compiler
Quoted 4 lines
CPUs when it uses "-mcpu=native" argument.
This patch will test if the compiler supports the current Power CPU type then proceeds with "-mcpu=native" argument, else it tries with older type. Limit to two older CPU type levels.
Such a change seems a bit late for 21.08, and is broken (see below). In any case, I would need a review from ppc maintainer.
Quoted 25 lines
Signed-off-by Thinh Tran <[email protected]>--- config/ppc/check_cpu_platform.sh | 2 ++ config/ppc/meson.build | 40 +++++++++++++++++++++++++------- 2 files changed, 34 insertions(+), 8 deletions(-) create mode 100644 config/ppc/check_cpu_platform.shconfig/ppc/check_cpu_platform.sh new file +2
-0@@ -0,0 +1,2 @@ +#! /bin/sh +LD_SHOW_AUXV=1 /bin/true | awk '/AT_PLATFORM/ {print $2}'|sed 's/\power//'config/ppc/meson.build +0
-1@@ -7,16 +7,40 @@ endif dpdk_conf.set('RTE_ARCH', 'ppc_64') dpdk_conf.set('RTE_ARCH_PPC_64', 1) -# RHEL 7.x uses gcc 4.8.X which doesn't generate code for Power 9 CPUs,
config/ppc/meson.build endif · line 12
Quoted 10 lines
config/ppc/meson.build +3
-7-# though it will detect a Power 9 CPU when the "-mcpu=native" argument -# is used, resulting in a build failure. -power9_supported = cc.has_argument('-mcpu=power9') -if not power9_supported - cpu_instruction_set = 'power8' - machine_args = ['-mcpu=power8', '-mtune=power8'] - dpdk_conf.set('RTE_MACHINE','power8') +# Checking compiler for supporting Power CPU platform +# For newer Power(N) System that current gcc may not supoort it yet, +# it falls back and try N-1 and N-2
double space unneeded.
Plus, wording reads odd to me.
config/ppc/meson.build endif · line 14
Quoted 2 lines
config/ppc/meson.build +2
-0+check_cpu = find_program(join_paths(meson.current_source_dir(), + 'check_cpu_platform.sh'))
Why do you need a separate script?
The value it returns is constant on a given system.
Looking at the script itself, this breaks cross compilation.
Compiler for C supports arguments -Wno-missing-field-initializers -Wmissing-field-initializers: YES (cached)
Program /home/dmarchan/dpdk/config/ppc/check_cpu_platform.sh found: YES
../../dpdk/config/ppc/meson.build:18:0: ERROR: String 'x86_64' cannot be converted to int
A full log can be found at /home/dmarchan/builds/build-ppc64le-power8/meson-logs/meson-log.txt
FAILED: build.ninja/usr/bin/meson --internal regenerate /home/dmarchan/dpdk /home/dmarchan/builds/build-ppc64le-power8 --backend ninja
ninja: error: rebuilding 'build.ninja': subcommand failed
Quoted 19 lines
config/ppc/meson.build +19
-0+ +target_cpu = run_command(check_cpu.path()).stdout().strip() + +cpu_int = target_cpu.to_int() +cpu_flag = '-mcpu=power@0@' +tune_flag = '-mtune=power@0@' +machine_type = 'power@0@' +debug = 'configure the compiler to build DPDK for POWER@0@ platform' + +if cc.has_argument(cpu_flag.format(cpu_int)) + + # target system cpu is supported by the compiler, use '-mcpu=native' + message(debug.format(target_cpu+'_native')) + machine_args = ['-mcpu=native'] + dpdk_conf.set('RTE_MACHINE',machine_type.format(cpu_int)) +elif cc.has_argument(cpu_flag.format(cpu_int-1)) + message(debug.format(cpu_int-1)) + machine_args = [cpu_flag.format(cpu_int-1),tune_flag.format(cpu_int-1)] + dpdk_conf.set('RTE_MACHINE',machine_type.format(cpu_int-1))
config/ppc/meson.build endif · line 43
Quoted 10 lines
config/ppc/meson.build +8
-0+elif cc.has_argument(cpu_flag.format(cpu_int-2)) + message(debug.format(cpu_int-2)) + machine_args = [cpu_flag.format(cpu_int-2),tune_flag.format(cpu_int-2)] + dpdk_conf.set('RTE_MACHINE',machine_type.format(cpu_int-2)) +else + error('The compiler does not support POWER@0@ platform' .format(cpu_int)) endif + +
One line is enough.
Quoted 6 lines
config/ppc/meson.build +0
-1# Certain POWER9 systems can scale as high as 1536 LCORES, but setting such a # high value can waste memory, cause timeouts in time limited autotests, and is # unlikely to be used in many production situations. Similarly, keeping the --2.17.1
Signature · 1 line
David Marchand
Thanks David for reviewing.
I'll fix the patch with cross compilation in mind.
Regards,
Thinh Tran
Quoted 121 lines · David Marchand
Quoted 2 lines · Thinh Tran
A older version of complier would fail to generate code for new Power
compiler
Quoted 4 lines
CPUs when it uses "-mcpu=native" argument.
This patch will test if the compiler supports the current Power CPU type then proceeds with "-mcpu=native" argument, else it tries with older type. Limit to two older CPU type levels.Such a change seems a bit late for 21.08, and is broken (see below). In any case, I would need a review from ppc maintainer.
Quoted 25 lines
Signed-off-by Thinh Tran <[email protected]>--- config/ppc/check_cpu_platform.sh | 2 ++ config/ppc/meson.build | 40 +++++++++++++++++++++++++------- 2 files changed, 34 insertions(+), 8 deletions(-)create mode 100644
config/ppc/check_cpu_platform.shconfig/ppc/check_cpu_platform.sh new file +2
-0@@ -0,0 +1,2 @@ +#! /bin/sh +LD_SHOW_AUXV=1 /bin/true | awk '/AT_PLATFORM/ {print $2}'|sed 's/\power//'config/ppc/meson.build +0
-1@@ -7,16 +7,40 @@ endif dpdk_conf.set('RTE_ARCH', 'ppc_64') dpdk_conf.set('RTE_ARCH_PPC_64', 1) -# RHEL 7.x uses gcc 4.8.X which doesn't generate code for Power 9 CPUs,config/ppc/meson.build endif · line 12
Quoted 10 lines
config/ppc/meson.build +3
-7-# though it will detect a Power 9 CPU when the "-mcpu=native" argument -# is used, resulting in a build failure. -power9_supported = cc.has_argument('-mcpu=power9') -if not power9_supported - cpu_instruction_set = 'power8' - machine_args = ['-mcpu=power8', '-mtune=power8'] - dpdk_conf.set('RTE_MACHINE','power8') +# Checking compiler for supporting Power CPU platform +# For newer Power(N) System that current gcc may not supoort it yet, +# it falls back and try N-1 and N-2double space unneeded.
Plus, wording reads odd to me.config/ppc/meson.build endif · line 14
Quoted 2 lines
config/ppc/meson.build +2
-0+check_cpu = find_program(join_paths(meson.current_source_dir(), + 'check_cpu_platform.sh'))Why do you need a separate script?
The value it returns is constant on a given system.Looking at the script itself, this breaks cross compilation.
Compiler for C supports arguments -Wno-missing-field-initializers -Wmissing-field-initializers: YES (cached)
Program/home/dmarchan/dpdk/config/ppc/check_cpu_platform.shfound: YES../../dpdk/config/ppc/meson.build:18:0: ERROR: String '
x86_64' cannot be converted to intA full log can be found at
/home/dmarchan/builds/build-ppc64le-power8/meson-logs/meson-log.txt
FAILED: build.ninja/usr/bin/meson--internal regenerate/home/dmarchan/dpdk/home/dmarchan/builds/build-ppc64le-power8--backend ninja
ninja: error: rebuilding 'build.ninja': subcommand failedQuoted 19 lines
config/ppc/meson.build +19
-0+ +target_cpu = run_command(check_cpu.path()).stdout().strip() + +cpu_int = target_cpu.to_int() +cpu_flag = '-mcpu=power@0@' +tune_flag = '-mtune=power@0@' +machine_type = 'power@0@' +debug = 'configure the compiler to build DPDK for POWER@0@ platform' + +if cc.has_argument(cpu_flag.format(cpu_int)) + + # target system cpu is supported by the compiler, use '-mcpu=native' + message(debug.format(target_cpu+'_native')) + machine_args = ['-mcpu=native'] + dpdk_conf.set('RTE_MACHINE',machine_type.format(cpu_int)) +elif cc.has_argument(cpu_flag.format(cpu_int-1)) + message(debug.format(cpu_int-1)) + machine_args = [cpu_flag.format(cpu_int-1),tune_flag.format(cpu_int-1)] + dpdk_conf.set('RTE_MACHINE',machine_type.format(cpu_int-1))config/ppc/meson.build endif · line 43
Quoted 10 lines
config/ppc/meson.build +8
-0+elif cc.has_argument(cpu_flag.format(cpu_int-2)) + message(debug.format(cpu_int-2)) + machine_args = [cpu_flag.format(cpu_int-2),tune_flag.format(cpu_int-2)] + dpdk_conf.set('RTE_MACHINE',machine_type.format(cpu_int-2)) +else + error('The compiler does not support POWER@0@ platform' .format(cpu_int)) endif + +One line is enough.
Quoted 6 lines
config/ppc/meson.build +0
-1# Certain POWER9 systems can scale as high as 1536 LCORES, but setting such a # high value can waste memory, cause timeouts in time limited autotests, and is # unlikely to be used in many production situations. Similarly, keeping the --2.17.1