Re: ELEMENTAL functions and performance



deltaquattro wrote:
Hi,

I would like to know if the attribute ELEMENTAL for a function/
subroutine can negatively affect performance or not.

I am going to code a lot of small functions, for things like Jacobi
polynomial evalution, Gauss point generation, etc. etc., to be used in
a "huge" code. I would like the functions to work for scalar as well
as for rank-1 array input/output. I'd prefer to write them as
ELEMENTAL, rather than forcing the user to read/write a scalar into a
rank-1 array of size 1 each time he has to use the subroutine for
scalars.
However, sometimes I heard that some "new" features of the language
may have an hit on performance, because they make optimization more
difficult for the compiler. I don't know if this is the case with
ELEMENTAL, however these functions will be called a lot of times, so
it's not a good idea if they are slow. The code will run on parallel
vectorial supercomputers. According to these informations, what would
you suggest me to do?
Thanks,

Hi,

I can't tell what your compiler does, but if you call the ELEMENTAL function on scalars I think it is quite probable that ELEMENTAL or not ELEMENTAL does not matter in this case (except that ELEMENTAL procedures have to be PURE for your point of view).

When called with an array argument, your ELEMENTAL procedure will be called for each element as opposed to when your procedure accepts the whole array for one call, and thus here's the possiblity that the performance changes; but I don't think you can really know in advance if it improves or degrades and how much; that probably depends on your code and how your compiler interprets it.

Yours,
Daniel

--
Done: Arc-Bar-Sam-Val-Wiz, Dwa-Elf-Gno-Hum-Orc, Law-Neu-Cha, Fem-Mal
Underway: Cav-Dwa-Law-Fem
To go: Cav-Hea-Kni-Mon-Pri-Ran-Rog-Tou
.



Relevant Pages

  • Re: ELEMENTAL functions and performance
    ... subroutine can negatively affect performance or not. ... I would like the functions to work for scalar as well ... as for rank-1 array input/output. ...
    (comp.lang.fortran)
  • Re: ELEMENTAL functions and performance
    ... subroutine can negatively affect performance or not. ... I would like the functions to work for scalar as well ... as for rank-1 array input/output. ...
    (comp.lang.fortran)
  • Re: reference to a hash
    ... understand why you have to pass the check_items_for_all subroutine a ... Why can't you just pass it the hash itself... ... Subroutines take arguments in scalar context. ...
    (perl.beginners)
  • Re: Scalar or array argument - How to on MODULE?
    ... program the variable is scalar but the argument, in a subroutine, is ... if not all compilers but it's still an error; ... no chance to catch when files are compiled separately w/ no interface ...
    (comp.lang.fortran)
  • Call sub with substiuted args
    ... My problem is I need to call a subroutine but the number of args can be ... template and capture the data from the template into a scalar and then ...
    (comp.lang.perl)