1 # SPDX-License-Identifier: BSD-3-Clause
2 # Copyright(c) 2018 Luca Boccassi <bluca@debian.org>
3 # Copyright(c) 2021 IBM Corporation
5 if not dpdk_conf.get('RTE_ARCH_64')
6 error('Only 64-bit compiles are supported for this platform type')
8 dpdk_conf.set('RTE_ARCH', 'ppc_64')
9 dpdk_conf.set('RTE_ARCH_PPC_64', 1)
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.
14 power9_supported = cc.has_argument('-mcpu=power9')
15 if not power9_supported
16 cpu_instruction_set = 'power8'
17 machine_args = ['-mcpu=power8', '-mtune=power8']
18 dpdk_conf.set('RTE_MACHINE','power8')
21 # Suppress the gcc warning "note: the layout of aggregates containing
22 # vectors with 4-byte alignment has changed in GCC 5".
23 if (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')
27 # If using a generic build, select the lowest common denominator
28 if 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.
34 elif 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'
42 __vector unsigned __int128 t, a, b;
44 __asm__("vcmpequq %0,%1,%2;" : "=v" (t) : "v" (a), "v" (b) : );
46 #error POWER10 not supported
48 printf("%d", (int)t[0]);
52 if not cc.compiles(test_p10, args : '-mcpu=power10', name: 'Detect P10')
53 error('POWER10 requested but not supported')
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
65 char * platform = (char*) getauxval(AT_PLATFORM);
67 if (!strncmp(platform,"power",5)) {
68 printf("%s", platform+5); return 0;
73 result = cc.run(detect_cpu, name : 'Detect host CPU type')
74 if not result.compiled()
75 error('Failed to detect CPU type')
77 cpu = result.stdout().to_int()
79 error('Unsupported POWER CPU detected')
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))
87 elif cc.has_argument(mcpu_flag.format(cpu-2))
90 error('Compiler does not support POWER@0@ platform'.format(cpu))
93 cpu_instruction_set = 'power'+cpu.to_string()
95 error('Compiler does not support POWER@0@ platform'.format(cpu))
98 endif #end if not cross-build
100 # User has explicitly chosen a platform for the build, use that
101 if cc.has_argument('-mcpu=' + platform)
102 cpu_instruction_set = platform
104 error('User selected platform ' + platform + ' not supported by compiler')
107 machine_args = ['-mcpu=' + cpu_instruction_set, '-mtune=' + cpu_instruction_set]
108 dpdk_conf.set('RTE_MACHINE', cpu_instruction_set)
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
117 dpdk_conf.set('RTE_MAX_LCORE', 128)
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.
123 dpdk_conf.set('RTE_MAX_NUMA_NODES', 16)
125 dpdk_conf.set('RTE_CACHE_LINE_SIZE', 128)