Re: It Hurts When I Do This



glen herrmannsfeldt wrote:

Certainly there is a test, which will presumably take a finite time. But
I don't see why the amount of time should be significant. Seems like it
ought to be a relatively fast test. I find it hard to image that being
very significant in the compared to an array assignment of even a
modest-sized array, much less a large one as might be most likely to use
allocatable.

I would say one to see that it is already allocated and one for
each dimension (rank). Conditional branches are considered expensive
these days, though, unless branch prediction works properly for them.
If the compiler doesn't know, it has to put the check in even for small
arrays that are inside deeply nested loops. If (:) is the official
"don't reallocate" operator then one can avoid that.

You have to check the upper and lower bounds of each dimension, and this is potentially a lot of conditional branches and a lot of intermediate language that makes life harder for the optimization phases. At least that's how it's currently implemented. Being an old libraries guy (I used to do compiler run-time libraries before working on compilers themselves), I'd have suggested moving this code to a library routine - just pass it the descriptors of the LHS and RHS. Indeed, we're starting to do that in similar cases and maybe will end up doing it here too.

But adding a library routine isn't without cost - it creates support headaches (see below) when users try to link objects with older libraries. This is an issue I have seen come up many times over the past 30 years. While we don't promise backward compatibility of objects, the reality is that such compatibility matters to many customers and we try not to break it without a really good reason.

In the interest of full disclosure, I no longer write compilers - I'm now on the support side. I was a compiler developer for 15 years (and a libraries developer for 10 before that). But I do still sit with the developers and we talk a lot about issues like this.
--

Steve Lionel
Developer Products Division
Intel Corporation
Nashua, NH

For email address, replace "invalid" with "com"

User communities for Intel Software Development Products
http://softwareforums.intel.com/
Intel Fortran Support
http://support.intel.com/support/performancetools/fortran
My Fortran blog
http://www.intel.com/software/drfortran
.



Relevant Pages

  • Re: Idea: Multitasking graphical OS for the GS
    ... IIgs 65816 compiler that has nearly the number of ... gcc also has a much larger support infrastructure where it will be easier to ... The software developer and the hardware ...
    (comp.sys.apple2)
  • Re: Who uses clapack?
    ... > with it and has a compatible compiler send me a line. ... wrapper for the BLAS/LAPACK or Intel MKL libraries. ... claim only to support a subset of the BLAS/LAPACK functionality (though ... I also support all of the ...
    (sci.math.num-analysis)
  • On User Defined Functions and OO
    ... nor was I ever a "compiler developer" (or even a run-time ... I know COBOL for its "externals". ... Now, when it comes to RUN-TIME support for these, there is a lot more than ...
    (comp.lang.cobol)
  • VS2005 #import "mytypelib.tlb" no_registry fails to find dependency
    ... files compile and output there respective TLB files. ... Now I noticed that the VS2005 C++ compiler now includes some new ... another developer the type libraries without requiring him/her to ...
    (microsoft.public.vc.atl)
  • Re: [FAQ] mini-FAQ V1.68 - essential reading for those new to the newsgroup
    ... Free Pascal is a 32/64 Object Pascal Compiler ... existing libraries, and a large set of non-visual classes in the ... The compiler is licensed under the GNU General Public License. ... incomplete support for Linux. ...
    (comp.lang.pascal.borland)

Loading