DPDK usage discussions
 help / color / mirror / Atom feed
* [dpdk-users] Is DPDK compatible with C++11 threads?
@ 2016-11-08 13:12 David Aldrich
  2016-11-08 17:04 ` Wiles, Keith
  0 siblings, 1 reply; 7+ messages in thread
From: David Aldrich @ 2016-11-08 13:12 UTC (permalink / raw)
  To: users

Hi

As a beginner with DPDK, I want to consider how we can convert an existing Linux application from using the kernel network stack to using DPDK.

This existing app is multi-threaded, using the C++11 thread, mutex etc. classes.  We assign threads to cores by calling pthread_setaffinity_np().

I have looked at the DPDK helloworld application and see that it launches threads using the DPDK API:

               /* call lcore_hello() on every slave lcore */
               RTE_LCORE_FOREACH_SLAVE(lcore_id) {
                              rte_eal_remote_launch(lcore_hello, NULL, lcore_id);
               }

If we use DPDK, can we retain our existing C++11 threads or are we obliged to use the DPDK threading APIs exclusively?

Perhaps a more basic question is applicable: is DPDK compatible with C++?

Best regards

David



Best regards

David

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

* Re: [dpdk-users] Is DPDK compatible with C++11 threads?
  2016-11-08 13:12 [dpdk-users] Is DPDK compatible with C++11 threads? David Aldrich
@ 2016-11-08 17:04 ` Wiles, Keith
  2016-11-08 17:23   ` Pavey, Nicholas
  0 siblings, 1 reply; 7+ messages in thread
From: Wiles, Keith @ 2016-11-08 17:04 UTC (permalink / raw)
  To: David Aldrich; +Cc: users


> On Nov 8, 2016, at 5:12 AM, David Aldrich <David.Aldrich@EMEA.NEC.COM> wrote:
> 
> Hi
> 
> As a beginner with DPDK, I want to consider how we can convert an existing Linux application from using the kernel network stack to using DPDK.
> 
> This existing app is multi-threaded, using the C++11 thread, mutex etc. classes.  We assign threads to cores by calling pthread_setaffinity_np().
> 
> I have looked at the DPDK helloworld application and see that it launches threads using the DPDK API:
> 
>               /* call lcore_hello() on every slave lcore */
>               RTE_LCORE_FOREACH_SLAVE(lcore_id) {
>                              rte_eal_remote_launch(lcore_hello, NULL, lcore_id);
>               }
> 
> If we use DPDK, can we retain our existing C++11 threads or are we obliged to use the DPDK threading APIs exclusively?

You should be able to use the standard C++11 threads I believe, in DPDK we are just using pthreads and set affinity to lock a thread to a core. You can still use pthreads in your application.

> 
> Perhaps a more basic question is applicable: is DPDK compatible with C++?

I believe building DPDK with C++ code does work,  but I have not tried it myself.

> 
> Best regards
> 
> David
> 
> 
> 
> Best regards
> 
> David
> 

Regards,
Keith

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

* Re: [dpdk-users] Is DPDK compatible with C++11 threads?
  2016-11-08 17:04 ` Wiles, Keith
@ 2016-11-08 17:23   ` Pavey, Nicholas
  2016-11-09  8:40     ` David Aldrich
  0 siblings, 1 reply; 7+ messages in thread
From: Pavey, Nicholas @ 2016-11-08 17:23 UTC (permalink / raw)
  To: Wiles, Keith, David Aldrich; +Cc: users

I’ve built the DPDK along with code in both C and C++. It works fine as long as you get the linkage between the languages correct and make sure that you don’t pass C++ headers into files compiled with the C compiler.

I did try building the DPDK itself with the “g++” compiler (v4.8.4, Ubuntu 14.04, 64bit), and I wasn’t able to get that working out of the box. I got hundreds of warnings, but I didn’t take the time to debug it – it’s possible that a few point fixes in the build system / DPDK code might yield a clean compile.

Thanks,


Nick

From: "Wiles, Keith" <keith.wiles@intel.com>
Date: Tuesday, November 8, 2016 at 12:04 PM
To: David Aldrich <David.Aldrich@EMEA.NEC.COM>
Cc: "users@dpdk.org" <users@dpdk.org>
Subject: Re: [dpdk-users] Is DPDK compatible with C++11 threads?


