comp.lang.ada
 help / color / mirror / Atom feed
From: Joakim Strandberg <joakimds@kth.se>
Subject: Re: Real_Arrays on heap with overloaded operators and clean syntax
Date: Sun, 22 Jan 2023 15:53:13 -0800 (PST)	[thread overview]
Message-ID: <9a0f1073-efb5-4ab1-89b3-37e86dc1504an@googlegroups.com> (raw)
In-Reply-To: <tqkh64$39v71$4@dont-email.me>

måndag 23 januari 2023 kl. 00:34:31 UTC+1 skrev roda...@gmail.com:
> On 23/1/23 10:20, Jim Paloander wrote: 
> >>> Dear ADA lovers, 
> >>> with stack allocation of Real_Vector ( 1 .. N ) when N >= 100,000 I get STACK_OVERFLOW ERROR while trying to check how fast operator overloading is working for an expression 
> >>> 
> >>> X := A + B + C + C + A + B, where 
> >>> A,B,C,X are all Real_Vector ( 1 .. N ). 
> >>> 
> >>> So my only option was to allocate on the heap using new. But then I lost the clean syntax 
> >>> 
> >>> X := A + B + C + C + A + B 
> >>> 
> >>> and I had to write instead: 
> >>> 
> >>> X.all := A.all + B.all + C.all + C.all + A.all + B.all. 
> >>> 
> >>> This is really ugly and annoying because when you are using Real_Arrays for implementing some linear algebra method who relies heavilly on matrix vector products and vector updates, you do need to allocate on the heap (sizes are determined in runtime) and you do need a clean syntax. So, is there any way to simplify my life without using the .all or even without declaring A,B,C,X as access Real_Vector? 
> >>> Thanks for your time! 
> >> If you are on linux, then you could set the stack size with 
> >> 
> >> $ ulimit -s unlimited 
> >> $ launch_my_app 
> >> 
> >> 
> >> 
> >> Regards. 
> > On Windows 10 with mingw64?
> Not sure. I don't have a windows machine. 
> 
> What happens when try ? 
> 
> $ ulimit -a

Something came up and I had to send my previous reply/e-mail as is. I wanted to find the video where Jean Pierre Rosen talks about how memory is handled in the Ada language from FOSDEM perhaps 2018-2019. Unfortunately I have been unable to find it.

Secondly, example of Ada code where Storage pool usage is demonstrated: https://github.com/joakim-strandberg/advent_of_code

Example of task with rendez-vous mechanism:
task T with Storage_Size => 10_000_000 is
   entry Run (I : Integer);
end T;

task body T is
begin
   loop
       begin
           select
                accept Run (I : Integer) do
                     null;  --  Here save the value of the integer I for later processing in the task
                end Run;
                null;  -- Whenever another task calls Run on this task, the work to be done should be put here.
               -- Put the mathematical calcuations here.
           or
                terminate;  --  To end the select-statement with "or terminate;" means the task will terminate when the environment task has finished execution of the "Main" procedure of the application. No need to tell the task T that now it is time to shutdown.
           end select;
       exception
            when Error : others =>
              -- Print error to standard out here using subprograms from Ada.Exceptions and Ada.Text_IO.
       end;
   end loop;
end T; 

Best regards,
Joakim

  reply	other threads:[~2023-01-22 23:53 UTC|newest]

Thread overview: 34+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2023-01-22 21:34 Real_Arrays on heap with overloaded operators and clean syntax Jim Paloander
2023-01-22 21:56 ` Joakim Strandberg
2023-01-22 22:07   ` Jim Paloander
2023-01-22 22:42     ` Joakim Strandberg
2023-01-22 22:49       ` Jim Paloander
2023-01-22 23:11         ` Joakim Strandberg
2023-01-22 23:14         ` Gautier write-only address
2023-01-23  1:14           ` Leo Brewin
2023-01-23  6:01             ` Jim Paloander
2023-01-23  8:39     ` G.B.
2023-01-22 22:13 ` Dmitry A. Kazakov
2023-01-22 22:36   ` Jim Paloander
2023-01-23  8:28     ` Dmitry A. Kazakov
2023-01-24  1:04       ` Jim Paloander
2023-01-24 10:42         ` J-P. Rosen
2023-01-25  9:52           ` Jim Paloander
2023-01-25 12:21             ` J-P. Rosen
2023-01-25 22:41               ` Gautier write-only address
2023-01-26 19:08                 ` Jim Paloander
2023-01-22 23:18 ` Rod Kay
2023-01-22 23:20   ` Jim Paloander
2023-01-22 23:34     ` Rod Kay
2023-01-22 23:53       ` Joakim Strandberg [this message]
2023-01-23  7:50         ` Egil H H
2023-01-23  8:51           ` J-P. Rosen
2023-01-23  6:34       ` Rod Kay
2023-01-23  6:56         ` Jim Paloander
2023-01-23  7:31           ` Rod Kay
2023-01-24 19:47 ` Gautier write-only address
2023-01-24 23:02   ` Gautier write-only address
2023-01-25  9:50     ` Jim Paloander
2023-01-26 20:39 ` Jerry
2023-01-26 21:52   ` Jim Paloander
2023-02-02 21:59     ` Jerry
replies disabled

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