acl: fix build with GCC 6.3

Message ID 20210521144207.13802-1-konstantin.ananyev@intel.com (mailing list archive)
State Accepted, archived
Delegated to: Thomas Monjalon
Headers
Series acl: fix build with GCC 6.3 |

Checks

Context Check Description
ci/checkpatch success coding style OK
ci/Intel-compilation success Compilation OK
ci/intel-Testing success Testing PASS
ci/iol-abi-testing success Testing PASS
ci/github-robot success github build: passed
ci/iol-testing fail Testing issues
ci/iol-mellanox-Performance fail Performance Testing issues
ci/iol-mellanox-Functional fail Functional Testing issues
ci/iol-intel-Performance success Performance Testing PASS
ci/iol-intel-Functional success Functional Testing PASS

Commit Message

Ananyev, Konstantin May 21, 2021, 2:42 p.m. UTC
  --buildtype=debug with gcc 6.3 produces the following error:

../lib/librte_acl/acl_run_avx512_common.h: In function
‘resolve_match_idx_avx512x16’:
../lib/librte_acl/acl_run_avx512x16.h:33:18: error:
	the last argument must be an 8-bit immediate
                               ^
../lib/librte_acl/acl_run_avx512_common.h:373:9: note:
	in expansion of macro ‘_M_I_’
      return _M_I_(slli_epi32)(mi, match_log);
             ^~~~~

Seems like gcc-6.3 complains about the following construct:

static const uint32_t match_log = 5;
    ...
_mm512_slli_epi32(mi, match_log);

It can't substitute constant variable 'match_log' with its actual value.
The fix replaces constant variable with its immediate value.

Bugzilla ID: 717
Fixes: b64c2295f7fc ("acl: add 256-bit AVX512 classify method")
Fixes: 45da22e42ec3 ("acl: add 512-bit AVX512 classify method")
Cc: stable@dpdk.org

Reported-by: Liang Ma <liangma@liangbit.com>
Signed-off-by: Konstantin Ananyev <konstantin.ananyev@intel.com>
---
 lib/acl/acl_run_avx512.c        | 8 ++++----
 lib/acl/acl_run_avx512_common.h | 4 ++--
 lib/acl/acl_run_avx512x16.h     | 6 ++----
 3 files changed, 8 insertions(+), 10 deletions(-)
  

Comments

Liang Ma May 21, 2021, 2:55 p.m. UTC | #1
On Fri, May 21, 2021 at 03:42:07PM +0100, Konstantin Ananyev wrote:
<snip>
I apply this patch but it caused i40e pmd avx512 build failure. 
not sure about the root cause. I build debug version with latest repo.
  
Thomas Monjalon May 21, 2021, 3:10 p.m. UTC | #2
21/05/2021 16:42, Konstantin Ananyev:
> --buildtype=debug with gcc 6.3 produces the following error:
> 
> ../lib/librte_acl/acl_run_avx512_common.h: In function
> ‘resolve_match_idx_avx512x16’:
> ../lib/librte_acl/acl_run_avx512x16.h:33:18: error:
> 	the last argument must be an 8-bit immediate
>                                ^
> ../lib/librte_acl/acl_run_avx512_common.h:373:9: note:
> 	in expansion of macro ‘_M_I_’
>       return _M_I_(slli_epi32)(mi, match_log);
>              ^~~~~
> 
> Seems like gcc-6.3 complains about the following construct:
> 
> static const uint32_t match_log = 5;
>     ...
> _mm512_slli_epi32(mi, match_log);
> 
> It can't substitute constant variable 'match_log' with its actual value.
> The fix replaces constant variable with its immediate value.
> 
> Bugzilla ID: 717
> Fixes: b64c2295f7fc ("acl: add 256-bit AVX512 classify method")
> Fixes: 45da22e42ec3 ("acl: add 512-bit AVX512 classify method")
> Cc: stable@dpdk.org
> 
> Reported-by: Liang Ma <liangma@liangbit.com>
> Signed-off-by: Konstantin Ananyev <konstantin.ananyev@intel.com>

How much critical is it?
It looks safer to wait for 21.08 cycle?
  