On Nov 8, 2016, at 5:12 AM, David Aldrich <David.Aldrich@EMEA.NEC.COM<mailto:David.Aldrich@EMEA.NEC.COM>> wrote:
Hi
As a beginner with DPDK, I want to consider how we can convert an existing Linux application from using the kernel network stack to using DPDK.
This existing app is multi-threaded, using the C++11 thread, mutex etc. classes.  We assign threads to cores by calling pthread_setaffinity_np().
I have looked at the DPDK helloworld application and see that it launches threads using the DPDK API:
               /* call lcore_hello() on every slave lcore */
               RTE_LCORE_FOREACH_SLAVE(lcore_id) {
                              rte_eal_remote_launch(lcore_hello, NULL, lcore_id);
               }
If we use DPDK, can we retain our existing C++11 threads or are we obliged to use the DPDK threading APIs exclusively?

You should be able to use the standard C++11 threads I believe, in DPDK we are just using pthreads and set affinity to lock a thread to a core. You can still use pthreads in your application.

Perhaps a more basic question is applicable: is DPDK compatible with C++?

I believe building DPDK with C++ code does work,  but I have not tried it myself.

Best regards
David
Best regards
David

Regards,
Keith



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

* Re: [dpdk-users] Is DPDK compatible with C++11 threads?
  2016-11-08 17:23   ` Pavey, Nicholas
@ 2016-11-09  8:40     ` David Aldrich
  2016-11-09 21:00       ` Wiles, Keith
  0 siblings, 1 reply; 7+ messages in thread
From: David Aldrich @ 2016-11-09  8:40 UTC (permalink / raw)
  To: Pavey, Nicholas, Wiles, Keith; +Cc: users

Hi Nick and Keith

Thank you both for your replies, they were very helpful.

Referring again to the helloworld example, we see that multiple threads are launched:

 RTE_LCORE_FOREACH_SLAVE(lcore_id)
 {
    rte_eal_remote_launch(lcore_hello, NULL, lcore_id);
 }

In our case, where our application is running C++11 threads, would I launch one dpdk thread for the dpdk process and launch my other threads as C++11 threads as before?

One of those C++11 threads will process my network data.  Will the dpdk’s locks and shared memory mechanisms allow this?

I realise that I am demonstrating a lack of understanding of the basics of how dpdk works, but I am just starting to understand it.

With best regards

David

From: Pavey, Nicholas [mailto:npavey@akamai.com]
Sent: 08 November 2016 17:23
To: Wiles, Keith <keith.wiles@intel.com>; David Aldrich <David.Aldrich@EMEA.NEC.COM>
Cc: users@dpdk.org
Subject: Re: [dpdk-users] Is DPDK compatible with C++11 threads?

I’ve built the DPDK along with code in both C and C++. It works fine as long as you get the linkage between the languages correct and make sure that you don’t pass C++ headers into files compiled with the C compiler.

I did try building the DPDK itself with the “g++” compiler (v4.8.4, Ubuntu 14.04, 64bit), and I wasn’t able to get that working out of the box. I got hundreds of warnings, but I didn’t take the time to debug it – it’s possible that a few point fixes in the build system / DPDK code might yield a clean compile.

Thanks,


Nick

From: "Wiles, Keith" <keith.wiles@intel.com<mailto:keith.wiles@intel.com>>
Date: Tuesday, November 8, 2016 at 12:04 PM
To: David Aldrich <David.Aldrich@EMEA.NEC.COM<mailto:David.Aldrich@EMEA.NEC.COM>>
Cc: "users@dpdk.org<mailto:users@dpdk.org>" <users@dpdk.org<mailto:users@dpdk.org>>
Subject: Re: [dpdk-users] Is DPDK compatible with C++11 threads?


On Nov 8, 2016, at 5:12 AM, David Aldrich <David.Aldrich@EMEA.NEC.COM<mailto:David.Aldrich@EMEA.NEC.COM>> wrote:
Hi
As a beginner with DPDK, I want to consider how we can convert an existing Linux application from using the kernel network stack to using DPDK.
This existing app is multi-threaded, using the C++11 thread, mutex etc. classes.  We assign threads to cores by calling pthread_setaffinity_np().
I have looked at the DPDK helloworld application and see that it launches threads using the DPDK API:
               /* call lcore_hello() on every slave lcore */
               RTE_LCORE_FOREACH_SLAVE(lcore_id) {
                              rte_eal_remote_launch(lcore_hello, NULL, lcore_id);
               }
If we use DPDK, can we retain our existing C++11 threads or are we obliged to use the DPDK threading APIs exclusively?

You should be able to use the standard C++11 threads I believe, in DPDK we are just using pthreads and set affinity to lock a thread to a core. You can still use pthreads in your application.

Perhaps a more basic question is applicable: is DPDK compatible with C++?

I believe building DPDK with C++ code does work,  but I have not tried it myself.

Best regards
David
Best regards
David

Regards,
Keith




Click here<https://www.mailcontrol.com/sr/GxhbYqLK+zTGX2PQPOmvUnp0s2vlqiGqxbHw0ywMJd7ksdbbH4X2NEgRg!p04FdRGIUhVPU27Gs5N50IUBelLw==> to report this email as spam.

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

* Re: [dpdk-users] Is DPDK compatible with C++11 threads?
  2016-11-09  8:40     ` David Aldrich
