comp.lang.ada
 help / color / mirror / Atom feed
* Q: Binding tasks to CPU's seems not to work with Task_Info pragma?!
@ 2013-08-10 17:56 Michael Erdmann
  2013-08-10 19:17 ` AdaMagica
  0 siblings, 1 reply; 7+ messages in thread
From: Michael Erdmann @ 2013-08-10 17:56 UTC (permalink / raw)


Hallo,

i am trying to bind my task to specific processors using gnat packages. 

      function CPU( i : Positive ) return Task_Info.Task_Info_Type is
         T : Task_Info.Task_Info_Type := new Thread_Attributes;
      begin
         T.CPU_Affinity.bits := (others => false );
         T.CPU_Affinity.bits(i) :=true;
         return T;
      end;
      
      task type Task_Type( id : Natural ) is
         Pragma Priority(4);
         Pragma Task_Info(CPU(Id));
      end Task_Type;

      TT : array(1..Nbr_Of_Threads) of Task_Access; 
   begin
      for i in TT'Range loop
         TT(i) := new Task_Type(i);
      end loop;
      ....

Assume Nbr_Of_Threads = 4; i get on my linux box (OpenSuse 12.3) the following
top results. 


top - 19:40:02 up 31 min,  2 users,  load average: 1.77, 0.46, 0.19
Tasks: 200 total,   1 running, 199 sleeping,   0 stopped,   0 zombie
Cpu0  :  0.3%us,  0.0%sy,  0.0%ni, 99.7%id,  0.0%wa,  0.0%hi,  0.0%si,  0.0%st
Cpu1  :  0.0%us,  0.0%sy,  0.0%ni,100.0%id,  0.0%wa,  0.0%hi,  0.0%si,  0.0%st
Cpu2  :100.0%us,  0.0%sy,  0.0%ni,  0.0%id,  0.0%wa,  0.0%hi,  0.0%si,  0.0%st
Cpu3  :100.0%us,  0.0%sy,  0.0%ni,  0.0%id,  0.0%wa,  0.0%hi,  0.0%si,  0.0%st
Cpu4  :100.0%us,  0.0%sy,  0.0%ni,  0.0%id,  0.0%wa,  0.0%hi,  0.0%si,  0.0%st
Cpu5  :  0.0%us,  0.0%sy,  0.0%ni,100.0%id,  0.0%wa,  0.0%hi,  0.0%si,  0.0%st
Cpu6  :100.0%us,  0.0%sy,  0.0%ni,  0.0%id,  0.0%wa,  0.0%hi,  0.0%si,  0.0%st
Cpu7  :  0.0%us,  0.0%sy,  0.0%ni,100.0%id,  0.0%wa,  0.0%hi,  0.0%si,  0.0%st
Mem:   3981796k total,   669496k used,  3312300k free,      856k buffers
Swap: 10482408k total,        0k used, 10482408k free,   340328k cached

I would have expected CPU 0..3 being busy. Even worse the next time i start 
my program the cpu's are assigned differently :-/

I am a bit frustrated because i can do the trick with taskset without any 
major effort. Any idea what i am doing wrong? 

The complete source should be avaiable here: https://gist.github.com/merdmann/6201405

I am using:
gcc version 4.5.4 20120510 for GNAT GPL 2012 (20120509) (GCC) 
Linux hal 3.1.10-1.29-xen #1 SMP Fri May 31 20:10:04 UTC 2013 (2529847) x86_64 x86_64 x86_64 GNU/Linux


Thanx in advance
    Michael







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

* Re: Q: Binding tasks to CPU's seems not to work with Task_Info pragma?!
  2013-08-10 17:56 Q: Binding tasks to CPU's seems not to work with Task_Info pragma?! Michael Erdmann
@ 2013-08-10 19:17 ` AdaMagica
  2013-08-10 19:51   ` Michael Erdmann
  0 siblings, 1 reply; 7+ messages in thread
From: AdaMagica @ 2013-08-10 19:17 UTC (permalink / raw)


Pragma Task_Info is not standard Ada. Must be GNAT specific.


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

* Re: Q: Binding tasks to CPU's seems not to work with Task_Info pragma?!
  2013-08-10 19:17 ` AdaMagica
@ 2013-08-10 19:51   ` Michael Erdmann
  2013-08-12 20:34     ` Randy Brukardt
  0 siblings, 1 reply; 7+ messages in thread
From: Michael Erdmann @ 2013-08-10 19:51 UTC (permalink / raw)


On Sat, 10 Aug 2013 12:17:03 -0700, AdaMagica wrote:

> Pragma Task_Info is not standard Ada. Must be GNAT specific.

Yes; it is GNAT specific:

http://gcc.gnu.org/onlinedocs/gnat_rm/Pragma-Task_005fInfo.html


/Michael

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

* Re: Q: Binding tasks to CPU's seems not to work with Task_Info pragma?!
  2013-08-10 19:51   ` Michael Erdmann
@ 2013-08-12 20:34     ` Randy Brukardt
  2013-08-12 21:49       ` Simon Wright
  2013-08-13  4:29       ` Michael Erdmann
  0 siblings, 2 replies; 7+ messages in thread
From: Randy Brukardt @ 2013-08-12 20:34 UTC (permalink / raw)


Why are you using that rather than the Ada 2012 pragma (or better yet, 
aspect) CPU?

     task type Task_Type (Id : Ada.Multiprocessors.CPU) is
         pragma Priority(4);
         pragma CPU(Id);
      end Task_Type;

or better still:

     task type Task_Type (Id : Ada.Multiprocessors.CPU)
       with Priority => 4, CPU => Id is
     end Task_Type;

                             Randy.

