[dpdk-dev,v2] lib/librte_sched: Fix compile with gcc 4.3.4

Message ID 1449022194-25510-1-git-send-email-michael.qiu@intel.com (mailing list archive)
State Superseded, archived
Headers

Commit Message

Michael Qiu Dec. 2, 2015, 2:09 a.m. UTC
  gcc 4.3.4 does not include "immintrin.h", and will post below error:
    lib/librte_sched/rte_sched.c:56:23: error:
    immintrin.h: No such file or directory

To avoid this issue, a gcc version check is need and a flag to indicate
vector ablility.

Fixes: 42ec27a0178a ("sched: enable SSE optimizations in config")

Signed-off-by: Michael Qiu <michael.qiu@intel.com>
---
v2 --> v1:
	include header file rte_vect.h instead of gcc version check
	change __AVX__ to __SSE2__ since all vector function are SSE2 related.

 lib/librte_sched/rte_sched.c | 9 +++++++--
 1 file changed, 7 insertions(+), 2 deletions(-)
  

Comments

Thomas Monjalon Dec. 2, 2015, 2:18 a.m. UTC | #1
2015-12-02 10:09, Michael Qiu:
> gcc 4.3.4 does not include "immintrin.h", and will post below error:
>     lib/librte_sched/rte_sched.c:56:23: error:
>     immintrin.h: No such file or directory

This compiler issue is fixed with rte_vect.h.

> To avoid this issue, a gcc version check is need and a flag to indicate
> vector ablility.

It is another issue: we need SSE2 support.

> --- a/lib/librte_sched/rte_sched.c
> +++ b/lib/librte_sched/rte_sched.c
> @@ -42,6 +42,7 @@
>  #include <rte_prefetch.h>
>  #include <rte_branch_prediction.h>
>  #include <rte_mbuf.h>
> +#include <rte_vect.h>

Shouldn't be in #ifdef RTE_SCHED_VECTOR ?

>  #include "rte_sched.h"
>  #include "rte_bitmap.h"
> @@ -53,7 +54,11 @@
>  #endif
>  
>  #ifdef RTE_SCHED_VECTOR
> -#include <immintrin.h>
> +
> +#if defined(__SSE2__)
> +#define SCHED_VECTOR_ENABLE
> +#endif

I think the flag should SCHED_VECTOR_SSE2

With this fix, the need for disabling SCHED_VECTOR for non-x86 platforms
should disappear.
But it may be safe to disable it (another patch).
Thanks
  
Michael Qiu Dec. 2, 2015, 2:29 a.m. UTC | #2
I will make v3 patch to fix the issue.

Thanks,
Michael

On 2015/12/2 10:19, Thomas Monjalon wrote:
> 2015-12-02 10:09, Michael Qiu:
>> gcc 4.3.4 does not include "immintrin.h", and will post below error:
>>     lib/librte_sched/rte_sched.c:56:23: error:
>>     immintrin.h: No such file or directory
> This compiler issue is fixed with rte_vect.h.
>
>> To avoid this issue, a gcc version check is need and a flag to indicate
>> vector ablility.
> It is another issue: we need SSE2 support.
>
>> --- a/lib/librte_sched/rte_sched.c
>> +++ b/lib/librte_sched/rte_sched.c
>> @@ -42,6 +42,7 @@
>>  #include <rte_prefetch.h>
>>  #include <rte_branch_prediction.h>
>>  #include <rte_mbuf.h>
>> +#include <rte_vect.h>
> Shouldn't be in #ifdef RTE_SCHED_VECTOR ?
>
>>  #include "rte_sched.h"
>>  #include "rte_bitmap.h"
>> @@ -53,7 +54,11 @@
>>  #endif
>>  
>>  #ifdef RTE_SCHED_VECTOR
>> -#include <immintrin.h>
>> +
>> +#if defined(__SSE2__)
>> +#define SCHED_VECTOR_ENABLE
>> +#endif
> I think the flag should SCHED_VECTOR_SSE2
>
> With this fix, the need for disabling SCHED_VECTOR for non-x86 platforms
> should disappear.
> But it may be safe to disable it (another patch).
> Thanks
>
  

Patch

diff --git a/lib/librte_sched/rte_sched.c b/lib/librte_sched/rte_sched.c
index d47cfc2..0d46618 100644
--- a/lib/librte_sched/rte_sched.c
+++ b/lib/librte_sched/rte_sched.c
@@ -42,6 +42,7 @@ 
 #include <rte_prefetch.h>
 #include <rte_branch_prediction.h>
 #include <rte_mbuf.h>
+#include <rte_vect.h>
 
 #include "rte_sched.h"
 #include "rte_bitmap.h"
@@ -53,7 +54,11 @@ 
 #endif
 
 #ifdef RTE_SCHED_VECTOR
-#include <immintrin.h>
+
+#if defined(__SSE2__)
+#define SCHED_VECTOR_ENABLE
+#endif
+
 #endif
 
 #define RTE_SCHED_TB_RATE_CONFIG_ERR          (1e-7)
@@ -1667,7 +1672,7 @@  grinder_schedule(struct rte_sched_port *port, uint32_t pos)
 	return 1;
 }
 
-#ifdef RTE_SCHED_VECTOR
+#ifdef SCHED_VECTOR_ENABLE
 
 static inline int
 grinder_pipe_exists(struct rte_sched_port *port, uint32_t base_pipe)