@ 2016-11-09 21:00       ` Wiles, Keith
  2016-11-10  4:14         ` Anupam Kapoor
  0 siblings, 1 reply; 7+ messages in thread
From: Wiles, Keith @ 2016-11-09 21:00 UTC (permalink / raw)
  To: David Aldrich; +Cc: Pavey, Nicholas, users


> On Nov 9, 2016, at 2:40 AM, David Aldrich <David.Aldrich@EMEA.NEC.COM> wrote:
> 
> Hi Nick and Keith
>  
> Thank you both for your replies, they were very helpful.
>  
> Referring again to the helloworld example, we see that multiple threads are launched:
>  
>  RTE_LCORE_FOREACH_SLAVE(lcore_id)
>  {
>     rte_eal_remote_launch(lcore_hello, NULL, lcore_id);
>  }
>  
> In our case, where our application is running C++11 threads, would I launch one dpdk thread for the dpdk process and launch my other threads as C++11 threads as before?
>  
> One of those C++11 threads will process my network data.  Will the dpdk’s locks and shared memory mechanisms allow this?

Each of the lcores will get one pthread and that pthread expects to be the main one for data polling, but it does not need to be. I assume you can use the launch command in DPDK and then your C++11 application can create its own threads. The spinlocks in DPDK should work without any issues as long as you use the same locks everywhere.

I have before launched a pthread to a given core using the DPDK APIs then created more pthreads on that same core for other purposes. Remember the standard way DPDK works is the pthread launched expects to poll the port(s) and never stop from your application. This means you would need to yield() the main polling loop to allow the other threads to run unless you are using priority and some type of interrupt or signal.

Also look at one of the DPDK examples as it uses a lthread on top of pthreads and it may give you some ideas as to how multiple threads can work. I am trying to remember which example and my dev machine is down at this time, but just search for lthread.

>  
> I realise that I am demonstrating a lack of understanding of the basics of how dpdk works, but I am just starting to understand it.
>  
> With best regards
>  
> David
>  
> From: Pavey, Nicholas [mailto:npavey@akamai.com] 
> Sent: 08 November 2016 17:23
> To: Wiles, Keith <keith.wiles@intel.com>; David Aldrich <David.Aldrich@EMEA.NEC.COM>
> Cc: users@dpdk.org
> Subject: Re: [dpdk-users] Is DPDK compatible with C++11 threads?
>  
> I’ve built the DPDK along with code in both C and C++. It works fine as long as you get the linkage between the languages correct and make sure that you don’t pass C++ headers into files compiled with the C compiler.
>  
> I did try building the DPDK itself with the “g++” compiler (v4.8.4, Ubuntu 14.04, 64bit), and I wasn’t able to get that working out of the box. I got hundreds of warnings, but I didn’t take the time to debug it – it’s possible that a few point fixes in the build system / DPDK code might yield a clean compile.
>  
> Thanks,
>  
>  
> Nick
>  
> From: "Wiles, Keith" <keith.wiles@intel.com>
> Date: Tuesday, November 8, 2016 at 12:04 PM
> To: David Aldrich <David.Aldrich@EMEA.NEC.COM>
> Cc: "users@dpdk.org" <users@dpdk.org>
> Subject: Re: [dpdk-users] Is DPDK compatible with C++11 threads?
>  
>  
> On Nov 8, 2016, at 5:12 AM, David Aldrich <David.Aldrich@EMEA.NEC.COM> wrote:
> Hi
> As a beginner with DPDK, I want to consider how we can convert an existing Linux application from using the kernel network stack to using DPDK.
> This existing app is multi-threaded, using the C++11 thread, mutex etc. classes.  We assign threads to cores by calling pthread_setaffinity_np().
> I have looked at the DPDK helloworld application and see that it launches threads using the DPDK API:
>                /* call lcore_hello() on every slave lcore */
>                RTE_LCORE_FOREACH_SLAVE(lcore_id) {
>                               rte_eal_remote_launch(lcore_hello, NULL, lcore_id);
>                }
> If we use DPDK, can we retain our existing C++11 threads or are we obliged to use the DPDK threading APIs exclusively?
>  
> You should be able to use the standard C++11 threads I believe, in DPDK we are just using pthreads and set affinity to lock a thread to a core. You can still use pthreads in your application.
>  
> Perhaps a more basic question is applicable: is DPDK compatible with C++?
>  
> I believe building DPDK with C++ code does work,  but I have not tried it myself.
>  
> Best regards
> David
> Best regards
> David
>  
> Regards,
> Keith
>  
>  
>  
> 
> Click here to report this email as spam.
> 

