1# SPDX-License-Identifier: BSD-3-Clause 2# Copyright(c) 2018 Luca Boccassi <[email protected]> 3# Copyright(c) 2021 IBM Corporation 4 5if not dpdk_conf.get('RTE_ARCH_64') 6 error('Only 64-bit compiles are supported for this platform type') 7endif 8dpdk_conf.set('RTE_ARCH', 'ppc_64') 9dpdk_conf.set('RTE_ARCH_PPC_64', 1) 10 11# RHEL 7.x uses gcc 4.8.X which doesn't generate code for Power 9 CPUs, 12# though it will detect a Power 9 CPU when the "-mcpu=native" argument 13# is used, resulting in a build failure. 14power9_supported = cc.has_argument('-mcpu=power9') 15if not power9_supported 16 cpu_instruction_set = 'power8' 17 machine_args = ['-mcpu=power8', '-mtune=power8'] 18 dpdk_conf.set('RTE_MACHINE','power8') 19endif 20 21# Suppress the gcc warning "note: the layout of aggregates containing 22# vectors with 4-byte alignment has changed in GCC 5". 23if (cc.get_id() == 'gcc' and cc.version().version_compare('>=10.0') and 24 cc.version().version_compare('<12.0') and cc.has_argument('-Wno-psabi')) 25 add_project_arguments('-Wno-psabi', language: 'c') 26endif 27# If using a generic build, select the lowest common denominator 28if platform == 'generic' 29 cpu_instruction_set = 'power8' 30# If using a native build, select the highest cpu_instruction_set supported 31# by the build host. (Native is the default platform type set in meson_options.txt.) 32# When a cross compile is detected, verify that the compiler/assembler supports 33# the requested cpu_instruction_set in the cross-file. 34elif platform == 'native' 35 if meson.is_cross_build() 36 # cpu_instruction_set specified in cross-compile file as "cpu" 37 if host_machine.cpu() == 'power10' 38 test_p10 = ''' 39#include <stdio.h> 40#include <altivec.h> 41int main() { 42 __vector unsigned __int128 t, a, b; 43#ifdef _ARCH_PWR10 44 __asm__("vcmpequq %0,%1,%2;" : "=v" (t) : "v" (a), "v" (b) : ); 45#else 46#error POWER10 not supported 47#endif 48 printf("%d", (int)t[0]); 49 return 0; 50} 51''' 52 if not cc.compiles(test_p10, args : '-mcpu=power10', name: 'Detect P10') 53 error('POWER10 requested but not supported') 54 endif 55 endif 56 else 57 # Using a POWER native build host. Assume P8 support, move to later CPUs 58 # if supported by the build host and the compiler. Detect the CPU used by 59 # the build host 60 detect_cpu = ''' 61#include <stdio.h> 62#include <string.h> 63#include <sys/auxv.h> 64int main() { 65 char * platform = (char*) getauxval(AT_PLATFORM); 66 if (platform) { 67 if (!strncmp(platform,"power",5)) { 68 printf("%s", platform+5); return 0; 69 } 70 } 71 return 1; 72}''' 73 result = cc.run(detect_cpu, name : 'Detect host CPU type') 74 if not result.compiled() 75 error('Failed to detect CPU type') 76 endif 77 cpu = result.stdout().to_int() 78 if cpu < 8 79 error('Unsupported POWER CPU detected') 80 else 81 # Found supported CPU on build host, verify compiler support 82 mcpu_flag = '-mcpu=power@0@' 83 if cc.has_argument(mcpu_flag.format(cpu)) 84 # Compiler supports current detected CPU 85 elif cc.has_argument(mcpu_flag.format(cpu-1)) 86 cpu = cpu-1 87 elif cc.has_argument(mcpu_flag.format(cpu-2)) 88 cpu = cpu-2 89 else 90 error('Compiler does not support POWER@0@ platform'.format(cpu)) 91 endif 92 if cpu >= 8 93 cpu_instruction_set = 'power'+cpu.to_string() 94 else 95 error('Compiler does not support POWER@0@ platform'.format(cpu)) 96 endif 97 endif 98 endif #end if not cross-build 99else 100 # User has explicitly chosen a platform for the build, use that 101 if cc.has_argument('-mcpu=' + platform) 102 cpu_instruction_set = platform 103 else 104 error('User selected platform ' + platform + ' not supported by compiler') 105 endif 106endif 107machine_args = ['-mcpu=' + cpu_instruction_set, '-mtune=' + cpu_instruction_set] 108dpdk_conf.set('RTE_MACHINE', cpu_instruction_set) 109 110 111# Certain POWER9 systems can scale as high as 1536 LCORES, but setting such a 112# high value can waste memory, cause timeouts in time limited autotests, and is 113# unlikely to be used in many production situations. Similarly, keeping the 114# default 64 LCORES seems too small as most POWER9 dual socket systems will have 115# at least 128 LCORES available. Set RTE_MAX_LCORE to 128 for POWER systems as 116# a compromise. 117dpdk_conf.set('RTE_MAX_LCORE', 128) 118 119# POWER systems do not allocate NUMA nodes sequentially. A dual socket system 120# will have CPUs associated with NUMA nodes 0 & 8, so ensure that the second 121# NUMA node will be supported by setting RTE_MAX_NUMA_NODES to 16. High end 122# systems can scale even higher with as many as 32 NUMA nodes. 123dpdk_conf.set('RTE_MAX_NUMA_NODES', 16) 124 125dpdk_conf.set('RTE_CACHE_LINE_SIZE', 128) 126