public inbox for gcc-bugs@sourceware.org
help / color / mirror / Atom feed
* [Bug fortran/53309] New: Unnecessary temporary array creation in subroutine call
@ 2012-05-10 19:47 townsend at astro dot wisc.edu
2013-07-24 19:33 ` [Bug fortran/53309] " tkoenig at gcc dot gnu.org
` (2 more replies)
0 siblings, 3 replies; 4+ messages in thread
From: townsend at astro dot wisc.edu @ 2012-05-10 19:47 UTC (permalink / raw)
To: gcc-bugs
http://gcc.gnu.org/bugzilla/show_bug.cgi?id=53309
Bug #: 53309
Summary: Unnecessary temporary array creation in subroutine
call
Classification: Unclassified
Product: gcc
Version: 4.7.1
Status: UNCONFIRMED
Severity: normal
Priority: P3
Component: fortran
AssignedTo: unassigned@gcc.gnu.org
ReportedBy: townsend@astro.wisc.edu
Created attachment 27367
--> http://gcc.gnu.org/bugzilla/attachment.cgi?id=27367
Example program
I'm encountering a situation where an unnecessary array is being created when
passing an assumed-shape dummy argument as the argument to a routine without an
explicit interface.
The attached example program illustrates the problem; when compiled with
-Warray-temporaries, I get the warning:
test_array_temp.f90:19.25:
call sub_set_a(3, 3, a)
1
Warning: Creating array temporary at (1)
At compile time, there is no way of determining whether a is contiguous, and so
it would seem an array temporary is necessary. However, is it possible to do a
*runtime* check on whether a is contiguous, and if so avoid the copy? Intel
Fortran seems to manage this.
BTW, this issue arises when calling many of the LAPACK and BLAS routines from
Fortran 9x; it seems array temporaries are being created all over the place,
doubtless with a performance impact.
^ permalink raw reply [flat|nested] 4+ messages in thread
* [Bug fortran/53309] Unnecessary temporary array creation in subroutine call
2012-05-10 19:47 [Bug fortran/53309] New: Unnecessary temporary array creation in subroutine call townsend at astro dot wisc.edu
@ 2013-07-24 19:33 ` tkoenig at gcc dot gnu.org
2013-07-24 23:11 ` burnus at gcc dot gnu.org
2013-07-24 23:14 ` townsend at astro dot wisc.edu
2 siblings, 0 replies; 4+ messages in thread
From: tkoenig at gcc dot gnu.org @ 2013-07-24 19:33 UTC (permalink / raw)
To: gcc-bugs
http://gcc.gnu.org/bugzilla/show_bug.cgi?id=53309
--- Comment #1 from Thomas Koenig <tkoenig at gcc dot gnu.org> ---
The runtime test is done by _gfortran_internal_pack. -Warray-temporaries
creates the warning if this is called.
If you want to know if a temporary has actually been created,
use -fcheck-array-temporaries.
Does this answer your concern?
^ permalink raw reply [flat|nested] 4+ messages in thread
* [Bug fortran/53309] Unnecessary temporary array creation in subroutine call
2012-05-10 19:47 [Bug fortran/53309] New: Unnecessary temporary array creation in subroutine call townsend at astro dot wisc.edu
2013-07-24 19:33 ` [Bug fortran/53309] " tkoenig at gcc dot gnu.org
@ 2013-07-24 23:11 ` burnus at gcc dot gnu.org
2013-07-24 23:14 ` townsend at astro dot wisc.edu
2 siblings, 0 replies; 4+ messages in thread
From: burnus at gcc dot gnu.org @ 2013-07-24 23:11 UTC (permalink / raw)
To: gcc-bugs
http://gcc.gnu.org/bugzilla/show_bug.cgi?id=53309
Tobias Burnus <burnus at gcc dot gnu.org> changed:
What |Removed |Added
----------------------------------------------------------------------------
Status|UNCONFIRMED |RESOLVED
CC| |burnus at gcc dot gnu.org
Depends on| |57959
Resolution|--- |WORKSFORME
--- Comment #2 from Tobias Burnus <burnus at gcc dot gnu.org> ---
Let's close this as WONTFIX.
-Warray-temporaries warns if the compiler adds code for temporaries. In case of
actual arguments, there is a run-time check, which only does the
copy-in/copy-out if the variable is noncontiguous.
As Thomas wrote, you can use -fcheck-array-temporaries which prints at runtime
a warning if the copy-in/copy-out actually happened.
If the compiler knows that the actual argument is contiguous, it can avoid the
copy-in altogether. For your example, simply mark the dummy argument "a" of
sub_wrap as CONTIGUOUS (or use an explicit/assumed-size array instead).
^ permalink raw reply [flat|nested] 4+ messages in thread
* [Bug fortran/53309] Unnecessary temporary array creation in subroutine call
2012-05-10 19:47 [Bug fortran/53309] New: Unnecessary temporary array creation in subroutine call townsend at astro dot wisc.edu
2013-07-24 19:33 ` [Bug fortran/53309] " tkoenig at gcc dot gnu.org
2013-07-24 23:11 ` burnus at gcc dot gnu.org
@ 2013-07-24 23:14 ` townsend at astro dot wisc.edu
2 siblings, 0 replies; 4+ messages in thread
From: townsend at astro dot wisc.edu @ 2013-07-24 23:14 UTC (permalink / raw)
To: gcc-bugs
http://gcc.gnu.org/bugzilla/show_bug.cgi?id=53309
--- Comment #3 from Rich Townsend <townsend at astro dot wisc.edu> ---
Thanks for the explanation about -Warray-temporaries vs.
-fcheck-array-temporaries -- got it!
Might be worth changing the output text from the former to something like
"Warning: Array temporary might be created at (1)"
^ permalink raw reply [flat|nested] 4+ messages in thread
end of thread, other threads:[~2013-07-24 23:14 UTC | newest]
Thread overview: 4+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2012-05-10 19:47 [Bug fortran/53309] New: Unnecessary temporary array creation in subroutine call townsend at astro dot wisc.edu
2013-07-24 19:33 ` [Bug fortran/53309] " tkoenig at gcc dot gnu.org
2013-07-24 23:11 ` burnus at gcc dot gnu.org
2013-07-24 23:14 ` townsend at astro dot wisc.edu
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for read-only IMAP folder(s) and NNTP newsgroup(s).