Regards,
Keith


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

* Re: [dpdk-users] Is DPDK compatible with C++11 threads?
  2016-11-09 21:00       ` Wiles, Keith
@ 2016-11-10  4:14         ` Anupam Kapoor
  2016-11-10 12:49           ` Pavey, Nicholas
  0 siblings, 1 reply; 7+ messages in thread
From: Anupam Kapoor @ 2016-11-10  4:14 UTC (permalink / raw)
  To: Wiles, Keith; +Cc: David Aldrich, Pavey, Nicholas, users

On Thu, Nov 10, 2016 at 2:30 AM, Wiles, Keith <keith.wiles@intel.com> wrote:

> Also look at one of the DPDK examples as it uses a lthread on top of
> pthreads and it may give you some ideas as to how multiple threads can
> work. I am trying to remember which example and my dev machine is down at
> this time, but just search for lthread.


​this one: ​http://dpdk.org/doc/guides/sample_app_ug/performance_thread.html

one more thing that you probably need to watch out for would be libc
interactions within your C++11 application e.g. usage of stl containers
might exact a severe performance penalty...

--
kind regards
anupam


In the beginning was the lambda, and the lambda was with Emacs, and Emacs
was the lambda.

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

* Re: [dpdk-users] Is DPDK compatible with C++11 threads?
  2016-11-10  4:14         ` Anupam Kapoor
@ 2016-11-10 12:49           ` Pavey, Nicholas
  0 siblings, 0 replies; 7+ messages in thread
From: Pavey, Nicholas @ 2016-11-10 12:49 UTC (permalink / raw)
  To: Anupam Kapoor, Wiles, Keith; +Cc: David Aldrich, users

Yes, agreed. We only use the STL in general purpose code, not the DPDK fast path.

Nick

From: Anupam Kapoor <anupam.kapoor@gmail.com>
Date: Wednesday, November 9, 2016 at 11:14 PM
To: "Wiles, Keith" <keith.wiles@intel.com>
Cc: David Aldrich <David.Aldrich@emea.nec.com>, "Pavey, Nicholas" <npavey@akamai.com>, "users@dpdk.org" <users@dpdk.org>
Subject: Re: [dpdk-users] Is DPDK compatible with C++11 threads?


On Thu, Nov 10, 2016 at 2:30 AM, Wiles, Keith <keith.wiles@intel.com<mailto:keith.wiles@intel.com>> wrote:
Also look at one of the DPDK examples as it uses a lthread on top of pthreads and it may give you some ideas as to how multiple threads can work. I am trying to remember which example and my dev machine is down at this time, but just search for lthread.

​this one: ​http://dpdk.org/doc/guides/sample_app_ug/performance_thread.html<https://urldefense.proofpoint.com/v2/url?u=http-3A__dpdk.org_doc_guides_sample-5Fapp-5Fug_performance-5Fthread.html&d=DgMFaQ&c=96ZbZZcaMF4w0F4jpN6LZg&r=ssgET6RyiWLuSGT5U4X0s-CtLYP5dr-AKGa5XH84zdM&m=7hZrbWDcflak8oiYezM8ikKmkjXi6bqa-uc-Tj8hzsE&s=Q6FKkqcR_EKo71KN5FKQYQEJGU--5ZdNjkqs5hLKk34&e=>

one more thing that you probably need to watch out for would be libc interactions within your C++11 application e.g. usage of stl containers might exact a severe performance penalty...

--
kind regards
anupam


In the beginning was the lambda, and the lambda was with Emacs, and Emacs was the lambda.

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

end of thread, other threads:[~2016-11-10 12:49 UTC | newest]

Thread overview: 7+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2016-11-08 13:12 [dpdk-users] Is DPDK compatible with C++11 threads? David Aldrich
2016-11-08 17:04 ` Wiles, Keith
2016-11-08 17:23   ` Pavey, Nicholas
2016-11-09  8:40     ` David Aldrich
2016-11-09 21:00       ` Wiles, Keith
2016-11-10  4:14         ` Anupam Kapoor
2016-11-10 12:49           ` Pavey, Nicholas

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).