comp.lang.ada
 help / color / mirror / Atom feed
From: Craig Carey <research@ada95.ijs.com>
Subject: Re: Making a package safe for use by multiple tasks
Date: Sat, 08 Jun 2002 13:14:00 GMT
Date: 2002-06-08T13:14:00+00:00	[thread overview]
Message-ID: <2tu3gu4cncgni43ljvrqenis1a6n296vt7@4ax.com> (raw)
In-Reply-To: 3D0122FF.F8BD771A@acm.org



On Fri, 07 Jun 2002 21:16:55 GMT, Jeffrey Carter <jrcarter@acm.org>
wrote:

>Using access values like this is dangerous, even without trying to bring
>tasking into the mix. I strongly recommend that you not use access types
>for your vector processing. Once you do that, it is simple to make your
>operations Pure, which makes adding tasking very easy, since you need do
>nothing else.

What is the name of the software and/or compiler, for which that problem
was detected ?. I guess that it is not GNAT 3.14+ in Windows and maybe
not GNAT in some other OSes.


Here is an old comp.lang.ada message of the creator of the thread that 
seems to have maybe significantly better advice:

From: Alexander Boucke (alexb@lufmech.rwth-aachen.de)
Subject: Re: efficient vector/matrix operations in Ada 
Newsgroups: comp.lang.ada
Date: 2001-08-14 01:17:27 PST 
...
>Together with a temporary vector holding all results from sums, this
> leads to equivalent efficiency as using the += operators. You have to
> deal with the overhead due to the garbage collection using controlled
> types, but that is negligible when using large vectors/matrices as in
> typical finite element programs.
...
>package vectors is
...
>  type Vector is new Ada.Finalization.Controlled with private;
...
>  type handled_vector_access is access handled_vector;
>
>  type vector is new ada.finalization.controlled with
>     record
>        the_vector : handled_vector_access;
>     end record;
>
>end vectors;
-----------------

Another message to this thread suggested use of the stack:

On Fri, 07 Jun 2002 15:31:31 +0200, "Dr. Michael Paus"
   <paus@ib-paus.com> wrote:
...
function "+" (left, right : vector) return vector is
>   tmp_vec : vector;
>begin
>    for i in tmp_vec'range loop
>       tmp_vec(i) := left(i) + right(i);
>    end loop;
>    return tmp_vec;
>end "+";
>
>Making tmp_vec a local variable has the following advantages:
>
>- You don't have any problems with tasking (of course the stack size
>   must be big enough to hold this array).


While the stack can be increased, the margin of safety is not especially
obvious. 

Also Ada 95 allows ".all"s to be omitted and hence the fact that access
values are being dereferenced, can be made less explicit and not
clutter up the code. It doesn't seem to be optional.


------------------

Some links to Ada matrix 95 source code doing matrix multiplication:

"Ada95 matrix package" (54KB tar.gz file): Drexel Fusion Laboratory:
   http://dflwww.ece.drexel.edu/research/ada/

Some vector operations in PragmAda (which is a thing going into the new
Ascl source code library, http://ascl.sourceforge.net/ ):
   http://home.earthlink.net/~jrcarter010/pragmarc.htm

Some matrix pivoting source code to solve linear equations:
  http://lglwww.epfl.ch//Team/MW/mw_components.html

Some Ada 95 maths software, simulated annealing:
   http://www.taygeta.com/ada.html , /annealing/simanneal.html

Multiply 2 matrices: http://www.almink.com/school/matrix.html

Bindings to a FORTRAN library:
   http://topo.math.u-psud.fr/~sands/Programs/BLAS/



Craig Carey

Mailing lists: http://www.ijs.co.nz/ada_95.htm





  reply	other threads:[~2002-06-08 13:14 UTC|newest]

Thread overview: 12+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2002-06-07 10:07 Making a package safe for use by multiple tasks Alexander Boucke
2002-06-07 11:11 ` Marc A. Criley
2002-06-07 11:47   ` Alexander Boucke
2002-06-07 13:31 ` Dr. Michael Paus
2002-06-07 13:44   ` Making a package safe for use by multiple tasks (Correction) Dr. Michael Paus
2002-06-07 15:00 ` Making a package safe for use by multiple tasks Ted Dennison
2002-06-07 16:37 ` Georg Bauhaus
2002-06-07 21:16 ` Jeffrey Carter
2002-06-08 13:14   ` Craig Carey [this message]
2002-06-08 13:39     ` Dr. Michael Paus
  -- strict thread matches above, loose matches on Subject: below --
2002-06-07 10:14 Grein, Christoph
2002-06-07 10:29 ` Alexander Boucke
replies disabled

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