Newsgroups: comp.theory,comp.lang.scheme,comp.software-eng
Path: cantaloupe.srv.cs.cmu.edu!rochester!cornellcs!newsstand.cit.cornell.edu!newsfeed.cit.cornell.edu!news.tc.cornell.edu!newsserver.sdsc.edu!news.cerf.net!mvb.saic.com!news.mathworks.com!newsfeed.internetmci.com!news.sprintlink.net!mv!usenet
From: ENGR@GSSI.MV.COM (Michael Furman)
Subject: Re: Style: multiple returns and relatives
Message-ID: <DIpMMp.AyE@mv.mv.com>
Mime-Version: 1.0
Organization: GSSI
Date: Mon, 27 Nov 1995 16:18:24 GMT
References: <RMARTIN.95Nov10210926@oma.com> <DIEFEK.7py@mv.mv.com> <1995Nov2119.02.10.16041@silverton.berkeley.edu> <DIEto8.FC3@mv.mv.com> <1995Nov2220.33.12.16907@silverton.berkeley.edu>
X-Newsreader: WinVN 0.93.10
X-Nntp-Posting-Host: gssi.mv.com
Lines: 60
Xref: glinda.oz.cs.cmu.edu comp.theory:14715 comp.lang.scheme:14409 comp.software-eng:39409

In article <1995Nov2220.33.12.16907@silverton.berkeley.edu>, 
djb@silverton.berkeley.edu says...
>
>In article <DIEto8.FC3@mv.mv.com>, Michael Furman <ENGR@GSSI.MV.COM> wrote:
>>     calculating index1 and index2 - it can be a very complicated algoritm
>>     some_function(memory + index1, memory + index2);
>
>My understanding is that such constructs are incorrect in Fortran. No
>aliasing really does mean no aliasing.

   It is incorrect only if there is an aliasing. If not - it is correct. And 
this example can be modified to remove pointers at all - just pass integer
indexes and use big common array. If you know that such code generated from 
Fortran (let's say by F2C) - you can optimize it. If you don't - you can not.
   And it is a contraexample for opinion that there is no problems of "code 
efficiency" for languages but just for compilers.
   There are two (I know of) source of "code efficiency" issue for languages.
First is what this example about: for some language compiler can know at 
compilation time some information that can be uset for optimization. And for 
another language this information can be only calculated at run time.
   For C/C++ this problem (I do not mean it in general, but alissing and 
optimization problem) is known and some compiler vendors use some extentions 
that let programmer (using #pragma or run time compiler switch) declare that 
there is no aliasing in whole program or part of it.
   Second issue - special hardware facilities (special instructions, 
interrupts, registers e.t.c). It related more to real time and OS 
programming, but often it is very important. Unfortunately there is no good 
enough solutions in high level languages - almost always we neeed some 
assembler.


not for Fortran. It was about "effectiveness" of langueges in general. In 
Fortran where aliasing is forbidden you (I mean you can create compiler that 
...)can optimize such code (

>
>There are many good reasons for this restriction. Some vector hardware,
>for example, demands that vectors be stored in different memory lines.
>Are you sure that index1 and index2 are separated by more than the line
>size? Do you even know the line size?
>
>The compiler knows the line size. It can store different arrays on
>different lines. Then it can vectorize. This is safe if you _never_
>use aliases.
>
>> I understand your point but it is true only for some class of programs - 
>> basically without dinamic memory allocation, pointer arithmetic e. t. c.
>
>Correct Fortran code does not engage in that sort of pointer arithmetic.
>
>---Dan

-- 
---------------------------------------------------------------
Michael Furman,                       (603)893-1109
Geophysical Survey Systems, Inc.  fax:(603)889-3984
13 Klein Drive - P.O. Box 97          engr@gssi.mv.com 
North Salem, NH 03073-0097            71543.1334@compuserve.com
---------------------------------------------------------------

