DPDK patches and discussions
 help / color / mirror / Atom feed
* [dpdk-dev] [RFC PATCH v1] build: add platform meson option
@ 2020-11-26 15:47 Juraj Linkeš
  2020-11-26 16:02 ` Bruce Richardson
  2021-01-04 11:52 ` [dpdk-dev] [RFC PATCH v2] " Juraj Linkeš
  0 siblings, 2 replies; 33+ messages in thread
From: Juraj Linkeš @ 2020-11-26 15:47 UTC (permalink / raw)
  To: thomas, bruce.richardson, Honnappa.Nagarahalli; +Cc: dev, Juraj Linkeš

The current meson option 'machine' should only specify the ISA, which is
not sufficient for Arm, where setting ISA implies other setting as well.
Add a new meson option, 'platform', which differentiates the type of the
build (native/generic) and sets machine accordingly, unless the user
chooses to override it.

Signed-off-by: Juraj Linkeš <juraj.linkes@pantheon.tech>
---
 config/arm/meson.build |  2 +-
 config/meson.build     | 14 +++++++++++++-
 meson_options.txt      |  6 ++++--
 3 files changed, 18 insertions(+), 4 deletions(-)

diff --git a/config/arm/meson.build b/config/arm/meson.build
index 42b4e43c7..ac680956f 100644
--- a/config/arm/meson.build
+++ b/config/arm/meson.build
@@ -6,7 +6,7 @@
 march_opt = '-march=@0@'.format(machine)
 
 arm_force_native_march = false
-arm_force_default_march = (machine == 'default')
+arm_force_default_march = (platform == 'generic')
 
 flags_common_default = [
 	# Accelarate rte_memcpy. Be sure to run unit test (memcpy_perf_autotest)
diff --git a/config/meson.build b/config/meson.build
index c02802c18..41d32e63e 100644
--- a/config/meson.build
+++ b/config/meson.build
@@ -63,6 +63,8 @@ if not is_windows
 			pmd_subdir_opt)
 endif
 
+platform = get_option('platform')
+
 # set the machine type and cflags for it
 if meson.is_cross_build()
 	machine = host_machine.cpu()
@@ -70,13 +72,23 @@ else
 	machine = get_option('machine')
 endif
 
+if platform == 'native'
+	if machine == 'auto'
+		machine = 'native'
+	endif
+elif platform == 'generic'
+	if machine == 'auto'
+		machine = 'default'
+	endif
+endif
+
+if machine == 'default'
 # machine type 'default' is special, it defaults to the per arch agreed common
 # minimal baseline needed for DPDK.
 # That might not be the most optimized, but the most portable version while
 # still being able to support the CPU features required for DPDK.
 # This can be bumped up by the DPDK project, but it can never be an
 # invariant like 'native'
-if machine == 'default'
 	if host_machine.cpu_family().startswith('x86')
 		# matches the old pre-meson build systems default
 		machine = 'corei7'
diff --git a/meson_options.txt b/meson_options.txt
index e384e6dbb..1a5e47fd3 100644
--- a/meson_options.txt
+++ b/meson_options.txt
@@ -20,14 +20,16 @@ option('kernel_dir', type: 'string', value: '',
 	description: 'Path to the kernel for building kernel modules. Headers must be in $kernel_dir/build. Modules will be installed in $DEST_DIR/$kernel_dir/extra/dpdk.')
 option('lib_musdk_dir', type: 'string', value: '',
 	description: 'path to the MUSDK library installation directory')
-option('machine', type: 'string', value: 'native',
-	description: 'set the target machine type')
+option('machine', type: 'string', value: 'auto',
+	description: 'set the target machine type/ISA')
 option('max_ethports', type: 'integer', value: 32,
 	description: 'maximum number of Ethernet devices')
 option('max_lcores', type: 'integer', value: 128,
 	description: 'maximum number of cores/threads supported by EAL')
 option('max_numa_nodes', type: 'integer', value: 4,
 	description: 'maximum number of NUMA nodes supported by EAL')
