comp.lang.ada
 help / color / mirror / Atom feed
From: "William B. Clodius" <wclodius@lanl.gov>
Subject: Re: Matrix Multiplication
Date: 1999/12/15
Date: 1999-12-15T22:10:17+00:00	[thread overview]
Message-ID: <385811C8.1E138A9E@lanl.gov> (raw)
In-Reply-To: 8390te$ksp$1@nnrp1.deja.com



Ted Dennison wrote:
> 
> In article <3857E220.26AE90BB@lanl.gov>,
>   "William B. Clodius" <wclodius@lanl.gov> wrote:
> > numerics question where the types are determined statically and
> > generally map to the equivalent hardware operations. In this case a
> > common performance difference between languages is the extent to which
> > the language can rely on local analyses for its optimizations, which
> > in turn mostly depends on the aliasing properties of entities in the
> > language, which in turn is most strongly influenced by the properties
> > of the arguments to procedures. In this case Ada has relatively loose
> > rules compared to some other languages, e.g., C/C++, but stronger
> > rules than Fortran, so that Ada is in principle harder to optimize
> > than Fortran. However, the difference between Fortran and Ada in this
> 
> That is a fairly accurate principle. So why did I end up finding so many
> "Ada could do better situations"? You may ask. Well there are two issues
> you missed in the above:
>   1)  In general, the more information a compiler has about the possible
> values of objects, the better it can optimize. That gives strongly typed
> languages an advantage. You may turn off the runtime checking, but the
> compiler can still assume the values will never exceed that range for
> code generation purposes.
> 
> For instance, a big issue is how much information about the possible
> values of the iteration variables the compiler has access to. The
> ability of an Ada developer to constrain his index types using subtypes
> potentially gives the compiler a trememdous boost here.

Yes it is a win, but I don't know how big a win it is compared to the
requirement in both Ada and Fortran that indexing outside the visible
indices of the array is illegal. I would expect that in the vast
majority of cases, both assumptions are equivalent. Of course what I
expect might not be what I would find.

> 
>   2)  You ignore non-local optimization issues. That's fair enough. But
> in their quest for more speed, researchers are delving into non-local
> optimizations. Ada's strong typing drasticly reduces the possible access
> paths the optimizer has to worry about for a location or value. Also, a
> lot of the language was written to allow compilers leeway in optimizing.
> For example, users aren't allowed to make assumptions about the
> parameter passing method used for subroutines except in certain
> situations. Generally the more information and freedom a compiler has at
> its disposal, the easier it will be for it to optimize.

I did not discuss non-local optimization issues, but one of your
arguments in favor of such optimizations for Ada, "users aren't allowed
to make assumptions about the parameter passing method used for
subroutines except in certain situations" is even more an argument in
favor of Fortran, which allows even fewer assumptions. That is precisely
what I meant by Ada having even stronger aliasing rules than Fortran for
arguments to its procedures. If I remember correctly, Ada requires
either copy-in/copy-out or call by reference semantics by the compiler
(without specifying the choice made) in most contexts, while Fortran
requires that code allow either copy-in/copy-out or call by reference
implementation, but does not require that the actual implementation be
consistent with either semantics, i.e. at arbitrary points in the
procedure arguments can be copied-in/copied-out without synchronizing
with other copy-ins/copy-outs. The other argument about strong typing is
not a strong argument against Fortran, as by almost any definition
Fortran is strongly typed (albeit some aspects of its typing are error
prone, e.g., implicit typing).

A better argument might be that Ada has better dataflow control
constructs than Fortran 77 and 66 (and in some aspects better than
Fortran 90, though WHERE and the more recent FORALL have their
advantages), but I don't know how strong an argument that is given that
reputedly most compilers use intermediate forms that replace those
constructs by their unstructured equivalents.

One reason I did not bring up non-local optimization is that for some
languages important cases of such optimizations are known to be NP hard
in the general case, e.g., C argument aliasing in the absence of C99's
restrict. I do not know how pertinent that is for Ada vs Fortran.

An additional problem in this discussion is that some compilers may have
a switch that in effect implements: this code has additional semantics
not specified by the standard. 

> <snip>




  reply	other threads:[~1999-12-15  0:00 UTC|newest]

Thread overview: 41+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
1999-12-14  0:00 Matrix Multiplication William Dale
1999-12-14  0:00 ` Gautier
     [not found]   ` <5l1f5s4kck891a2s6o8bhvkirm4q79hm6c@4ax.com>
1999-12-15  0:00     ` Gautier
1999-12-15  0:00       ` Marin D. Condic
1999-12-15  0:00         ` Ted Dennison
1999-12-15  0:00           ` Gautier
1999-12-15  0:00             ` Tucker Taft
1999-12-16  0:00             ` Ted Dennison
1999-12-16  0:00             ` Ted Dennison
1999-12-15  0:00         ` Gautier
1999-12-16  0:00           ` Marin D. Condic
1999-12-27  0:00             ` Jeffrey L Straszheim
1999-12-15  0:00   ` Gautier
1999-12-14  0:00 ` David C. Hoos, Sr.
1999-12-15  0:00 ` Greg Lindahl
1999-12-15  0:00   ` Preben Randhol
1999-12-15  0:00 ` E. Robert Tisdale
     [not found]   ` <3856FD3F.8291A71C@ucar.edu>
1999-12-15  0:00     ` E. Robert Tisdale
1999-12-14  0:00       ` Richard Maine
1999-12-15  0:00 ` Ted Dennison
1999-12-15  0:00   ` William B. Clodius
1999-12-15  0:00     ` Ted Dennison
1999-12-15  0:00       ` William B. Clodius [this message]
1999-12-16  0:00         ` Robert A Duff
1999-12-16  0:00           ` William B. Clodius
     [not found] ` <01bf4708$99ef98f0$022a6282@dieppe>
1999-12-15  0:00   ` Robert A Duff
1999-12-15  0:00     ` Marin D. Condic
1999-12-16  0:00     ` Dieter Britz
1999-12-16  0:00     ` Pascal Obry
1999-12-16  0:00       ` Greg Martin
1999-12-16  0:00       ` Brian Rogoff
1999-12-15  0:00   ` Gautier
  -- strict thread matches above, loose matches on Subject: below --
1999-12-15  0:00 Carlisle, Martin
1999-12-15  0:00 ` Mario Klebsch
1999-12-19  0:00   ` Robert Dewar
1999-12-19  0:00 ` Robert Dewar
1999-12-19  0:00 ` Robert Dewar
1999-12-16  0:00 Carlisle, Martin
1999-12-16  0:00 ` Howard W. LUDWIG
     [not found] <637de084-0e71-4077-a1c5-fc4200cad3cf@googlegroups.com>
2012-07-10  8:39 ` Does Ada need elemental functions to make it suitable for scientific work? Nasser M. Abbasi
2012-07-10  9:07   ` Dmitry A. Kazakov
2012-07-12  0:31     ` robin.vowels
2012-07-12  7:12       ` Dmitry A. Kazakov
2012-07-29 13:39         ` Robin Vowels
2012-07-29 14:22           ` Dmitry A. Kazakov
2012-07-29 20:54             ` glen herrmannsfeldt
     [not found]               ` <apib1897s56dkultqmfl3emvk1os3tfdak@invalid.netcom.com>
2012-07-30  4:15                 ` glen herrmannsfeldt
     [not found]                   ` <nfhd181tv9u87mcqfb7rgd8lm48ihr9f4r@invalid.netcom.com>
2012-07-31  8:53                     ` MATRIX MULTIPLICATION Robin Vowels
2012-07-31  9:05                       ` Robin Vowels
replies disabled

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