From patchwork Thu Sep 30 00:08:11 2021 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Thinh Tran X-Patchwork-Id: 100042 X-Patchwork-Delegate: david.marchand@redhat.com Return-Path: X-Original-To: patchwork@inbox.dpdk.org Delivered-To: patchwork@inbox.dpdk.org Received: from mails.dpdk.org (mails.dpdk.org [217.70.189.124]) by inbox.dpdk.org (Postfix) with ESMTP id 245C5A0C41; Thu, 30 Sep 2021 02:08:43 +0200 (CEST) Received: from [217.70.189.124] (localhost [127.0.0.1]) by mails.dpdk.org (Postfix) with ESMTP id 9CE9540DDA; Thu, 30 Sep 2021 02:08:42 +0200 (CEST) Received: from mx0a-001b2d01.pphosted.com (mx0a-001b2d01.pphosted.com [148.163.156.1]) by mails.dpdk.org (Postfix) with ESMTP id A1C4D4067E for ; Thu, 30 Sep 2021 02:08:40 +0200 (CEST) Received: from pps.filterd (m0187473.ppops.net [127.0.0.1]) by mx0a-001b2d01.pphosted.com (8.16.1.2/8.16.1.2) with SMTP id 18TMwl1I025930 for ; Wed, 29 Sep 2021 20:08:38 -0400 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=ibm.com; h=from : to : cc : subject : date : message-id : mime-version : content-transfer-encoding; s=pp1; bh=ZflPi9kpIAfd6uCN64IqpOjzBPCl5XuY9Ibz9kUwOCA=; b=fGtjBg9CCggYbT4TrTfNCOBekwdTHIFpDwVHnFaOx/sF6Au8JRcwqySfhFBSmVLz8XGl jLUjo68f6dA0MNPQ7p9Eg4aZikTFrEkSliRBhnpXQQ5BPASg9UuRfPk6z/J5fUnrLz9o A/fslu+TyMj10cL+hj2hK2+L5JspegF59idecm1RTrePVQ4KZuqw75UgAEz1vnhE8I9G bp2d/yy3qu0rIWHj2JVRdQOgSt1xmNnlrcaj03ZoGYpN0MIl4gt34s6qA5RLEbDpqwEc bllEw00DtnHptIoQwsZhSE/90VpNyER0RMb7HIRfk1CmifI8M7wyq/XNMcABrw+yZjF/ Lg== Received: from ppma01dal.us.ibm.com (83.d6.3fa9.ip4.static.sl-reverse.com [169.63.214.131]) by mx0a-001b2d01.pphosted.com with ESMTP id 3bcufw1vk5-1 (version=TLSv1.2 cipher=ECDHE-RSA-AES256-GCM-SHA384 bits=256 verify=NOT) for ; Wed, 29 Sep 2021 20:08:38 -0400 Received: from pps.filterd (ppma01dal.us.ibm.com [127.0.0.1]) by ppma01dal.us.ibm.com (8.16.1.2/8.16.1.2) with SMTP id 18TNvDOK031510 for ; Thu, 30 Sep 2021 00:08:37 GMT Received: from b03cxnp07029.gho.boulder.ibm.com (b03cxnp07029.gho.boulder.ibm.com [9.17.130.16]) by ppma01dal.us.ibm.com with ESMTP id 3b9udd0gdt-1 (version=TLSv1.2 cipher=ECDHE-RSA-AES256-GCM-SHA384 bits=256 verify=NOT) for ; Thu, 30 Sep 2021 00:08:37 +0000 Received: from b03ledav004.gho.boulder.ibm.com (b03ledav004.gho.boulder.ibm.com [9.17.130.235]) by b03cxnp07029.gho.boulder.ibm.com (8.14.9/8.14.9/NCO v10.0) with ESMTP id 18U08aLd47972664 (version=TLSv1/SSLv3 cipher=DHE-RSA-AES256-GCM-SHA384 bits=256 verify=OK); Thu, 30 Sep 2021 00:08:36 GMT Received: from b03ledav004.gho.boulder.ibm.com (unknown [127.0.0.1]) by IMSVA (Postfix) with ESMTP id E97A07805C; Thu, 30 Sep 2021 00:08:35 +0000 (GMT) Received: from b03ledav004.gho.boulder.ibm.com (unknown [127.0.0.1]) by IMSVA (Postfix) with ESMTP id A8B7D7805F; Thu, 30 Sep 2021 00:08:35 +0000 (GMT) Received: from linux.vnet.ibm.com (unknown [9.114.219.126]) by b03ledav004.gho.boulder.ibm.com (Postfix) with ESMTP; Thu, 30 Sep 2021 00:08:35 +0000 (GMT) From: Thinh Tran To: dev@dpdk.org Cc: Thinh Tran , David Christensen Date: Thu, 30 Sep 2021 00:08:11 +0000 Message-Id: <20210930000811.593298-1-thinhtr@linux.vnet.ibm.com> X-Mailer: git-send-email 2.25.1 MIME-Version: 1.0 X-TM-AS-GCONF: 00 X-Proofpoint-GUID: RBzrqsoxu-wkXjJC8ArBMaV3a_fcF5Uo X-Proofpoint-ORIG-GUID: RBzrqsoxu-wkXjJC8ArBMaV3a_fcF5Uo X-Proofpoint-Virus-Version: vendor=baseguard engine=ICAP:2.0.182.1,Aquarius:18.0.790,Hydra:6.0.391,FMLib:17.0.607.475 definitions=2021-09-29_09,2021-09-29_01,2020-04-07_01 X-Proofpoint-Spam-Details: rule=outbound_notspam policy=outbound score=0 lowpriorityscore=0 phishscore=0 priorityscore=1501 mlxscore=0 bulkscore=0 malwarescore=0 spamscore=0 impostorscore=0 adultscore=0 suspectscore=0 clxscore=1011 mlxlogscore=999 classifier=spam adjust=0 reason=mlx scancount=1 engine=8.12.0-2109230001 definitions=main-2109290141 Subject: [dpdk-dev] [PATCH] build/ppc: enable build support for Power10 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 Sender: "dev" For native build, enabling building the highest cpu_instruction_set supported by the build host, including the new POWER10. For cross compile, verifying that the compiler supports the cpu_instruction_set specified in the cross-file Signed-off-by: Thinh Tran Reviewed-by: David Christensen --- config/ppc/meson.build | 83 ++++++++++++++++++++++++++++++++++++++++++ 1 file changed, 83 insertions(+) diff --git a/config/ppc/meson.build b/config/ppc/meson.build index aa1327a595..cba8222163 100644 --- a/config/ppc/meson.build +++ b/config/ppc/meson.build @@ -24,6 +24,89 @@ if (cc.get_id() == 'gcc' and cc.version().version_compare('>=10.0') and cc.version().version_compare('<12.0') and cc.has_argument('-Wno-psabi')) add_project_arguments('-Wno-psabi', language: 'c') endif +# If using a generic build, select the lowest common denominator +if platform == 'generic' + cpu_instruction_set = 'power8' +# If using a native build, select the highest cpu_instruction_set supported +# by the build host. (Native is the default platform type set in meson_options.txt.) +# When a cross compile is detected, verify that the compiler/assembler supports +# the requested cpu_instruction_set in the cross-file. +elif platform == 'native' + if meson.is_cross_build() + # cpu_instruction_set specified in cross-compile file as "cpu" + if host_machine.cpu() == 'power10' + test_p10 = ''' +#include +#include +int main() { + __vector unsigned __int128 t, a, b; +#ifdef _ARCH_PWR10 + __asm__("vcmpequq %0,%1,%2;" : "=v" (t) : "v" (a), "v" (b) : ); +#else +#error POWER10 not supported +#endif + printf("%d", (int)t[0]); + return 0; +} +''' + if not cc.compiles(test_p10, args : '-mcpu=power10', name: 'Detect P10') + error('POWER10 requested but not supported') + endif + endif + else + # Using a POWER native build host. Assume P8 support, move to later CPUs + # if supported by the build host and the compiler. Detect the CPU used by + # the build host + detect_cpu = ''' +#include +#include +#include +int main() { + char * platform = (char*) getauxval(AT_PLATFORM); + if (platform) { + if (!strncmp(platform,"power",5)) { + printf("%s", platform+5); return 0; + } + } + return 1; +}''' + result = cc.run(detect_cpu, name : 'Detect host CPU type') + if not result.compiled() + error('Failed to detect CPU type') + endif + cpu = result.stdout().to_int() + if cpu < 8 + error('Unsupported POWER CPU detected') + else + # Found supported CPU on build host, verify compiler support + mcpu_flag = '-mcpu=power@0@' + if cc.has_argument(mcpu_flag.format(cpu)) + # Compiler supports current detected CPU + elif cc.has_argument(mcpu_flag.format(cpu-1)) + cpu = cpu-1 + elif cc.has_argument(mcpu_flag.format(cpu-2)) + cpu = cpu-2 + else + error('Compiler does not support POWER@0@ platform'.format(cpu)) + endif + if cpu > 8 + cpu_instruction_set = 'power'+cpu.to_string() + else + error('Compiler does not support POWER@0@ platform'.format(cpu)) + endif + endif + endif #end if not cross-build +else + # User has explicitly chosen a platform for the build, use that + if cc.has_argument('-mcpu=' + platform) + cpu_instruction_set = platform + else + error('User selected platform ' + platform + ' not supported by compiler') + endif +endif +machine_args = ['-mcpu=' + cpu_instruction_set, '-mtune=' + cpu_instruction_set] +dpdk_conf.set('RTE_MACHINE', cpu_instruction_set) + # 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