DPDK patches and discussions
 help / color / mirror / Atom feed
From: Thinh Tran <thinhtr@linux.vnet.ibm.com>
To: dev@dpdk.org
Cc: Thinh Tran <thinhtr@linux.vnet.ibm.com>
Subject: [dpdk-dev] [PATCH] build: enable to build on power10 or newer for ppc
Date: Wed, 21 Jul 2021 16:13:08 -0500	[thread overview]
Message-ID: <20210721211308.16644-1-thinhtr@linux.vnet.ibm.com> (raw)

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.

Signed-off-by: Thinh Tran <thinhtr@linux.vnet.ibm.com>
---
 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

diff --git a/config/ppc/check_cpu_platform.sh b/config/ppc/check_cpu_platform.sh
new file mode 100644
index 0000000000..cdea24561b
--- /dev/null
+++ b/config/ppc/check_cpu_platform.sh
@@ -0,0 +1,2 @@
+#! /bin/sh
+LD_SHOW_AUXV=1 /bin/true | awk '/AT_PLATFORM/ {print $2}'|sed  's/\power//'
diff --git a/config/ppc/meson.build b/config/ppc/meson.build
index adf49e1f42..05aa860cfd 100644
--- a/config/ppc/meson.build
+++ b/config/ppc/meson.build
@@ -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
-- 
2.17.1


             reply	other threads:[~2021-07-21 21:14 UTC|newest]

Thread overview: 3+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2021-07-21 21:13 Thinh Tran [this message]
2021-07-22 20:20 ` David Marchand
2021-07-23 16:50   ` Thinh Tran

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=20210721211308.16644-1-thinhtr@linux.vnet.ibm.com \
    --to=thinhtr@linux.vnet.ibm.com \
    --cc=dev@dpdk.org \
    /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).