From mboxrd@z Thu Jan 1 00:00:00 1970 X-Spam-Checker-Version: SpamAssassin 3.4.4 (2020-01-24) on polar.synack.me X-Spam-Level: X-Spam-Status: No, score=-1.9 required=5.0 tests=BAYES_00 autolearn=ham autolearn_force=no version=3.4.4 X-Google-Language: ENGLISH,ASCII-7-bit X-Google-Thread: 103376,9bc0262607f781e9 X-Google-Attributes: gid103376,public X-Google-ArrivalTime: 2002-06-08 06:14:17 PST Path: archiver1.google.com!news1.google.com!newsfeed.stanford.edu!nntp.cs.ubc.ca!cyclone.bc.net!newsfeed.telusplanet.net!peer1-sjc1.usenetserver.com!usenetserver.com!border1.nntp.aus1.giganews.com!nntp.giganews.com!nntp3.aus1.giganews.com!bin4.nnrp.aus1.giganews.com.POSTED!news.clear.net.nz From: Craig Carey Newsgroups: comp.lang.ada Subject: Re: Making a package safe for use by multiple tasks Message-ID: <2tu3gu4cncgni43ljvrqenis1a6n296vt7@4ax.com> References: <3D0122FF.F8BD771A@acm.org> X-Newsreader: Forte Agent 1.9/32.560 MIME-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Transfer-Encoding: 7bit Organization: Customer of Mercury Telecommunications Ltd Cache-Post-Path: drone4.qsi.net.nz!unknown@tnt1-357.quicksilver.net.nz X-Cache: nntpcache 2.4.0b2 (see http://www.nntpcache.org/) X-Original-NNTP-Posting-Host: drone4-svc-skyt.qsi.net.nz X-Original-Trace: 9 Jun 2002 01:12:00 +1200, drone4-svc-skyt.qsi.net.nz NNTP-Posting-Date: Sat, 08 Jun 2002 08:12:09 CDT X-Trace: sv3-sfqGxupACI0GqlDH2z1Ba636VQUP7IoSDAn9JNQA5TAuFNd7SOP2LNUIm2h+3FAOt76ySAyC408fJJG!yJyi7yYAIf5p7DJ8gRB9QB3PrqtKRxuiDkJ/HeTENcC6Kh8zfYXQIL2gfqAQLtJfKOwCmlzAGTTu!KCA6hQ== X-Complaints-To: abuse@GigaNews.Com X-DMCA-Notifications: http://www.giganews.com/info/dmca.html X-Abuse-Info: Please be sure to forward a copy of ALL headers X-Abuse-Info: Otherwise we will be unable to process your complaint properly Date: Sat, 08 Jun 2002 13:14:00 GMT Xref: archiver1.google.com comp.lang.ada:25534 Date: 2002-06-08T13:14:00+00:00 List-Id: On Fri, 07 Jun 2002 21:16:55 GMT, Jeffrey Carter 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" 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