+option('platform', type: 'string', value: 'generic',
+	description: 'Platform to build for, either "native" or "generic".')
 option('enable_trace_fp', type: 'boolean', value: false,
 	description: 'enable fast path trace points.')
 option('tests', type: 'boolean', value: true,
-- 
2.20.1


^ permalink raw reply	[flat|nested] 33+ messages in thread

* Re: [dpdk-dev] [RFC PATCH v1] build: add platform meson option
  2020-11-26 15:47 [dpdk-dev] [RFC PATCH v1] build: add platform meson option Juraj Linkeš
@ 2020-11-26 16:02 ` Bruce Richardson
  2020-11-27  8:31   ` Juraj Linkeš
  2021-01-04 11:52 ` [dpdk-dev] [RFC PATCH v2] " Juraj Linkeš
  1 sibling, 1 reply; 33+ messages in thread
From: Bruce Richardson @ 2020-11-26 16:02 UTC (permalink / raw)
  To: Juraj Linkeš; +Cc: thomas, Honnappa.Nagarahalli, dev

On Thu, Nov 26, 2020 at 04:47:29PM +0100, Juraj Linkeš wrote:
> The current meson option 'machine' should only specify the ISA, which is
> not sufficient for Arm, where setting ISA implies other setting as well.
> Add a new meson option, 'platform', which differentiates the type of the
> build (native/generic) and sets machine accordingly, unless the user
> chooses to override it.
> 
> Signed-off-by: Juraj Linkeš <juraj.linkes@pantheon.tech>
> ---
>  config/arm/meson.build |  2 +-
>  config/meson.build     | 14 +++++++++++++-
>  meson_options.txt      |  6 ++++--
>  3 files changed, 18 insertions(+), 4 deletions(-)
> 
> diff --git a/config/arm/meson.build b/config/arm/meson.build
> index 42b4e43c7..ac680956f 100644
> --- a/config/arm/meson.build
> +++ b/config/arm/meson.build
> @@ -6,7 +6,7 @@
>  march_opt = '-march=@0@'.format(machine)
>  
>  arm_force_native_march = false
> -arm_force_default_march = (machine == 'default')
> +arm_force_default_march = (platform == 'generic')
>  
>  flags_common_default = [
>  	# Accelarate rte_memcpy. Be sure to run unit test (memcpy_perf_autotest)
> diff --git a/config/meson.build b/config/meson.build
> index c02802c18..41d32e63e 100644
> --- a/config/meson.build
> +++ b/config/meson.build
> @@ -63,6 +63,8 @@ if not is_windows
>  			pmd_subdir_opt)
>  endif
>  
> +platform = get_option('platform')
> +
>  # set the machine type and cflags for it
>  if meson.is_cross_build()
>  	machine = host_machine.cpu()
> @@ -70,13 +72,23 @@ else
>  	machine = get_option('machine')
>  endif
>  
> +if platform == 'native'
> +	if machine == 'auto'
> +		machine = 'native'
> +	endif
> +elif platform == 'generic'
> +	if machine == 'auto'
> +		machine = 'default'
> +	endif
> +endif
> +
> +if machine == 'default'
>  # machine type 'default' is special, it defaults to the per arch agreed common
>  # minimal baseline needed for DPDK.
>  # That might not be the most optimized, but the most portable version while
>  # still being able to support the CPU features required for DPDK.
>  # This can be bumped up by the DPDK project, but it can never be an
>  # invariant like 'native'
> -if machine == 'default'
>  	if host_machine.cpu_family().startswith('x86')
>  		# matches the old pre-meson build systems default
>  		machine = 'corei7'
> diff --git a/meson_options.txt b/meson_options.txt
> index e384e6dbb..1a5e47fd3 100644
> --- a/meson_options.txt
> +++ b/meson_options.txt
> @@ -20,14 +20,16 @@ option('kernel_dir', type: 'string', value: '',
>  	description: 'Path to the kernel for building kernel modules. Headers must be in $kernel_dir/build. Modules will be installed in $DEST_DIR/$kernel_dir/extra/dpdk.')
>  option('lib_musdk_dir', type: 'string', value: '',
>  	description: 'path to the MUSDK library installation directory')
> -option('machine', type: 'string', value: 'native',
> -	description: 'set the target machine type')
> +option('machine', type: 'string', value: 'auto',
> +	description: 'set the target machine type/ISA')
>  option('max_ethports', type: 'integer', value: 32,
>  	description: 'maximum number of Ethernet devices')
>  option('max_lcores', type: 'integer', value: 128,
>  	description: 'maximum number of cores/threads supported by EAL')
>  option('max_numa_nodes', type: 'integer', value: 4,
>  	description: 'maximum number of NUMA nodes supported by EAL')
> +option('platform', type: 'string', value: 'generic',
> +	description: 'Platform to build for, either "native" or "generic".')

As well as this short description option, I think we need more
comprehensive coverage of this option in the docs. Presumably for ARM
systems this will have other options for various SOC's rather than just
generic/native?

/Bruce

^ permalink raw reply	[flat|nested] 33+ messages in thread

* Re: [dpdk-dev] [RFC PATCH v1] build: add platform meson option
  2020-11-26 16:02 ` Bruce Richardson
@ 2020-11-27  8:31   ` Juraj Linkeš
  2020-11-27 14:07     ` Bruce Richardson
  0 siblings, 1 reply; 33+ messages in thread
From: Juraj Linkeš @ 2020-11-27  8:31 UTC (permalink / raw)
  To: Bruce Richardson; +Cc: thomas, Honnappa.Nagarahalli, dev



> -----Original Message-----
> From: Bruce Richardson <bruce.richardson@intel.com>
> Sent: Thursday, November 26, 2020 5:03 PM
> To: Juraj Linkeš <juraj.linkes@pantheon.tech>
> Cc: thomas@monjalon.net; Honnappa.Nagarahalli@arm.com; dev@dpdk.org
> Subject: Re: [RFC PATCH v1] build: add platform meson option
> 
> On Thu, Nov 26, 2020 at 04:47:29PM +0100, Juraj Linkeš wrote:
> > The current meson option 'machine' should only specify the ISA, which
> > is not sufficient for Arm, where setting ISA implies other setting as well.
> > Add a new meson option, 'platform', which differentiates the type of
> > the build (native/generic) and sets machine accordingly, unless the
> > user chooses to override it.
> >
> > Signed-off-by: Juraj Linkeš <juraj.linkes@pantheon.tech>
> > ---
> >  config/arm/meson.build |  2 +-
> >  config/meson.build     | 14 +++++++++++++-
> >  meson_options.txt      |  6 ++++--
> >  3 files changed, 18 insertions(+), 4 deletions(-)
> >
> > diff --git a/config/arm/meson.build b/config/arm/meson.build index
> > 42b4e43c7..ac680956f 100644
> > --- a/config/arm/meson.build
> > +++ b/config/arm/meson.build
> > @@ -6,7 +6,7 @@
> >  march_opt = '-march=@0@'.format(machine)
> >
> >  arm_force_native_march = false
> > -arm_force_default_march = (machine == 'default')
> > +arm_force_default_march = (platform == 'generic')
> >
> >  flags_common_default = [
> >  	# Accelarate rte_memcpy. Be sure to run unit test
> > (memcpy_perf_autotest) diff --git a/config/meson.build
> > b/config/meson.build index c02802c18..41d32e63e 100644
> > --- a/config/meson.build
> > +++ b/config/meson.build
> > @@ -63,6 +63,8 @@ if not is_windows
> >  			pmd_subdir_opt)
> >  endif
> >
> > +platform = get_option('platform')
> > +
> >  # set the machine type and cflags for it  if meson.is_cross_build()
> >  	machine = host_machine.cpu()
> > @@ -70,13 +72,23 @@ else
> >  	machine = get_option('machine')
> >  endif
> >
> > +if platform == 'native'
> > +	if machine == 'auto'
> > +		machine = 'native'
> > +	endif
> > +elif platform == 'generic'
> > +	if machine == 'auto'
> > +		machine = 'default'
> > +	endif
> > +endif
> > +
> > +if machine == 'default'
> >  # machine type 'default' is special, it defaults to the per arch
> > agreed common  # minimal baseline needed for DPDK.
> >  # That might not be the most optimized, but the most portable version
> > while  # still being able to support the CPU features required for DPDK.
> >  # This can be bumped up by the DPDK project, but it can never be an
> > # invariant like 'native'
> > -if machine == 'default'
> >  	if host_machine.cpu_family().startswith('x86')
> >  		# matches the old pre-meson build systems default
> >  		machine = 'corei7'
> > diff --git a/meson_options.txt b/meson_options.txt index
> > e384e6dbb..1a5e47fd3 100644
> > --- a/meson_options.txt
> > +++ b/meson_options.txt
> > @@ -20,14 +20,16 @@ option('kernel_dir', type: 'string', value: '',
> >  	description: 'Path to the kernel for building kernel modules.
> > Headers must be in $kernel_dir/build. Modules will be installed in
> > $DEST_DIR/$kernel_dir/extra/dpdk.')
> >  option('lib_musdk_dir', type: 'string', value: '',
> >  	description: 'path to the MUSDK library installation directory')
> > -option('machine', type: 'string', value: 'native',
> > -	description: 'set the target machine type')
> > +option('machine', type: 'string', value: 'auto',
> > +	description: 'set the target machine type/ISA')
> >  option('max_ethports', type: 'integer', value: 32,
> >  	description: 'maximum number of Ethernet devices')
> > option('max_lcores', type: 'integer', value: 128,
> >  	description: 'maximum number of cores/threads supported by EAL')
> > option('max_numa_nodes', type: 'integer', value: 4,
> >  	description: 'maximum number of NUMA nodes supported by EAL')
> > +option('platform', type: 'string', value: 'generic',
> > +	description: 'Platform to build for, either "native" or "generic".')
> 
> As well as this short description option, I think we need more comprehensive
> coverage of this option in the docs.

Where should this be documented? In doc/guides/linux_gsg/build_dpdk.rst or somewhere else?

> Presumably for ARM systems this will have
> other options for various SOC's rather than just generic/native?
> 

Yes, I'm planning on using the platform option for this. Since we've separated the changes into their own patch sets, only this small change is in this patch set. It'll affect how we're doing the automatic numa/core detection as well as how we're choosic which Arm SoC to build for, but those changes are in different patch sets.

I mainly want feedback on naming - I like 'platform' and I don't think we need to rename 'machine', maybe just document it better - and on the overall idea. I think this is in line with what you had in mind, right?

> /Bruce


^ permalink raw reply	[flat|nested] 33+ messages in thread

* Re: [dpdk-dev] [RFC PATCH v1] build: add platform meson option
  2020-11-27  8:31   ` Juraj Linkeš
@ 2020-11-27 14:07     ` Bruce Richardson
  2020-12-23 11:23       ` Juraj Linkeš
  0 siblings, 1 reply; 33+ messages in thread
From: Bruce Richardson @ 2020-11-27 14:07 UTC (permalink / raw)
  To: Juraj Linkeš; +Cc: thomas, Honnappa.Nagarahalli, dev

On Fri, Nov 27, 2020 at 08:31:47AM +0000, Juraj Linkeš wrote:
> 
> 
> > -----Original Message-----
> > From: Bruce Richardson <bruce.richardson@intel.com>
> > Sent: Thursday, November 26, 2020 5:03 PM
> > To: Juraj Linkeš <juraj.linkes@pantheon.tech>
> > Cc: thomas@monjalon.net; Honnappa.Nagarahalli@arm.com; dev@dpdk.org
> > Subject: Re: [RFC PATCH v1] build: add platform meson option
> > 
> > On Thu, Nov 26, 2020 at 04:47:29PM +0100, Juraj Linkeš wrote:
> > > The current meson option 'machine' should only specify the ISA, which
> > > is not sufficient for Arm, where setting ISA implies other setting as well.
> > > Add a new meson option, 'platform', which differentiates the type of
> > > the build (native/generic) and sets machine accordingly, unless the
> > > user chooses to override it.
> > >
> > > Signed-off-by: Juraj Linkeš <juraj.linkes@pantheon.tech>
> > > ---
> > >  config/arm/meson.build |  2 +-
> > >  config/meson.build     | 14 +++++++++++++-
> > >  meson_options.txt      |  6 ++++--
> > >  3 files changed, 18 insertions(+), 4 deletions(-)
> > >
> > > diff --git a/config/arm/meson.build b/config/arm/meson.build index
> > > 42b4e43c7..ac680956f 100644
> > > --- a/config/arm/meson.build
> > > +++ b/config/arm/meson.build
> > > @@ -6,7 +6,7 @@
> > >  march_opt = '-march=@0@'.format(machine)
> > >
> > >  arm_force_native_march = false
> > > -arm_force_default_march = (machine == 'default')
> > > +arm_force_default_march = (platform == 'generic')
> > >
> > >  flags_common_default = [
> > >  	# Accelarate rte_memcpy. Be sure to run unit test
> > > (memcpy_perf_autotest) diff --git a/config/meson.build
> > > b/config/meson.build index c02802c18..41d32e63e 100644
> > > --- a/config/meson.build
> > > +++ b/config/meson.build
> > > @@ -63,6 +63,8 @@ if not is_windows
> > >  			pmd_subdir_opt)
> > >  endif
> > >
> > > +platform = get_option('platform')
> > > +
> > >  # set the machine type and cflags for it  if meson.is_cross_build()
> > >  	machine = host_machine.cpu()
> > > @@ -70,13 +72,23 @@ else
> > >  	machine = get_option('machine')
> > >  endif
> > >
> > > +if platform == 'native'
> > > +	if machine == 'auto'
> > > +		machine = 'native'
> > > +	endif
> > > +elif platform == 'generic'
> > > +	if machine == 'auto'
> > > +		machine = 'default'
> > > +	endif
> > > +endif
> > > +
> > > +if machine == 'default'
> > >  # machine type 'default' is special, it defaults to the per arch
> > > agreed common  # minimal baseline needed for DPDK.
> > >  # That might not be the most optimized, but the most portable version
> > > while  # still being able to support the CPU features required for DPDK.
> > >  # This can be bumped up by the DPDK project, but it can never be an
> > > # invariant like 'native'
> > > -if machine == 'default'
> > >  	if host_machine.cpu_family().startswith('x86')
> > >  		# matches the old pre-meson build systems default
> > >  		machine = 'corei7'
> > > diff --git a/meson_options.txt b/meson_options.txt index
> > > e384e6dbb..1a5e47fd3 100644
> > > --- a/meson_options.txt
> > > +++ b/meson_options.txt
> > > @@ -20,14 +20,16 @@ option('kernel_dir', type: 'string', value: '',
> > >  	description: 'Path to the kernel for building kernel modules.
> > > Headers must be in $kernel_dir/build. Modules will be installed in
> > > $DEST_DIR/$kernel_dir/extra/dpdk.')
> > >  option('lib_musdk_dir', type: 'string', value: '',
> > >  	description: 'path to the MUSDK library installation directory')
> > > -option('machine', type: 'string', value: 'native',
> > > -	description: 'set the target machine type')
> > > +option('machine', type: 'string', value: 'auto',
> > > +	description: 'set the target machine type/ISA')
> > >  option('max_ethports', type: 'integer', value: 32,
> > >  	description: 'maximum number of Ethernet devices')
> > > option('max_lcores', type: 'integer', value: 128,
> > >  	description: 'maximum number of cores/threads supported by EAL')
> > > option('max_numa_nodes', type: 'integer', value: 4,
> > >  	description: 'maximum number of NUMA nodes supported by EAL')
> > > +option('platform', type: 'string', value: 'generic',
> > > +	description: 'Platform to build for, either "native" or "generic".')
> > 
> > As well as this short description option, I think we need more comprehensive
> > coverage of this option in the docs.
> 
> Where should this be documented? In doc/guides/linux_gsg/build_dpdk.rst or somewhere else?
> 
I'll need to look into this, but I think that we need to expand that
section to cover in more detail all build options as we rework them.

> > Presumably for ARM systems this will have
> > other options for various SOC's rather than just generic/native?
> > 
> 
> Yes, I'm planning on using the platform option for this. Since we've separated the changes into their own patch sets, only this small change is in this patch set. It'll affect how we're doing the automatic numa/core detection as well as how we're choosic which Arm SoC to build for, but those changes are in different patch sets.
> 
> I mainly want feedback on naming - I like 'platform' and I don't think we need to rename 'machine', maybe just document it better - and on the overall idea. I think this is in line with what you had in mind, right?
> 
Yes this is in line with what I had in mind, thanks for doing the work.

I'm still of a mind to rename "machine", since it's a very ambiguous term.
I think something like "cpu_instruction_set" would be a lot clearer. With
choice of a good name, the amount of documentation needed around it is much
reduced.

We should probably get feedback from a number of people before making a
decision.

Regards,
/Bruce

^ permalink raw reply	[flat|nested] 33+ messages in thread

* Re: [dpdk-dev] [RFC PATCH v1] build: add platform meson option
  2020-11-27 14:07     ` Bruce Richardson
@ 2020-12-23 11:23       ` Juraj Linkeš
  0 siblings, 0 replies; 33+ messages in thread
From: Juraj Linkeš @ 2020-12-23 11:23 UTC (permalink / raw)
  To: Bruce Richardson; +Cc: thomas, Honnappa.Nagarahalli, dev



> -----Original Message-----
> From: Bruce Richardson <bruce.richardson@intel.com>
> Sent: Friday, November 27, 2020 3:07 PM
> To: Juraj Linkeš <juraj.linkes@pantheon.tech>
> Cc: thomas@monjalon.net; Honnappa.Nagarahalli@arm.com; dev@dpdk.org
> Subject: Re: [RFC PATCH v1] build: add platform meson option
> 
> On Fri, Nov 27, 2020 at 08:31:47AM +0000, Juraj Linkeš wrote:
> >
> >
> > > -----Original Message-----
> > > From: Bruce Richardson <bruce.richardson@intel.com>
> > > Sent: Thursday, November 26, 2020 5:03 PM
> > > To: Juraj Linkeš <juraj.linkes@pantheon.tech>
> > > Cc: thomas@monjalon.net; Honnappa.Nagarahalli@arm.com;
> dev@dpdk.org
> > > Subject: Re: [RFC PATCH v1] build: add platform meson option
> > >
> > > On Thu, Nov 26, 2020 at 04:47:29PM +0100, Juraj Linkeš wrote:
> > > > The current meson option 'machine' should only specify the ISA,
> > > > which is not sufficient for Arm, where setting ISA implies other setting as
> well.
> > > > Add a new meson option, 'platform', which differentiates the type
> > > > of the build (native/generic) and sets machine accordingly, unless
> > > > the user chooses to override it.
> > > >
> > > > Signed-off-by: Juraj Linkeš <juraj.linkes@pantheon.tech>
> > > > ---
> > > >  config/arm/meson.build |  2 +-
> > > >  config/meson.build     | 14 +++++++++++++-
> > > >  meson_options.txt      |  6 ++++--
> > > >  3 files changed, 18 insertions(+), 4 deletions(-)
> > > >
> > > > diff --git a/config/arm/meson.build b/config/arm/meson.build index
> > > > 42b4e43c7..ac680956f 100644
> > > > --- a/config/arm/meson.build
> > > > +++ b/config/arm/meson.build
> > > > @@ -6,7 +6,7 @@
> > > >  march_opt = '-march=@0@'.format(machine)
> > > >
> > > >  arm_force_native_march = false
> > > > -arm_force_default_march = (machine == 'default')
> > > > +arm_force_default_march = (platform == 'generic')
> > > >
> > > >  flags_common_default = [
> > > >  	# Accelarate rte_memcpy. Be sure to run unit test
> > > > (memcpy_perf_autotest) diff --git a/config/meson.build
> > > > b/config/meson.build index c02802c18..41d32e63e 100644
> > > > --- a/config/meson.build
> > > > +++ b/config/meson.build
> > > > @@ -63,6 +63,8 @@ if not is_windows
> > > >  			pmd_subdir_opt)
> > > >  endif
> > > >
> > > > +platform = get_option('platform')
> > > > +
> > > >  # set the machine type and cflags for it  if meson.is_cross_build()
> > > >  	machine = host_machine.cpu()
> > > > @@ -70,13 +72,23 @@ else
> > > >  	machine = get_option('machine')
> > > >  endif
> > > >
> > > > +if platform == 'native'
> > > > +	if machine == 'auto'
> > > > +		machine = 'native'
> > > > +	endif
> > > > +elif platform == 'generic'
> > > > +	if machine == 'auto'
> > > > +		machine = 'default'
> > > > +	endif
> > > > +endif
> > > > +
> > > > +if machine == 'default'
> > > >  # machine type 'default' is special, it defaults to the per arch
> > > > agreed common  # minimal baseline needed for DPDK.
> > > >  # That might not be the most optimized, but the most portable
> > > > version while  # still being able to support the CPU features required for
> DPDK.
> > > >  # This can be bumped up by the DPDK project, but it can never be
> > > > an # invariant like 'native'
> > > > -if machine == 'default'
> > > >  	if host_machine.cpu_family().startswith('x86')
> > > >  		# matches the old pre-meson build systems default
> > > >  		machine = 'corei7'
> > > > diff --git a/meson_options.txt b/meson_options.txt index
> > > > e384e6dbb..1a5e47fd3 100644
> > > > --- a/meson_options.txt
> > > > +++ b/meson_options.txt
> > > > @@ -20,14 +20,16 @@ option('kernel_dir', type: 'string', value: '',
> > > >  	description: 'Path to the kernel for building kernel modules.
> > > > Headers must be in $kernel_dir/build. Modules will be installed in
> > > > $DEST_DIR/$kernel_dir/extra/dpdk.')
> > > >  option('lib_musdk_dir', type: 'string', value: '',
> > > >  	description: 'path to the MUSDK library installation directory')
> > > > -option('machine', type: 'string', value: 'native',
> > > > -	description: 'set the target machine type')
> > > > +option('machine', type: 'string', value: 'auto',
> > > > +	description: 'set the target machine type/ISA')
> > > >  option('max_ethports', type: 'integer', value: 32,
> > > >  	description: 'maximum number of Ethernet devices')
> > > > option('max_lcores', type: 'integer', value: 128,
> > > >  	description: 'maximum number of cores/threads supported by EAL')
> > > > option('max_numa_nodes', type: 'integer', value: 4,
> > > >  	description: 'maximum number of NUMA nodes supported by EAL')
> > > > +option('platform', type: 'string', value: 'generic',
> > > > +	description: 'Platform to build for, either "native" or
> > > > +"generic".')
> > >
> > > As well as this short description option, I think we need more
> > > comprehensive coverage of this option in the docs.
> >
> > Where should this be documented? In doc/guides/linux_gsg/build_dpdk.rst or
> somewhere else?
> >
> I'll need to look into this, but I think that we need to expand that section to
> cover in more detail all build options as we rework them.
> 

Any news on this? If we want to document this in just doc/guides/linux_gsg/build_dpdk.rst I can propose some changes.

> > > Presumably for ARM systems this will have other options for various
> > > SOC's rather than just generic/native?
> > >
> >
> > Yes, I'm planning on using the platform option for this. Since we've separated
> the changes into their own patch sets, only this small change is in this patch set.
> It'll affect how we're doing the automatic numa/core detection as well as how
> we're choosic which Arm SoC to build for, but those changes are in different
> patch sets.
> >
> > I mainly want feedback on naming - I like 'platform' and I don't think we need
> to rename 'machine', maybe just document it better - and on the overall idea. I
> think this is in line with what you had in mind, right?
> >
> Yes this is in line with what I had in mind, thanks for doing the work.
> 
> I'm still of a mind to rename "machine", since it's a very ambiguous term.
> I think something like "cpu_instruction_set" would be a lot clearer. With choice
> of a good name, the amount of documentation needed around it is much
> reduced.
> 

I wanted to keep machine mainly for backwards compatibilty, but we can do that anyway, as in keep machine for a release a two with a deprecation notice and then remove it while using a differently named (but same in function) option.

What's were doing with the option is setting the appropriate "machine args", as the variable  is called. For x86, that means setting -march (which is just the instruction set according to the docs [0]), for ppc it sets -mcpu and -mtune (architecture type, register usage, and instruction scheduling parameters according to [1]) and we're not using it to set machine args for arm at all (we are setting machine args based on other criteria; when this new option along with platform are in effect, we can think about using cpu_instruction_set somehow).

With this in mind, cpu_instruction_set seems like the best candidate. I'll submit a new version with both cpu_instruction_set and machine if there aren't any objections in some time.

[0] https://gcc.gnu.org/onlinedocs/gcc-8.4.0/gcc/x86-Options.html#x86-Options
[1] https://gcc.gnu.org/onlinedocs/gcc-8.4.0/gcc/RS_002f6000-and-PowerPC-Options.html#RS_002f6000-and-PowerPC-Options

> We should probably get feedback from a number of people before making a
> decision.
> 

Unfortunately we didn't get any feedback. Do you have anyone in particular in mind?

> Regards,
> /Bruce


^ permalink raw reply	[flat|nested] 33+ messages in thread

* [dpdk-dev] [RFC PATCH v2] build: add platform meson option
  2020-11-26 15:47 [dpdk-dev] [RFC PATCH v1] build: add platform meson option Juraj Linkeš
  2020-11-26 16:02 ` Bruce Richardson
@ 2021-01-04 11:52 ` Juraj Linkeš
  2021-01-04 11:59   ` Juraj Linkeš
  2021-03-29 11:03   ` [dpdk-dev] [PATCH v3] " Juraj Linkeš
  1 sibling, 2 replies; 33+ messages in thread
From: Juraj Linkeš @ 2021-01-04 11:52 UTC (permalink / raw)
  To: thomas, bruce.richardson, Honnappa.Nagarahalli; +Cc: dev, Juraj Linkeš

The current meson option 'machine' should only specify the ISA, which is
not sufficient for Arm, where setting ISA implies other setting as well.
Add a new meson option, 'platform', which differentiates the type of the
build (native/generic) and sets machine accordingly, unless the user
chooses to override it.
The 'machine' option also doesn't describe very well what it sets, so
introduce a new option 'cpu_instruction_set', but keep 'machine' for
backward compatibility.
These two new variables, taken together, achieve what 'machine' was
setting per architecture - setting the ISA in x86 build and setting
native/default 'build type' in aarch64 build - is now properly being set
for all architectures in a uniform manner.

Signed-off-by: Juraj Linkeš <juraj.linkes@pantheon.tech>
---
 config/arm/meson.build        |  4 +--
 config/meson.build            | 47 +++++++++++++++++++++++++----------
 devtools/test-meson-builds.sh |  9 ++++---
 meson_options.txt             |  8 ++++--
 4 files changed, 47 insertions(+), 21 deletions(-)

diff --git a/config/arm/meson.build b/config/arm/meson.build
index 42b4e43c7..6b09a74a7 100644
--- a/config/arm/meson.build
+++ b/config/arm/meson.build
@@ -3,10 +3,10 @@
 # Copyright(c) 2017 Cavium, Inc
 
 # for checking defines we need to use the correct compiler flags
-march_opt = '-march=@0@'.format(machine)
+march_opt = '-march=@0@'.format(cpu_instruction_set)
 
 arm_force_native_march = false
-arm_force_default_march = (machine == 'default')
+arm_force_default_march = (platform == 'generic')
 
 flags_common_default = [
 	# Accelarate rte_memcpy. Be sure to run unit test (memcpy_perf_autotest)
diff --git a/config/meson.build b/config/meson.build
index a3154e29c..647116513 100644
--- a/config/meson.build
+++ b/config/meson.build
@@ -63,42 +63,63 @@ if not is_windows
 			pmd_subdir_opt)
 endif
 
-# set the machine type and cflags for it
+platform = get_option('platform')
+
+# set the cpu_instruction_set type and cflags for it
 if meson.is_cross_build()
-	machine = host_machine.cpu()
+	cpu_instruction_set = host_machine.cpu()
 else
-	machine = get_option('machine')
+	cpu_instruction_set = get_option('cpu_instruction_set')
+	if get_option('machine') != 'auto'
+		warning('The "machine" option is deprecated. ' +
+		        'Please use "cpu_instruction_set" instead.')
+		if cpu_instruction_set != 'auto'
+			error('Setting both "machine" and ' +
+			      '"cpu_instruction_set" is unsupported.')
+		endif
+		cpu_instruction_set = get_option('machine')
+	endif
+endif
+
+if platform == 'native'
+	if cpu_instruction_set == 'auto'
+		cpu_instruction_set = 'native'
+	endif
+elif platform == 'generic'
+	if cpu_instruction_set == 'auto'
+		cpu_instruction_set = 'default'
+	endif
 endif
 
-# machine type 'default' is special, it defaults to the per arch agreed common
+if cpu_instruction_set == 'default'
+# cpu_instruction_set type 'default' is special, it defaults to the per arch agreed common
 # minimal baseline needed for DPDK.
 # That might not be the most optimized, but the most portable version while
 # still being able to support the CPU features required for DPDK.
 # This can be bumped up by the DPDK project, but it can never be an
 # invariant like 'native'
-if machine == 'default'
 	if host_machine.cpu_family().startswith('x86')
 		# matches the old pre-meson build systems default
-		machine = 'corei7'
+		cpu_instruction_set = 'corei7'
 	elif host_machine.cpu_family().startswith('arm')
-		machine = 'armv7-a'
+		cpu_instruction_set = 'armv7-a'
 	elif host_machine.cpu_family().startswith('aarch')
 		# arm64 manages defaults in config/arm/meson.build
-		machine = 'default'
+		cpu_instruction_set = 'default'
 	elif host_machine.cpu_family().startswith('ppc')
-		machine = 'power8'
+		cpu_instruction_set = 'power8'
 	endif
 endif
 
-dpdk_conf.set('RTE_MACHINE', machine)
+dpdk_conf.set('RTE_MACHINE', cpu_instruction_set)
 machine_args = []
 
 # ppc64 does not support -march= at all, use -mcpu and -mtune for that
 if host_machine.cpu_family().startswith('ppc')
-	machine_args += '-mcpu=' + machine
-	machine_args += '-mtune=' + machine
+	machine_args += '-mcpu=' + cpu_instruction_set
+	machine_args += '-mtune=' + cpu_instruction_set
 else
-	machine_args += '-march=' + machine
+	machine_args += '-march=' + cpu_instruction_set
 endif
 
 toolchain = cc.get_id()
diff --git a/devtools/test-meson-builds.sh b/devtools/test-meson-builds.sh
index 7280b7a93..33845d998 100755
--- a/devtools/test-meson-builds.sh
+++ b/devtools/test-meson-builds.sh
@@ -211,11 +211,12 @@ done
 # test compilation with minimal x86 instruction set
 # Set the install path for libraries to "lib" explicitly to prevent problems
 # with pkg-config prefixes if installed in "lib/x86_64-linux-gnu" later.
-default_machine='nehalem'
-if ! check_cc_flags "-march=$default_machine" ; then
-	default_machine='corei7'
+default_isa='nehalem'
+if ! check_cc_flags "-march=$default_isa" ; then
+	default_isa='corei7'
 fi
-build build-x86-default cc -Dlibdir=lib -Dmachine=$default_machine $use_shared
+build build-x86-default cc -Dlibdir=lib -Dcpu_instruction_set=$default_isa \
+      $use_shared
 
 # 32-bit with default compiler
 if check_cc_flags '-m32' ; then
diff --git a/meson_options.txt b/meson_options.txt
index e384e6dbb..9db03a87d 100644
--- a/meson_options.txt
+++ b/meson_options.txt
@@ -1,5 +1,7 @@
 # Please keep these options sorted alphabetically.
 
+option('cpu_instruction_set', type: 'string', value: 'auto',
+	description: 'Set the target machine ISA (instruction set architecture)/')
 option('disable_drivers', type: 'string', value: '',
 	description: 'Comma-separated list of drivers to explicitly disable.')
 option('drivers_install_subdir', type: 'string', value: 'dpdk/pmds-<VERSION>',
@@ -20,14 +22,16 @@ option('kernel_dir', type: 'string', value: '',
 	description: 'Path to the kernel for building kernel modules. Headers must be in $kernel_dir/build. Modules will be installed in $DEST_DIR/$kernel_dir/extra/dpdk.')
 option('lib_musdk_dir', type: 'string', value: '',
 	description: 'path to the MUSDK library installation directory')
-option('machine', type: 'string', value: 'native',
-	description: 'set the target machine type')
+option('machine', type: 'string', value: 'auto',
+	description: 'set the target machine type/ISA')
 option('max_ethports', type: 'integer', value: 32,
 	description: 'maximum number of Ethernet devices')
 option('max_lcores', type: 'integer', value: 128,
 	description: 'maximum number of cores/threads supported by EAL')
 option('max_numa_nodes', type: 'integer', value: 4,
 	description: 'maximum number of NUMA nodes supported by EAL')
+option('platform', type: 'string', value: 'generic',
+	description: 'Platform to build for, either "native" or "generic".')
 option('enable_trace_fp', type: 'boolean', value: false,
 	description: 'enable fast path trace points.')
 option('tests', type: 'boolean', value: true,
-- 
2.20.1


^ permalink raw reply	[flat|nested] 33+ messages in thread

* Re: [dpdk-dev] [RFC PATCH v2] build: add platform meson option
  2021-01-04 11:52 ` [dpdk-dev] [RFC PATCH v2] " Juraj Linkeš
@ 2021-01-04 11:59   ` Juraj Linkeš
  2021-01-05 22:17     ` David Christensen
  2021-03-29 11:03   ` [dpdk-dev] [PATCH v3] " Juraj Linkeš
  1 sibling, 1 reply; 33+ messages in thread
From: Juraj Linkeš @ 2021-01-04 11:59 UTC (permalink / raw)
  To: Juraj Linkeš, thomas, bruce.richardson, Honnappa.Nagarahalli, drc
  Cc: dev

Apologies, I meant to add David as well.

> -----Original Message-----
> From: Juraj Linkeš <juraj.linkes@pantheon.tech>
> Sent: Monday, January 4, 2021 12:52 PM
> To: thomas@monjalon.net; bruce.richardson@intel.com;
> Honnappa.Nagarahalli@arm.com
> Cc: dev@dpdk.org; Juraj Linkeš <juraj.linkes@pantheon.tech>
> Subject: [RFC PATCH v2] build: add platform meson option
> 
> The current meson option 'machine' should only specify the ISA, which is not
> sufficient for Arm, where setting ISA implies other setting as well.
> Add a new meson option, 'platform', which differentiates the type of the build
> (native/generic) and sets machine accordingly, unless the user chooses to
> override it.
> The 'machine' option also doesn't describe very well what it sets, so introduce a
> new option 'cpu_instruction_set', but keep 'machine' for backward
> compatibility.
> These two new variables, taken together, achieve what 'machine' was setting
> per architecture - setting the ISA in x86 build and setting native/default 'build
> type' in aarch64 build - is now properly being set for all architectures in a
> uniform manner.
> 
> Signed-off-by: Juraj Linkeš <juraj.linkes@pantheon.tech>
> ---
>  config/arm/meson.build        |  4 +--
>  config/meson.build            | 47 +++++++++++++++++++++++++----------
>  devtools/test-meson-builds.sh |  9 ++++---
>  meson_options.txt             |  8 ++++--
>  4 files changed, 47 insertions(+), 21 deletions(-)
> 
> diff --git a/config/arm/meson.build b/config/arm/meson.build index
> 42b4e43c7..6b09a74a7 100644
> --- a/config/arm/meson.build
> +++ b/config/arm/meson.build
> @@ -3,10 +3,10 @@
>  # Copyright(c) 2017 Cavium, Inc
> 
>  # for checking defines we need to use the correct compiler flags -march_opt = '-
> march=@0@'.format(machine)
> +march_opt = '-march=@0@'.format(cpu_instruction_set)
> 
>  arm_force_native_march = false
> -arm_force_default_march = (machine == 'default')
> +arm_force_default_march = (platform == 'generic')
> 
>  flags_common_default = [
>  	# Accelarate rte_memcpy. Be sure to run unit test
> (memcpy_perf_autotest) diff --git a/config/meson.build b/config/meson.build
> index a3154e29c..647116513 100644
> --- a/config/meson.build
> +++ b/config/meson.build
> @@ -63,42 +63,63 @@ if not is_windows
>  			pmd_subdir_opt)
>  endif
> 
> -# set the machine type and cflags for it
> +platform = get_option('platform')
> +
> +# set the cpu_instruction_set type and cflags for it
>  if meson.is_cross_build()
> -	machine = host_machine.cpu()
> +	cpu_instruction_set = host_machine.cpu()
>  else
> -	machine = get_option('machine')
> +	cpu_instruction_set = get_option('cpu_instruction_set')
> +	if get_option('machine') != 'auto'
> +		warning('The "machine" option is deprecated. ' +
> +		        'Please use "cpu_instruction_set" instead.')
> +		if cpu_instruction_set != 'auto'
> +			error('Setting both "machine" and ' +
> +			      '"cpu_instruction_set" is unsupported.')
> +		endif
> +		cpu_instruction_set = get_option('machine')
> +	endif
> +endif
> +
> +if platform == 'native'
> +	if cpu_instruction_set == 'auto'
> +		cpu_instruction_set = 'native'
> +	endif
> +elif platform == 'generic'
> +	if cpu_instruction_set == 'auto'
> +		cpu_instruction_set = 'default'
> +	endif
>  endif
> 
> -# machine type 'default' is special, it defaults to the per arch agreed common
> +if cpu_instruction_set == 'default'
> +# cpu_instruction_set type 'default' is special, it defaults to the per
> +arch agreed common
>  # minimal baseline needed for DPDK.
>  # That might not be the most optimized, but the most portable version while  #
> still being able to support the CPU features required for DPDK.
>  # This can be bumped up by the DPDK project, but it can never be an  # invariant
> like 'native'
> -if machine == 'default'
>  	if host_machine.cpu_family().startswith('x86')
>  		# matches the old pre-meson build systems default
> -		machine = 'corei7'
> +		cpu_instruction_set = 'corei7'
>  	elif host_machine.cpu_family().startswith('arm')
> -		machine = 'armv7-a'
> +		cpu_instruction_set = 'armv7-a'
>  	elif host_machine.cpu_family().startswith('aarch')
>  		# arm64 manages defaults in config/arm/meson.build
> -		machine = 'default'
> +		cpu_instruction_set = 'default'
>  	elif host_machine.cpu_family().startswith('ppc')
> -		machine = 'power8'
> +		cpu_instruction_set = 'power8'
>  	endif
>  endif
> 
> -dpdk_conf.set('RTE_MACHINE', machine)
> +dpdk_conf.set('RTE_MACHINE', cpu_instruction_set)
>  machine_args = []
> 
>  # ppc64 does not support -march= at all, use -mcpu and -mtune for that  if
> host_machine.cpu_family().startswith('ppc')
> -	machine_args += '-mcpu=' + machine
> -	machine_args += '-mtune=' + machine
> +	machine_args += '-mcpu=' + cpu_instruction_set
> +	machine_args += '-mtune=' + cpu_instruction_set
>  else
> -	machine_args += '-march=' + machine
> +	machine_args += '-march=' + cpu_instruction_set
>  endif
> 
>  toolchain = cc.get_id()
> diff --git a/devtools/test-meson-builds.sh b/devtools/test-meson-builds.sh index
> 7280b7a93..33845d998 100755
> --- a/devtools/test-meson-builds.sh
> +++ b/devtools/test-meson-builds.sh
> @@ -211,11 +211,12 @@ done
>  # test compilation with minimal x86 instruction set  # Set the install path for
> libraries to "lib" explicitly to prevent problems  # with pkg-config prefixes if
> installed in "lib/x86_64-linux-gnu" later.
> -default_machine='nehalem'
> -if ! check_cc_flags "-march=$default_machine" ; then
> -	default_machine='corei7'
> +default_isa='nehalem'
> +if ! check_cc_flags "-march=$default_isa" ; then
> +	default_isa='corei7'
>  fi
> -build build-x86-default cc -Dlibdir=lib -Dmachine=$default_machine
> $use_shared
> +build build-x86-default cc -Dlibdir=lib -Dcpu_instruction_set=$default_isa \
> +      $use_shared
> 
>  # 32-bit with default compiler
>  if check_cc_flags '-m32' ; then
> diff --git a/meson_options.txt b/meson_options.txt index
> e384e6dbb..9db03a87d 100644
> --- a/meson_options.txt
> +++ b/meson_options.txt
> @@ -1,5 +1,7 @@
>  # Please keep these options sorted alphabetically.
> 
> +option('cpu_instruction_set', type: 'string', value: 'auto',
> +	description: 'Set the target machine ISA (instruction set
> +architecture)/')
>  option('disable_drivers', type: 'string', value: '',
>  	description: 'Comma-separated list of drivers to explicitly disable.')
> option('drivers_install_subdir', type: 'string', value: 'dpdk/pmds-<VERSION>',
> @@ -20,14 +22,16 @@ option('kernel_dir', type: 'string', value: '',
>  	description: 'Path to the kernel for building kernel modules. Headers
> must be in $kernel_dir/build. Modules will be installed in
> $DEST_DIR/$kernel_dir/extra/dpdk.')
>  option('lib_musdk_dir', type: 'string', value: '',
>  	description: 'path to the MUSDK library installation directory') -
> option('machine', type: 'string', value: 'native',
> -	description: 'set the target machine type')
> +option('machine', type: 'string', value: 'auto',
> +	description: 'set the target machine type/ISA')
>  option('max_ethports', type: 'integer', value: 32,
>  	description: 'maximum number of Ethernet devices')
> option('max_lcores', type: 'integer', value: 128,
>  	description: 'maximum number of cores/threads supported by EAL')
> option('max_numa_nodes', type: 'integer', value: 4,
>  	description: 'maximum number of NUMA nodes supported by EAL')
> +option('platform', type: 'string', value: 'generic',
> +	description: 'Platform to build for, either "native" or "generic".')
>  option('enable_trace_fp', type: 'boolean', value: false,
>  	description: 'enable fast path trace points.')  option('tests', type:
> 'boolean', value: true,
> --
> 2.20.1


^ permalink raw reply	[flat|nested] 33+ messages in thread

* Re: [dpdk-dev] [RFC PATCH v2] build: add platform meson option
  2021-01-04 11:59   ` Juraj Linkeš
@ 2021-01-05 22:17     ` David Christensen
  2021-01-06 14:42       ` Bruce Richardson
  0 siblings, 1 reply; 33+ messages in thread
From: David Christensen @ 2021-01-05 22:17 UTC (permalink / raw)
  To: Juraj Linkeš, thomas, bruce.richardson, Honnappa.Nagarahalli; +Cc: dev

>> The current meson option 'machine' should only specify the ISA, which is not
>> sufficient for Arm, where setting ISA implies other setting as well.
>> Add a new meson option, 'platform', which differentiates the type of the build
>> (native/generic) and sets machine accordingly, unless the user chooses to
>> override it.
>> The 'machine' option also doesn't describe very well what it sets, so introduce a
>> new option 'cpu_instruction_set', but keep 'machine' for backward
>> compatibility.
>> These two new variables, taken together, achieve what 'machine' was setting
>> per architecture - setting the ISA in x86 build and setting native/default 'build
>> type' in aarch64 build - is now properly being set for all architectures in a
>> uniform manner.
>>
>> Signed-off-by: Juraj Linkeš <juraj.linkes@pantheon.tech>
>> ---
>>   config/arm/meson.build        |  4 +--
>>   config/meson.build            | 47 +++++++++++++++++++++++++----------
>>   devtools/test-meson-builds.sh |  9 ++++---
>>   meson_options.txt             |  8 ++++--
>>   4 files changed, 47 insertions(+), 21 deletions(-)
>>
>> diff --git a/config/arm/meson.build b/config/arm/meson.build index
>> 42b4e43c7..6b09a74a7 100644
>> --- a/config/arm/meson.build
>> +++ b/config/arm/meson.build
>> @@ -3,10 +3,10 @@
>>   # Copyright(c) 2017 Cavium, Inc
>>
>>   # for checking defines we need to use the correct compiler flags -march_opt = '-
>> march=@0@'.format(machine)
>> +march_opt = '-march=@0@'.format(cpu_instruction_set)
>>
>>   arm_force_native_march = false
>> -arm_force_default_march = (machine == 'default')
>> +arm_force_default_march = (platform == 'generic')
>>
>>   flags_common_default = [
>>   	# Accelarate rte_memcpy. Be sure to run unit test
>> (memcpy_perf_autotest) diff --git a/config/meson.build b/config/meson.build
>> index a3154e29c..647116513 100644
>> --- a/config/meson.build
>> +++ b/config/meson.build
>> @@ -63,42 +63,63 @@ if not is_windows
>>   			pmd_subdir_opt)
>>   endif
>>
>> -# set the machine type and cflags for it
>> +platform = get_option('platform')
>> +
>> +# set the cpu_instruction_set type and cflags for it
>>   if meson.is_cross_build()
>> -	machine = host_machine.cpu()
>> +	cpu_instruction_set = host_machine.cpu()
>>   else
>> -	machine = get_option('machine')
>> +	cpu_instruction_set = get_option('cpu_instruction_set')
>> +	if get_option('machine') != 'auto'
>> +		warning('The "machine" option is deprecated. ' +
>> +		        'Please use "cpu_instruction_set" instead.')
>> +		if cpu_instruction_set != 'auto'
>> +			error('Setting both "machine" and ' +
>> +			      '"cpu_instruction_set" is unsupported.')
>> +		endif
>> +		cpu_instruction_set = get_option('machine')
>> +	endif
>> +endif
>> +
>> +if platform == 'native'
>> +	if cpu_instruction_set == 'auto'
>> +		cpu_instruction_set = 'native'
>> +	endif
>> +elif platform == 'generic'
>> +	if cpu_instruction_set == 'auto'
>> +		cpu_instruction_set = 'default'
>> +	endif
>>   endif
>>
>> -# machine type 'default' is special, it defaults to the per arch agreed common
>> +if cpu_instruction_set == 'default'
>> +# cpu_instruction_set type 'default' is special, it defaults to the per
>> +arch agreed common
>>   # minimal baseline needed for DPDK.
>>   # That might not be the most optimized, but the most portable version while  #
>> still being able to support the CPU features required for DPDK.
>>   # This can be bumped up by the DPDK project, but it can never be an  # invariant
>> like 'native'
>> -if machine == 'default'
>>   	if host_machine.cpu_family().startswith('x86')
>>   		# matches the old pre-meson build systems default
>> -		machine = 'corei7'
>> +		cpu_instruction_set = 'corei7'
>>   	elif host_machine.cpu_family().startswith('arm')
>> -		machine = 'armv7-a'
>> +		cpu_instruction_set = 'armv7-a'
>>   	elif host_machine.cpu_family().startswith('aarch')
>>   		# arm64 manages defaults in config/arm/meson.build
>> -		machine = 'default'
>> +		cpu_instruction_set = 'default'
>>   	elif host_machine.cpu_family().startswith('ppc')
>> -		machine = 'power8'
>> +		cpu_instruction_set = 'power8'
>>   	endif
>>   endif

This change forces the build on a P9 system to use the P8 instruction 
set.  Prior to this change the "native" machine type was used which 
resulted in P9 instructions when built on a P9 system.  How do I force 
the build to use the power9 instruction set in this case?

Dave

^ permalink raw reply	[flat|nested] 33+ messages in thread

* Re: [dpdk-dev] [RFC PATCH v2] build: add platform meson option
  2021-01-05 22:17     ` David Christensen
@ 2021-01-06 14:42       ` Bruce Richardson
  2021-02-19  9:11         ` Juraj Linkeš
  0 siblings, 1 reply; 33+ messages in thread
From: Bruce Richardson @ 2021-01-06 14:42 UTC (permalink / raw)
  To: David Christensen; +Cc: Juraj Linkeš, thomas, Honnappa.Nagarahalli, dev

On Tue, Jan 05, 2021 at 02:17:44PM -0800, David Christensen wrote:
> > > The current meson option 'machine' should only specify the ISA, which is not
> > > sufficient for Arm, where setting ISA implies other setting as well.
> > > Add a new meson option, 'platform', which differentiates the type of the build
> > > (native/generic) and sets machine accordingly, unless the user chooses to
> > > override it.
> > > The 'machine' option also doesn't describe very well what it sets, so introduce a
> > > new option 'cpu_instruction_set', but keep 'machine' for backward
> > > compatibility.
> > > These two new variables, taken together, achieve what 'machine' was setting
> > > per architecture - setting the ISA in x86 build and setting native/default 'build
> > > type' in aarch64 build - is now properly being set for all architectures in a
> > > uniform manner.
> > > 
> > > Signed-off-by: Juraj Linkeš <juraj.linkes@pantheon.tech>
> > > ---
> > >   config/arm/meson.build        |  4 +--
> > >   config/meson.build            | 47 +++++++++++++++++++++++++----------
> > >   devtools/test-meson-builds.sh |  9 ++++---
> > >   meson_options.txt             |  8 ++++--
> > >   4 files changed, 47 insertions(+), 21 deletions(-)
> > > 
> > > diff --git a/config/arm/meson.build b/config/arm/meson.build index
> > > 42b4e43c7..6b09a74a7 100644
> > > --- a/config/arm/meson.build
> > > +++ b/config/arm/meson.build
> > > @@ -3,10 +3,10 @@
> > >   # Copyright(c) 2017 Cavium, Inc
> > > 
> > >   # for checking defines we need to use the correct compiler flags -march_opt = '-
> > > march=@0@'.format(machine)
> > > +march_opt = '-march=@0@'.format(cpu_instruction_set)
> > > 
> > >   arm_force_native_march = false
> > > -arm_force_default_march = (machine == 'default')
> > > +arm_force_default_march = (platform == 'generic')
> > > 
> > >   flags_common_default = [
> > >   	# Accelarate rte_memcpy. Be sure to run unit test
> > > (memcpy_perf_autotest) diff --git a/config/meson.build b/config/meson.build
> > > index a3154e29c..647116513 100644
> > > --- a/config/meson.build
> > > +++ b/config/meson.build
> > > @@ -63,42 +63,63 @@ if not is_windows
> > >   			pmd_subdir_opt)
> > >   endif
> > > 
> > > -# set the machine type and cflags for it
> > > +platform = get_option('platform')
> > > +
> > > +# set the cpu_instruction_set type and cflags for it
> > >   if meson.is_cross_build()
> > > -	machine = host_machine.cpu()
> > > +	cpu_instruction_set = host_machine.cpu()
> > >   else
> > > -	machine = get_option('machine')
> > > +	cpu_instruction_set = get_option('cpu_instruction_set')
> > > +	if get_option('machine') != 'auto'
> > > +		warning('The "machine" option is deprecated. ' +
> > > +		        'Please use "cpu_instruction_set" instead.')
> > > +		if cpu_instruction_set != 'auto'
> > > +			error('Setting both "machine" and ' +
> > > +			      '"cpu_instruction_set" is unsupported.')
> > > +		endif
> > > +		cpu_instruction_set = get_option('machine')
> > > +	endif
> > > +endif
> > > +
> > > +if platform == 'native'
> > > +	if cpu_instruction_set == 'auto'
> > > +		cpu_instruction_set = 'native'
> > > +	endif
> > > +elif platform == 'generic'
> > > +	if cpu_instruction_set == 'auto'
> > > +		cpu_instruction_set = 'default'
> > > +	endif
> > >   endif
> > > 
> > > -# machine type 'default' is special, it defaults to the per arch agreed common
> > > +if cpu_instruction_set == 'default'
> > > +# cpu_instruction_set type 'default' is special, it defaults to the per
> > > +arch agreed common
> > >   # minimal baseline needed for DPDK.
> > >   # That might not be the most optimized, but the most portable version while  #
> > > still being able to support the CPU features required for DPDK.
> > >   # This can be bumped up by the DPDK project, but it can never be an  # invariant
> > > like 'native'
> > > -if machine == 'default'
> > >   	if host_machine.cpu_family().startswith('x86')
> > >   		# matches the old pre-meson build systems default
> > > -		machine = 'corei7'
> > > +		cpu_instruction_set = 'corei7'
> > >   	elif host_machine.cpu_family().startswith('arm')
> > > -		machine = 'armv7-a'
> > > +		cpu_instruction_set = 'armv7-a'
> > >   	elif host_machine.cpu_family().startswith('aarch')
> > >   		# arm64 manages defaults in config/arm/meson.build
> > > -		machine = 'default'
> > > +		cpu_instruction_set = 'default'
> > >   	elif host_machine.cpu_family().startswith('ppc')
> > > -		machine = 'power8'
> > > +		cpu_instruction_set = 'power8'
> > >   	endif
> > >   endif
> 
> This change forces the build on a P9 system to use the P8 instruction set.
> Prior to this change the "native" machine type was used which resulted in P9
> instructions when built on a P9 system.  How do I force the build to use the
> power9 instruction set in this case?
> 
> Dave

From looking at the patch, setting the "platform" to "native", or the
instruction_set to "native" should do this.
While I consider generic builds a good thing, I wonder if there is an
expectation that "native" is always the default build type for DPDK builds?

/Bruce

^ permalink raw reply	[flat|nested] 33+ messages in thread

* Re: [dpdk-dev] [RFC PATCH v2] build: add platform meson option
  2021-01-06 14:42       ` Bruce Richardson
@ 2021-02-19  9:11         ` Juraj Linkeš
  2021-02-22 21:25           ` David Christensen
  0 siblings, 1 reply; 33+ messages in thread
From: Juraj Linkeš @ 2021-02-19  9:11 UTC (permalink / raw)
  To: Bruce Richardson, David Christensen; +Cc: thomas, Honnappa.Nagarahalli, dev



> -----Original Message-----
> From: Bruce Richardson <bruce.richardson@intel.com>
> Sent: Wednesday, January 6, 2021 3:43 PM
> To: David Christensen <drc@linux.vnet.ibm.com>
> Cc: Juraj Linkeš <juraj.linkes@pantheon.tech>; thomas@monjalon.net;
> Honnappa.Nagarahalli@arm.com; dev@dpdk.org
> Subject: Re: [RFC PATCH v2] build: add platform meson option
> 
> On Tue, Jan 05, 2021 at 02:17:44PM -0800, David Christensen wrote:
> > > > The current meson option 'machine' should only specify the ISA,
> > > > which is not sufficient for Arm, where setting ISA implies other setting as
> well.
> > > > Add a new meson option, 'platform', which differentiates the type
> > > > of the build
> > > > (native/generic) and sets machine accordingly, unless the user
> > > > chooses to override it.
> > > > The 'machine' option also doesn't describe very well what it sets,
> > > > so introduce a new option 'cpu_instruction_set', but keep
> > > > 'machine' for backward compatibility.
> > > > These two new variables, taken together, achieve what 'machine'
> > > > was setting per architecture - setting the ISA in x86 build and
> > > > setting native/default 'build type' in aarch64 build - is now
> > > > properly being set for all architectures in a uniform manner.
> > > >
> > > > Signed-off-by: Juraj Linkeš <juraj.linkes@pantheon.tech>
> > > > ---
> > > >   config/arm/meson.build        |  4 +--
> > > >   config/meson.build            | 47 +++++++++++++++++++++++++----------
> > > >   devtools/test-meson-builds.sh |  9 ++++---
> > > >   meson_options.txt             |  8 ++++--
> > > >   4 files changed, 47 insertions(+), 21 deletions(-)
> > > >
> > > > diff --git a/config/arm/meson.build b/config/arm/meson.build index
> > > > 42b4e43c7..6b09a74a7 100644
> > > > --- a/config/arm/meson.build
> > > > +++ b/config/arm/meson.build
> > > > @@ -3,10 +3,10 @@
> > > >   # Copyright(c) 2017 Cavium, Inc
> > > >
> > > >   # for checking defines we need to use the correct compiler flags
> > > > -march_opt = '-
> > > > march=@0@'.format(machine)
> > > > +march_opt = '-march=@0@'.format(cpu_instruction_set)
> > > >
> > > >   arm_force_native_march = false
> > > > -arm_force_default_march = (machine == 'default')
> > > > +arm_force_default_march = (platform == 'generic')
> > > >
> > > >   flags_common_default = [
> > > >   	# Accelarate rte_memcpy. Be sure to run unit test
> > > > (memcpy_perf_autotest) diff --git a/config/meson.build
> > > > b/config/meson.build index a3154e29c..647116513 100644
> > > > --- a/config/meson.build
> > > > +++ b/config/meson.build
> > > > @@ -63,42 +63,63 @@ if not is_windows
> > > >   			pmd_subdir_opt)
> > > >   endif
> > > >
> > > > -# set the machine type and cflags for it
> > > > +platform = get_option('platform')
> > > > +
> > > > +# set the cpu_instruction_set type and cflags for it
> > > >   if meson.is_cross_build()
> > > > -	machine = host_machine.cpu()
> > > > +	cpu_instruction_set = host_machine.cpu()
> > > >   else
> > > > -	machine = get_option('machine')
> > > > +	cpu_instruction_set = get_option('cpu_instruction_set')
> > > > +	if get_option('machine') != 'auto'
> > > > +		warning('The "machine" option is deprecated. ' +
> > > > +		        'Please use "cpu_instruction_set" instead.')
> > > > +		if cpu_instruction_set != 'auto'
> > > > +			error('Setting both "machine" and ' +
> > > > +			      '"cpu_instruction_set" is unsupported.')
> > > > +		endif
> > > > +		cpu_instruction_set = get_option('machine')
> > > > +	endif
> > > > +endif
> > > > +
> > > > +if platform == 'native'
> > > > +	if cpu_instruction_set == 'auto'
> > > > +		cpu_instruction_set = 'native'
> > > > +	endif
> > > > +elif platform == 'generic'
> > > > +	if cpu_instruction_set == 'auto'
> > > > +		cpu_instruction_set = 'default'
> > > > +	endif
> > > >   endif
> > > >
> > > > -# machine type 'default' is special, it defaults to the per arch
> > > > agreed common
> > > > +if cpu_instruction_set == 'default'
> > > > +# cpu_instruction_set type 'default' is special, it defaults to
> > > > +the per arch agreed common
> > > >   # minimal baseline needed for DPDK.
> > > >   # That might not be the most optimized, but the most portable
> > > > version while  # still being able to support the CPU features required for
> DPDK.
> > > >   # This can be bumped up by the DPDK project, but it can never be
> > > > an  # invariant like 'native'
> > > > -if machine == 'default'
> > > >   	if host_machine.cpu_family().startswith('x86')
> > > >   		# matches the old pre-meson build systems default
> > > > -		machine = 'corei7'
> > > > +		cpu_instruction_set = 'corei7'
> > > >   	elif host_machine.cpu_family().startswith('arm')
> > > > -		machine = 'armv7-a'
> > > > +		cpu_instruction_set = 'armv7-a'
> > > >   	elif host_machine.cpu_family().startswith('aarch')
> > > >   		# arm64 manages defaults in config/arm/meson.build
> > > > -		machine = 'default'
> > > > +		cpu_instruction_set = 'default'
> > > >   	elif host_machine.cpu_family().startswith('ppc')
> > > > -		machine = 'power8'
> > > > +		cpu_instruction_set = 'power8'
> > > >   	endif
> > > >   endif
> >
> > This change forces the build on a P9 system to use the P8 instruction set.
> > Prior to this change the "native" machine type was used which resulted
> > in P9 instructions when built on a P9 system.  How do I force the
> > build to use the
> > power9 instruction set in this case?
> >
> > Dave
> 
> From looking at the patch, setting the "platform" to "native", or the
> instruction_set to "native" should do this.
> While I consider generic builds a good thing, I wonder if there is an expectation
> that "native" is always the default build type for DPDK builds?
> 
> /Bruce

I left this patch alone so that people could chime in, but noone did, so let's try to find some agreeable solution.

My current thoughts are as such:
The platform parameter specifies a set of DPDK options that will be used. This is what arm uses for its builds, x86 and ppc don't use this.
The cpu_instruction_set sets just one configuration among the "platform" configuration set.
We want the build to work on most machines of the machine architecture. That implies platform=generic (as in use config options that will work on everything of that architecture) and cpu_instruction_set=generic (as in use ISA that will work on all cpus of the build machine architecture).
Setting cpu_instruction_set=generic changes the build without cmdline options for ppc. Thus, the expectation may be that cpu_instruction_set should be native by default.

For arm, cpu_instruction_set is ignored (and thus the value doen't matter), since we can't use that without other config options (e.g. DPDK config for an SoC (such as RTE_ARM_FEATURE_ATOMICS) used with an invalid cpu_instuction_set). That means the only relevant parameter for Arm is platform and if we want to have a build usable on most machines of the build type, we have to use platform=generic.

For x86 and ppc, there's no difference between native and generic platform (as it's a new argument, the purpose of which is to differentiate DPDK config across platforms, which doesn't exist for x86 and ppc - DPDK config is the same (correct me if I'm wrong)).

So it basically boils down to what should be the default value of cpu_instruction_set when platform=generic (for platform=native, it's obviously native):
1. cpu_instruction_set=native, this would preserve the current behavior, but we won't use the 'auto' default. I think we can fall back to this if we don't agree on anything better.
2. cpu_instruction_set=auto, the same as cpu_instruction_set=generic,
3. cpu_instruction_set=generic, this changes behavior for ppc builds, but we may be able to remedy this:
Similarly to arm (arm is using platform for this, but the idea is the same), if cpu_instruction_set is generic, we can do some discovery for pcc and set the ISA accordingly (either power8 or power9). If I understand it correctly, power8 is a different architecture from power9 (I could be wrong on this), so this is desirable. There's some logic in config/ppc/meson.build, but it doesn't seem sufficient as a discovery mechanism between power8/power9.

I like 3 if we can find a way to discover power8/power9 ppc (that way we would be able to use cpu_instruction_set=auto), if not, we should probably go with 1 (in which case we can't use cpu_instruction_set=auto).

Or maybe we're overthingking this and we really should go with 1. What's (or should be) the difference between cpu_instruction_set=generic and cpu_instruction_set=native for x86 and ppc?

^ permalink raw reply	[flat|nested] 33+ messages in thread

* Re: [dpdk-dev] [RFC PATCH v2] build: add platform meson option
  2021-02-19  9:11         ` Juraj Linkeš
@ 2021-02-22 21:25           ` David Christensen
  2021-02-23  8:45             ` Juraj Linkeš
  0 siblings, 1 reply; 33+ messages in thread
From: David Christensen @ 2021-02-22 21:25 UTC (permalink / raw)
  To: Juraj Linkeš, Bruce Richardson; +Cc: thomas, Honnappa.Nagarahalli, dev



On 2/19/21 1:11 AM, Juraj Linkeš wrote:
> 
> 
>> -----Original Message-----
>> From: Bruce Richardson <bruce.richardson@intel.com>
>> Sent: Wednesday, January 6, 2021 3:43 PM
>> To: David Christensen <drc@linux.vnet.ibm.com>
>> Cc: Juraj Linkeš <juraj.linkes@pantheon.tech>; thomas@monjalon.net;
>> Honnappa.Nagarahalli@arm.com; dev@dpdk.org
>> Subject: Re: [RFC PATCH v2] build: add platform meson option
>>
>> On Tue, Jan 05, 2021 at 02:17:44PM -0800, David Christensen wrote:
>>>>> The current meson option 'machine' should only specify the ISA,
>>>>> which is not sufficient for Arm, where setting ISA implies other setting as
>> well.
>>>>> Add a new meson option, 'platform', which differentiates the type
>>>>> of the build
>>>>> (native/generic) and sets machine accordingly, unless the user
>>>>> chooses to override it.
>>>>> The 'machine' option also doesn't describe very well what it sets,
>>>>> so introduce a new option 'cpu_instruction_set', but keep
>>>>> 'machine' for backward compatibility.
>>>>> These two new variables, taken together, achieve what 'machine'
>>>>> was setting per architecture - setting the ISA in x86 build and
>>>>> setting native/default 'build type' in aarch64 build - is now
>>>>> properly being set for all architectures in a uniform manner.
>>>>>
>>>>> Signed-off-by: Juraj Linkeš <juraj.linkes@pantheon.tech>
>>>>> ---
>>>>>    config/arm/meson.build        |  4 +--
>>>>>    config/meson.build            | 47 +++++++++++++++++++++++++----------
>>>>>    devtools/test-meson-builds.sh |  9 ++++---
>>>>>    meson_options.txt             |  8 ++++--
>>>>>    4 files changed, 47 insertions(+), 21 deletions(-)
>>>>>
>>>>> diff --git a/config/arm/meson.build b/config/arm/meson.build index
>>>>> 42b4e43c7..6b09a74a7 100644
>>>>> --- a/config/arm/meson.build
>>>>> +++ b/config/arm/meson.build
>>>>> @@ -3,10 +3,10 @@
>>>>>    # Copyright(c) 2017 Cavium, Inc
>>>>>
>>>>>    # for checking defines we need to use the correct compiler flags
>>>>> -march_opt = '-
>>>>> march=@0@'.format(machine)
>>>>> +march_opt = '-march=@0@'.format(cpu_instruction_set)
>>>>>
>>>>>    arm_force_native_march = false
>>>>> -arm_force_default_march = (machine == 'default')
>>>>> +arm_force_default_march = (platform == 'generic')
>>>>>
>>>>>    flags_common_default = [
>>>>>    	# Accelarate rte_memcpy. Be sure to run unit test
>>>>> (memcpy_perf_autotest) diff --git a/config/meson.build
>>>>> b/config/meson.build index a3154e29c..647116513 100644
>>>>> --- a/config/meson.build
>>>>> +++ b/config/meson.build
>>>>> @@ -63,42 +63,63 @@ if not is_windows
>>>>>    			pmd_subdir_opt)
>>>>>    endif
>>>>>
>>>>> -# set the machine type and cflags for it
>>>>> +platform = get_option('platform')
>>>>> +
>>>>> +# set the cpu_instruction_set type and cflags for it
>>>>>    if meson.is_cross_build()
>>>>> -	machine = host_machine.cpu()
>>>>> +	cpu_instruction_set = host_machine.cpu()
>>>>>    else
>>>>> -	machine = get_option('machine')
>>>>> +	cpu_instruction_set = get_option('cpu_instruction_set')
>>>>> +	if get_option('machine') != 'auto'
>>>>> +		warning('The "machine" option is deprecated. ' +
>>>>> +		        'Please use "cpu_instruction_set" instead.')
>>>>> +		if cpu_instruction_set != 'auto'
>>>>> +			error('Setting both "machine" and ' +
>>>>> +			      '"cpu_instruction_set" is unsupported.')
>>>>> +		endif
>>>>> +		cpu_instruction_set = get_option('machine')
>>>>> +	endif
>>>>> +endif
>>>>> +
>>>>> +if platform == 'native'
>>>>> +	if cpu_instruction_set == 'auto'
>>>>> +		cpu_instruction_set = 'native'
>>>>> +	endif
>>>>> +elif platform == 'generic'
>>>>> +	if cpu_instruction_set == 'auto'
>>>>> +		cpu_instruction_set = 'default'
>>>>> +	endif
>>>>>    endif
>>>>>
>>>>> -# machine type 'default' is special, it defaults to the per arch
>>>>> agreed common
>>>>> +if cpu_instruction_set == 'default'
>>>>> +# cpu_instruction_set type 'default' is special, it defaults to
>>>>> +the per arch agreed common
>>>>>    # minimal baseline needed for DPDK.
>>>>>    # That might not be the most optimized, but the most portable
>>>>> version while  # still being able to support the CPU features required for
>> DPDK.
>>>>>    # This can be bumped up by the DPDK project, but it can never be
>>>>> an  # invariant like 'native'
>>>>> -if machine == 'default'
>>>>>    	if host_machine.cpu_family().startswith('x86')
>>>>>    		# matches the old pre-meson build systems default
>>>>> -		machine = 'corei7'
>>>>> +		cpu_instruction_set = 'corei7'
>>>>>    	elif host_machine.cpu_family().startswith('arm')
>>>>> -		machine = 'armv7-a'
>>>>> +		cpu_instruction_set = 'armv7-a'
>>>>>    	elif host_machine.cpu_family().startswith('aarch')
>>>>>    		# arm64 manages defaults in config/arm/meson.build
>>>>> -		machine = 'default'
>>>>> +		cpu_instruction_set = 'default'
>>>>>    	elif host_machine.cpu_family().startswith('ppc')
>>>>> -		machine = 'power8'
>>>>> +		cpu_instruction_set = 'power8'
>>>>>    	endif
>>>>>    endif
>>>
>>> This change forces the build on a P9 system to use the P8 instruction set.
>>> Prior to this change the "native" machine type was used which resulted
>>> in P9 instructions when built on a P9 system.  How do I force the
>>> build to use the
>>> power9 instruction set in this case?
>>>
>>> Dave
>>
>>  From looking at the patch, setting the "platform" to "native", or the
>> instruction_set to "native" should do this.
>> While I consider generic builds a good thing, I wonder if there is an expectation
>> that "native" is always the default build type for DPDK builds?
>>
>> /Bruce
> 
> I left this patch alone so that people could chime in, but noone did, so let's try to find some agreeable solution.
> 
> My current thoughts are as such:
> The platform parameter specifies a set of DPDK options that will be used. This is what arm uses for its builds, x86 and ppc don't use this.
> The cpu_instruction_set sets just one configuration among the "platform" configuration set.
> We want the build to work on most machines of the machine architecture. That implies platform=generic (as in use config options that will work on everything of that architecture) and cpu_instruction_set=generic (as in use ISA that will work on all cpus of the build machine architecture).
> Setting cpu_instruction_set=generic changes the build without cmdline options for ppc. Thus, the expectation may be that cpu_instruction_set should be native by default.
> 
> For arm, cpu_instruction_set is ignored (and thus the value doen't matter), since we can't use that without other config options (e.g. DPDK config for an SoC (such as RTE_ARM_FEATURE_ATOMICS) used with an invalid cpu_instuction_set). That means the only relevant parameter for Arm is platform and if we want to have a build usable on most machines of the build type, we have to use platform=generic.
> 
> For x86 and ppc, there's no difference between native and generic platform (as it's a new argument, the purpose of which is to differentiate DPDK config across platforms, which doesn't exist for x86 and ppc - DPDK config is the same (correct me if I'm wrong)).
> 
> So it basically boils down to what should be the default value of cpu_instruction_set when platform=generic (for platform=native, it's obviously native):
> 1. cpu_instruction_set=native, this would preserve the current behavior, but we won't use the 'auto' default. I think we can fall back to this if we don't agree on anything better.
> 2. cpu_instruction_set=auto, the same as cpu_instruction_set=generic,
> 3. cpu_instruction_set=generic, this changes behavior for ppc builds, but we may be able to remedy this:
> Similarly to arm (arm is using platform for this, but the idea is the same), if cpu_instruction_set is generic, we can do some discovery for pcc and set the ISA accordingly (either power8 or power9). If I understand it correctly, power8 is a different architecture from power9 (I could be wrong on this), so this is desirable. There's some logic in config/ppc/meson.build, but it doesn't seem sufficient as a discovery mechanism between power8/power9.

POWER8 code (Power ISA v2.07) runs on POWER9 CPUs (Power ISA v3.0), so 
setting cpu_instruction_set to GENERIC is a reasonable option. POWER10 
CPUs (Power ISA v3.1) are around the corner so I want to make sure 
developers can tune the application for the platform as easily as 
possible.  I'm fine with supporting GENERIC, just need clear 
instructions on how to build for a particular ISA.

Dave

^ permalink raw reply	[flat|nested] 33+ messages in thread

* Re: [dpdk-dev] [RFC PATCH v2] build: add platform meson option
  2021-02-22 21:25           ` David Christensen
@ 2021-02-23  8:45             ` Juraj Linkeš
  2021-02-23  9:43               ` Bruce Richardson
  0 siblings, 1 reply; 33+ messages in thread
From: Juraj Linkeš @ 2021-02-23  8:45 UTC (permalink / raw)
  To: David Christensen, Bruce Richardson; +Cc: thomas, Honnappa.Nagarahalli, dev



> -----Original Message-----
> From: David Christensen <drc@linux.vnet.ibm.com>
> Sent: Monday, February 22, 2021 10:25 PM
> To: Juraj Linkeš <juraj.linkes@pantheon.tech>; Bruce Richardson
> <bruce.richardson@intel.com>
> Cc: thomas@monjalon.net; Honnappa.Nagarahalli@arm.com; dev@dpdk.org
> Subject: Re: [RFC PATCH v2] build: add platform meson option
> 
> 
> 
> On 2/19/21 1:11 AM, Juraj Linkeš wrote:
> >
> >
> >> -----Original Message-----
> >> From: Bruce Richardson <bruce.richardson@intel.com>
> >> Sent: Wednesday, January 6, 2021 3:43 PM
> >> To: David Christensen <drc@linux.vnet.ibm.com>
> >> Cc: Juraj Linkeš <juraj.linkes@pantheon.tech>; thomas@monjalon.net;
> >> Honnappa.Nagarahalli@arm.com; dev@dpdk.org
> >> Subject: Re: [RFC PATCH v2] build: add platform meson option
> >>
> >> On Tue, Jan 05, 2021 at 02:17:44PM -0800, David Christensen wrote:
> >>>>> The current meson option 'machine' should only specify the ISA,
> >>>>> which is not sufficient for Arm, where setting ISA implies other
> >>>>> setting as
> >> well.
> >>>>> Add a new meson option, 'platform', which differentiates the type
> >>>>> of the build
> >>>>> (native/generic) and sets machine accordingly, unless the user
> >>>>> chooses to override it.
> >>>>> The 'machine' option also doesn't describe very well what it sets,
> >>>>> so introduce a new option 'cpu_instruction_set', but keep
> >>>>> 'machine' for backward compatibility.
> >>>>> These two new variables, taken together, achieve what 'machine'
> >>>>> was setting per architecture - setting the ISA in x86 build and
> >>>>> setting native/default 'build type' in aarch64 build - is now
> >>>>> properly being set for all architectures in a uniform manner.
> >>>>>
> >>>>> Signed-off-by: Juraj Linkeš <juraj.linkes@pantheon.tech>
> >>>>> ---
> >>>>>    config/arm/meson.build        |  4 +--
> >>>>>    config/meson.build            | 47 +++++++++++++++++++++++++----------
> >>>>>    devtools/test-meson-builds.sh |  9 ++++---
> >>>>>    meson_options.txt             |  8 ++++--
> >>>>>    4 files changed, 47 insertions(+), 21 deletions(-)
> >>>>>
> >>>>> diff --git a/config/arm/meson.build b/config/arm/meson.build index
> >>>>> 42b4e43c7..6b09a74a7 100644
> >>>>> --- a/config/arm/meson.build
> >>>>> +++ b/config/arm/meson.build
> >>>>> @@ -3,10 +3,10 @@
> >>>>>    # Copyright(c) 2017 Cavium, Inc
> >>>>>
> >>>>>    # for checking defines we need to use the correct compiler
> >>>>> flags -march_opt = '-
> >>>>> march=@0@'.format(machine)
> >>>>> +march_opt = '-march=@0@'.format(cpu_instruction_set)
> >>>>>
> >>>>>    arm_force_native_march = false
> >>>>> -arm_force_default_march = (machine == 'default')
> >>>>> +arm_force_default_march = (platform == 'generic')
> >>>>>
> >>>>>    flags_common_default = [
> >>>>>    	# Accelarate rte_memcpy. Be sure to run unit test
> >>>>> (memcpy_perf_autotest) diff --git a/config/meson.build
> >>>>> b/config/meson.build index a3154e29c..647116513 100644
> >>>>> --- a/config/meson.build
> >>>>> +++ b/config/meson.build
> >>>>> @@ -63,42 +63,63 @@ if not is_windows
> >>>>>    			pmd_subdir_opt)
> >>>>>    endif
> >>>>>
> >>>>> -# set the machine type and cflags for it
> >>>>> +platform = get_option('platform')
> >>>>> +
> >>>>> +# set the cpu_instruction_set type and cflags for it
> >>>>>    if meson.is_cross_build()
> >>>>> -	machine = host_machine.cpu()
> >>>>> +	cpu_instruction_set = host_machine.cpu()
> >>>>>    else
> >>>>> -	machine = get_option('machine')
> >>>>> +	cpu_instruction_set = get_option('cpu_instruction_set')
> >>>>> +	if get_option('machine') != 'auto'
> >>>>> +		warning('The "machine" option is deprecated. ' +
> >>>>> +		        'Please use "cpu_instruction_set" instead.')
> >>>>> +		if cpu_instruction_set != 'auto'
> >>>>> +			error('Setting both "machine" and ' +
> >>>>> +			      '"cpu_instruction_set" is unsupported.')
> >>>>> +		endif
> >>>>> +		cpu_instruction_set = get_option('machine')
> >>>>> +	endif
> >>>>> +endif
> >>>>> +
> >>>>> +if platform == 'native'
> >>>>> +	if cpu_instruction_set == 'auto'
> >>>>> +		cpu_instruction_set = 'native'
> >>>>> +	endif
> >>>>> +elif platform == 'generic'
> >>>>> +	if cpu_instruction_set == 'auto'
> >>>>> +		cpu_instruction_set = 'default'
> >>>>> +	endif
> >>>>>    endif
> >>>>>
> >>>>> -# machine type 'default' is special, it defaults to the per arch
> >>>>> agreed common
> >>>>> +if cpu_instruction_set == 'default'
> >>>>> +# cpu_instruction_set type 'default' is special, it defaults to
> >>>>> +the per arch agreed common
> >>>>>    # minimal baseline needed for DPDK.
> >>>>>    # That might not be the most optimized, but the most portable
> >>>>> version while  # still being able to support the CPU features
> >>>>> required for
> >> DPDK.
> >>>>>    # This can be bumped up by the DPDK project, but it can never
> >>>>> be an  # invariant like 'native'
> >>>>> -if machine == 'default'
> >>>>>    	if host_machine.cpu_family().startswith('x86')
> >>>>>    		# matches the old pre-meson build systems default
> >>>>> -		machine = 'corei7'
> >>>>> +		cpu_instruction_set = 'corei7'
> >>>>>    	elif host_machine.cpu_family().startswith('arm')
> >>>>> -		machine = 'armv7-a'
> >>>>> +		cpu_instruction_set = 'armv7-a'
> >>>>>    	elif host_machine.cpu_family().startswith('aarch')
> >>>>>    		# arm64 manages defaults in config/arm/meson.build
> >>>>> -		machine = 'default'
> >>>>> +		cpu_instruction_set = 'default'
> >>>>>    	elif host_machine.cpu_family().startswith('ppc')
> >>>>> -		machine = 'power8'
> >>>>> +		cpu_instruction_set = 'power8'
> >>>>>    	endif
> >>>>>    endif
> >>>
> >>> This change forces the build on a P9 system to use the P8 instruction set.
> >>> Prior to this change the "native" machine type was used which
> >>> resulted in P9 instructions when built on a P9 system.  How do I
> >>> force the build to use the
> >>> power9 instruction set in this case?
> >>>
> >>> Dave
> >>
> >>  From looking at the patch, setting the "platform" to "native", or
> >> the instruction_set to "native" should do this.
> >> While I consider generic builds a good thing, I wonder if there is an
> >> expectation that "native" is always the default build type for DPDK builds?
> >>
> >> /Bruce
> >
> > I left this patch alone so that people could chime in, but noone did, so let's try
> to find some agreeable solution.
> >
> > My current thoughts are as such:
> > The platform parameter specifies a set of DPDK options that will be used. This
> is what arm uses for its builds, x86 and ppc don't use this.
> > The cpu_instruction_set sets just one configuration among the "platform"
> configuration set.
> > We want the build to work on most machines of the machine architecture.
> That implies platform=generic (as in use config options that will work on
> everything of that architecture) and cpu_instruction_set=generic (as in use ISA
> that will work on all cpus of the build machine architecture).
> > Setting cpu_instruction_set=generic changes the build without cmdline options
> for ppc. Thus, the expectation may be that cpu_instruction_set should be native
> by default.
> >
> > For arm, cpu_instruction_set is ignored (and thus the value doen't matter),
> since we can't use that without other config options (e.g. DPDK config for an
> SoC (such as RTE_ARM_FEATURE_ATOMICS) used with an invalid
> cpu_instuction_set). That means the only relevant parameter for Arm is platform
> and if we want to have a build usable on most machines of the build type, we
> have to use platform=generic.
> >
> > For x86 and ppc, there's no difference between native and generic platform (as
> it's a new argument, the purpose of which is to differentiate DPDK config across
> platforms, which doesn't exist for x86 and ppc - DPDK config is the same (correct
> me if I'm wrong)).
> >
> > So it basically boils down to what should be the default value of
> cpu_instruction_set when platform=generic (for platform=native, it's obviously
> native):
> > 1. cpu_instruction_set=native, this would preserve the current behavior, but
> we won't use the 'auto' default. I think we can fall back to this if we don't agree
> on anything better.
> > 2. cpu_instruction_set=auto, the same as cpu_instruction_set=generic,
> > 3. cpu_instruction_set=generic, this changes behavior for ppc builds, but we
> may be able to remedy this:
> > Similarly to arm (arm is using platform for this, but the idea is the same), if
> cpu_instruction_set is generic, we can do some discovery for pcc and set the ISA
> accordingly (either power8 or power9). If I understand it correctly, power8 is a
> different architecture from power9 (I could be wrong on this), so this is
> desirable. There's some logic in config/ppc/meson.build, but it doesn't seem
> sufficient as a discovery mechanism between power8/power9.
> 
> POWER8 code (Power ISA v2.07) runs on POWER9 CPUs (Power ISA v3.0), so
> setting cpu_instruction_set to GENERIC is a reasonable option. POWER10 CPUs
> (Power ISA v3.1) are around the corner so I want to make sure developers can
> tune the application for the platform as easily as possible.  I'm fine with
> supporting GENERIC, just need clear instructions on how to build for a particular
> ISA.
> 

That's good to hear. Setting cpu_instruction_set will set the ISA.

We'll need to document the behavior properly, but I'm not sure where - Bruce? Seems like meson_options.txt doesn't have enough room for that.

The default bahavior is the ISA will be set according to the platform parameter. If cpu_instruction_set is specified, that value will be used.

> Dave


^ permalink raw reply	[flat|nested] 33+ messages in thread

* Re: [dpdk-dev] [RFC PATCH v2] build: add platform meson option
  2021-02-23  8:45             ` Juraj Linkeš
@ 2021-02-23  9:43               ` Bruce Richardson
  2021-02-25 12:51                 ` Juraj Linkeš
  0 siblings, 1 reply; 33+ messages in thread
From: Bruce Richardson @ 2021-02-23  9:43 UTC (permalink / raw)
  To: Juraj Linkeš; +Cc: David Christensen, thomas, Honnappa.Nagarahalli, dev

On Tue, Feb 23, 2021 at 08:45:09AM +0000, Juraj Linkeš wrote:
> 
> 
> > -----Original Message-----
> > From: David Christensen <drc@linux.vnet.ibm.com>
> > Sent: Monday, February 22, 2021 10:25 PM
> > To: Juraj Linkeš <juraj.linkes@pantheon.tech>; Bruce Richardson
> > <bruce.richardson@intel.com>
> > Cc: thomas@monjalon.net; Honnappa.Nagarahalli@arm.com; dev@dpdk.org
> > Subject: Re: [RFC PATCH v2] build: add platform meson option
> > 
> > 
> > 
> > On 2/19/21 1:11 AM, Juraj Linkeš wrote:
> > >
> > >
> > >> -----Original Message-----
> > >> From: Bruce Richardson <bruce.richardson@intel.com>
> > >> Sent: Wednesday, January 6, 2021 3:43 PM
> > >> To: David Christensen <drc@linux.vnet.ibm.com>
> > >> Cc: Juraj Linkeš <juraj.linkes@pantheon.tech>; thomas@monjalon.net;
> > >> Honnappa.Nagarahalli@arm.com; dev@dpdk.org
> > >> Subject: Re: [RFC PATCH v2] build: add platform meson option
> > >>
> > >> On Tue, Jan 05, 2021 at 02:17:44PM -0800, David Christensen wrote:
> > >>>>> The current meson option 'machine' should only specify the ISA,
> > >>>>> which is not sufficient for Arm, where setting ISA implies other
> > >>>>> setting as
> > >> well.
> > >>>>> Add a new meson option, 'platform', which differentiates the type
> > >>>>> of the build
> > >>>>> (native/generic) and sets machine accordingly, unless the user
> > >>>>> chooses to override it.
> > >>>>> The 'machine' option also doesn't describe very well what it sets,
> > >>>>> so introduce a new option 'cpu_instruction_set', but keep
> > >>>>> 'machine' for backward compatibility.
> > >>>>> These two new variables, taken together, achieve what 'machine'
> > >>>>> was setting per architecture - setting the ISA in x86 build and
> > >>>>> setting native/default 'build type' in aarch64 build - is now
> > >>>>> properly being set for all architectures in a uniform manner.
> > >>>>>
> > >>>>> Signed-off-by: Juraj Linkeš <juraj.linkes@pantheon.tech>
> > >>>>> ---
> > >>>>>    config/arm/meson.build        |  4 +--
> > >>>>>    config/meson.build            | 47 +++++++++++++++++++++++++----------
> > >>>>>    devtools/test-meson-builds.sh |  9 ++++---
> > >>>>>    meson_options.txt             |  8 ++++--
> > >>>>>    4 files changed, 47 insertions(+), 21 deletions(-)
> > >>>>>
> > >>>>> diff --git a/config/arm/meson.build b/config/arm/meson.build index
> > >>>>> 42b4e43c7..6b09a74a7 100644
> > >>>>> --- a/config/arm/meson.build
> > >>>>> +++ b/config/arm/meson.build
> > >>>>> @@ -3,10 +3,10 @@
> > >>>>>    # Copyright(c) 2017 Cavium, Inc
> > >>>>>
> > >>>>>    # for checking defines we need to use the correct compiler
> > >>>>> flags -march_opt = '-
> > >>>>> march=@0@'.format(machine)
> > >>>>> +march_opt = '-march=@0@'.format(cpu_instruction_set)
> > >>>>>
> > >>>>>    arm_force_native_march = false
> > >>>>> -arm_force_default_march = (machine == 'default')
> > >>>>> +arm_force_default_march = (platform == 'generic')
> > >>>>>
> > >>>>>    flags_common_default = [
> > >>>>>    	# Accelarate rte_memcpy. Be sure to run unit test
> > >>>>> (memcpy_perf_autotest) diff --git a/config/meson.build
> > >>>>> b/config/meson.build index a3154e29c..647116513 100644
> > >>>>> --- a/config/meson.build
> > >>>>> +++ b/config/meson.build
> > >>>>> @@ -63,42 +63,63 @@ if not is_windows
> > >>>>>    			pmd_subdir_opt)
> > >>>>>    endif
> > >>>>>
> > >>>>> -# set the machine type and cflags for it
> > >>>>> +platform = get_option('platform')
> > >>>>> +
> > >>>>> +# set the cpu_instruction_set type and cflags for it
> > >>>>>    if meson.is_cross_build()
> > >>>>> -	machine = host_machine.cpu()
> > >>>>> +	cpu_instruction_set = host_machine.cpu()
> > >>>>>    else
> > >>>>> -	machine = get_option('machine')
> > >>>>> +	cpu_instruction_set = get_option('cpu_instruction_set')
> > >>>>> +	if get_option('machine') != 'auto'
> > >>>>> +		warning('The "machine" option is deprecated. ' +
> > >>>>> +		        'Please use "cpu_instruction_set" instead.')
> > >>>>> +		if cpu_instruction_set != 'auto'
> > >>>>> +			error('Setting both "machine" and ' +
> > >>>>> +			      '"cpu_instruction_set" is unsupported.')
> > >>>>> +		endif
> > >>>>> +		cpu_instruction_set = get_option('machine')
> > >>>>> +	endif
> > >>>>> +endif
> > >>>>> +
> > >>>>> +if platform == 'native'
> > >>>>> +	if cpu_instruction_set == 'auto'
> > >>>>> +		cpu_instruction_set = 'native'
> > >>>>> +	endif
> > >>>>> +elif platform == 'generic'
> > >>>>> +	if cpu_instruction_set == 'auto'
> > >>>>> +		cpu_instruction_set = 'default'
> > >>>>> +	endif
> > >>>>>    endif
> > >>>>>
> > >>>>> -# machine type 'default' is special, it defaults to the per arch
> > >>>>> agreed common
> > >>>>> +if cpu_instruction_set == 'default'
> > >>>>> +# cpu_instruction_set type 'default' is special, it defaults to
> > >>>>> +the per arch agreed common
> > >>>>>    # minimal baseline needed for DPDK.
> > >>>>>    # That might not be the most optimized, but the most portable
> > >>>>> version while  # still being able to support the CPU features
> > >>>>> required for
> > >> DPDK.
> > >>>>>    # This can be bumped up by the DPDK project, but it can never
> > >>>>> be an  # invariant like 'native'
> > >>>>> -if machine == 'default'
> > >>>>>    	if host_machine.cpu_family().startswith('x86')
> > >>>>>    		# matches the old pre-meson build systems default
> > >>>>> -		machine = 'corei7'
> > >>>>> +		cpu_instruction_set = 'corei7'
> > >>>>>    	elif host_machine.cpu_family().startswith('arm')
> > >>>>> -		machine = 'armv7-a'
> > >>>>> +		cpu_instruction_set = 'armv7-a'
> > >>>>>    	elif host_machine.cpu_family().startswith('aarch')
> > >>>>>    		# arm64 manages defaults in config/arm/meson.build
> > >>>>> -		machine = 'default'
> > >>>>> +		cpu_instruction_set = 'default'
> > >>>>>    	elif host_machine.cpu_family().startswith('ppc')
> > >>>>> -		machine = 'power8'
> > >>>>> +		cpu_instruction_set = 'power8'
> > >>>>>    	endif
> > >>>>>    endif
> > >>>
> > >>> This change forces the build on a P9 system to use the P8 instruction set.
> > >>> Prior to this change the "native" machine type was used which
> > >>> resulted in P9 instructions when built on a P9 system.  How do I
> > >>> force the build to use the
> > >>> power9 instruction set in this case?
> > >>>
> > >>> Dave
> > >>
> > >>  From looking at the patch, setting the "platform" to "native", or
> > >> the instruction_set to "native" should do this.
> > >> While I consider generic builds a good thing, I wonder if there is an
> > >> expectation that "native" is always the default build type for DPDK builds?
> > >>
> > >> /Bruce
> > >
> > > I left this patch alone so that people could chime in, but noone did, so let's try
> > to find some agreeable solution.
> > >
> > > My current thoughts are as such:
> > > The platform parameter specifies a set of DPDK options that will be used. This
> > is what arm uses for its builds, x86 and ppc don't use this.
> > > The cpu_instruction_set sets just one configuration among the "platform"
> > configuration set.
> > > We want the build to work on most machines of the machine architecture.
> > That implies platform=generic (as in use config options that will work on
> > everything of that architecture) and cpu_instruction_set=generic (as in use ISA
> > that will work on all cpus of the build machine architecture).
> > > Setting cpu_instruction_set=generic changes the build without cmdline options
> > for ppc. Thus, the expectation may be that cpu_instruction_set should be native
> > by default.
> > >
> > > For arm, cpu_instruction_set is ignored (and thus the value doen't matter),
> > since we can't use that without other config options (e.g. DPDK config for an
> > SoC (such as RTE_ARM_FEATURE_ATOMICS) used with an invalid
> > cpu_instuction_set). That means the only relevant parameter for Arm is platform
> > and if we want to have a build usable on most machines of the build type, we
> > have to use platform=generic.
> > >
> > > For x86 and ppc, there's no difference between native and generic platform (as
> > it's a new argument, the purpose of which is to differentiate DPDK config across
> > platforms, which doesn't exist for x86 and ppc - DPDK config is the same (correct
> > me if I'm wrong)).
> > >
> > > So it basically boils down to what should be the default value of
> > cpu_instruction_set when platform=generic (for platform=native, it's obviously
> > native):
> > > 1. cpu_instruction_set=native, this would preserve the current behavior, but
> > we won't use the 'auto' default. I think we can fall back to this if we don't agree
> > on anything better.
> > > 2. cpu_instruction_set=auto, the same as cpu_instruction_set=generic,
> > > 3. cpu_instruction_set=generic, this changes behavior for ppc builds, but we
> > may be able to remedy this:
> > > Similarly to arm (arm is using platform for this, but the idea is the same), if
> > cpu_instruction_set is generic, we can do some discovery for pcc and set the ISA
> > accordingly (either power8 or power9). If I understand it correctly, power8 is a
> > different architecture from power9 (I could be wrong on this), so this is
> > desirable. There's some logic in config/ppc/meson.build, but it doesn't seem
> > sufficient as a discovery mechanism between power8/power9.
> > 
> > POWER8 code (Power ISA v2.07) runs on POWER9 CPUs (Power ISA v3.0), so
> > setting cpu_instruction_set to GENERIC is a reasonable option. POWER10 CPUs
> > (Power ISA v3.1) are around the corner so I want to make sure developers can
> > tune the application for the platform as easily as possible.  I'm fine with
> > supporting GENERIC, just need clear instructions on how to build for a particular
> > ISA.
> > 
> 
> That's good to hear. Setting cpu_instruction_set will set the ISA.
> 
> We'll need to document the behavior properly, but I'm not sure where - Bruce? Seems like meson_options.txt doesn't have enough room for that.
> 

Yes, agreed. I suggest putting in the option help text a link to the
documentation where we explain the options more fully.

/Bruce

^ permalink raw reply	[flat|nested] 33+ messages in thread

* Re: [dpdk-dev] [RFC PATCH v2] build: add platform meson option
  2021-02-23  9:43               ` Bruce Richardson
@ 2021-02-25 12:51                 ` Juraj Linkeš
  2021-02-25 12:54                   ` Bruce Richardson
  0 siblings, 1 reply; 33+ messages in thread
From: Juraj Linkeš @ 2021-02-25 12:51 UTC (permalink / raw)
  To: Bruce Richardson; +Cc: David Christensen, thomas, Honnappa.Nagarahalli, dev



> -----Original Message-----
> From: Bruce Richardson <bruce.richardson@intel.com>
> Sent: Tuesday, February 23, 2021 10:43 AM
> To: Juraj Linkeš <juraj.linkes@pantheon.tech>
> Cc: David Christensen <drc@linux.vnet.ibm.com>; thomas@monjalon.net;
> Honnappa.Nagarahalli@arm.com; dev@dpdk.org
> Subject: Re: [RFC PATCH v2] build: add platform meson option
> 
> On Tue, Feb 23, 2021 at 08:45:09AM +0000, Juraj Linkeš wrote:
> >
> >
> > > -----Original Message-----
> > > From: David Christensen <drc@linux.vnet.ibm.com>
> > > Sent: Monday, February 22, 2021 10:25 PM
> > > To: Juraj Linkeš <juraj.linkes@pantheon.tech>; Bruce Richardson
> > > <bruce.richardson@intel.com>
> > > Cc: thomas@monjalon.net; Honnappa.Nagarahalli@arm.com;
> dev@dpdk.org
> > > Subject: Re: [RFC PATCH v2] build: add platform meson option
> > >
> > >
> > >
> > > On 2/19/21 1:11 AM, Juraj Linkeš wrote:
> > > >
> > > >
> > > >> -----Original Message-----
> > > >> From: Bruce Richardson <bruce.richardson@intel.com>
> > > >> Sent: Wednesday, January 6, 2021 3:43 PM
> > > >> To: David Christensen <drc@linux.vnet.ibm.com>
> > > >> Cc: Juraj Linkeš <juraj.linkes@pantheon.tech>;
> > > >> thomas@monjalon.net; Honnappa.Nagarahalli@arm.com; dev@dpdk.org
> > > >> Subject: Re: [RFC PATCH v2] build: add platform meson option
> > > >>
> > > >> On Tue, Jan 05, 2021 at 02:17:44PM -0800, David Christensen wrote:
> > > >>>>> The current meson option 'machine' should only specify the
> > > >>>>> ISA, which is not sufficient for Arm, where setting ISA
> > > >>>>> implies other setting as
> > > >> well.
> > > >>>>> Add a new meson option, 'platform', which differentiates the
> > > >>>>> type of the build
> > > >>>>> (native/generic) and sets machine accordingly, unless the user
> > > >>>>> chooses to override it.
> > > >>>>> The 'machine' option also doesn't describe very well what it
> > > >>>>> sets, so introduce a new option 'cpu_instruction_set', but
> > > >>>>> keep 'machine' for backward compatibility.
> > > >>>>> These two new variables, taken together, achieve what 'machine'
> > > >>>>> was setting per architecture - setting the ISA in x86 build
> > > >>>>> and setting native/default 'build type' in aarch64 build - is
> > > >>>>> now properly being set for all architectures in a uniform manner.
> > > >>>>>
> > > >>>>> Signed-off-by: Juraj Linkeš <juraj.linkes@pantheon.tech>
> > > >>>>> ---
> > > >>>>>    config/arm/meson.build        |  4 +--
> > > >>>>>    config/meson.build            | 47 +++++++++++++++++++++++++--------
> --
> > > >>>>>    devtools/test-meson-builds.sh |  9 ++++---
> > > >>>>>    meson_options.txt             |  8 ++++--
> > > >>>>>    4 files changed, 47 insertions(+), 21 deletions(-)
> > > >>>>>
> > > >>>>> diff --git a/config/arm/meson.build b/config/arm/meson.build
> > > >>>>> index
> > > >>>>> 42b4e43c7..6b09a74a7 100644
> > > >>>>> --- a/config/arm/meson.build
> > > >>>>> +++ b/config/arm/meson.build
> > > >>>>> @@ -3,10 +3,10 @@
> > > >>>>>    # Copyright(c) 2017 Cavium, Inc
> > > >>>>>
> > > >>>>>    # for checking defines we need to use the correct compiler
> > > >>>>> flags -march_opt = '-
> > > >>>>> march=@0@'.format(machine)
> > > >>>>> +march_opt = '-march=@0@'.format(cpu_instruction_set)
> > > >>>>>
> > > >>>>>    arm_force_native_march = false -arm_force_default_march =
> > > >>>>> (machine == 'default')
> > > >>>>> +arm_force_default_march = (platform == 'generic')
> > > >>>>>
> > > >>>>>    flags_common_default = [
> > > >>>>>    	# Accelarate rte_memcpy. Be sure to run unit test
> > > >>>>> (memcpy_perf_autotest) diff --git a/config/meson.build
> > > >>>>> b/config/meson.build index a3154e29c..647116513 100644
> > > >>>>> --- a/config/meson.build
> > > >>>>> +++ b/config/meson.build
> > > >>>>> @@ -63,42 +63,63 @@ if not is_windows
> > > >>>>>    			pmd_subdir_opt)
> > > >>>>>    endif
> > > >>>>>
> > > >>>>> -# set the machine type and cflags for it
> > > >>>>> +platform = get_option('platform')
> > > >>>>> +
> > > >>>>> +# set the cpu_instruction_set type and cflags for it
> > > >>>>>    if meson.is_cross_build()
> > > >>>>> -	machine = host_machine.cpu()
> > > >>>>> +	cpu_instruction_set = host_machine.cpu()
> > > >>>>>    else
> > > >>>>> -	machine = get_option('machine')
> > > >>>>> +	cpu_instruction_set = get_option('cpu_instruction_set')
> > > >>>>> +	if get_option('machine') != 'auto'
> > > >>>>> +		warning('The "machine" option is deprecated. ' +
> > > >>>>> +		        'Please use "cpu_instruction_set" instead.')
> > > >>>>> +		if cpu_instruction_set != 'auto'
> > > >>>>> +			error('Setting both "machine" and ' +
> > > >>>>> +			      '"cpu_instruction_set" is unsupported.')
> > > >>>>> +		endif
> > > >>>>> +		cpu_instruction_set = get_option('machine')
> > > >>>>> +	endif
> > > >>>>> +endif
> > > >>>>> +
> > > >>>>> +if platform == 'native'
> > > >>>>> +	if cpu_instruction_set == 'auto'
> > > >>>>> +		cpu_instruction_set = 'native'
> > > >>>>> +	endif
> > > >>>>> +elif platform == 'generic'
> > > >>>>> +	if cpu_instruction_set == 'auto'
> > > >>>>> +		cpu_instruction_set = 'default'
> > > >>>>> +	endif
> > > >>>>>    endif
> > > >>>>>
> > > >>>>> -# machine type 'default' is special, it defaults to the per
> > > >>>>> arch agreed common
> > > >>>>> +if cpu_instruction_set == 'default'
> > > >>>>> +# cpu_instruction_set type 'default' is special, it defaults
> > > >>>>> +to the per arch agreed common
> > > >>>>>    # minimal baseline needed for DPDK.
> > > >>>>>    # That might not be the most optimized, but the most
> > > >>>>> portable version while  # still being able to support the CPU
> > > >>>>> features required for
> > > >> DPDK.
> > > >>>>>    # This can be bumped up by the DPDK project, but it can
> > > >>>>> never be an  # invariant like 'native'
> > > >>>>> -if machine == 'default'
> > > >>>>>    	if host_machine.cpu_family().startswith('x86')
> > > >>>>>    		# matches the old pre-meson build systems default
> > > >>>>> -		machine = 'corei7'
> > > >>>>> +		cpu_instruction_set = 'corei7'
> > > >>>>>    	elif host_machine.cpu_family().startswith('arm')
> > > >>>>> -		machine = 'armv7-a'
> > > >>>>> +		cpu_instruction_set = 'armv7-a'
> > > >>>>>    	elif host_machine.cpu_family().startswith('aarch')
> > > >>>>>    		# arm64 manages defaults in config/arm/meson.build
> > > >>>>> -		machine = 'default'
> > > >>>>> +		cpu_instruction_set = 'default'
> > > >>>>>    	elif host_machine.cpu_family().startswith('ppc')
> > > >>>>> -		machine = 'power8'
> > > >>>>> +		cpu_instruction_set = 'power8'
> > > >>>>>    	endif
> > > >>>>>    endif
> > > >>>
> > > >>> This change forces the build on a P9 system to use the P8 instruction set.
> > > >>> Prior to this change the "native" machine type was used which
> > > >>> resulted in P9 instructions when built on a P9 system.  How do I
> > > >>> force the build to use the
> > > >>> power9 instruction set in this case?
> > > >>>
> > > >>> Dave
> > > >>
> > > >>  From looking at the patch, setting the "platform" to "native",
> > > >> or the instruction_set to "native" should do this.
> > > >> While I consider generic builds a good thing, I wonder if there
> > > >> is an expectation that "native" is always the default build type for DPDK
> builds?
> > > >>
> > > >> /Bruce
> > > >
> > > > I left this patch alone so that people could chime in, but noone
> > > > did, so let's try
> > > to find some agreeable solution.
> > > >
> > > > My current thoughts are as such:
> > > > The platform parameter specifies a set of DPDK options that will
> > > > be used. This
> > > is what arm uses for its builds, x86 and ppc don't use this.
> > > > The cpu_instruction_set sets just one configuration among the "platform"
> > > configuration set.
> > > > We want the build to work on most machines of the machine architecture.
> > > That implies platform=generic (as in use config options that will
> > > work on everything of that architecture) and
> > > cpu_instruction_set=generic (as in use ISA that will work on all cpus of the
> build machine architecture).
> > > > Setting cpu_instruction_set=generic changes the build without
> > > > cmdline options
> > > for ppc. Thus, the expectation may be that cpu_instruction_set
> > > should be native by default.
> > > >
> > > > For arm, cpu_instruction_set is ignored (and thus the value doen't
> > > > matter),
> > > since we can't use that without other config options (e.g. DPDK
> > > config for an SoC (such as RTE_ARM_FEATURE_ATOMICS) used with an
> > > invalid cpu_instuction_set). That means the only relevant parameter
> > > for Arm is platform and if we want to have a build usable on most
> > > machines of the build type, we have to use platform=generic.
> > > >
> > > > For x86 and ppc, there's no difference between native and generic
> > > > platform (as
> > > it's a new argument, the purpose of which is to differentiate DPDK
> > > config across platforms, which doesn't exist for x86 and ppc - DPDK
> > > config is the same (correct me if I'm wrong)).
> > > >
> > > > So it basically boils down to what should be the default value of
> > > cpu_instruction_set when platform=generic (for platform=native, it's
> > > obviously
> > > native):
> > > > 1. cpu_instruction_set=native, this would preserve the current
> > > > behavior, but
> > > we won't use the 'auto' default. I think we can fall back to this if
> > > we don't agree on anything better.
> > > > 2. cpu_instruction_set=auto, the same as
> > > > cpu_instruction_set=generic, 3. cpu_instruction_set=generic, this
> > > > changes behavior for ppc builds, but we
> > > may be able to remedy this:
> > > > Similarly to arm (arm is using platform for this, but the idea is
> > > > the same), if
> > > cpu_instruction_set is generic, we can do some discovery for pcc and
> > > set the ISA accordingly (either power8 or power9). If I understand
> > > it correctly, power8 is a different architecture from power9 (I
> > > could be wrong on this), so this is desirable. There's some logic in
> > > config/ppc/meson.build, but it doesn't seem sufficient as a discovery
> mechanism between power8/power9.
> > >
> > > POWER8 code (Power ISA v2.07) runs on POWER9 CPUs (Power ISA v3.0),
> > > so setting cpu_instruction_set to GENERIC is a reasonable option.
> > > POWER10 CPUs (Power ISA v3.1) are around the corner so I want to
> > > make sure developers can tune the application for the platform as
> > > easily as possible.  I'm fine with supporting GENERIC, just need
> > > clear instructions on how to build for a particular ISA.
> > >
> >
> > That's good to hear. Setting cpu_instruction_set will set the ISA.
> >
> > We'll need to document the behavior properly, but I'm not sure where - Bruce?
> Seems like meson_options.txt doesn't have enough room for that.
> >
> 
> Yes, agreed. I suggest putting in the option help text a link to the documentation
> where we explain the options more fully.
> 
> /Bruce

You mentioned in the kni cross compile patch that we should do a separate patch where we explain the option in docs and I believe this would go into that patch. Before we do that, let's figure out the best description without the link. I currently have:
option('cpu_instruction_set', type: 'string', value: 'auto',
	description: 'Set the target machine ISA (instruction set architecture). Will be set according to the platform option by default.')
option('platform', type: 'string', value: 'generic',
	description: 'Platform to build, either "native" or "generic".')

What do you think? Should we expand the platform description a bit?

^ permalink raw reply	[flat|nested] 33+ messages in thread

* Re: [dpdk-dev] [RFC PATCH v2] build: add platform meson option
  2021-02-25 12:51                 ` Juraj Linkeš
@ 2021-02-25 12:54                   ` Bruce Richardson
  2021-02-25 12:57                     ` Juraj Linkeš
  0 siblings, 1 reply; 33+ messages in thread
From: Bruce Richardson @ 2021-02-25 12:54 UTC (permalink / raw)
  To: Juraj Linkeš; +Cc: David Christensen, thomas, Honnappa.Nagarahalli, dev

On Thu, Feb 25, 2021 at 12:51:57PM +0000, Juraj Linkeš wrote:
> 
> 
> > -----Original Message-----
> > From: Bruce Richardson <bruce.richardson@intel.com>
> > Sent: Tuesday, February 23, 2021 10:43 AM
> > To: Juraj Linkeš <juraj.linkes@pantheon.tech>
> > Cc: David Christensen <drc@linux.vnet.ibm.com>; thomas@monjalon.net;
> > Honnappa.Nagarahalli@arm.com; dev@dpdk.org
> > Subject: Re: [RFC PATCH v2] build: add platform meson option
> > 
> > On Tue, Feb 23, 2021 at 08:45:09AM +0000, Juraj Linkeš wrote:
> > >
> > >
> > > > -----Original Message-----
> > > > From: David Christensen <drc@linux.vnet.ibm.com>
> > > > Sent: Monday, February 22, 2021 10:25 PM
> > > > To: Juraj Linkeš <juraj.linkes@pantheon.tech>; Bruce Richardson
> > > > <bruce.richardson@intel.com>
> > > > Cc: thomas@monjalon.net; Honnappa.Nagarahalli@arm.com;
> > dev@dpdk.org
> > > > Subject: Re: [RFC PATCH v2] build: add platform meson option
> > > >
> > > >
> > > >
> > > > On 2/19/21 1:11 AM, Juraj Linkeš wrote:
> > > > >
> > > > >
> > > > >> -----Original Message-----
> > > > >> From: Bruce Richardson <bruce.richardson@intel.com>
> > > > >> Sent: Wednesday, January 6, 2021 3:43 PM
> > > > >> To: David Christensen <drc@linux.vnet.ibm.com>
> > > > >> Cc: Juraj Linkeš <juraj.linkes@pantheon.tech>;
> > > > >> thomas@monjalon.net; Honnappa.Nagarahalli@arm.com; dev@dpdk.org
> > > > >> Subject: Re: [RFC PATCH v2] build: add platform meson option
> > > > >>
> > > > >> On Tue, Jan 05, 2021 at 02:17:44PM -0800, David Christensen wrote:
> > > > >>>>> The current meson option 'machine' should only specify the
> > > > >>>>> ISA, which is not sufficient for Arm, where setting ISA
> > > > >>>>> implies other setting as
> > > > >> well.
> > > > >>>>> Add a new meson option, 'platform', which differentiates the
> > > > >>>>> type of the build
> > > > >>>>> (native/generic) and sets machine accordingly, unless the user
> > > > >>>>> chooses to override it.
> > > > >>>>> The 'machine' option also doesn't describe very well what it
> > > > >>>>> sets, so introduce a new option 'cpu_instruction_set', but
> > > > >>>>> keep 'machine' for backward compatibility.
> > > > >>>>> These two new variables, taken together, achieve what 'machine'
> > > > >>>>> was setting per architecture - setting the ISA in x86 build
> > > > >>>>> and setting native/default 'build type' in aarch64 build - is
> > > > >>>>> now properly being set for all architectures in a uniform manner.
> > > > >>>>>
> > > > >>>>> Signed-off-by: Juraj Linkeš <juraj.linkes@pantheon.tech>
> > > > >>>>> ---
> > > > >>>>>    config/arm/meson.build        |  4 +--
> > > > >>>>>    config/meson.build            | 47 +++++++++++++++++++++++++--------
> > --
> > > > >>>>>    devtools/test-meson-builds.sh |  9 ++++---
> > > > >>>>>    meson_options.txt             |  8 ++++--
> > > > >>>>>    4 files changed, 47 insertions(+), 21 deletions(-)
> > > > >>>>>
> > > > >>>>> diff --git a/config/arm/meson.build b/config/arm/meson.build
> > > > >>>>> index
> > > > >>>>> 42b4e43c7..6b09a74a7 100644
> > > > >>>>> --- a/config/arm/meson.build
> > > > >>>>> +++ b/config/arm/meson.build
> > > > >>>>> @@ -3,10 +3,10 @@
> > > > >>>>>    # Copyright(c) 2017 Cavium, Inc
> > > > >>>>>
> > > > >>>>>    # for checking defines we need to use the correct compiler
> > > > >>>>> flags -march_opt = '-
> > > > >>>>> march=@0@'.format(machine)
> > > > >>>>> +march_opt = '-march=@0@'.format(cpu_instruction_set)
> > > > >>>>>
> > > > >>>>>    arm_force_native_march = false -arm_force_default_march =
> > > > >>>>> (machine == 'default')
> > > > >>>>> +arm_force_default_march = (platform == 'generic')
> > > > >>>>>
> > > > >>>>>    flags_common_default = [
> > > > >>>>>    	# Accelarate rte_memcpy. Be sure to run unit test
> > > > >>>>> (memcpy_perf_autotest) diff --git a/config/meson.build
> > > > >>>>> b/config/meson.build index a3154e29c..647116513 100644
> > > > >>>>> --- a/config/meson.build
> > > > >>>>> +++ b/config/meson.build
> > > > >>>>> @@ -63,42 +63,63 @@ if not is_windows
> > > > >>>>>    			pmd_subdir_opt)
> > > > >>>>>    endif
> > > > >>>>>
> > > > >>>>> -# set the machine type and cflags for it
> > > > >>>>> +platform = get_option('platform')
> > > > >>>>> +
> > > > >>>>> +# set the cpu_instruction_set type and cflags for it
> > > > >>>>>    if meson.is_cross_build()
> > > > >>>>> -	machine = host_machine.cpu()
> > > > >>>>> +	cpu_instruction_set = host_machine.cpu()
> > > > >>>>>    else
> > > > >>>>> -	machine = get_option('machine')
> > > > >>>>> +	cpu_instruction_set = get_option('cpu_instruction_set')
> > > > >>>>> +	if get_option('machine') != 'auto'
> > > > >>>>> +		warning('The "machine" option is deprecated. ' +
> > > > >>>>> +		        'Please use "cpu_instruction_set" instead.')
> > > > >>>>> +		if cpu_instruction_set != 'auto'
> > > > >>>>> +			error('Setting both "machine" and ' +
> > > > >>>>> +			      '"cpu_instruction_set" is unsupported.')
> > > > >>>>> +		endif
> > > > >>>>> +		cpu_instruction_set = get_option('machine')
> > > > >>>>> +	endif
> > > > >>>>> +endif
> > > > >>>>> +
> > > > >>>>> +if platform == 'native'
> > > > >>>>> +	if cpu_instruction_set == 'auto'
> > > > >>>>> +		cpu_instruction_set = 'native'
> > > > >>>>> +	endif
> > > > >>>>> +elif platform == 'generic'
> > > > >>>>> +	if cpu_instruction_set == 'auto'
> > > > >>>>> +		cpu_instruction_set = 'default'
> > > > >>>>> +	endif
> > > > >>>>>    endif
> > > > >>>>>
> > > > >>>>> -# machine type 'default' is special, it defaults to the per
> > > > >>>>> arch agreed common
> > > > >>>>> +if cpu_instruction_set == 'default'
> > > > >>>>> +# cpu_instruction_set type 'default' is special, it defaults
> > > > >>>>> +to the per arch agreed common
> > > > >>>>>    # minimal baseline needed for DPDK.
> > > > >>>>>    # That might not be the most optimized, but the most
> > > > >>>>> portable version while  # still being able to support the CPU
> > > > >>>>> features required for
> > > > >> DPDK.
> > > > >>>>>    # This can be bumped up by the DPDK project, but it can
> > > > >>>>> never be an  # invariant like 'native'
> > > > >>>>> -if machine == 'default'
> > > > >>>>>    	if host_machine.cpu_family().startswith('x86')
> > > > >>>>>    		# matches the old pre-meson build systems default
> > > > >>>>> -		machine = 'corei7'
> > > > >>>>> +		cpu_instruction_set = 'corei7'
> > > > >>>>>    	elif host_machine.cpu_family().startswith('arm')
> > > > >>>>> -		machine = 'armv7-a'
> > > > >>>>> +		cpu_instruction_set = 'armv7-a'
> > > > >>>>>    	elif host_machine.cpu_family().startswith('aarch')
> > > > >>>>>    		# arm64 manages defaults in config/arm/meson.build
> > > > >>>>> -		machine = 'default'
> > > > >>>>> +		cpu_instruction_set = 'default'
> > > > >>>>>    	elif host_machine.cpu_family().startswith('ppc')
> > > > >>>>> -		machine = 'power8'
> > > > >>>>> +		cpu_instruction_set = 'power8'
> > > > >>>>>    	endif
> > > > >>>>>    endif
> > > > >>>
> > > > >>> This change forces the build on a P9 system to use the P8 instruction set.
> > > > >>> Prior to this change the "native" machine type was used which
> > > > >>> resulted in P9 instructions when built on a P9 system.  How do I
> > > > >>> force the build to use the
> > > > >>> power9 instruction set in this case?
> > > > >>>
> > > > >>> Dave
> > > > >>
> > > > >>  From looking at the patch, setting the "platform" to "native",
> > > > >> or the instruction_set to "native" should do this.
> > > > >> While I consider generic builds a good thing, I wonder if there
> > > > >> is an expectation that "native" is always the default build type for DPDK
> > builds?
> > > > >>
> > > > >> /Bruce
> > > > >
> > > > > I left this patch alone so that people could chime in, but noone
> > > > > did, so let's try
> > > > to find some agreeable solution.
> > > > >
> > > > > My current thoughts are as such:
> > > > > The platform parameter specifies a set of DPDK options that will
> > > > > be used. This
> > > > is what arm uses for its builds, x86 and ppc don't use this.
> > > > > The cpu_instruction_set sets just one configuration among the "platform"
> > > > configuration set.
> > > > > We want the build to work on most machines of the machine architecture.
> > > > That implies platform=generic (as in use config options that will
> > > > work on everything of that architecture) and
> > > > cpu_instruction_set=generic (as in use ISA that will work on all cpus of the
> > build machine architecture).
> > > > > Setting cpu_instruction_set=generic changes the build without
> > > > > cmdline options
> > > > for ppc. Thus, the expectation may be that cpu_instruction_set
> > > > should be native by default.
> > > > >
> > > > > For arm, cpu_instruction_set is ignored (and thus the value doen't
> > > > > matter),
> > > > since we can't use that without other config options (e.g. DPDK
> > > > config for an SoC (such as RTE_ARM_FEATURE_ATOMICS) used with an
> > > > invalid cpu_instuction_set). That means the only relevant parameter
> > > > for Arm is platform and if we want to have a build usable on most
> > > > machines of the build type, we have to use platform=generic.
> > > > >
> > > > > For x86 and ppc, there's no difference between native and generic
> > > > > platform (as
> > > > it's a new argument, the purpose of which is to differentiate DPDK
> > > > config across platforms, which doesn't exist for x86 and ppc - DPDK
> > > > config is the same (correct me if I'm wrong)).
> > > > >
> > > > > So it basically boils down to what should be the default value of
> > > > cpu_instruction_set when platform=generic (for platform=native, it's
> > > > obviously
> > > > native):
> > > > > 1. cpu_instruction_set=native, this would preserve the current
> > > > > behavior, but
> > > > we won't use the 'auto' default. I think we can fall back to this if
> > > > we don't agree on anything better.
> > > > > 2. cpu_instruction_set=auto, the same as
> > > > > cpu_instruction_set=generic, 3. cpu_instruction_set=generic, this
> > > > > changes behavior for ppc builds, but we
> > > > may be able to remedy this:
> > > > > Similarly to arm (arm is using platform for this, but the idea is
> > > > > the same), if
> > > > cpu_instruction_set is generic, we can do some discovery for pcc and
> > > > set the ISA accordingly (either power8 or power9). If I understand
> > > > it correctly, power8 is a different architecture from power9 (I
> > > > could be wrong on this), so this is desirable. There's some logic in
> > > > config/ppc/meson.build, but it doesn't seem sufficient as a discovery
> > mechanism between power8/power9.
> > > >
> > > > POWER8 code (Power ISA v2.07) runs on POWER9 CPUs (Power ISA v3.0),
> > > > so setting cpu_instruction_set to GENERIC is a reasonable option.
> > > > POWER10 CPUs (Power ISA v3.1) are around the corner so I want to
> > > > make sure developers can tune the application for the platform as
> > > > easily as possible.  I'm fine with supporting GENERIC, just need
> > > > clear instructions on how to build for a particular ISA.
> > > >
> > >
> > > That's good to hear. Setting cpu_instruction_set will set the ISA.
> > >
> > > We'll need to document the behavior properly, but I'm not sure where - Bruce?
> > Seems like meson_options.txt doesn't have enough room for that.
> > >
> > 
> > Yes, agreed. I suggest putting in the option help text a link to the documentation
> > where we explain the options more fully.
> > 
> > /Bruce
> 
> You mentioned in the kni cross compile patch that we should do a separate patch where we explain the option in docs and I believe this would go into that patch. Before we do that, let's figure out the best description without the link. I currently have:
> option('cpu_instruction_set', type: 'string', value: 'auto',
> 	description: 'Set the target machine ISA (instruction set architecture). Will be set according to the platform option by default.')
> option('platform', type: 'string', value: 'generic',
> 	description: 'Platform to build, either "native" or "generic".')
> 
> What do you think? Should we expand the platform description a bit?

Are there not more platform options than just those two?

^ permalink raw reply	[flat|nested] 33+ messages in thread

* Re: [dpdk-dev] [RFC PATCH v2] build: add platform meson option
  2021-02-25 12:54                   ` Bruce Richardson
@ 2021-02-25 12:57                     ` Juraj Linkeš
  0 siblings, 0 replies; 33+ messages in thread
From: Juraj Linkeš @ 2021-02-25 12:57 UTC (permalink / raw)
  To: Bruce Richardson; +Cc: David Christensen, thomas, Honnappa.Nagarahalli, dev



> -----Original Message-----
> From: Bruce Richardson <bruce.richardson@intel.com>
> Sent: Thursday, February 25, 2021 1:54 PM
> To: Juraj Linkeš <juraj.linkes@pantheon.tech>
> Cc: David Christensen <drc@linux.vnet.ibm.com>; thomas@monjalon.net;
> Honnappa.Nagarahalli@arm.com; dev@dpdk.org
> Subject: Re: [RFC PATCH v2] build: add platform meson option
> 
> On Thu, Feb 25, 2021 at 12:51:57PM +0000, Juraj Linkeš wrote:
> >
> >
> > > -----Original Message-----
> > > From: Bruce Richardson <bruce.richardson@intel.com>
> > > Sent: Tuesday, February 23, 2021 10:43 AM
> > > To: Juraj Linkeš <juraj.linkes@pantheon.tech>
> > > Cc: David Christensen <drc@linux.vnet.ibm.com>; thomas@monjalon.net;
> > > Honnappa.Nagarahalli@arm.com; dev@dpdk.org
> > > Subject: Re: [RFC PATCH v2] build: add platform meson option
> > >
> > > On Tue, Feb 23, 2021 at 08:45:09AM +0000, Juraj Linkeš wrote:
> > > >
> > > >
> > > > > -----Original Message-----
> > > > > From: David Christensen <drc@linux.vnet.ibm.com>
> > > > > Sent: Monday, February 22, 2021 10:25 PM
> > > > > To: Juraj Linkeš <juraj.linkes@pantheon.tech>; Bruce Richardson
> > > > > <bruce.richardson@intel.com>
> > > > > Cc: thomas@monjalon.net; Honnappa.Nagarahalli@arm.com;
> > > dev@dpdk.org
> > > > > Subject: Re: [RFC PATCH v2] build: add platform meson option
> > > > >
> > > > >
> > > > >
> > > > > On 2/19/21 1:11 AM, Juraj Linkeš wrote:
> > > > > >
> > > > > >
> > > > > >> -----Original Message-----
> > > > > >> From: Bruce Richardson <bruce.richardson@intel.com>
> > > > > >> Sent: Wednesday, January 6, 2021 3:43 PM
> > > > > >> To: David Christensen <drc@linux.vnet.ibm.com>
> > > > > >> Cc: Juraj Linkeš <juraj.linkes@pantheon.tech>;
> > > > > >> thomas@monjalon.net; Honnappa.Nagarahalli@arm.com;
> > > > > >> dev@dpdk.org
> > > > > >> Subject: Re: [RFC PATCH v2] build: add platform meson option
> > > > > >>
> > > > > >> On Tue, Jan 05, 2021 at 02:17:44PM -0800, David Christensen wrote:
> > > > > >>>>> The current meson option 'machine' should only specify the
> > > > > >>>>> ISA, which is not sufficient for Arm, where setting ISA
> > > > > >>>>> implies other setting as
> > > > > >> well.
> > > > > >>>>> Add a new meson option, 'platform', which differentiates
> > > > > >>>>> the type of the build
> > > > > >>>>> (native/generic) and sets machine accordingly, unless the
> > > > > >>>>> user chooses to override it.
> > > > > >>>>> The 'machine' option also doesn't describe very well what
> > > > > >>>>> it sets, so introduce a new option 'cpu_instruction_set',
> > > > > >>>>> but keep 'machine' for backward compatibility.
> > > > > >>>>> These two new variables, taken together, achieve what 'machine'
> > > > > >>>>> was setting per architecture - setting the ISA in x86
> > > > > >>>>> build and setting native/default 'build type' in aarch64
> > > > > >>>>> build - is now properly being set for all architectures in a uniform
> manner.
> > > > > >>>>>
> > > > > >>>>> Signed-off-by: Juraj Linkeš <juraj.linkes@pantheon.tech>
> > > > > >>>>> ---
> > > > > >>>>>    config/arm/meson.build        |  4 +--
> > > > > >>>>>    config/meson.build            | 47 +++++++++++++++++++++++++----
> ----
> > > --
> > > > > >>>>>    devtools/test-meson-builds.sh |  9 ++++---
> > > > > >>>>>    meson_options.txt             |  8 ++++--
> > > > > >>>>>    4 files changed, 47 insertions(+), 21 deletions(-)
> > > > > >>>>>
> > > > > >>>>> diff --git a/config/arm/meson.build
> > > > > >>>>> b/config/arm/meson.build index
> > > > > >>>>> 42b4e43c7..6b09a74a7 100644
> > > > > >>>>> --- a/config/arm/meson.build
> > > > > >>>>> +++ b/config/arm/meson.build
> > > > > >>>>> @@ -3,10 +3,10 @@
> > > > > >>>>>    # Copyright(c) 2017 Cavium, Inc
> > > > > >>>>>
> > > > > >>>>>    # for checking defines we need to use the correct
> > > > > >>>>> compiler flags -march_opt = '-
> > > > > >>>>> march=@0@'.format(machine)
> > > > > >>>>> +march_opt = '-march=@0@'.format(cpu_instruction_set)
> > > > > >>>>>
> > > > > >>>>>    arm_force_native_march = false -arm_force_default_march
> > > > > >>>>> = (machine == 'default')
> > > > > >>>>> +arm_force_default_march = (platform == 'generic')
> > > > > >>>>>
> > > > > >>>>>    flags_common_default = [
> > > > > >>>>>    	# Accelarate rte_memcpy. Be sure to run unit test
> > > > > >>>>> (memcpy_perf_autotest) diff --git a/config/meson.build
> > > > > >>>>> b/config/meson.build index a3154e29c..647116513 100644
> > > > > >>>>> --- a/config/meson.build
> > > > > >>>>> +++ b/config/meson.build
> > > > > >>>>> @@ -63,42 +63,63 @@ if not is_windows
> > > > > >>>>>    			pmd_subdir_opt)
> > > > > >>>>>    endif
> > > > > >>>>>
> > > > > >>>>> -# set the machine type and cflags for it
> > > > > >>>>> +platform = get_option('platform')
> > > > > >>>>> +
> > > > > >>>>> +# set the cpu_instruction_set type and cflags for it
> > > > > >>>>>    if meson.is_cross_build()
> > > > > >>>>> -	machine = host_machine.cpu()
> > > > > >>>>> +	cpu_instruction_set = host_machine.cpu()
> > > > > >>>>>    else
> > > > > >>>>> -	machine = get_option('machine')
> > > > > >>>>> +	cpu_instruction_set = get_option('cpu_instruction_set')
> > > > > >>>>> +	if get_option('machine') != 'auto'
> > > > > >>>>> +		warning('The "machine" option is deprecated. ' +
> > > > > >>>>> +		        'Please use "cpu_instruction_set" instead.')
> > > > > >>>>> +		if cpu_instruction_set != 'auto'
> > > > > >>>>> +			error('Setting both "machine" and ' +
> > > > > >>>>> +			      '"cpu_instruction_set" is unsupported.')
> > > > > >>>>> +		endif
> > > > > >>>>> +		cpu_instruction_set = get_option('machine')
> > > > > >>>>> +	endif
> > > > > >>>>> +endif
> > > > > >>>>> +
> > > > > >>>>> +if platform == 'native'
> > > > > >>>>> +	if cpu_instruction_set == 'auto'
> > > > > >>>>> +		cpu_instruction_set = 'native'
> > > > > >>>>> +	endif
> > > > > >>>>> +elif platform == 'generic'
> > > > > >>>>> +	if cpu_instruction_set == 'auto'
> > > > > >>>>> +		cpu_instruction_set = 'default'
> > > > > >>>>> +	endif
> > > > > >>>>>    endif
> > > > > >>>>>
> > > > > >>>>> -# machine type 'default' is special, it defaults to the
> > > > > >>>>> per arch agreed common
> > > > > >>>>> +if cpu_instruction_set == 'default'
> > > > > >>>>> +# cpu_instruction_set type 'default' is special, it
> > > > > >>>>> +defaults to the per arch agreed common
> > > > > >>>>>    # minimal baseline needed for DPDK.
> > > > > >>>>>    # That might not be the most optimized, but the most
> > > > > >>>>> portable version while  # still being able to support the
> > > > > >>>>> CPU features required for
> > > > > >> DPDK.
> > > > > >>>>>    # This can be bumped up by the DPDK project, but it can
> > > > > >>>>> never be an  # invariant like 'native'
> > > > > >>>>> -if machine == 'default'
> > > > > >>>>>    	if host_machine.cpu_family().startswith('x86')
> > > > > >>>>>    		# matches the old pre-meson build systems default
> > > > > >>>>> -		machine = 'corei7'
> > > > > >>>>> +		cpu_instruction_set = 'corei7'
> > > > > >>>>>    	elif host_machine.cpu_family().startswith('arm')
> > > > > >>>>> -		machine = 'armv7-a'
> > > > > >>>>> +		cpu_instruction_set = 'armv7-a'
> > > > > >>>>>    	elif host_machine.cpu_family().startswith('aarch')
> > > > > >>>>>    		# arm64 manages defaults in config/arm/meson.build
> > > > > >>>>> -		machine = 'default'
> > > > > >>>>> +		cpu_instruction_set = 'default'
> > > > > >>>>>    	elif host_machine.cpu_family().startswith('ppc')
> > > > > >>>>> -		machine = 'power8'
> > > > > >>>>> +		cpu_instruction_set = 'power8'
> > > > > >>>>>    	endif
> > > > > >>>>>    endif
> > > > > >>>
> > > > > >>> This change forces the build on a P9 system to use the P8 instruction
> set.
> > > > > >>> Prior to this change the "native" machine type was used
> > > > > >>> which resulted in P9 instructions when built on a P9 system.
> > > > > >>> How do I force the build to use the
> > > > > >>> power9 instruction set in this case?
> > > > > >>>
> > > > > >>> Dave
> > > > > >>
> > > > > >>  From looking at the patch, setting the "platform" to
> > > > > >> "native", or the instruction_set to "native" should do this.
> > > > > >> While I consider generic builds a good thing, I wonder if
> > > > > >> there is an expectation that "native" is always the default
> > > > > >> build type for DPDK
> > > builds?
> > > > > >>
> > > > > >> /Bruce
> > > > > >
> > > > > > I left this patch alone so that people could chime in, but
> > > > > > noone did, so let's try
> > > > > to find some agreeable solution.
> > > > > >
> > > > > > My current thoughts are as such:
> > > > > > The platform parameter specifies a set of DPDK options that
> > > > > > will be used. This
> > > > > is what arm uses for its builds, x86 and ppc don't use this.
> > > > > > The cpu_instruction_set sets just one configuration among the
> "platform"
> > > > > configuration set.
> > > > > > We want the build to work on most machines of the machine
> architecture.
> > > > > That implies platform=generic (as in use config options that
> > > > > will work on everything of that architecture) and
> > > > > cpu_instruction_set=generic (as in use ISA that will work on all
> > > > > cpus of the
> > > build machine architecture).
> > > > > > Setting cpu_instruction_set=generic changes the build without
> > > > > > cmdline options
> > > > > for ppc. Thus, the expectation may be that cpu_instruction_set
> > > > > should be native by default.
> > > > > >
> > > > > > For arm, cpu_instruction_set is ignored (and thus the value
> > > > > > doen't matter),
> > > > > since we can't use that without other config options (e.g. DPDK
> > > > > config for an SoC (such as RTE_ARM_FEATURE_ATOMICS) used with an
> > > > > invalid cpu_instuction_set). That means the only relevant
> > > > > parameter for Arm is platform and if we want to have a build
> > > > > usable on most machines of the build type, we have to use
> platform=generic.
> > > > > >
> > > > > > For x86 and ppc, there's no difference between native and
> > > > > > generic platform (as
> > > > > it's a new argument, the purpose of which is to differentiate
> > > > > DPDK config across platforms, which doesn't exist for x86 and
> > > > > ppc - DPDK config is the same (correct me if I'm wrong)).
> > > > > >
> > > > > > So it basically boils down to what should be the default value
> > > > > > of
> > > > > cpu_instruction_set when platform=generic (for platform=native,
> > > > > it's obviously
> > > > > native):
> > > > > > 1. cpu_instruction_set=native, this would preserve the current
> > > > > > behavior, but
> > > > > we won't use the 'auto' default. I think we can fall back to
> > > > > this if we don't agree on anything better.
> > > > > > 2. cpu_instruction_set=auto, the same as
> > > > > > cpu_instruction_set=generic, 3. cpu_instruction_set=generic,
> > > > > > this changes behavior for ppc builds, but we
> > > > > may be able to remedy this:
> > > > > > Similarly to arm (arm is using platform for this, but the idea
> > > > > > is the same), if
> > > > > cpu_instruction_set is generic, we can do some discovery for pcc
> > > > > and set the ISA accordingly (either power8 or power9). If I
> > > > > understand it correctly, power8 is a different architecture from
> > > > > power9 (I could be wrong on this), so this is desirable. There's
> > > > > some logic in config/ppc/meson.build, but it doesn't seem
> > > > > sufficient as a discovery
> > > mechanism between power8/power9.
> > > > >
> > > > > POWER8 code (Power ISA v2.07) runs on POWER9 CPUs (Power ISA
> > > > > v3.0), so setting cpu_instruction_set to GENERIC is a reasonable option.
> > > > > POWER10 CPUs (Power ISA v3.1) are around the corner so I want to
> > > > > make sure developers can tune the application for the platform
> > > > > as easily as possible.  I'm fine with supporting GENERIC, just
> > > > > need clear instructions on how to build for a particular ISA.
> > > > >
> > > >
> > > > That's good to hear. Setting cpu_instruction_set will set the ISA.
> > > >
> > > > We'll need to document the behavior properly, but I'm not sure where -
> Bruce?
> > > Seems like meson_options.txt doesn't have enough room for that.
> > > >
> > >
> > > Yes, agreed. I suggest putting in the option help text a link to the
> > > documentation where we explain the options more fully.
> > >
> > > /Bruce
> >
> > You mentioned in the kni cross compile patch that we should do a separate
> patch where we explain the option in docs and I believe this would go into that
> patch. Before we do that, let's figure out the best description without the link. I
> currently have:
> > option('cpu_instruction_set', type: 'string', value: 'auto',
> > 	description: 'Set the target machine ISA (instruction set
> > architecture). Will be set according to the platform option by default.')
> option('platform', type: 'string', value: 'generic',
> > 	description: 'Platform to build, either "native" or "generic".')
> >
> > What do you think? Should we expand the platform description a bit?
> 
> Are there not more platform options than just those two?

We're adding more in http://patches.dpdk.org/project/dpdk/patch/1612361037-12746-3-git-send-email-juraj.linkes@pantheon.tech/. I don't think there are more than two without that.

^ permalink raw reply	[flat|nested] 33+ messages in thread

* [dpdk-dev] [PATCH v3] build: add platform meson option
  2021-01-04 11:52 ` [dpdk-dev] [RFC PATCH v2] " Juraj Linkeš
  2021-01-04 11:59   ` Juraj Linkeš
@ 2021-03-29 11:03   ` Juraj Linkeš
  2021-03-29 12:50     ` [dpdk-dev] [PATCH v4] " Juraj Linkeš
  1 sibling, 1 reply; 33+ messages in thread
From: Juraj Linkeš @ 2021-03-29 11:03 UTC (permalink / raw)
  To: thomas, david.marchand, bruce.richardson, Honnappa.Nagarahalli
  Cc: dev, Juraj Linkeš

The current meson option 'machine' should only specify the ISA, which is
not sufficient for Arm, where setting ISA implies other setting as well.
Add a new meson option, 'platform', which differentiates the type of the
build (native/generic) and sets machine accordingly, unless the user
chooses to override it.
The 'machine' option also doesn't describe very well what it sets, so
introduce a new option 'cpu_instruction_set', but keep 'machine' for
backwards compatibility.
These two new variables, taken together, achieve what 'machine' was
setting per architecture - setting the ISA in x86 build and setting
native/default 'build type' in aarch64 build - is now properly being set
for all architectures in a uniform manner.

Signed-off-by: Juraj Linkeš <juraj.linkes@pantheon.tech>
---
 config/meson.build            | 47 +++++++++++++++++++++++++----------
 devtools/test-meson-builds.sh |  9 ++++---
 meson_options.txt             |  8 ++++--
 3 files changed, 45 insertions(+), 19 deletions(-)

diff --git a/config/meson.build b/config/meson.build
index 66a2edcc47..32c9e18c17 100644
--- a/config/meson.build
+++ b/config/meson.build
@@ -63,42 +63,63 @@ if not is_windows
 			pmd_subdir_opt)
 endif
 
-# set the machine type and cflags for it
+platform = get_option('platform')
+
+# set the cpu_instruction_set type and cflags for it
 if meson.is_cross_build()
-	machine = host_machine.cpu()
+	cpu_instruction_set = host_machine.cpu()
 else
-	machine = get_option('machine')
+	cpu_instruction_set = get_option('cpu_instruction_set')
+	if get_option('machine') != 'auto'
+		warning('The "machine" option is deprecated. ' +
+		        'Please use "cpu_instruction_set" instead.')
+		if cpu_instruction_set != 'auto'
+			error('Setting both "machine" and ' +
+			      '"cpu_instruction_set" is unsupported.')
+		endif
+		cpu_instruction_set = get_option('machine')
+	endif
+endif
+
+if platform == 'native'
+	if cpu_instruction_set == 'auto'
+		cpu_instruction_set = 'native'
+	endif
+elif platform == 'generic'
+	if cpu_instruction_set == 'auto'
+		cpu_instruction_set = 'default'
+	endif
 endif
 
-# machine type 'default' is special, it defaults to the per arch agreed common
+if cpu_instruction_set == 'default'
+# cpu_instruction_set type 'default' is special, it defaults to the per arch agreed common
 # minimal baseline needed for DPDK.
 # That might not be the most optimized, but the most portable version while
 # still being able to support the CPU features required for DPDK.
 # This can be bumped up by the DPDK project, but it can never be an
 # invariant like 'native'
-if machine == 'default'
 	if host_machine.cpu_family().startswith('x86')
 		# matches the old pre-meson build systems default
-		machine = 'corei7'
+		cpu_instruction_set = 'corei7'
 	elif host_machine.cpu_family().startswith('arm')
-		machine = 'armv7-a'
+		cpu_instruction_set = 'armv7-a'
 	elif host_machine.cpu_family().startswith('aarch')
 		# arm64 manages defaults in config/arm/meson.build
-		machine = 'default'
+		cpu_instruction_set = 'default'
 	elif host_machine.cpu_family().startswith('ppc')
-		machine = 'power8'
+		cpu_instruction_set = 'power8'
 	endif
 endif
 
-dpdk_conf.set('RTE_MACHINE', machine)
+dpdk_conf.set('RTE_MACHINE', cpu_instruction_set)
 machine_args = []
 
 # ppc64 does not support -march= at all, use -mcpu and -mtune for that
 if host_machine.cpu_family().startswith('ppc')
-	machine_args += '-mcpu=' + machine
-	machine_args += '-mtune=' + machine
+	machine_args += '-mcpu=' + cpu_instruction_set
+	machine_args += '-mtune=' + cpu_instruction_set
 else
-	machine_args += '-march=' + machine
+	machine_args += '-march=' + cpu_instruction_set
 endif
 
 toolchain = cc.get_id()
diff --git a/devtools/test-meson-builds.sh b/devtools/test-meson-builds.sh
index c11ae87e0d..b413b9e96a 100755
--- a/devtools/test-meson-builds.sh
+++ b/devtools/test-meson-builds.sh
@@ -223,12 +223,13 @@ done
 # test compilation with minimal x86 instruction set
 # Set the install path for libraries to "lib" explicitly to prevent problems
 # with pkg-config prefixes if installed in "lib/x86_64-linux-gnu" later.
-default_machine='nehalem'
-if ! check_cc_flags "-march=$default_machine" ; then
-	default_machine='corei7'
+default_isa='nehalem'
+if ! check_cc_flags "-march=$default_isa" ; then
+	default_isa='corei7'
 fi
 build build-x86-default cc skipABI -Dcheck_includes=true \
-	-Dlibdir=lib -Dmachine=$default_machine $use_shared
+	-Dlibdir=lib -Dcpu_instruction_set=$default_isa \
+	$use_shared
 
 # 32-bit with default compiler
 if check_cc_flags '-m32' ; then
diff --git a/meson_options.txt b/meson_options.txt
index 3b8c5d316d..c6047f3405 100644
--- a/meson_options.txt
+++ b/meson_options.txt
@@ -2,6 +2,8 @@
 
 option('check_includes', type: 'boolean', value: false,
 	description: 'build "chkincs" to verify each header file can compile alone')
+option('cpu_instruction_set', type: 'string', value: 'auto',
+	description: 'Set the target machine ISA (instruction set architecture). Will be set according to the platform option by default.')
 option('disable_drivers', type: 'string', value: '',
 	description: 'Comma-separated list of drivers to explicitly disable.')
 option('drivers_install_subdir', type: 'string', value: 'dpdk/pmds-<VERSION>',
@@ -20,14 +22,16 @@ option('include_subdir_arch', type: 'string', value: '',
 	description: 'subdirectory where to install arch-dependent headers')
 option('kernel_dir', type: 'string', value: '',
 	description: 'Path to the kernel for building kernel modules. Headers must be in $kernel_dir or $kernel_dir/build. Modules will be installed in /lib/modules.')
-option('machine', type: 'string', value: 'native',
-	description: 'set the target machine type')
+option('machine', type: 'string', value: 'auto',
+	description: 'Set the target machine ISA (instruction set architecture).')
 option('max_ethports', type: 'integer', value: 32,
 	description: 'maximum number of Ethernet devices')
 option('max_lcores', type: 'integer', value: 128,
 	description: 'maximum number of cores/threads supported by EAL')
 option('max_numa_nodes', type: 'integer', value: 32,
 	description: 'maximum number of NUMA nodes supported by EAL')
+option('platform', type: 'string', value: 'generic',
+	description: 'Platform to build, either "native" or "generic".')
 option('enable_trace_fp', type: 'boolean', value: false,
 	description: 'enable fast path trace points.')
 option('tests', type: 'boolean', value: true,
-- 
2.20.1


^ permalink raw reply	[flat|nested] 33+ messages in thread

* [dpdk-dev] [PATCH v4] build: add platform meson option
  2021-03-29 11:03   ` [dpdk-dev] [PATCH v3] " Juraj Linkeš
@ 2021-03-29 12:50     ` Juraj Linkeš
  2021-03-31 12:16       ` Juraj Linkeš
  2021-04-20  8:08       ` [dpdk-dev] [PATCH v5] build: use platform option for generic and native Juraj Linkeš
  0 siblings, 2 replies; 33+ messages in thread
From: Juraj Linkeš @ 2021-03-29 12:50 UTC (permalink / raw)
  To: thomas, david.marchand, bruce.richardson, Honnappa.Nagarahalli
  Cc: dev, Juraj Linkeš

The current meson option 'machine' should only specify the ISA, which is
not sufficient for Arm, where setting ISA implies other setting as well.
Add a new meson option, 'platform', which differentiates the type of the
build (native/generic) and sets machine accordingly, unless the user
chooses to override it.
The 'machine' option also doesn't describe very well what it sets, so
introduce a new option 'cpu_instruction_set', but keep 'machine' for
backwards compatibility.
These two new variables, taken together, achieve what 'machine' was
setting per architecture - setting the ISA in x86 build and setting
native/default 'build type' in aarch64 build - is now properly being set
for all architectures in a uniform manner.

Signed-off-by: Juraj Linkeš <juraj.linkes@pantheon.tech>
---
 config/arm/meson.build        |  6 ++---
 config/meson.build            | 47 +++++++++++++++++++++++++----------
 devtools/test-meson-builds.sh |  9 ++++---
 meson_options.txt             |  8 ++++--
 4 files changed, 48 insertions(+), 22 deletions(-)

diff --git a/config/arm/meson.build b/config/arm/meson.build
index 00bc4610a3..e3a23c4228 100644
--- a/config/arm/meson.build
+++ b/config/arm/meson.build
@@ -208,7 +208,7 @@ if dpdk_conf.get('RTE_ARCH_32')
 else
 	# aarch64 build
 	if not meson.is_cross_build()
-		if machine == 'default'
+		if platform == 'generic'
 			# default build
 			implementer_id = 'generic'
 			part_number = 'generic'
@@ -238,7 +238,7 @@ else
 	else
 		error('Unsupported Arm implementer: @0@. '.format(implementer_id) +
 		      'Please add support for it or use the generic ' +
-		      '(-Dmachine=generic) build.')
+		      '(-Dplatform=generic) build.')
 	endif
 
 	message('Arm implementer: ' + implementer_config['description'])
@@ -253,7 +253,7 @@ else
 		error('Unsupported part number @0@ of implementer @1@. '
 		      .format(part_number, implementer_id) +
 		      'Please add support for it or use the generic ' +
-		      '(-Dmachine=generic) build.')
+		      '(-Dplatform=generic) build.')
 	endif
 
 	# use default flags with implementer flags
diff --git a/config/meson.build b/config/meson.build
index 66a2edcc47..32c9e18c17 100644
--- a/config/meson.build
+++ b/config/meson.build
@@ -63,42 +63,63 @@ if not is_windows
 			pmd_subdir_opt)
 endif
 
-# set the machine type and cflags for it
+platform = get_option('platform')
+
+# set the cpu_instruction_set type and cflags for it
 if meson.is_cross_build()
-	machine = host_machine.cpu()
+	cpu_instruction_set = host_machine.cpu()
 else
-	machine = get_option('machine')
+	cpu_instruction_set = get_option('cpu_instruction_set')
+	if get_option('machine') != 'auto'
+		warning('The "machine" option is deprecated. ' +
+		        'Please use "cpu_instruction_set" instead.')
+		if cpu_instruction_set != 'auto'
+			error('Setting both "machine" and ' +
+			      '"cpu_instruction_set" is unsupported.')
+		endif
+		cpu_instruction_set = get_option('machine')
+	endif
+endif
+
+if platform == 'native'
+	if cpu_instruction_set == 'auto'
+		cpu_instruction_set = 'native'
+	endif
+elif platform == 'generic'
+	if cpu_instruction_set == 'auto'
+		cpu_instruction_set = 'default'
+	endif
 endif
 
-# machine type 'default' is special, it defaults to the per arch agreed common
+if cpu_instruction_set == 'default'
+# cpu_instruction_set type 'default' is special, it defaults to the per arch agreed common
 # minimal baseline needed for DPDK.
 # That might not be the most optimized, but the most portable version while
 # still being able to support the CPU features required for DPDK.
 # This can be bumped up by the DPDK project, but it can never be an
 # invariant like 'native'
-if machine == 'default'
 	if host_machine.cpu_family().startswith('x86')
 		# matches the old pre-meson build systems default
-		machine = 'corei7'
+		cpu_instruction_set = 'corei7'
 	elif host_machine.cpu_family().startswith('arm')
-		machine = 'armv7-a'
+		cpu_instruction_set = 'armv7-a'
 	elif host_machine.cpu_family().startswith('aarch')
 		# arm64 manages defaults in config/arm/meson.build
-		machine = 'default'
+		cpu_instruction_set = 'default'
 	elif host_machine.cpu_family().startswith('ppc')
-		machine = 'power8'
+		cpu_instruction_set = 'power8'
 	endif
 endif
 
-dpdk_conf.set('RTE_MACHINE', machine)
+dpdk_conf.set('RTE_MACHINE', cpu_instruction_set)
 machine_args = []
 
 # ppc64 does not support -march= at all, use -mcpu and -mtune for that
 if host_machine.cpu_family().startswith('ppc')
-	machine_args += '-mcpu=' + machine
-	machine_args += '-mtune=' + machine
+	machine_args += '-mcpu=' + cpu_instruction_set
+	machine_args += '-mtune=' + cpu_instruction_set
 else
-	machine_args += '-march=' + machine
+	machine_args += '-march=' + cpu_instruction_set
 endif
 
 toolchain = cc.get_id()
diff --git a/devtools/test-meson-builds.sh b/devtools/test-meson-builds.sh
index c11ae87e0d..b413b9e96a 100755
--- a/devtools/test-meson-builds.sh
+++ b/devtools/test-meson-builds.sh
@@ -223,12 +223,13 @@ done
 # test compilation with minimal x86 instruction set
 # Set the install path for libraries to "lib" explicitly to prevent problems
 # with pkg-config prefixes if installed in "lib/x86_64-linux-gnu" later.
-default_machine='nehalem'
-if ! check_cc_flags "-march=$default_machine" ; then
-	default_machine='corei7'
+default_isa='nehalem'
+if ! check_cc_flags "-march=$default_isa" ; then
+	default_isa='corei7'
 fi
 build build-x86-default cc skipABI -Dcheck_includes=true \
-	-Dlibdir=lib -Dmachine=$default_machine $use_shared
+	-Dlibdir=lib -Dcpu_instruction_set=$default_isa \
+	$use_shared
 
 # 32-bit with default compiler
 if check_cc_flags '-m32' ; then
diff --git a/meson_options.txt b/meson_options.txt
index 3b8c5d316d..c6047f3405 100644
--- a/meson_options.txt
+++ b/meson_options.txt
@@ -2,6 +2,8 @@
 
 option('check_includes', type: 'boolean', value: false,
 	description: 'build "chkincs" to verify each header file can compile alone')
+option('cpu_instruction_set', type: 'string', value: 'auto',
+	description: 'Set the target machine ISA (instruction set architecture). Will be set according to the platform option by default.')
 option('disable_drivers', type: 'string', value: '',
 	description: 'Comma-separated list of drivers to explicitly disable.')
 option('drivers_install_subdir', type: 'string', value: 'dpdk/pmds-<VERSION>',
@@ -20,14 +22,16 @@ option('include_subdir_arch', type: 'string', value: '',
 	description: 'subdirectory where to install arch-dependent headers')
 option('kernel_dir', type: 'string', value: '',
 	description: 'Path to the kernel for building kernel modules. Headers must be in $kernel_dir or $kernel_dir/build. Modules will be installed in /lib/modules.')
-option('machine', type: 'string', value: 'native',
-	description: 'set the target machine type')
+option('machine', type: 'string', value: 'auto',
+	description: 'Set the target machine ISA (instruction set architecture).')
 option('max_ethports', type: 'integer', value: 32,
 	description: 'maximum number of Ethernet devices')
 option('max_lcores', type: 'integer', value: 128,
 	description: 'maximum number of cores/threads supported by EAL')
 option('max_numa_nodes', type: 'integer', value: 32,
 	description: 'maximum number of NUMA nodes supported by EAL')
+option('platform', type: 'string', value: 'generic',
+	description: 'Platform to build, either "native" or "generic".')
 option('enable_trace_fp', type: 'boolean', value: false,
 	description: 'enable fast path trace points.')
 option('tests', type: 'boolean', value: true,
-- 
2.20.1


^ permalink raw reply	[flat|nested] 33+ messages in thread

* Re: [dpdk-dev] [PATCH v4] build: add platform meson option
  2021-03-29 12:50     ` [dpdk-dev] [PATCH v4] " Juraj Linkeš
@ 2021-03-31 12:16       ` Juraj Linkeš
  2021-03-31 12:19         ` Juraj Linkeš
  2021-03-31 12:39         ` Bruce Richardson
  2021-04-20  8:08       ` [dpdk-dev] [PATCH v5] build: use platform option for generic and native Juraj Linkeš
  1 sibling, 2 replies; 33+ messages in thread
From: Juraj Linkeš @ 2021-03-31 12:16 UTC (permalink / raw)
  To: Juraj Linkeš,
	thomas, david.marchand, bruce.richardson, Honnappa.Nagarahalli
  Cc: dev

Bruce, what do you think of the patch now? Do we need to add/change anything else, like documentation?

One thing to note is that we're changing the default behavior in this patch from machine=native to machine=generic (or more accurately, to cpu_instruction_set=generic). Do we want to do that?

> -----Original Message-----
> From: Juraj Linkeš <juraj.linkes@pantheon.tech>
> Sent: Monday, March 29, 2021 2:51 PM
> To: thomas@monjalon.net; david.marchand@redhat.com;
> bruce.richardson@intel.com; Honnappa.Nagarahalli@arm.com
> Cc: dev@dpdk.org; Juraj Linkeš <juraj.linkes@pantheon.tech>
> Subject: [PATCH v4] build: add platform meson option
> 
> The current meson option 'machine' should only specify the ISA, which is not
> sufficient for Arm, where setting ISA implies other setting as well.
> Add a new meson option, 'platform', which differentiates the type of the build
> (native/generic) and sets machine accordingly, unless the user chooses to
> override it.
> The 'machine' option also doesn't describe very well what it sets, so introduce a
> new option 'cpu_instruction_set', but keep 'machine' for backwards
> compatibility.
> These two new variables, taken together, achieve what 'machine' was setting
> per architecture - setting the ISA in x86 build and setting native/default 'build
> type' in aarch64 build - is now properly being set for all architectures in a
> uniform manner.
> 
> Signed-off-by: Juraj Linkeš <juraj.linkes@pantheon.tech>
> ---
>  config/arm/meson.build        |  6 ++---
>  config/meson.build            | 47 +++++++++++++++++++++++++----------
>  devtools/test-meson-builds.sh |  9 ++++---
>  meson_options.txt             |  8 ++++--
>  4 files changed, 48 insertions(+), 22 deletions(-)
> 


^ permalink raw reply	[flat|nested] 33+ messages in thread

* Re: [dpdk-dev] [PATCH v4] build: add platform meson option
  2021-03-31 12:16       ` Juraj Linkeš
@ 2021-03-31 12:19         ` Juraj Linkeš
  2021-03-31 12:39         ` Bruce Richardson
  1 sibling, 0 replies; 33+ messages in thread
From: Juraj Linkeš @ 2021-03-31 12:19 UTC (permalink / raw)
  To: thomas, david.marchand, bruce.richardson, Honnappa.Nagarahalli; +Cc: dev



> -----Original Message-----
> From: Juraj Linkeš <juraj.linkes@pantheon.tech>
> Sent: Wednesday, March 31, 2021 2:17 PM
> To: Juraj Linkeš <juraj.linkes@pantheon.tech>; thomas@monjalon.net;
> david.marchand@redhat.com; bruce.richardson@intel.com;
> Honnappa.Nagarahalli@arm.com
> Cc: dev@dpdk.org
> Subject: RE: [PATCH v4] build: add platform meson option
> 
> Bruce, what do you think of the patch now? Do we need to add/change anything
> else, like documentation?
> 
> One thing to note is that we're changing the default behavior in this patch from
> machine=native to machine=generic (or more accurately, to
> cpu_instruction_set=generic). Do we want to do that?
> 

This change in behavior is likely behind the CI failure: http://patches.dpdk.org/project/dpdk/patch/1617022234-13618-1-git-send-email-juraj.linkes@pantheon.tech/

The generic build should work everywhere, which hints at something we may need to look at. 

> > -----Original Message-----
> > From: Juraj Linkeš <juraj.linkes@pantheon.tech>
> > Sent: Monday, March 29, 2021 2:51 PM
> > To: thomas@monjalon.net; david.marchand@redhat.com;
> > bruce.richardson@intel.com; Honnappa.Nagarahalli@arm.com
> > Cc: dev@dpdk.org; Juraj Linkeš <juraj.linkes@pantheon.tech>
> > Subject: [PATCH v4] build: add platform meson option
> >
> > The current meson option 'machine' should only specify the ISA, which
> > is not sufficient for Arm, where setting ISA implies other setting as well.
> > Add a new meson option, 'platform', which differentiates the type of
> > the build
> > (native/generic) and sets machine accordingly, unless the user chooses
> > to override it.
> > The 'machine' option also doesn't describe very well what it sets, so
> > introduce a new option 'cpu_instruction_set', but keep 'machine' for
> > backwards compatibility.
> > These two new variables, taken together, achieve what 'machine' was
> > setting per architecture - setting the ISA in x86 build and setting
> > native/default 'build type' in aarch64 build - is now properly being
> > set for all architectures in a uniform manner.
> >
> > Signed-off-by: Juraj Linkeš <juraj.linkes@pantheon.tech>
> > ---
> >  config/arm/meson.build        |  6 ++---
> >  config/meson.build            | 47 +++++++++++++++++++++++++----------
> >  devtools/test-meson-builds.sh |  9 ++++---
> >  meson_options.txt             |  8 ++++--
> >  4 files changed, 48 insertions(+), 22 deletions(-)
> >


^ permalink raw reply	[flat|nested] 33+ messages in thread

* Re: [dpdk-dev] [PATCH v4] build: add platform meson option
  2021-03-31 12:16       ` Juraj Linkeš
  2021-03-31 12:19         ` Juraj Linkeš
@ 2021-03-31 12:39         ` Bruce Richardson
  2021-04-15 13:32           ` Juraj Linkeš
  1 sibling, 1 reply; 33+ messages in thread
From: Bruce Richardson @ 2021-03-31 12:39 UTC (permalink / raw)
  To: Juraj Linkeš; +Cc: thomas, david.marchand, Honnappa.Nagarahalli, dev

On Wed, Mar 31, 2021 at 12:16:59PM +0000, Juraj Linkeš wrote:
> Bruce, what do you think of the patch now? Do we need to add/change anything else, like documentation?
> 
> One thing to note is that we're changing the default behavior in this patch from machine=native to machine=generic (or more accurately, to cpu_instruction_set=generic). Do we want to do that?
> 
The patch in general looks ok, but I am uncertain about this change indeed.
Especially since the -march flag we mirror to the pkg-config file. I'd like
to see something like [1] included along with such a change. It allows us
per-arch to select the flags to send to the pkg-config file, rather than
just always using machine_args blindly.

Feedback appreciated.

/Bruce

[1] http://patches.dpdk.org/project/dpdk/patch/20201211155111.145279-1-bruce.richardson@intel.com/

^ permalink raw reply	[flat|nested] 33+ messages in thread

* Re: [dpdk-dev] [PATCH v4] build: add platform meson option
  2021-03-31 12:39         ` Bruce Richardson
@ 2021-04-15 13:32           ` Juraj Linkeš
  2021-04-15 13:51             ` Bruce Richardson
  0 siblings, 1 reply; 33+ messages in thread
From: Juraj Linkeš @ 2021-04-15 13:32 UTC (permalink / raw)
  To: Bruce Richardson; +Cc: thomas, david.marchand, Honnappa.Nagarahalli, dev



> -----Original Message-----
> From: Bruce Richardson <bruce.richardson@intel.com>
> Sent: Wednesday, March 31, 2021 2:39 PM
> To: Juraj Linkeš <juraj.linkes@pantheon.tech>
> Cc: thomas@monjalon.net; david.marchand@redhat.com;
> Honnappa.Nagarahalli@arm.com; dev@dpdk.org
> Subject: Re: [PATCH v4] build: add platform meson option
> 
> On Wed, Mar 31, 2021 at 12:16:59PM +0000, Juraj Linkeš wrote:
> > Bruce, what do you think of the patch now? Do we need to add/change
> anything else, like documentation?
> >
> > One thing to note is that we're changing the default behavior in this patch
> from machine=native to machine=generic (or more accurately, to
> cpu_instruction_set=generic). Do we want to do that?
> >
> The patch in general looks ok, but I am uncertain about this change indeed.
> Especially since the -march flag we mirror to the pkg-config file. I'd like to see
> something like [1] included along with such a change. It allows us per-arch to
> select the flags to send to the pkg-config file, rather than just always using
> machine_args blindly.
> 
> Feedback appreciated.
> 

I'm not sure what feedback do you want here. I'm not that familiar with pkg-config files. I think this is about DPDK being built a set of instructions and an app using DPDK being able to be built another set of instructions and the pkg-config file bridges these? Could you expand a bit? I read the other commit msg (in [1]) as well and I don't know how it's related to this patch.

> /Bruce
> 
> [1] http://patches.dpdk.org/project/dpdk/patch/20201211155111.145279-1-
> bruce.richardson@intel.com/


^ permalink raw reply	[flat|nested] 33+ messages in thread

* Re: [dpdk-dev] [PATCH v4] build: add platform meson option
  2021-04-15 13:32           ` Juraj Linkeš
@ 2021-04-15 13:51             ` Bruce Richardson
  0 siblings, 0 replies; 33+ messages in thread
From: Bruce Richardson @ 2021-04-15 13:51 UTC (permalink / raw)
  To: Juraj Linkeš; +Cc: thomas, david.marchand, Honnappa.Nagarahalli, dev

On Thu, Apr 15, 2021 at 01:32:08PM +0000, Juraj Linkeš wrote:
> 
> 
> > -----Original Message-----
> > From: Bruce Richardson <bruce.richardson@intel.com>
> > Sent: Wednesday, March 31, 2021 2:39 PM
> > To: Juraj Linkeš <juraj.linkes@pantheon.tech>
> > Cc: thomas@monjalon.net; david.marchand@redhat.com;
> > Honnappa.Nagarahalli@arm.com; dev@dpdk.org
> > Subject: Re: [PATCH v4] build: add platform meson option
> > 
> > On Wed, Mar 31, 2021 at 12:16:59PM +0000, Juraj Linkeš wrote:
> > > Bruce, what do you think of the patch now? Do we need to add/change
> > anything else, like documentation?
> > >
> > > One thing to note is that we're changing the default behavior in this patch
> > from machine=native to machine=generic (or more accurately, to
> > cpu_instruction_set=generic). Do we want to do that?
> > >
> > The patch in general looks ok, but I am uncertain about this change indeed.
> > Especially since the -march flag we mirror to the pkg-config file. I'd like to see
> > something like [1] included along with such a change. It allows us per-arch to
> > select the flags to send to the pkg-config file, rather than just always using
> > machine_args blindly.
> > 
> > Feedback appreciated.
> > 
> 
> I'm not sure what feedback do you want here. I'm not that familiar with pkg-config files. I think this is about DPDK being built a set of instructions and an app using DPDK being able to be built another set of instructions and the pkg-config file bridges these? Could you expand a bit? I read the other commit msg (in [1]) as well and I don't know how it's related to this patch.
> 
The main thing I suppose I'm concerned about is that I'd like more input
from people on the change from "native" to "generic" build by default.

On top of that, the patch I linked to adjusts things a little further
allowing separation of the ISA level used for building DPDK and for
building the app using DPDK. For example, for x86, it would probably be
more respectful for applications to have "-msse4" in the pkg-config file,
rather than -march=native or -march=corei7. The fact that DPDK was compiled
for a particular micro-arch should not force the user to use the same
micro-arch. Instead, each architecture should be able to output a separate
value that is suitable - in x86 case, turning on SSE4.2 as the minimum
needed ISA level.

However, I'm prepared to accept that discussion of the latter change can be
dealt with separately from this patch. So long as others have no objection
to change in default machine flags, I'm ok with it too.

/Bruce

^ permalink raw reply	[flat|nested] 33+ messages in thread

* [dpdk-dev] [PATCH v5] build: use platform option for generic and native
  2021-03-29 12:50     ` [dpdk-dev] [PATCH v4] " Juraj Linkeš
  2021-03-31 12:16       ` Juraj Linkeš
@ 2021-04-20  8:08       ` Juraj Linkeš
  2021-04-20  8:16         ` Juraj Linkeš
  2021-06-30 13:09         ` [dpdk-dev] [PATCH v6] build: use platform for generic and native builds Juraj Linkeš
  1 sibling, 2 replies; 33+ messages in thread
From: Juraj Linkeš @ 2021-04-20  8:08 UTC (permalink / raw)
  To: thomas, david.marchand, bruce.richardson, Honnappa.Nagarahalli,
	Ruifeng.Wang
  Cc: dev, Juraj Linkeš

The current meson option 'machine' should only specify the ISA, which is
not sufficient for Arm, where setting ISA implies other setting as well.
Use the existing 'platform' meson option to differentiate the type of
the build (native/generic) and set machine accordingly, unless the user
chooses to override it.
The 'machine' option also doesn't describe very well what it sets, so
introduce a new option 'cpu_instruction_set', but keep 'machine' for
backwards compatibility.
'machine' was setting the ISA in x86 builds and setting native/default
'build type' in aarch64 builds. These two new variables, taken
together, are now properly setting both for all architectures in a
uniform manner.

Signed-off-by: Juraj Linkeš <juraj.linkes@pantheon.tech>
---
 config/arm/meson.build              |  6 ++--
 config/meson.build                  | 53 ++++++++++++++++++++---------
 devtools/test-meson-builds.sh       |  9 ++---
 doc/guides/linux_gsg/build_dpdk.rst | 28 ++++++++++++++-
 meson_options.txt                   | 10 +++---
 5 files changed, 78 insertions(+), 28 deletions(-)

diff --git a/config/arm/meson.build b/config/arm/meson.build
index 86cdb9b53b..59c788f1fa 100644
--- a/config/arm/meson.build
+++ b/config/arm/meson.build
@@ -347,7 +347,7 @@ else
 	soc = get_option('platform')
 	soc_config = {}
 	if not meson.is_cross_build()
-		if machine == 'generic'
+		if platform == 'generic'
 			# generic build
 			if soc != ''
 				error('Building for a particular platform is ' +
@@ -402,7 +402,7 @@ else
 	else
 		error('Unsupported Arm implementer: @0@. '.format(implementer_id) +
 		      'Please add support for it or use the generic ' +
-		      '(-Dmachine=generic) build.')
+		      '(-Dplatform=generic) build.')
 	endif
 
 	message('Arm implementer: ' + implementer_config['description'])
@@ -417,7 +417,7 @@ else
 		error('Unsupported part number @0@ of implementer @1@. '
 		      .format(part_number, implementer_id) +
 		      'Please add support for it or use the generic ' +
-		      '(-Dmachine=generic) build.')
+		      '(-Dplatform=generic) build.')
 	endif
 
 	# add/overwrite flags in the proper order
diff --git a/config/meson.build b/config/meson.build
index 6e6ef8c0e1..1b6dcab8f5 100644
--- a/config/meson.build
+++ b/config/meson.build
@@ -67,43 +67,64 @@ endif
 disable_drivers = ''
 enable_drivers = ''
 
-# set the machine type and cflags for it
+platform = get_option('platform')
+
+# set the cpu_instruction_set and cflags for it
 if meson.is_cross_build()
-	machine = host_machine.cpu()
+	cpu_instruction_set = host_machine.cpu()
 else
-	machine = get_option('machine')
+	cpu_instruction_set = get_option('cpu_instruction_set')
+	if get_option('machine') != 'auto'
+		warning('The "machine" option is deprecated. ' +
+		        'Please use "cpu_instruction_set" instead.')
+		if cpu_instruction_set != 'auto'
+			error('Setting both "machine" and ' +
+			      '"cpu_instruction_set" is unsupported.')
+		endif
+		cpu_instruction_set = get_option('machine')
+	endif
+endif
+
+if platform == 'native'
+	if cpu_instruction_set == 'auto'
+		cpu_instruction_set = 'native'
+	endif
+elif platform == 'generic'
+	if cpu_instruction_set == 'auto'
+		cpu_instruction_set = 'generic'
+	endif
 endif
 
-# machine type 'generic' is special, it selects the per arch agreed common
-# minimal baseline needed for DPDK. Machine type 'default' is also supported
-# with the same meaning for backwards compatibility.
+# cpu_instruction_set 'generic' is special, it selects the per arch agreed
+# common minimal baseline needed for DPDK. cpu_instruction_set 'default' is
+# also supported with the same meaning for backwards compatibility.
 # That might not be the most optimized, but the most portable version while
 # still being able to support the CPU features required for DPDK.
 # This can be bumped up by the DPDK project, but it can never be an
 # invariant like 'native'
-if machine == 'default' or machine == 'generic'
+if cpu_instruction_set == 'generic' or cpu_instruction_set == 'default'
 	if host_machine.cpu_family().startswith('x86')
-		# matches the old pre-meson build systems generic machine
-		machine = 'corei7'
+		# matches the old pre-meson build systems generic cpu_instruction_set
+		cpu_instruction_set = 'corei7'
 	elif host_machine.cpu_family().startswith('arm')
-		machine = 'armv7-a'
+		cpu_instruction_set = 'armv7-a'
 	elif host_machine.cpu_family().startswith('aarch')
 		# arm64 manages generic config in config/arm/meson.build
-		machine = 'generic'
+		cpu_instruction_set = 'generic'
 	elif host_machine.cpu_family().startswith('ppc')
-		machine = 'power8'
+		cpu_instruction_set = 'power8'
 	endif
 endif
 
-dpdk_conf.set('RTE_MACHINE', machine)
+dpdk_conf.set('RTE_MACHINE', cpu_instruction_set)
 machine_args = []
 
 # ppc64 does not support -march= at all, use -mcpu and -mtune for that
 if host_machine.cpu_family().startswith('ppc')
-	machine_args += '-mcpu=' + machine
-	machine_args += '-mtune=' + machine
+	machine_args += '-mcpu=' + cpu_instruction_set
+	machine_args += '-mtune=' + cpu_instruction_set
 else
-	machine_args += '-march=' + machine
+	machine_args += '-march=' + cpu_instruction_set
 endif
 
 toolchain = cc.get_id()
diff --git a/devtools/test-meson-builds.sh b/devtools/test-meson-builds.sh
index daf817ac3e..7edbd6c717 100755
--- a/devtools/test-meson-builds.sh
+++ b/devtools/test-meson-builds.sh
@@ -223,12 +223,13 @@ done
 # test compilation with minimal x86 instruction set
 # Set the install path for libraries to "lib" explicitly to prevent problems
 # with pkg-config prefixes if installed in "lib/x86_64-linux-gnu" later.
-generic_machine='nehalem'
-if ! check_cc_flags "-march=$generic_machine" ; then
-	generic_machine='corei7'
+generic_isa='nehalem'
+if ! check_cc_flags "-march=$generic_isa" ; then
+	generic_isa='corei7'
 fi
 build build-x86-generic cc skipABI -Dcheck_includes=true \
-	-Dlibdir=lib -Dmachine=$generic_machine $use_shared
+	-Dlibdir=lib -Dcpu_instruction_set=$generic_isa \
+	$use_shared
 
 # 32-bit with default compiler
 if check_cc_flags '-m32' ; then
diff --git a/doc/guides/linux_gsg/build_dpdk.rst b/doc/guides/linux_gsg/build_dpdk.rst
index f78eef2517..787b2c2d1f 100644
--- a/doc/guides/linux_gsg/build_dpdk.rst
+++ b/doc/guides/linux_gsg/build_dpdk.rst
@@ -89,7 +89,33 @@ to a regular "debug" build, you can either:
 * run ``meson configure -Dbuildtype=debug`` inside the build folder after the initial meson run.
 
 Other options are specific to the DPDK project but can be adjusted similarly.
-To set the "max_lcores" value to 256, for example, you can either:
+The "platform" option specifies a set a configuration parameters that will be
+used. The valid values are:
+
+* ``-Dplatform=native`` will tailor the configuration to the build machine.
+
+* ``-Dplatform=generic`` will use configuration that works on all machines
+of the same architecture as the build machine.
+
+* ``-Dplatform=<Arm_SoC>`` will use configuration optimized for a particular
+Arm SoC. Consult the "socs" dictionary in config/arm/meson.build to see which
+SoC are supported.
+
+An important configuration parameter that "platform" sets is the instruction
+set to use in x86 and ppc builds:
+
+* ``-Dplatform=native`` sets "cpu_instruction_set" to "native", which
+configures -march, -mcpu, -mtune to "native".
+
+* ``-Dplatform=generic`` sets "cpu_instruction_set" to "generic", which
+configures -march, -mcpu, -mtune to a common minimal baseline needed for DPDK.
+
+"cpu_instruction_set" is not used in Arm builds, as setting the instruction set
+without other parameters leads to inferior builds. The way to tailor Arm builds
+is to build for an SoC or a native build using the "platform" option.
+
+The values determined by the "platform" parameter may be overwritten. For
+example, to set the "max_lcores" value to 256, you can either:
 
 * pass ``-Dmax_lcores=256`` to meson when configuring the build folder initially
 
diff --git a/meson_options.txt b/meson_options.txt
index b78f3bd9d5..07db5146db 100644
--- a/meson_options.txt
+++ b/meson_options.txt
@@ -2,6 +2,8 @@
 
 option('check_includes', type: 'boolean', value: false,
 	description: 'build "chkincs" to verify each header file can compile alone')
+option('cpu_instruction_set', type: 'string', value: 'auto',
+	description: 'Set the target machine ISA (instruction set architecture). Will be set according to the platform option by default.')
 option('developer_mode', type: 'feature',
 	description: 'turn on additional build checks relevant for DPDK developers')
 option('disable_drivers', type: 'string', value: '',
@@ -26,16 +28,16 @@ option('include_subdir_arch', type: 'string', value: '',
 	description: 'subdirectory where to install arch-dependent headers')
 option('kernel_dir', type: 'string', value: '',
 	description: 'Path to the kernel for building kernel modules. Headers must be in $kernel_dir or $kernel_dir/build. Modules will be installed in /lib/modules.')
-option('machine', type: 'string', value: 'native',
-	description: 'set the target machine type or "generic", a build usable on all machines of the build machine architecture or "native", which lets the compiler pick the architecture of the build machine.')
+option('machine', type: 'string', value: 'auto',
+	description: 'Alias of cpu_instruction_set.')
 option('max_ethports', type: 'integer', value: 32,
 	description: 'maximum number of Ethernet devices')
 option('max_lcores', type: 'integer', value: 128,
 	description: 'maximum number of cores/threads supported by EAL')
 option('max_numa_nodes', type: 'integer', value: 32,
 	description: 'maximum number of NUMA nodes supported by EAL')
-option('platform', type: 'string', value: '',
-	description: 'use configuration for a particular platform (such as a SoC).')
+option('platform', type: 'string', value: 'generic',
+	description: 'Platform to build, either "native", "generic" or an Arm SoC. Please refer to the Linux build guide for more information.')
 option('enable_trace_fp', type: 'boolean', value: false,
 	description: 'enable fast path trace points.')
 option('tests', type: 'boolean', value: true,
-- 
2.20.1


^ permalink raw reply	[flat|nested] 33+ messages in thread

* Re: [dpdk-dev] [PATCH v5] build: use platform option for generic and native
  2021-04-20  8:08       ` [dpdk-dev] [PATCH v5] build: use platform option for generic and native Juraj Linkeš
@ 2021-04-20  8:16         ` Juraj Linkeš
  2021-04-20  8:36           ` Thomas Monjalon
  2021-06-30 13:09         ` [dpdk-dev] [PATCH v6] build: use platform for generic and native builds Juraj Linkeš
  1 sibling, 1 reply; 33+ messages in thread
From: Juraj Linkeš @ 2021-04-20  8:16 UTC (permalink / raw)
  To: Juraj Linkeš,
	thomas, david.marchand, bruce.richardson, Honnappa.Nagarahalli,
	Ruifeng.Wang
  Cc: dev



> -----Original Message-----
> From: Juraj Linkeš <juraj.linkes@pantheon.tech>
> Sent: Tuesday, April 20, 2021 10:08 AM
> To: thomas@monjalon.net; david.marchand@redhat.com;
> bruce.richardson@intel.com; Honnappa.Nagarahalli@arm.com;
> Ruifeng.Wang@arm.com
> Cc: dev@dpdk.org; Juraj Linkeš <juraj.linkes@pantheon.tech>
> Subject: [PATCH v5] build: use platform option for generic and native
> 
> The current meson option 'machine' should only specify the ISA, which is not
> sufficient for Arm, where setting ISA implies other setting as well.
> Use the existing 'platform' meson option to differentiate the type of the build
> (native/generic) and set machine accordingly, unless the user chooses to
> override it.
> The 'machine' option also doesn't describe very well what it sets, so introduce a
> new option 'cpu_instruction_set', but keep 'machine' for backwards
> compatibility.
> 'machine' was setting the ISA in x86 builds and setting native/default 'build type'
> in aarch64 builds. These two new variables, taken together, are now properly
> setting both for all architectures in a uniform manner.
> 
> Signed-off-by: Juraj Linkeš <juraj.linkes@pantheon.tech>
> ---
>  config/arm/meson.build              |  6 ++--
>  config/meson.build                  | 53 ++++++++++++++++++++---------
>  devtools/test-meson-builds.sh       |  9 ++---
>  doc/guides/linux_gsg/build_dpdk.rst | 28 ++++++++++++++-
>  meson_options.txt                   | 10 +++---
>  5 files changed, 78 insertions(+), 28 deletions(-)
> 
> diff --git a/config/arm/meson.build b/config/arm/meson.build index
> 86cdb9b53b..59c788f1fa 100644
> --- a/config/arm/meson.build
> +++ b/config/arm/meson.build
> @@ -347,7 +347,7 @@ else
>  	soc = get_option('platform')
>  	soc_config = {}
>  	if not meson.is_cross_build()
> -		if machine == 'generic'
> +		if platform == 'generic'
>  			# generic build
>  			if soc != ''
>  				error('Building for a particular platform is ' +
> @@ -402,7 +402,7 @@ else
>  	else
>  		error('Unsupported Arm implementer: @0@.
> '.format(implementer_id) +
>  		      'Please add support for it or use the generic ' +
> -		      '(-Dmachine=generic) build.')
> +		      '(-Dplatform=generic) build.')
>  	endif
> 
>  	message('Arm implementer: ' + implementer_config['description'])
> @@ -417,7 +417,7 @@ else
>  		error('Unsupported part number @0@ of implementer @1@. '
>  		      .format(part_number, implementer_id) +
>  		      'Please add support for it or use the generic ' +
> -		      '(-Dmachine=generic) build.')
> +		      '(-Dplatform=generic) build.')
>  	endif
> 
>  	# add/overwrite flags in the proper order diff --git a/config/meson.build
> b/config/meson.build index 6e6ef8c0e1..1b6dcab8f5 100644
> --- a/config/meson.build
> +++ b/config/meson.build
> @@ -67,43 +67,64 @@ endif
>  disable_drivers = ''
>  enable_drivers = ''
> 
> -# set the machine type and cflags for it
> +platform = get_option('platform')
> +
> +# set the cpu_instruction_set and cflags for it
>  if meson.is_cross_build()
> -	machine = host_machine.cpu()
> +	cpu_instruction_set = host_machine.cpu()
>  else
> -	machine = get_option('machine')
> +	cpu_instruction_set = get_option('cpu_instruction_set')
> +	if get_option('machine') != 'auto'
> +		warning('The "machine" option is deprecated. ' +
> +		        'Please use "cpu_instruction_set" instead.')
> +		if cpu_instruction_set != 'auto'
> +			error('Setting both "machine" and ' +
> +			      '"cpu_instruction_set" is unsupported.')
> +		endif
> +		cpu_instruction_set = get_option('machine')
> +	endif
> +endif
> +
> +if platform == 'native'
> +	if cpu_instruction_set == 'auto'
> +		cpu_instruction_set = 'native'
> +	endif
> +elif platform == 'generic'
> +	if cpu_instruction_set == 'auto'
> +		cpu_instruction_set = 'generic'
> +	endif
>  endif
> 
> -# machine type 'generic' is special, it selects the per arch agreed common -#
> minimal baseline needed for DPDK. Machine type 'default' is also supported -#
> with the same meaning for backwards compatibility.
> +# cpu_instruction_set 'generic' is special, it selects the per arch
> +agreed # common minimal baseline needed for DPDK. cpu_instruction_set
> +'default' is # also supported with the same meaning for backwards
> compatibility.
>  # That might not be the most optimized, but the most portable version while  #
> still being able to support the CPU features required for DPDK.
>  # This can be bumped up by the DPDK project, but it can never be an  # invariant
> like 'native'
> -if machine == 'default' or machine == 'generic'
> +if cpu_instruction_set == 'generic' or cpu_instruction_set == 'default'
>  	if host_machine.cpu_family().startswith('x86')
> -		# matches the old pre-meson build systems generic machine
> -		machine = 'corei7'
> +		# matches the old pre-meson build systems generic
> cpu_instruction_set
> +		cpu_instruction_set = 'corei7'
>  	elif host_machine.cpu_family().startswith('arm')
> -		machine = 'armv7-a'
> +		cpu_instruction_set = 'armv7-a'
>  	elif host_machine.cpu_family().startswith('aarch')
>  		# arm64 manages generic config in config/arm/meson.build
> -		machine = 'generic'
> +		cpu_instruction_set = 'generic'
>  	elif host_machine.cpu_family().startswith('ppc')
> -		machine = 'power8'
> +		cpu_instruction_set = 'power8'
>  	endif
>  endif
> 
> -dpdk_conf.set('RTE_MACHINE', machine)
> +dpdk_conf.set('RTE_MACHINE', cpu_instruction_set)
>  machine_args = []
> 
>  # ppc64 does not support -march= at all, use -mcpu and -mtune for that  if
> host_machine.cpu_family().startswith('ppc')
> -	machine_args += '-mcpu=' + machine
> -	machine_args += '-mtune=' + machine
> +	machine_args += '-mcpu=' + cpu_instruction_set
> +	machine_args += '-mtune=' + cpu_instruction_set
>  else
> -	machine_args += '-march=' + machine
> +	machine_args += '-march=' + cpu_instruction_set
>  endif
> 
>  toolchain = cc.get_id()
> diff --git a/devtools/test-meson-builds.sh b/devtools/test-meson-builds.sh index
> daf817ac3e..7edbd6c717 100755
> --- a/devtools/test-meson-builds.sh
> +++ b/devtools/test-meson-builds.sh
> @@ -223,12 +223,13 @@ done
>  # test compilation with minimal x86 instruction set  # Set the install path for
> libraries to "lib" explicitly to prevent problems  # with pkg-config prefixes if
> installed in "lib/x86_64-linux-gnu" later.
> -generic_machine='nehalem'
> -if ! check_cc_flags "-march=$generic_machine" ; then
> -	generic_machine='corei7'
> +generic_isa='nehalem'
> +if ! check_cc_flags "-march=$generic_isa" ; then
> +	generic_isa='corei7'
>  fi
>  build build-x86-generic cc skipABI -Dcheck_includes=true \
> -	-Dlibdir=lib -Dmachine=$generic_machine $use_shared
> +	-Dlibdir=lib -Dcpu_instruction_set=$generic_isa \
> +	$use_shared
> 
>  # 32-bit with default compiler
>  if check_cc_flags '-m32' ; then
> diff --git a/doc/guides/linux_gsg/build_dpdk.rst
> b/doc/guides/linux_gsg/build_dpdk.rst
> index f78eef2517..787b2c2d1f 100644
> --- a/doc/guides/linux_gsg/build_dpdk.rst
> +++ b/doc/guides/linux_gsg/build_dpdk.rst
> @@ -89,7 +89,33 @@ to a regular "debug" build, you can either:
>  * run ``meson configure -Dbuildtype=debug`` inside the build folder after the
> initial meson run.
> 
>  Other options are specific to the DPDK project but can be adjusted similarly.
> -To set the "max_lcores" value to 256, for example, you can either:
> +The "platform" option specifies a set a configuration parameters that
> +will be used. The valid values are:
> +
> +* ``-Dplatform=native`` will tailor the configuration to the build machine.
> +
> +* ``-Dplatform=generic`` will use configuration that works on all
> +machines of the same architecture as the build machine.
> +
> +* ``-Dplatform=<Arm_SoC>`` will use configuration optimized for a
> +particular Arm SoC. Consult the "socs" dictionary in
> +config/arm/meson.build to see which SoC are supported.
> +
> +An important configuration parameter that "platform" sets is the
> +instruction set to use in x86 and ppc builds:
> +
> +* ``-Dplatform=native`` sets "cpu_instruction_set" to "native", which
> +configures -march, -mcpu, -mtune to "native".
> +
> +* ``-Dplatform=generic`` sets "cpu_instruction_set" to "generic", which
> +configures -march, -mcpu, -mtune to a common minimal baseline needed for
> DPDK.
> +
> +"cpu_instruction_set" is not used in Arm builds, as setting the
> +instruction set without other parameters leads to inferior builds. The
> +way to tailor Arm builds is to build for an SoC or a native build using the
> "platform" option.
> +
> +The values determined by the "platform" parameter may be overwritten.
> +For example, to set the "max_lcores" value to 256, you can either:
> 

I documented the new options in more detail here. I don't think this is the right place to document these, since this is only the Linux guide and the options should be os agnostic. I'm not sure where the better place to put this would be.

>  * pass ``-Dmax_lcores=256`` to meson when configuring the build folder initially
> 
> diff --git a/meson_options.txt b/meson_options.txt index
> b78f3bd9d5..07db5146db 100644
> --- a/meson_options.txt
> +++ b/meson_options.txt
> @@ -2,6 +2,8 @@
> 
>  option('check_includes', type: 'boolean', value: false,
>  	description: 'build "chkincs" to verify each header file can compile
> alone')
> +option('cpu_instruction_set', type: 'string', value: 'auto',
> +	description: 'Set the target machine ISA (instruction set
> +architecture). Will be set according to the platform option by
> +default.')
>  option('developer_mode', type: 'feature',
>  	description: 'turn on additional build checks relevant for DPDK
> developers')  option('disable_drivers', type: 'string', value: '', @@ -26,16 +28,16
> @@ option('include_subdir_arch', type: 'string', value: '',
>  	description: 'subdirectory where to install arch-dependent headers')
> option('kernel_dir', type: 'string', value: '',
>  	description: 'Path to the kernel for building kernel modules. Headers
> must be in $kernel_dir or $kernel_dir/build. Modules will be installed in
> /lib/modules.') -option('machine', type: 'string', value: 'native',
> -	description: 'set the target machine type or "generic", a build usable on
> all machines of the build machine architecture or "native", which lets the
> compiler pick the architecture of the build machine.')
> +option('machine', type: 'string', value: 'auto',
> +	description: 'Alias of cpu_instruction_set.')
>  option('max_ethports', type: 'integer', value: 32,
>  	description: 'maximum number of Ethernet devices')
> option('max_lcores', type: 'integer', value: 128,
>  	description: 'maximum number of cores/threads supported by EAL')
> option('max_numa_nodes', type: 'integer', value: 32,
>  	description: 'maximum number of NUMA nodes supported by EAL') -
> option('platform', type: 'string', value: '',
> -	description: 'use configuration for a particular platform (such as a SoC).')
> +option('platform', type: 'string', value: 'generic',
> +	description: 'Platform to build, either "native", "generic" or an Arm
> +SoC. Please refer to the Linux build guide for more information.')

The other thing we need to discuss is the fact that we're changing the behavior in this patch from machine=native to platform=generic (and the implied cpu_instruction_set=genetic which equals to machine=generic). We need more feedback on this - Thomas, David? Should we include more people? The reason for this change is we want the build without any meson options (specified on cmdline) to be usable on as many different machines of the same architecture (this is my understanding form the discussion with Bruce), which is the generic platform. We could preserve the current behavior by setting the default to native, so we just need more discussion.

>  option('enable_trace_fp', type: 'boolean', value: false,
>  	description: 'enable fast path trace points.')  option('tests', type:
> 'boolean', value: true,
> --
> 2.20.1


^ permalink raw reply	[flat|nested] 33+ messages in thread

* Re: [dpdk-dev] [PATCH v5] build: use platform option for generic and native
  2021-04-20  8:16         ` Juraj Linkeš
@ 2021-04-20  8:36           ` Thomas Monjalon
  2021-04-21  8:37             ` Juraj Linkeš
  0 siblings, 1 reply; 33+ messages in thread
From: Thomas Monjalon @ 2021-04-20  8:36 UTC (permalink / raw)
  To: Juraj Linkeš
  Cc: david.marchand, bruce.richardson, Honnappa.Nagarahalli,
	Ruifeng.Wang, dev

20/04/2021 10:16, Juraj Linkeš:
> > option('platform', type: 'string', value: '',
> > -	description: 'use configuration for a particular platform (such as a SoC).')
> > +option('platform', type: 'string', value: 'generic',
> > +	description: 'Platform to build, either "native", "generic" or an Arm
> > +SoC. Please refer to the Linux build guide for more information.')
> 
> The other thing we need to discuss is the fact that we're changing the behavior in this patch from machine=native to platform=generic (and the implied cpu_instruction_set=genetic which equals to machine=generic). We need more feedback on this - Thomas, David? Should we include more people? The reason for this change is we want the build without any meson options (specified on cmdline) to be usable on as many different machines of the same architecture (this is my understanding form the discussion with Bruce), which is the generic platform. We could preserve the current behavior by setting the default to native, so we just need more discussion.

I don't understand why you need to change the behaviour.
If we change the behaviour, it must be done carefully
after a deprecation notice and an agreement of the Technical Board.



^ permalink raw reply	[flat|nested] 33+ messages in thread

* Re: [dpdk-dev] [PATCH v5] build: use platform option for generic and native
  2021-04-20  8:36           ` Thomas Monjalon
@ 2021-04-21  8:37             ` Juraj Linkeš
  2021-04-22  8:34               ` Wang, Yinan
  0 siblings, 1 reply; 33+ messages in thread
From: Juraj Linkeš @ 2021-04-21  8:37 UTC (permalink / raw)
  To: Thomas Monjalon
  Cc: david.marchand, bruce.richardson, Honnappa.Nagarahalli,
	Ruifeng.Wang, dev



> -----Original Message-----
> From: Thomas Monjalon <thomas@monjalon.net>
> Sent: Tuesday, April 20, 2021 10:36 AM
> To: Juraj Linkeš <juraj.linkes@pantheon.tech>
> Cc: david.marchand@redhat.com; bruce.richardson@intel.com;
> Honnappa.Nagarahalli@arm.com; Ruifeng.Wang@arm.com; dev@dpdk.org
> Subject: Re: [PATCH v5] build: use platform option for generic and native
> 
> 20/04/2021 10:16, Juraj Linkeš:
> > > option('platform', type: 'string', value: '',
> > > -	description: 'use configuration for a particular platform (such as a SoC).')
> > > +option('platform', type: 'string', value: 'generic',
> > > +	description: 'Platform to build, either "native", "generic" or an
> > > +Arm SoC. Please refer to the Linux build guide for more
> > > +information.')
> >
> > The other thing we need to discuss is the fact that we're changing the behavior
> in this patch from machine=native to platform=generic (and the implied
> cpu_instruction_set=genetic which equals to machine=generic). We need more
> feedback on this - Thomas, David? Should we include more people? The reason
> for this change is we want the build without any meson options (specified on
> cmdline) to be usable on as many different machines of the same architecture
> (this is my understanding form the discussion with Bruce), which is the generic
> platform. We could preserve the current behavior by setting the default to
> native, so we just need more discussion.
> 
> I don't understand why you need to change the behaviour.

Well, we don't *need* to change the behavior - I don't mind it either way. We've come to this point after discussing the change with Bruce. I believe Bruce mentioned the intention of the build without any meson cmdline options was to produce a build usable on most machines that match the build architecture and the generic build fits better (native build being more tailored to the build machine as opposed to the generic build).

I don't want to speak for Bruce though, so it'd be the best if he gave his thoughts on the matter.

> If we change the behaviour, it must be done carefully after a deprecation notice
> and an agreement of the Technical Board.
> 
> 

Ok, one thing we could do is preserve the behavior in this patch and go through this process with a separate change.

^ permalink raw reply	[flat|nested] 33+ messages in thread

* Re: [dpdk-dev] [PATCH v5] build: use platform option for generic and native
  2021-04-21  8:37             ` Juraj Linkeš
@ 2021-04-22  8:34               ` Wang, Yinan
  0 siblings, 0 replies; 33+ messages in thread
From: Wang, Yinan @ 2021-04-22  8:34 UTC (permalink / raw)
  To: Juraj Linkeš, Thomas Monjalon
  Cc: david.marchand, Richardson, Bruce, Honnappa.Nagarahalli,
	Ruifeng.Wang, dev, Xia, Chenbo, maxime.coquelin

Hi Linkeš,

This patch cause vhost/virtio basic pvp test with 1518 packet size performance drop about 9% on IA platform.

BR,
Yinan

> -----Original Message-----
> From: dev <dev-bounces@dpdk.org> On Behalf Of Juraj Linkeš
> Sent: 2021年4月21日 16:38
> To: Thomas Monjalon <thomas@monjalon.net>
> Cc: david.marchand@redhat.com; Richardson, Bruce
> <bruce.richardson@intel.com>; Honnappa.Nagarahalli@arm.com;
> Ruifeng.Wang@arm.com; dev@dpdk.org
> Subject: Re: [dpdk-dev] [PATCH v5] build: use platform option for generic
> and native
> 
> 
> 
> > -----Original Message-----
> > From: Thomas Monjalon <thomas@monjalon.net>
> > Sent: Tuesday, April 20, 2021 10:36 AM
> > To: Juraj Linkeš <juraj.linkes@pantheon.tech>
> > Cc: david.marchand@redhat.com; bruce.richardson@intel.com;
> > Honnappa.Nagarahalli@arm.com; Ruifeng.Wang@arm.com;
> dev@dpdk.org
> > Subject: Re: [PATCH v5] build: use platform option for generic and native
> >
> > 20/04/2021 10:16, Juraj Linkeš:
> > > > option('platform', type: 'string', value: '',
> > > > -	description: 'use configuration for a particular platform (such as a
> SoC).')
> > > > +option('platform', type: 'string', value: 'generic',
> > > > +	description: 'Platform to build, either "native", "generic" or an
> > > > +Arm SoC. Please refer to the Linux build guide for more
> > > > +information.')
> > >
> > > The other thing we need to discuss is the fact that we're changing the
> behavior
> > in this patch from machine=native to platform=generic (and the implied
> > cpu_instruction_set=genetic which equals to machine=generic). We need
> more
> > feedback on this - Thomas, David? Should we include more people? The
> reason
> > for this change is we want the build without any meson options (specified
> on
> > cmdline) to be usable on as many different machines of the same
> architecture
> > (this is my understanding form the discussion with Bruce), which is the
> generic
> > platform. We could preserve the current behavior by setting the default
> to
> > native, so we just need more discussion.
> >
> > I don't understand why you need to change the behaviour.
> 
> Well, we don't *need* to change the behavior - I don't mind it either way.
> We've come to this point after discussing the change with Bruce. I believe
> Bruce mentioned the intention of the build without any meson cmdline
> options was to produce a build usable on most machines that match the
> build architecture and the generic build fits better (native build being more
> tailored to the build machine as opposed to the generic build).
> 
> I don't want to speak for Bruce though, so it'd be the best if he gave his
> thoughts on the matter.
> 
> > If we change the behaviour, it must be done carefully after a deprecation
> notice
> > and an agreement of the Technical Board.
> >
> >
> 
> Ok, one thing we could do is preserve the behavior in this patch and go
> through this process with a separate change.

^ permalink raw reply	[flat|nested] 33+ messages in thread

* [dpdk-dev] [PATCH v6] build: use platform for generic and native builds
  2021-04-20  8:08       ` [dpdk-dev] [PATCH v5] build: use platform option for generic and native Juraj Linkeš
  2021-04-20  8:16         ` Juraj Linkeš
@ 2021-06-30 13:09         ` Juraj Linkeš
  2021-07-06  9:44           ` [dpdk-dev] [PATCH v7] " Juraj Linkeš
  1 sibling, 1 reply; 33+ messages in thread
From: Juraj Linkeš @ 2021-06-30 13:09 UTC (permalink / raw)
  To: thomas, david.marchand, bruce.richardson, Honnappa.Nagarahalli,
	Ruifeng.Wang, ferruh.yigit, jerinjacobk
  Cc: dev, Juraj Linkeš

The current meson option 'machine' should only specify the ISA, which is
not sufficient for Arm, where setting ISA implies other settings as well
(and is used in Arm configuration as such).
Use the existing 'platform' meson option to differentiate the type of
the build (native/generic) and set ISA accordingly, unless the user
chooses to override it with a new option, 'cpu_instruction_set'.
The 'machine' option set the ISA in x86 builds and set native/default
'build type' in aarch64 builds. These two new variables, 'platform' and
'cpu_instruction_set', now properly set both ISA and build type for all
architectures in a uniform manner.
The 'machine' option also doesn't describe very well what it sets. The
new option, 'cpu_instruction_set', is much more descriptive. Keep
'machine' for backwards compatibility.

Signed-off-by: Juraj Linkeš <juraj.linkes@pantheon.tech>
---
 config/arm/meson.build              | 33 ++++++++++-------
 config/meson.build                  | 55 +++++++++++++++++++++--------
 config/ppc/meson.build              |  2 +-
 devtools/test-meson-builds.sh       |  9 ++---
 doc/guides/linux_gsg/build_dpdk.rst | 33 ++++++++++++++++-
 meson_options.txt                   | 10 +++---
 6 files changed, 104 insertions(+), 38 deletions(-)

diff --git a/config/arm/meson.build b/config/arm/meson.build
index 9b147c0b93..77ee5fabfc 100644
--- a/config/arm/meson.build
+++ b/config/arm/meson.build
@@ -380,19 +380,23 @@ if dpdk_conf.get('RTE_ARCH_32')
     machine_args += '-mfpu=neon'
 else
     # aarch64 build
-    soc = get_option('platform')
+    # for backwards compatibility:
+    #   machine=native is the same behavior as platform=native
+    #   machine=generic/default is the same as platform=generic
+    if machine != 'auto'
+        # cpu_instruction_set holds the proper value - native, generic or cpu
+        # the old behavior only distinguished between generic and native build
+        if cpu_instruction_set == 'generic'
+            soc = 'generic'
+        else
+            soc = 'native'
+        endif
+    else
+        soc = platform
+    endif
     soc_config = {}
     if not meson.is_cross_build()
-        if machine == 'generic'
-            # generic build
-            if soc != ''
-                error('Building for a particular platform is unsupported with generic build.')
-            endif
-            implementer_id = 'generic'
-            part_number = 'generic'
-        elif soc != ''
-            soc_config = socs.get(soc, {'not_supported': true})
-        else
+        if soc == 'native'
             # native build
             # The script returns ['Implementer', 'Variant', 'Architecture',
             # 'Primary Part number', 'Revision']
@@ -406,6 +410,9 @@ else
             else
                 error('Error when getting Arm Implementer ID and part number.')
             endif
+        else
+            # SoC build
+            soc_config = socs.get(soc, {'not_supported': true})
         endif
     else
         # cross build
@@ -437,7 +444,7 @@ else
     else
         error('Unsupported Arm implementer: @0@. '.format(implementer_id) +
               'Please add support for it or use the generic ' +
-              '(-Dmachine=generic) build.')
+              '(-Dplatform=generic) build.')
     endif
 
     message('Arm implementer: ' + implementer_config['description'])
@@ -452,7 +459,7 @@ else
         error('Unsupported part number @0@ of implementer @1@. '
               .format(part_number, implementer_id) +
               'Please add support for it or use the generic ' +
-              '(-Dmachine=generic) build.')
+              '(-Dplatform=generic) build.')
     endif
 
     # add/overwrite flags in the proper order
diff --git a/config/meson.build b/config/meson.build
index 017bb2efbb..77826452b4 100644
--- a/config/meson.build
+++ b/config/meson.build
@@ -65,43 +65,68 @@ endif
 disable_drivers = ''
 enable_drivers = ''
 
-# set the machine type and cflags for it
+platform = get_option('platform')
+
+# set the cpu_instruction_set and cflags for it
 if meson.is_cross_build()
-    machine = host_machine.cpu()
+    cpu_instruction_set = host_machine.cpu()
 else
+    cpu_instruction_set = get_option('cpu_instruction_set')
     machine = get_option('machine')
+    if machine != 'auto'
+        warning('The "machine" option is deprecated. ' +
+                'Please use "cpu_instruction_set" instead.')
+        if cpu_instruction_set != 'auto'
+            error('Setting both "machine" and ' +
+                '"cpu_instruction_set" is unsupported.')
+        endif
+        cpu_instruction_set = machine
+        if cpu_instruction_set == 'default'
+            cpu_instruction_set = 'generic'
+        endif
+    endif
+endif
+
+if platform == 'native'
+    if cpu_instruction_set == 'auto'
+        cpu_instruction_set = 'native'
+    endif
+elif platform == 'generic'
+    if cpu_instruction_set == 'auto'
+        cpu_instruction_set = 'generic'
+    endif
 endif
 
-# machine type 'generic' is special, it selects the per arch agreed common
-# minimal baseline needed for DPDK. Machine type 'default' is also supported
-# with the same meaning for backwards compatibility.
+# cpu_instruction_set 'generic' is special, it selects the per arch agreed
+# common minimal baseline needed for DPDK. cpu_instruction_set 'default' is
+# also supported with the same meaning for backwards compatibility.
 # That might not be the most optimized, but the most portable version while
 # still being able to support the CPU features required for DPDK.
 # This can be bumped up by the DPDK project, but it can never be an
 # invariant like 'native'
-if machine == 'default' or machine == 'generic'
+if cpu_instruction_set == 'generic'
     if host_machine.cpu_family().startswith('x86')
-        # matches the old pre-meson build systems generic machine
-        machine = 'corei7'
+        # matches the old pre-meson build systems generic cpu_instruction_set
+        cpu_instruction_set = 'corei7'
     elif host_machine.cpu_family().startswith('arm')
-        machine = 'armv7-a'
+        cpu_instruction_set = 'armv7-a'
     elif host_machine.cpu_family().startswith('aarch')
         # arm64 manages generic config in config/arm/meson.build
-        machine = 'generic'
+        cpu_instruction_set = 'generic'
     elif host_machine.cpu_family().startswith('ppc')
-        machine = 'power8'
+        cpu_instruction_set = 'power8'
     endif
 endif
 
-dpdk_conf.set('RTE_MACHINE', machine)
+dpdk_conf.set('RTE_MACHINE', cpu_instruction_set)
 machine_args = []
 
 # ppc64 does not support -march= at all, use -mcpu and -mtune for that
 if host_machine.cpu_family().startswith('ppc')
-    machine_args += '-mcpu=' + machine
-    machine_args += '-mtune=' + machine
+    machine_args += '-mcpu=' + cpu_instruction_set
+    machine_args += '-mtune=' + cpu_instruction_set
 else
-    machine_args += '-march=' + machine
+    machine_args += '-march=' + cpu_instruction_set
 endif
 
 toolchain = cc.get_id()
diff --git a/config/ppc/meson.build b/config/ppc/meson.build
index 4f7806bab1..adf49e1f42 100644
--- a/config/ppc/meson.build
+++ b/config/ppc/meson.build
@@ -12,7 +12,7 @@ dpdk_conf.set('RTE_ARCH_PPC_64', 1)
 # is used, resulting in a build failure.
 power9_supported = cc.has_argument('-mcpu=power9')
 if not power9_supported
-    machine = 'power8'
+    cpu_instruction_set = 'power8'
     machine_args = ['-mcpu=power8', '-mtune=power8']
     dpdk_conf.set('RTE_MACHINE','power8')
 endif
diff --git a/devtools/test-meson-builds.sh b/devtools/test-meson-builds.sh
index daf817ac3e..7edbd6c717 100755
--- a/devtools/test-meson-builds.sh
+++ b/devtools/test-meson-builds.sh
@@ -223,12 +223,13 @@ done
 # test compilation with minimal x86 instruction set
 # Set the install path for libraries to "lib" explicitly to prevent problems
 # with pkg-config prefixes if installed in "lib/x86_64-linux-gnu" later.
-generic_machine='nehalem'
-if ! check_cc_flags "-march=$generic_machine" ; then
-	generic_machine='corei7'
+generic_isa='nehalem'
+if ! check_cc_flags "-march=$generic_isa" ; then
+	generic_isa='corei7'
 fi
 build build-x86-generic cc skipABI -Dcheck_includes=true \
-	-Dlibdir=lib -Dmachine=$generic_machine $use_shared
+	-Dlibdir=lib -Dcpu_instruction_set=$generic_isa \
+	$use_shared
 
 # 32-bit with default compiler
 if check_cc_flags '-m32' ; then
diff --git a/doc/guides/linux_gsg/build_dpdk.rst b/doc/guides/linux_gsg/build_dpdk.rst
index f78eef2517..204c63631d 100644
--- a/doc/guides/linux_gsg/build_dpdk.rst
+++ b/doc/guides/linux_gsg/build_dpdk.rst
@@ -89,7 +89,38 @@ to a regular "debug" build, you can either:
 * run ``meson configure -Dbuildtype=debug`` inside the build folder after the initial meson run.
 
 Other options are specific to the DPDK project but can be adjusted similarly.
-To set the "max_lcores" value to 256, for example, you can either:
+The "platform" option specifies a set a configuration parameters that will be
+used. The valid values are:
+
+* ``-Dplatform=native`` will tailor the configuration to the build machine.
+
+* ``-Dplatform=generic`` will use configuration that works on all machines
+  of the same architecture as the build machine.
+
+* ``-Dplatform=<Arm_SoC>`` will use configuration optimized for a particular
+  Arm SoC. Consult the "socs" dictionary in config/arm/meson.build to see which
+  SoC are supported.
+
+The instruction set will be set automatically by default according to these
+rules:
+
+* ``-Dplatform=native`` sets "cpu_instruction_set" to "native", which
+  configures -march (x86_64), -mcpu (ppc), -mtune (ppc) to "native".
+
+* ``-Dplatform=generic`` sets "cpu_instruction_set" to "generic", which
+  configures -march (x86_64), -mcpu (ppc), -mtune (ppc) to a common
+  minimal baseline needed for DPDK.
+
+To override what instruction set will be used, set the "cpu_instruction_set"
+parameter to the instruction set of your choice (such as "corei7", "power8",
+etc.).
+
+"cpu_instruction_set" is not used in Arm builds, as setting the instruction set
+without other parameters leads to inferior builds. The way to tailor Arm builds
+is to build for an SoC using ``-Dplatform=<Arm_SoC>`` mentioned above.
+
+The values determined by the "platform" parameter may be overwritten. For
+example, to set the "max_lcores" value to 256, you can either:
 
 * pass ``-Dmax_lcores=256`` to meson when configuring the build folder initially
 
diff --git a/meson_options.txt b/meson_options.txt
index 56bdfd0f0a..0240a5da48 100644
--- a/meson_options.txt
+++ b/meson_options.txt
@@ -2,6 +2,8 @@
 
 option('check_includes', type: 'boolean', value: false, description:
        'build "chkincs" to verify each header file can compile alone')
+option('cpu_instruction_set', type: 'string', value: 'auto',
+	description: 'Set the target machine ISA (instruction set architecture). Will be set according to the platform option by default.')
 option('developer_mode', type: 'feature', description:
        'turn on additional build checks relevant for DPDK developers')
 option('disable_drivers', type: 'string', value: '', description:
@@ -28,16 +30,16 @@ option('include_subdir_arch', type: 'string', value: '', description:
        'subdirectory where to install arch-dependent headers')
 option('kernel_dir', type: 'string', value: '', description:
        'Path to the kernel for building kernel modules. Headers must be in $kernel_dir or $kernel_dir/build. Modules will be installed in /lib/modules.')
-option('machine', type: 'string', value: 'native', description:
-       'set the target machine type or "generic", a build usable on all machines of the build machine architecture or "native", which lets the compiler pick the architecture of the build machine.')
+option('machine', type: 'string', value: 'auto', description:
+       'Alias of cpu_instruction_set.')
 option('max_ethports', type: 'integer', value: 32, description:
        'maximum number of Ethernet devices')
 option('max_lcores', type: 'integer', value: 128, description:
        'maximum number of cores/threads supported by EAL')
 option('max_numa_nodes', type: 'integer', value: 32, description:
        'maximum number of NUMA nodes supported by EAL')
-option('platform', type: 'string', value: '', description:
-       'use configuration for a particular platform (such as a SoC).')
+option('platform', type: 'string', value: 'native', description:
+       'Platform to build, either "native", "generic" or an Arm SoC. Please refer to the Linux build guide for more information.')
 option('enable_trace_fp', type: 'boolean', value: false, description:
        'enable fast path trace points.')
 option('tests', type: 'boolean', value: true, description:
-- 
2.20.1


^ permalink raw reply	[flat|nested] 33+ messages in thread

* [dpdk-dev] [PATCH v7] build: use platform for generic and native builds
  2021-06-30 13:09         ` [dpdk-dev] [PATCH v6] build: use platform for generic and native builds Juraj Linkeš
@ 2021-07-06  9:44           ` Juraj Linkeš
  2021-07-07 13:59             ` Bruce Richardson
  0 siblings, 1 reply; 33+ messages in thread
From: Juraj Linkeš @ 2021-07-06  9:44 UTC (permalink / raw)
  To: thomas, david.marchand, bruce.richardson, Honnappa.Nagarahalli,
	Ruifeng.Wang, ferruh.yigit, jerinjacobk
  Cc: dev, Juraj Linkeš

The current meson option 'machine' should only specify the ISA, which is
not sufficient for Arm, where setting ISA implies other settings as well
(and is used in Arm configuration as such).
Use the existing 'platform' meson option to differentiate the type of
the build (native/generic) and set ISA accordingly, unless the user
chooses to override it with a new option, 'cpu_instruction_set'.
The 'machine' option set the ISA in x86 builds and set native/default
'build type' in aarch64 builds. These two new variables, 'platform' and
'cpu_instruction_set', now properly set both ISA and build type for all
architectures in a uniform manner.
The 'machine' option also doesn't describe very well what it sets. The
new option, 'cpu_instruction_set', is much more descriptive. Keep
'machine' for backwards compatibility.

Signed-off-by: Juraj Linkeš <juraj.linkes@pantheon.tech>
---
v7: fixed CI issue:
    config/arm/meson.build:386:7: ERROR: Unknown variable "machine".
---
 config/arm/meson.build              | 29 +++++++++------
 config/meson.build                  | 55 +++++++++++++++++++++--------
 config/ppc/meson.build              |  2 +-
 devtools/test-meson-builds.sh       |  9 ++---
 doc/guides/linux_gsg/build_dpdk.rst | 33 ++++++++++++++++-
 meson_options.txt                   | 10 +++---
 6 files changed, 102 insertions(+), 36 deletions(-)

diff --git a/config/arm/meson.build b/config/arm/meson.build
index 9b147c0b93..5273c56fe1 100644
--- a/config/arm/meson.build
+++ b/config/arm/meson.build
@@ -380,19 +380,23 @@ if dpdk_conf.get('RTE_ARCH_32')
     machine_args += '-mfpu=neon'
 else
     # aarch64 build
-    soc = get_option('platform')
     soc_config = {}
     if not meson.is_cross_build()
-        if machine == 'generic'
-            # generic build
-            if soc != ''
-                error('Building for a particular platform is unsupported with generic build.')
+        # for backwards compatibility:
+        #   machine=native is the same behavior as soc=native
+        #   machine=generic/default is the same as soc=generic
+        # cpu_instruction_set holds the proper value - native, generic or cpu
+        # the old behavior only distinguished between generic and native build
+        if machine != 'auto'
+            if cpu_instruction_set == 'generic'
+                soc = 'generic'
+            else
+                soc = 'native'
             endif
-            implementer_id = 'generic'
-            part_number = 'generic'
-        elif soc != ''
-            soc_config = socs.get(soc, {'not_supported': true})
         else
+            soc = platform
+        endif
+        if soc == 'native'
             # native build
             # The script returns ['Implementer', 'Variant', 'Architecture',
             # 'Primary Part number', 'Revision']
@@ -406,6 +410,9 @@ else
             else
                 error('Error when getting Arm Implementer ID and part number.')
             endif
+        else
+            # SoC build
+            soc_config = socs.get(soc, {'not_supported': true})
         endif
     else
         # cross build
@@ -437,7 +444,7 @@ else
     else
         error('Unsupported Arm implementer: @0@. '.format(implementer_id) +
               'Please add support for it or use the generic ' +
-              '(-Dmachine=generic) build.')
+              '(-Dplatform=generic) build.')
     endif
 
     message('Arm implementer: ' + implementer_config['description'])
@@ -452,7 +459,7 @@ else
         error('Unsupported part number @0@ of implementer @1@. '
               .format(part_number, implementer_id) +
               'Please add support for it or use the generic ' +
-              '(-Dmachine=generic) build.')
+              '(-Dplatform=generic) build.')
     endif
 
     # add/overwrite flags in the proper order
diff --git a/config/meson.build b/config/meson.build
index 017bb2efbb..77826452b4 100644
--- a/config/meson.build
+++ b/config/meson.build
@@ -65,43 +65,68 @@ endif
 disable_drivers = ''
 enable_drivers = ''
 
-# set the machine type and cflags for it
+platform = get_option('platform')
+
+# set the cpu_instruction_set and cflags for it
 if meson.is_cross_build()
-    machine = host_machine.cpu()
+    cpu_instruction_set = host_machine.cpu()
 else
+    cpu_instruction_set = get_option('cpu_instruction_set')
     machine = get_option('machine')
+    if machine != 'auto'
+        warning('The "machine" option is deprecated. ' +
+                'Please use "cpu_instruction_set" instead.')
+        if cpu_instruction_set != 'auto'
+            error('Setting both "machine" and ' +
+                '"cpu_instruction_set" is unsupported.')
+        endif
+        cpu_instruction_set = machine
+        if cpu_instruction_set == 'default'
+            cpu_instruction_set = 'generic'
+        endif
+    endif
+endif
+
+if platform == 'native'
+    if cpu_instruction_set == 'auto'
+        cpu_instruction_set = 'native'
+    endif
+elif platform == 'generic'
+    if cpu_instruction_set == 'auto'
+        cpu_instruction_set = 'generic'
+    endif
 endif
 
-# machine type 'generic' is special, it selects the per arch agreed common
-# minimal baseline needed for DPDK. Machine type 'default' is also supported
-# with the same meaning for backwards compatibility.
+# cpu_instruction_set 'generic' is special, it selects the per arch agreed
+# common minimal baseline needed for DPDK. cpu_instruction_set 'default' is
+# also supported with the same meaning for backwards compatibility.
 # That might not be the most optimized, but the most portable version while
 # still being able to support the CPU features required for DPDK.
 # This can be bumped up by the DPDK project, but it can never be an
 # invariant like 'native'
-if machine == 'default' or machine == 'generic'
+if cpu_instruction_set == 'generic'
     if host_machine.cpu_family().startswith('x86')
-        # matches the old pre-meson build systems generic machine
-        machine = 'corei7'
+        # matches the old pre-meson build systems generic cpu_instruction_set
+        cpu_instruction_set = 'corei7'
     elif host_machine.cpu_family().startswith('arm')
-        machine = 'armv7-a'
+        cpu_instruction_set = 'armv7-a'
     elif host_machine.cpu_family().startswith('aarch')
         # arm64 manages generic config in config/arm/meson.build
-        machine = 'generic'
+        cpu_instruction_set = 'generic'
     elif host_machine.cpu_family().startswith('ppc')
-        machine = 'power8'
+        cpu_instruction_set = 'power8'
     endif
 endif
 
-dpdk_conf.set('RTE_MACHINE', machine)
+dpdk_conf.set('RTE_MACHINE', cpu_instruction_set)
 machine_args = []
 
 # ppc64 does not support -march= at all, use -mcpu and -mtune for that
 if host_machine.cpu_family().startswith('ppc')
-    machine_args += '-mcpu=' + machine
-    machine_args += '-mtune=' + machine
+    machine_args += '-mcpu=' + cpu_instruction_set
+    machine_args += '-mtune=' + cpu_instruction_set
 else
-    machine_args += '-march=' + machine
+    machine_args += '-march=' + cpu_instruction_set
 endif
 
 toolchain = cc.get_id()
diff --git a/config/ppc/meson.build b/config/ppc/meson.build
index 4f7806bab1..adf49e1f42 100644
--- a/config/ppc/meson.build
+++ b/config/ppc/meson.build
@@ -12,7 +12,7 @@ dpdk_conf.set('RTE_ARCH_PPC_64', 1)
 # is used, resulting in a build failure.
 power9_supported = cc.has_argument('-mcpu=power9')
 if not power9_supported
-    machine = 'power8'
+    cpu_instruction_set = 'power8'
     machine_args = ['-mcpu=power8', '-mtune=power8']
     dpdk_conf.set('RTE_MACHINE','power8')
 endif
diff --git a/devtools/test-meson-builds.sh b/devtools/test-meson-builds.sh
index daf817ac3e..7edbd6c717 100755
--- a/devtools/test-meson-builds.sh
+++ b/devtools/test-meson-builds.sh
@@ -223,12 +223,13 @@ done
 # test compilation with minimal x86 instruction set
 # Set the install path for libraries to "lib" explicitly to prevent problems
 # with pkg-config prefixes if installed in "lib/x86_64-linux-gnu" later.
-generic_machine='nehalem'
-if ! check_cc_flags "-march=$generic_machine" ; then
-	generic_machine='corei7'
+generic_isa='nehalem'
+if ! check_cc_flags "-march=$generic_isa" ; then
+	generic_isa='corei7'
 fi
 build build-x86-generic cc skipABI -Dcheck_includes=true \
-	-Dlibdir=lib -Dmachine=$generic_machine $use_shared
+	-Dlibdir=lib -Dcpu_instruction_set=$generic_isa \
+	$use_shared
 
 # 32-bit with default compiler
 if check_cc_flags '-m32' ; then
diff --git a/doc/guides/linux_gsg/build_dpdk.rst b/doc/guides/linux_gsg/build_dpdk.rst
index f78eef2517..204c63631d 100644
--- a/doc/guides/linux_gsg/build_dpdk.rst
+++ b/doc/guides/linux_gsg/build_dpdk.rst
@@ -89,7 +89,38 @@ to a regular "debug" build, you can either:
 * run ``meson configure -Dbuildtype=debug`` inside the build folder after the initial meson run.
 
 Other options are specific to the DPDK project but can be adjusted similarly.
-To set the "max_lcores" value to 256, for example, you can either:
+The "platform" option specifies a set a configuration parameters that will be
+used. The valid values are:
+
+* ``-Dplatform=native`` will tailor the configuration to the build machine.
+
+* ``-Dplatform=generic`` will use configuration that works on all machines
+  of the same architecture as the build machine.
+
+* ``-Dplatform=<Arm_SoC>`` will use configuration optimized for a particular
+  Arm SoC. Consult the "socs" dictionary in config/arm/meson.build to see which
+  SoC are supported.
+
+The instruction set will be set automatically by default according to these
+rules:
+
+* ``-Dplatform=native`` sets "cpu_instruction_set" to "native", which
+  configures -march (x86_64), -mcpu (ppc), -mtune (ppc) to "native".
+
+* ``-Dplatform=generic`` sets "cpu_instruction_set" to "generic", which
+  configures -march (x86_64), -mcpu (ppc), -mtune (ppc) to a common
+  minimal baseline needed for DPDK.
+
+To override what instruction set will be used, set the "cpu_instruction_set"
+parameter to the instruction set of your choice (such as "corei7", "power8",
+etc.).
+
+"cpu_instruction_set" is not used in Arm builds, as setting the instruction set
+without other parameters leads to inferior builds. The way to tailor Arm builds
+is to build for an SoC using ``-Dplatform=<Arm_SoC>`` mentioned above.
+
+The values determined by the "platform" parameter may be overwritten. For
+example, to set the "max_lcores" value to 256, you can either:
 
 * pass ``-Dmax_lcores=256`` to meson when configuring the build folder initially
 
diff --git a/meson_options.txt b/meson_options.txt
index 56bdfd0f0a..0240a5da48 100644
--- a/meson_options.txt
+++ b/meson_options.txt
@@ -2,6 +2,8 @@
 
 option('check_includes', type: 'boolean', value: false, description:
        'build "chkincs" to verify each header file can compile alone')
+option('cpu_instruction_set', type: 'string', value: 'auto',
+	description: 'Set the target machine ISA (instruction set architecture). Will be set according to the platform option by default.')
 option('developer_mode', type: 'feature', description:
        'turn on additional build checks relevant for DPDK developers')
 option('disable_drivers', type: 'string', value: '', description:
@@ -28,16 +30,16 @@ option('include_subdir_arch', type: 'string', value: '', description:
        'subdirectory where to install arch-dependent headers')
 option('kernel_dir', type: 'string', value: '', description:
        'Path to the kernel for building kernel modules. Headers must be in $kernel_dir or $kernel_dir/build. Modules will be installed in /lib/modules.')
-option('machine', type: 'string', value: 'native', description:
-       'set the target machine type or "generic", a build usable on all machines of the build machine architecture or "native", which lets the compiler pick the architecture of the build machine.')
+option('machine', type: 'string', value: 'auto', description:
+       'Alias of cpu_instruction_set.')
 option('max_ethports', type: 'integer', value: 32, description:
        'maximum number of Ethernet devices')
 option('max_lcores', type: 'integer', value: 128, description:
        'maximum number of cores/threads supported by EAL')
 option('max_numa_nodes', type: 'integer', value: 32, description:
        'maximum number of NUMA nodes supported by EAL')
-option('platform', type: 'string', value: '', description:
-       'use configuration for a particular platform (such as a SoC).')
+option('platform', type: 'string', value: 'native', description:
+       'Platform to build, either "native", "generic" or an Arm SoC. Please refer to the Linux build guide for more information.')
 option('enable_trace_fp', type: 'boolean', value: false, description:
        'enable fast path trace points.')
 option('tests', type: 'boolean', value: true, description:
-- 
2.20.1


^ permalink raw reply	[flat|nested] 33+ messages in thread

* Re: [dpdk-dev] [PATCH v7] build: use platform for generic and native builds
  2021-07-06  9:44           ` [dpdk-dev] [PATCH v7] " Juraj Linkeš
@ 2021-07-07 13:59             ` Bruce Richardson
  2021-07-09 12:30               ` Thomas Monjalon
  0 siblings, 1 reply; 33+ messages in thread
From: Bruce Richardson @ 2021-07-07 13:59 UTC (permalink / raw)
  To: Juraj Linkeš
  Cc: thomas, david.marchand, Honnappa.Nagarahalli, Ruifeng.Wang,
	ferruh.yigit, jerinjacobk, dev

On Tue, Jul 06, 2021 at 11:44:28AM +0200, Juraj Linkeš wrote:
> The current meson option 'machine' should only specify the ISA, which is
> not sufficient for Arm, where setting ISA implies other settings as well
> (and is used in Arm configuration as such).
> Use the existing 'platform' meson option to differentiate the type of
> the build (native/generic) and set ISA accordingly, unless the user
> chooses to override it with a new option, 'cpu_instruction_set'.
> The 'machine' option set the ISA in x86 builds and set native/default
> 'build type' in aarch64 builds. These two new variables, 'platform' and
> 'cpu_instruction_set', now properly set both ISA and build type for all
> architectures in a uniform manner.
> The 'machine' option also doesn't describe very well what it sets. The
> new option, 'cpu_instruction_set', is much more descriptive. Keep
> 'machine' for backwards compatibility.
> 
> Signed-off-by: Juraj Linkeš <juraj.linkes@pantheon.tech>

Acked-by: Bruce Richardson <bruce.richardson@intel.com>

^ permalink raw reply	[flat|nested] 33+ messages in thread

* Re: [dpdk-dev] [PATCH v7] build: use platform for generic and native builds
  2021-07-07 13:59             ` Bruce Richardson
@ 2021-07-09 12:30               ` Thomas Monjalon
  2021-07-09 13:55                 ` Juraj Linkeš
  0 siblings, 1 reply; 33+ messages in thread
From: Thomas Monjalon @ 2021-07-09 12:30 UTC (permalink / raw)
  To: Juraj Linkeš, Bruce Richardson
  Cc: dev, david.marchand, Honnappa.Nagarahalli, Ruifeng.Wang,
	ferruh.yigit, jerinjacobk

07/07/2021 15:59, Bruce Richardson:
> On Tue, Jul 06, 2021 at 11:44:28AM +0200, Juraj Linkeš wrote:
> > The current meson option 'machine' should only specify the ISA, which is
> > not sufficient for Arm, where setting ISA implies other settings as well
> > (and is used in Arm configuration as such).
> > Use the existing 'platform' meson option to differentiate the type of
> > the build (native/generic) and set ISA accordingly, unless the user
> > chooses to override it with a new option, 'cpu_instruction_set'.
> > The 'machine' option set the ISA in x86 builds and set native/default
> > 'build type' in aarch64 builds. These two new variables, 'platform' and
> > 'cpu_instruction_set', now properly set both ISA and build type for all
> > architectures in a uniform manner.
> > The 'machine' option also doesn't describe very well what it sets. The
> > new option, 'cpu_instruction_set', is much more descriptive. Keep
> > 'machine' for backwards compatibility.
> > 
> > Signed-off-by: Juraj Linkeš <juraj.linkes@pantheon.tech>
> 
> Acked-by: Bruce Richardson <bruce.richardson@intel.com>

Applied, thanks.

I did few doc formatting improvements and removed some mentions to Arm
as a SoC is not necessarily Arm (Risc-V is coming).



^ permalink raw reply	[flat|nested] 33+ messages in thread

* Re: [dpdk-dev] [PATCH v7] build: use platform for generic and native builds
  2021-07-09 12:30               ` Thomas Monjalon
@ 2021-07-09 13:55                 ` Juraj Linkeš
  0 siblings, 0 replies; 33+ messages in thread
From: Juraj Linkeš @ 2021-07-09 13:55 UTC (permalink / raw)
  To: Thomas Monjalon, Bruce Richardson
  Cc: dev, david.marchand, Honnappa.Nagarahalli, Ruifeng.Wang,
	ferruh.yigit, jerinjacobk



> -----Original Message-----
> From: Thomas Monjalon <thomas@monjalon.net>
> Sent: Friday, July 9, 2021 2:31 PM
> To: Juraj Linkeš <juraj.linkes@pantheon.tech>; Bruce Richardson
> <bruce.richardson@intel.com>
> Cc: dev@dpdk.org; david.marchand@redhat.com;
> Honnappa.Nagarahalli@arm.com; Ruifeng.Wang@arm.com;
> ferruh.yigit@intel.com; jerinjacobk@gmail.com
> Subject: Re: [dpdk-dev] [PATCH v7] build: use platform for generic and native
> builds
> 
> 07/07/2021 15:59, Bruce Richardson:
> > On Tue, Jul 06, 2021 at 11:44:28AM +0200, Juraj Linkeš wrote:
> > > The current meson option 'machine' should only specify the ISA,
> > > which is not sufficient for Arm, where setting ISA implies other
> > > settings as well (and is used in Arm configuration as such).
> > > Use the existing 'platform' meson option to differentiate the type
> > > of the build (native/generic) and set ISA accordingly, unless the
> > > user chooses to override it with a new option, 'cpu_instruction_set'.
> > > The 'machine' option set the ISA in x86 builds and set
> > > native/default 'build type' in aarch64 builds. These two new
> > > variables, 'platform' and 'cpu_instruction_set', now properly set
> > > both ISA and build type for all architectures in a uniform manner.
> > > The 'machine' option also doesn't describe very well what it sets.
> > > The new option, 'cpu_instruction_set', is much more descriptive.
> > > Keep 'machine' for backwards compatibility.
> > >
> > > Signed-off-by: Juraj Linkeš <juraj.linkes@pantheon.tech>
> >
> > Acked-by: Bruce Richardson <bruce.richardson@intel.com>
> 
> Applied, thanks.
> 
> I did few doc formatting improvements and removed some mentions to Arm as
> a SoC is not necessarily Arm (Risc-V is coming).
> 
> 

Ok, thanks, Thomas.

^ permalink raw reply	[flat|nested] 33+ messages in thread

end of thread, other threads:[~2021-07-09 13:55 UTC | newest]

Thread overview: 33+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2020-11-26 15:47 [dpdk-dev] [RFC PATCH v1] build: add platform meson option Juraj Linkeš
2020-11-26 16:02 ` Bruce Richardson
2020-11-27  8:31   ` Juraj Linkeš
2020-11-27 14:07     ` Bruce Richardson
2020-12-23 11:23       ` Juraj Linkeš
2021-01-04 11:52 ` [dpdk-dev] [RFC PATCH v2] " Juraj Linkeš
2021-01-04 11:59   ` Juraj Linkeš
2021-01-05 22:17     ` David Christensen
2021-01-06 14:42       ` Bruce Richardson
2021-02-19  9:11         ` Juraj Linkeš
2021-02-22 21:25           ` David Christensen
2021-02-23  8:45             ` Juraj Linkeš
2021-02-23  9:43               ` Bruce Richardson
2021-02-25 12:51                 ` Juraj Linkeš
2021-02-25 12:54                   ` Bruce Richardson
2021-02-25 12:57                     ` Juraj Linkeš
2021-03-29 11:03   ` [dpdk-dev] [PATCH v3] " Juraj Linkeš
2021-03-29 12:50     ` [dpdk-dev] [PATCH v4] " Juraj Linkeš
2021-03-31 12:16       ` Juraj Linkeš
2021-03-31 12:19         ` Juraj Linkeš
2021-03-31 12:39         ` Bruce Richardson
2021-04-15 13:32           ` Juraj Linkeš
2021-04-15 13:51             ` Bruce Richardson
2021-04-20  8:08       ` [dpdk-dev] [PATCH v5] build: use platform option for generic and native Juraj Linkeš
2021-04-20  8:16         ` Juraj Linkeš
2021-04-20  8:36           ` Thomas Monjalon
2021-04-21  8:37             ` Juraj Linkeš
2021-04-22  8:34               ` Wang, Yinan
2021-06-30 13:09         ` [dpdk-dev] [PATCH v6] build: use platform for generic and native builds Juraj Linkeš
2021-07-06  9:44           ` [dpdk-dev] [PATCH v7] " Juraj Linkeš
2021-07-07 13:59             ` Bruce Richardson
2021-07-09 12:30               ` Thomas Monjalon
2021-07-09 13:55                 ` Juraj Linkeš

DPDK patches and discussions

This inbox may be cloned and mirrored by anyone:

	git clone --mirror https://inbox.dpdk.org/dev/0 dev/git/0.git

	# If you have public-inbox 1.1+ installed, you may
	# initialize and index your mirror using the following commands:
	public-inbox-init -V2 dev dev/ https://inbox.dpdk.org/dev \
		dev@dpdk.org
	public-inbox-index dev

Example config snippet for mirrors.
Newsgroup available over NNTP:
	nntp://inbox.dpdk.org/inbox.dpdk.dev


AGPL code for this site: git clone https://public-inbox.org/public-inbox.git