Ananyev, Konstantin May 21, 2021, 3:16 p.m. UTC | #3
> -----Original Message-----
> From: Thomas Monjalon <thomas@monjalon.net>
> Sent: Friday, May 21, 2021 4:11 PM
> To: liangma@liangbit.com; Ananyev, Konstantin <konstantin.ananyev@intel.com>
> Cc: dev@dpdk.org; stable@dpdk.org
> Subject: Re: [dpdk-dev] [PATCH] acl: fix build with GCC 6.3
> 
> 21/05/2021 16:42, Konstantin Ananyev:
> > --buildtype=debug with gcc 6.3 produces the following error:
> >
> > ../lib/librte_acl/acl_run_avx512_common.h: In function
> > ‘resolve_match_idx_avx512x16’:
> > ../lib/librte_acl/acl_run_avx512x16.h:33:18: error:
> > 	the last argument must be an 8-bit immediate
> >                                ^
> > ../lib/librte_acl/acl_run_avx512_common.h:373:9: note:
> > 	in expansion of macro ‘_M_I_’
> >       return _M_I_(slli_epi32)(mi, match_log);
> >              ^~~~~
> >
> > Seems like gcc-6.3 complains about the following construct:
> >
> > static const uint32_t match_log = 5;
> >     ...
> > _mm512_slli_epi32(mi, match_log);
> >
> > It can't substitute constant variable 'match_log' with its actual value.
> > The fix replaces constant variable with its immediate value.
> >
> > Bugzilla ID: 717
> > Fixes: b64c2295f7fc ("acl: add 256-bit AVX512 classify method")
> > Fixes: 45da22e42ec3 ("acl: add 512-bit AVX512 classify method")
> > Cc: stable@dpdk.org
> >
> > Reported-by: Liang Ma <liangma@liangbit.com>
> > Signed-off-by: Konstantin Ananyev <konstantin.ananyev@intel.com>
> 
> How much critical is it?
> It looks safer to wait for 21.08 cycle?

I think we can wait till 21.08 cycle.
  
Liang Ma May 21, 2021, 3:21 p.m. UTC | #4
On Fri, May 21, 2021 at 05:10:41PM +0200, Thomas Monjalon wrote:
> 21/05/2021 16:42, Konstantin Ananyev:
> > --buildtype=debug with gcc 6.3 produces the following error:
> > 
> > ../lib/librte_acl/acl_run_avx512_common.h: In function
> > ‘resolve_match_idx_avx512x16’:
> > ../lib/librte_acl/acl_run_avx512x16.h:33:18: error:
> > 	the last argument must be an 8-bit immediate
> >                                ^
> > ../lib/librte_acl/acl_run_avx512_common.h:373:9: note:
> > 	in expansion of macro ‘_M_I_’
> >       return _M_I_(slli_epi32)(mi, match_log);
> >              ^~~~~
> > 
> > Seems like gcc-6.3 complains about the following construct:
> > 
> > static const uint32_t match_log = 5;
> >     ...
> > _mm512_slli_epi32(mi, match_log);
> > 
> > It can't substitute constant variable 'match_log' with its actual value.
> > The fix replaces constant variable with its immediate value.
> > 
> > Bugzilla ID: 717
> > Fixes: b64c2295f7fc ("acl: add 256-bit AVX512 classify method")
> > Fixes: 45da22e42ec3 ("acl: add 512-bit AVX512 classify method")
> > Cc: stable@dpdk.org
> > 
> > Reported-by: Liang Ma <liangma@liangbit.com>
> > Signed-off-by: Konstantin Ananyev <konstantin.ananyev@intel.com>
> 
> How much critical is it?
> It looks safer to wait for 21.08 cycle?
+1. gcc8.30 is OK. It's a bit late now. 
> 
>
  
Thomas Monjalon June 17, 2021, 6:57 a.m. UTC | #5
21/05/2021 16:42, Konstantin Ananyev:
> --buildtype=debug with gcc 6.3 produces the following error:
> 
> ../lib/librte_acl/acl_run_avx512_common.h: In function
> ‘resolve_match_idx_avx512x16’:
> ../lib/librte_acl/acl_run_avx512x16.h:33:18: error:
> 	the last argument must be an 8-bit immediate
>                                ^
> ../lib/librte_acl/acl_run_avx512_common.h:373:9: note:
> 	in expansion of macro ‘_M_I_’
>       return _M_I_(slli_epi32)(mi, match_log);
>              ^~~~~
> 
> Seems like gcc-6.3 complains about the following construct:
> 
> static const uint32_t match_log = 5;
>     ...
> _mm512_slli_epi32(mi, match_log);
> 
> It can't substitute constant variable 'match_log' with its actual value.
> The fix replaces constant variable with its immediate value.
> 
> Bugzilla ID: 717
> Fixes: b64c2295f7fc ("acl: add 256-bit AVX512 classify method")
> Fixes: 45da22e42ec3 ("acl: add 512-bit AVX512 classify method")
> Cc: stable@dpdk.org
> 
> Reported-by: Liang Ma <liangma@liangbit.com>
> Signed-off-by: Konstantin Ananyev <konstantin.ananyev@intel.com>