"Michael Erdmann" <michael.erdmann@snafu.de> wrote in message 
news:520699bb$0$2256$afc38c87@news6.united-newsserver.de...
> On Sat, 10 Aug 2013 12:17:03 -0700, AdaMagica wrote:
>
>> Pragma Task_Info is not standard Ada. Must be GNAT specific.
>
> Yes; it is GNAT specific:
>
> http://gcc.gnu.org/onlinedocs/gnat_rm/Pragma-Task_005fInfo.html
>
>
> /Michael
> 




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

* Re: Q: Binding tasks to CPU's seems not to work with Task_Info pragma?!
  2013-08-12 20:34     ` Randy Brukardt
@ 2013-08-12 21:49       ` Simon Wright
  2013-08-13  4:29       ` Michael Erdmann
  1 sibling, 0 replies; 7+ messages in thread
From: Simon Wright @ 2013-08-12 21:49 UTC (permalink / raw)


"Randy Brukardt" <randy@rrsoftware.com> writes:

> Why are you using that [pragma Task_Info] rather than the Ada 2012
> pragma (or better yet, aspect) CPU?

Especially since GNAT's pragma Task_Info is OS-specific: on Mac OS X you
can only specify whether a task will contend with all threads or just
threads in the same process.


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

* Re: Q: Binding tasks to CPU's seems not to work with Task_Info pragma?!
  2013-08-12 20:34     ` Randy Brukardt
  2013-08-12 21:49       ` Simon Wright
@ 2013-08-13  4:29       ` Michael Erdmann
  2013-08-13  5:15         ` Jeffrey Carter
  1 sibling, 1 reply; 7+ messages in thread
From: Michael Erdmann @ 2013-08-13  4:29 UTC (permalink / raw)


On Mon, 12 Aug 2013 15:34:58 -0500, Randy Brukardt wrote:

> Why are you using that rather than the Ada 2012 pragma (or better yet, 
> aspect) CPU?
I did not now it; GPS does not show this Pargma; anyway the following
construct

     task type Task_Type( id : Natural ) with CPU => CPU_Range(Id) ;
      type Task_Access is access all Task_Type;

      task body Task_Type is 
      begin
 
         while true loop
            null;
         end loop;
         
         Put_Line("Terminated");
      end;

yields constant the utilization below:

Cpu0  :100.0%us,  0.0%sy,  0.0%ni,  0.0%id,  0.0%wa,  0.0%hi,  0.0%si,  0.0%st
Cpu1  :100.0%us,  0.0%sy,  0.0%ni,  0.0%id,  0.0%wa,  0.0%hi,  0.0%si,  0.0%st
Cpu2  :100.0%us,  0.0%sy,  0.0%ni,  0.0%id,  0.0%wa,  0.0%hi,  0.0%si,  0.0%st
Cpu3  :100.0%us,  0.0%sy,  0.0%ni,  0.0%id,  0.0%wa,  0.0%hi,  0.0%si,  0.0%st
Cpu4  :  0.0%us,  0.0%sy,  0.0%ni,100.0%id,  0.0%wa,  0.0%hi,  0.0%si,  0.0%st
Cpu5  :  0.0%us,  0.0%sy,  0.0%ni,100.0%id,  0.0%wa,  0.0%hi,  0.0%si,  0.0%st
Cpu6  :  0.0%us,  0.0%sy,  0.0%ni, 99.7%id,  0.0%wa,  0.0%hi,  0.0%si,  0.3%st
Cpu7  :  0.0%us,  0.3%sy,  0.0%ni, 99.7%id,  0.0%wa,  0.0%hi,  0.0%si,  0.0%st
Mem:   3981796k total,   738592k used,  3243204k free,      860k buffers

Thanxs
   /Michael



> 
>      task type Task_Type (Id : Ada.Multiprocessors.CPU) is
>          pragma Priority(4);
>          pragma CPU(Id);
>       end Task_Type;
> 
> or better still:
> 
>      task type Task_Type (Id : Ada.Multiprocessors.CPU)
>        with Priority => 4, CPU => Id is
>      end Task_Type;
> 
>                              Randy.
> 
> "Michael Erdmann" <michael.erdmann@snafu.de> wrote in message 
> news:520699bb$0$2256$afc38c87@news6.united-newsserver.de...
>> On Sat, 10 Aug 2013 12:17:03 -0700, AdaMagica wrote:
>>
>>> Pragma Task_Info is not standard Ada. Must be GNAT specific.
>>
>> Yes; it is GNAT specific:
>>
>> http://gcc.gnu.org/onlinedocs/gnat_rm/Pragma-Task_005fInfo.html
>>
>>
>> /Michael
>>



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

* Re: Q: Binding tasks to CPU's seems not to work with Task_Info pragma?!
  2013-08-13  4:29       ` Michael Erdmann
@ 2013-08-13  5:15         ` Jeffrey Carter
  0 siblings, 0 replies; 7+ messages in thread
From: Jeffrey Carter @ 2013-08-13  5:15 UTC (permalink / raw)


On 08/12/2013 09:29 PM, Michael Erdmann wrote:
>
>           while true loop
>              null;
>           end loop;

In Ada, we say

loop
    null;
end loop;

-- 
Jeff Carter
"I wave my private parts at your aunties."
Monty Python & the Holy Grail
13


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

end of thread, other threads:[~2013-08-13  5:15 UTC | newest]

Thread overview: 7+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2013-08-10 17:56 Q: Binding tasks to CPU's seems not to work with Task_Info pragma?! Michael Erdmann
2013-08-10 19:17 ` AdaMagica
2013-08-10 19:51   ` Michael Erdmann
2013-08-12 20:34     ` Randy Brukardt
2013-08-12 21:49       ` Simon Wright
2013-08-13  4:29       ` Michael Erdmann
2013-08-13  5:15         ` Jeffrey Carter

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox