[prev in list] [next in list] [prev in thread] [next in thread] 

List:       gcc-fortran
Subject:    Re: preprocessor macro vs. contained function: performance with array-valued arguments
From:       Arjen Markus <arjen.markus895 () gmail ! com>
Date:       2012-04-24 11:19:20
Message-ID: CAMCbSMpRjFLbGms0GoDmu0-Onu4xC3hZUMoWPj3i06SWvKUWyA () mail ! gmail ! com
[Download RAW message or body]

Hi Sylwester,

now that is great! The folkore has it that they can be slower than an
ordinary routine/function, but in this case you avoid any copying into
and out of temporary arrays (if that is indeed the cause, of course).

AIUI, elemental functions and subroutines are meant to avoid the problem
that a function may be applied to arrays of any number of dimensions
but without elemental functions you would have to supply a version for
each rank you want to support.

They were introduced in Fortran 95 to alleviate that problem - the intrinsic
functions (sin, cos, ...) could already do that in Fortran 90.

Regards,

Arjen

2012/4/24 Sylwester Arabas <sarabas@igf.fuw.edu.pl>:
> Hi Arjen,

>> One other thought: have you tried an elemental function?
>
> Never heard of them before, but apparently that's the right answer:
>
> $ ./a.out
> =A0func =A00.58931798
> =A0mcro =A00.55261207
>
> Thanks a lot!!
> Regards,
> Sylwester
>
> --
[prev in list] [next in list] [prev in thread] [next in thread] 

Configure | About | News | Add a list | Sponsored by KoreLogic