Applied, thanks
  

Patch

diff --git a/lib/acl/acl_run_avx512.c b/lib/acl/acl_run_avx512.c
index 3fd1e33c3..78fbe34f7 100644
--- a/lib/acl/acl_run_avx512.c
+++ b/lib/acl/acl_run_avx512.c
@@ -4,8 +4,8 @@ 
 
 #include "acl_run_sse.h"
 
-/*sizeof(uint32_t) << match_log == sizeof(struct rte_acl_match_results)*/
-static const uint32_t match_log = 5;
+/*sizeof(uint32_t) << ACL_MATCH_LOG == sizeof(struct rte_acl_match_results)*/
+#define ACL_MATCH_LOG	5
 
 struct acl_flow_avx512 {
 	uint32_t num_packets;       /* number of packets processed */
@@ -82,7 +82,7 @@  resolve_mcle8_avx512x1(uint32_t result[],
 
 	for (k = 0; k != nb_pkt; k++, result += nb_cat) {
 
-		mi = match[k] << match_log;
+		mi = match[k] << ACL_MATCH_LOG;
 
 		for (j = 0; j != nb_cat; j += RTE_ACL_RESULTS_MULTIPLIER) {
 
@@ -92,7 +92,7 @@  resolve_mcle8_avx512x1(uint32_t result[],
 			for (i = 1, pm = match + nb_pkt; i != nb_trie;
 				i++, pm += nb_pkt) {
 
-				mn = j + (pm[k] << match_log);
+				mn = j + (pm[k] << ACL_MATCH_LOG);
 
 				nr = _mm_loadu_si128((const xmm_t *)(res + mn));
 				np = _mm_loadu_si128((const xmm_t *)(pri + mn));
diff --git a/lib/acl/acl_run_avx512_common.h b/lib/acl/acl_run_avx512_common.h
index fbad74d45..578eaa1d0 100644
--- a/lib/acl/acl_run_avx512_common.h
+++ b/lib/acl/acl_run_avx512_common.h
@@ -393,8 +393,8 @@  static inline _T_simd
 _F_(resolve_match_idx)(_T_simd mi)
 {
 	RTE_BUILD_BUG_ON(sizeof(struct rte_acl_match_results) !=
-		1 << (match_log + 2));
-	return _M_I_(slli_epi32)(mi, match_log);
+		1 << (ACL_MATCH_LOG + 2));
+	return _M_I_(slli_epi32)(mi, ACL_MATCH_LOG);
 }
 
 /*
diff --git a/lib/acl/acl_run_avx512x16.h b/lib/acl/acl_run_avx512x16.h
index da244bc25..48bb6fed8 100644
--- a/lib/acl/acl_run_avx512x16.h
+++ b/lib/acl/acl_run_avx512x16.h
@@ -252,8 +252,6 @@  resolve_mcgt8_avx512x1(uint32_t result[],
 	__mmask16 cm, sm;
 	__m512i cp, cr, np, nr;
 
-	const uint32_t match_log = 5;
-
 	res = pr->results;
 	pri = pr->priority;
 
@@ -261,7 +259,7 @@  resolve_mcgt8_avx512x1(uint32_t result[],
 
 	for (k = 0; k != nb_pkt; k++, result += nb_cat) {
 
-		mi = match[k] << match_log;
+		mi = match[k] << ACL_MATCH_LOG;
 
 		cr = _mm512_maskz_loadu_epi32(cm, res + mi);
 		cp = _mm512_maskz_loadu_epi32(cm, pri + mi);
@@ -269,7 +267,7 @@  resolve_mcgt8_avx512x1(uint32_t result[],
 		for (i = 1, pm = match + nb_pkt; i != nb_trie;
 				i++, pm += nb_pkt) {
 
-			mi = pm[k] << match_log;
+			mi = pm[k] << ACL_MATCH_LOG;
 
 			nr = _mm512_maskz_loadu_epi32(cm, res + mi);
 			np = _mm512_maskz_loadu_epi32(cm, pri + mi);