* [Xenomai-help] SMP load
@ 2010-10-22 21:48 Simon Leonard
2010-10-22 21:52 ` Simon Leonard
2010-10-22 21:54 ` Gilles Chanteperdrix
0 siblings, 2 replies; 3+ messages in thread
From: Simon Leonard @ 2010-10-22 21:48 UTC (permalink / raw)
To: xenomai
I sort of have a newbie problem regarding getting multiple threads
running on multiple cores (quad core). It did work on my previous system
(2.5-rc1) but I can't get it to work with 2.5.5.2 (or 2.5.5.1, 2.5.4).
Here's my small example:
#include <pthread.h>
void* thread( void* ){
unsigned long long i=0;
while( 1 ) i++;
return NULL;
}
int main(){
pthread_t tid1, tid2, tid3, tid4;
pthread_attr_t at1, at2, at3, at4;
pthread_attr_init( &at1 );
pthread_attr_init( &at2 );
pthread_attr_init( &at3 );
pthread_attr_init( &at4 );
pthread_create( &tid1, &at1, thread, NULL );
pthread_create( &tid2, &at2, thread, NULL );
pthread_create( &tid3, &at3, thread, NULL );
pthread_create( &tid4, &at4, thread, NULL );
pthread_join( tid1, NULL );
return 0;
}
If I compile with
g++ main.cpp -lpthread
and run I get 400% load (4 cores)
If I compile with
g++ main.cpp `/usr/xenomai/bin/xeno-config --skin posix --cflags`
`/usr/xenomai/bin/xeno-config --skin posix --ldflags`
I only get 100% load (1 core)
Regards.
/sl
^ permalink raw reply [flat|nested] 3+ messages in thread
* Re: [Xenomai-help] SMP load
2010-10-22 21:48 [Xenomai-help] SMP load Simon Leonard
@ 2010-10-22 21:52 ` Simon Leonard
2010-10-22 21:54 ` Gilles Chanteperdrix
1 sibling, 0 replies; 3+ messages in thread
From: Simon Leonard @ 2010-10-22 21:52 UTC (permalink / raw)
To: xenomai
BTW, before someone ask, I did configure with --enable-smp
--enable-x86-sep --enable-posix-auto-mlockall
/sl
On 10/22/2010 05:48 PM, Simon Leonard wrote:
>
> I sort of have a newbie problem regarding getting multiple threads
> running on multiple cores (quad core). It did work on my previous system
> (2.5-rc1) but I can't get it to work with 2.5.5.2 (or 2.5.5.1, 2.5.4).
> Here's my small example:
>
> #include<pthread.h>
> void* thread( void* ){
> unsigned long long i=0;
> while( 1 ) i++;
> return NULL;
> }
>
> int main(){
>
> pthread_t tid1, tid2, tid3, tid4;
> pthread_attr_t at1, at2, at3, at4;
>
> pthread_attr_init(&at1 );
> pthread_attr_init(&at2 );
> pthread_attr_init(&at3 );
> pthread_attr_init(&at4 );
>
> pthread_create(&tid1,&at1, thread, NULL );
> pthread_create(&tid2,&at2, thread, NULL );
> pthread_create(&tid3,&at3, thread, NULL );
> pthread_create(&tid4,&at4, thread, NULL );
>
> pthread_join( tid1, NULL );
>
> return 0;
> }
>
> If I compile with
> g++ main.cpp -lpthread
> and run I get 400% load (4 cores)
>
> If I compile with
> g++ main.cpp `/usr/xenomai/bin/xeno-config --skin posix --cflags`
> `/usr/xenomai/bin/xeno-config --skin posix --ldflags`
> I only get 100% load (1 core)
>
> Regards.
>
> /sl
>
> _______________________________________________
> Xenomai-help mailing list
> Xenomai-help@domain.hid
> https://mail.gna.org/listinfo/xenomai-help
^ permalink raw reply [flat|nested] 3+ messages in thread
* Re: [Xenomai-help] SMP load
2010-10-22 21:48 [Xenomai-help] SMP load Simon Leonard
2010-10-22 21:52 ` Simon Leonard
@ 2010-10-22 21:54 ` Gilles Chanteperdrix
1 sibling, 0 replies; 3+ messages in thread
From: Gilles Chanteperdrix @ 2010-10-22 21:54 UTC (permalink / raw)
To: Simon Leonard; +Cc: xenomai
Simon Leonard wrote:
> I sort of have a newbie problem regarding getting multiple threads
> running on multiple cores (quad core). It did work on my previous system
> (2.5-rc1) but I can't get it to work with 2.5.5.2 (or 2.5.5.1, 2.5.4).
> Here's my small example:
>
> #include <pthread.h>
> void* thread( void* ){
> unsigned long long i=0;
> while( 1 ) i++;
> return NULL;
> }
>
> int main(){
>
> pthread_t tid1, tid2, tid3, tid4;
> pthread_attr_t at1, at2, at3, at4;
>
> pthread_attr_init( &at1 );
> pthread_attr_init( &at2 );
> pthread_attr_init( &at3 );
> pthread_attr_init( &at4 );
>
> pthread_create( &tid1, &at1, thread, NULL );
> pthread_create( &tid2, &at2, thread, NULL );
> pthread_create( &tid3, &at3, thread, NULL );
> pthread_create( &tid4, &at4, thread, NULL );
>
> pthread_join( tid1, NULL );
>
> return 0;
> }
>
> If I compile with
> g++ main.cpp -lpthread
> and run I get 400% load (4 cores)
>
> If I compile with
> g++ main.cpp `/usr/xenomai/bin/xeno-config --skin posix --cflags`
> `/usr/xenomai/bin/xeno-config --skin posix --ldflags`
> I only get 100% load (1 core)
You need to use sched_setaffinity to set the cpu on which each thread
should run. Xenomai does not do any load balancing because threads
migrations introduce latencies.
By the way, if you do that with this test program, your computer will be
frozen unless you enable Xenomai watchdog.
--
Gilles.
^ permalink raw reply [flat|nested] 3+ messages in thread
end of thread, other threads:[~2010-10-22 21:54 UTC | newest]
Thread overview: 3+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2010-10-22 21:48 [Xenomai-help] SMP load Simon Leonard
2010-10-22 21:52 ` Simon Leonard
2010-10-22 21:54 ` Gilles Chanteperdrix
This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.