public inbox for gcc-bugs@sourceware.org
help / color / mirror / Atom feed
* [Bug fortran/60392] Problem with TRANSPOSE and CONTIGUOUS dummy arguments
  2014-03-02 21:45 [Bug fortran/60392] New: Problem with TRANSPOSE and CONTIGUOUS dummy arguments a.vogt at fulguritus dot com
@ 2014-03-02 21:45 ` a.vogt at fulguritus dot com
  2014-03-03  8:57 ` janus at gcc dot gnu.org
                   ` (9 subsequent siblings)
  10 siblings, 0 replies; 12+ messages in thread
From: a.vogt at fulguritus dot com @ 2014-03-02 21:45 UTC (permalink / raw)
  To: gcc-bugs

http://gcc.gnu.org/bugzilla/show_bug.cgi?id=60392

--- Comment #1 from Alexander Vogt <a.vogt at fulguritus dot com> ---
Created attachment 32243
  --> http://gcc.gnu.org/bugzilla/attachment.cgi?id=32243&action=edit
Sample code


^ permalink raw reply	[flat|nested] 12+ messages in thread

* [Bug fortran/60392] New: Problem with TRANSPOSE and CONTIGUOUS dummy arguments
@ 2014-03-02 21:45 a.vogt at fulguritus dot com
  2014-03-02 21:45 ` [Bug fortran/60392] " a.vogt at fulguritus dot com
                   ` (10 more replies)
  0 siblings, 11 replies; 12+ messages in thread
From: a.vogt at fulguritus dot com @ 2014-03-02 21:45 UTC (permalink / raw)
  To: gcc-bugs

http://gcc.gnu.org/bugzilla/show_bug.cgi?id=60392

            Bug ID: 60392
           Summary: Problem with TRANSPOSE and CONTIGUOUS dummy arguments
           Product: gcc
           Version: 4.8.2
            Status: UNCONFIRMED
          Severity: normal
          Priority: P3
         Component: fortran
          Assignee: unassigned at gcc dot gnu.org
          Reporter: a.vogt at fulguritus dot com

When I use the TRANSPOSE intrinsic for function calls where the CONTIGUOUS
statement is set I get wrong results. 

In the attached sample code I have two subroutines that multiply a 3x3 matrix
with another one. One subroutine has the contiguous attribute set for the
input, the other one does not. 

Using gfortran, I get a different result from both calls when the TRANSPOSE
intrinsic is used:

 Normal:       0.0000000000000000     
 Transposed:   6.9428321395983108 

Ifort (14.0.1) shows no deviations. 

I am using 

gfortran -v
Using built-in specs.
COLLECT_GCC=gfortran
COLLECT_LTO_WRAPPER=/usr/libexec/gcc/x86_64-redhat-linux/4.8.2/lto-wrapper
Target: x86_64-redhat-linux
Configured with: ../configure --prefix=/usr --mandir=/usr/share/man
--infodir=/usr/share/info --with-bugurl=http://bugzilla.redhat.com/bugzilla
--enable-bootstrap --enable-shared --enable-threads=posix
--enable-checking=release --with-system-zlib --enable-__cxa_atexit
--disable-libunwind-exceptions --enable-gnu-unique-object
--enable-linker-build-id --with-linker-hash-style=gnu
--enable-languages=c,c++,objc,obj-c++,java,fortran,ada,go,lto --enable-plugin
--enable-initfini-array --enable-java-awt=gtk --disable-dssi
--with-java-home=/usr/lib/jvm/java-1.5.0-gcj-1.5.0.0/jre
--enable-libgcj-multifile --enable-java-maintainer-mode
--with-ecj-jar=/usr/share/java/eclipse-ecj.jar --disable-libjava-multilib
--with-isl=/builddir/build/BUILD/gcc-4.8.2-20131212/obj-x86_64-redhat-linux/isl-install
--with-cloog=/builddir/build/BUILD/gcc-4.8.2-20131212/obj-x86_64-redhat-linux/cloog-install
--with-tune=generic --with-arch_32=i686 --build=x86_64-redhat-linux
Thread model: posix
gcc version 4.8.2 20131212 (Red Hat 4.8.2-7) (GCC)


^ permalink raw reply	[flat|nested] 12+ messages in thread

* [Bug fortran/60392] Problem with TRANSPOSE and CONTIGUOUS dummy arguments
  2014-03-02 21:45 [Bug fortran/60392] New: Problem with TRANSPOSE and CONTIGUOUS dummy arguments a.vogt at fulguritus dot com
  2014-03-02 21:45 ` [Bug fortran/60392] " a.vogt at fulguritus dot com
@ 2014-03-03  8:57 ` janus at gcc dot gnu.org
  2014-03-05 20:39 ` mikael at gcc dot gnu.org
                   ` (8 subsequent siblings)
  10 siblings, 0 replies; 12+ messages in thread
From: janus at gcc dot gnu.org @ 2014-03-03  8:57 UTC (permalink / raw)
  To: gcc-bugs

http://gcc.gnu.org/bugzilla/show_bug.cgi?id=60392

janus at gcc dot gnu.org changed:

           What    |Removed                     |Added
----------------------------------------------------------------------------
           Keywords|                            |wrong-code
                 CC|                            |janus at gcc dot gnu.org

--- Comment #2 from janus at gcc dot gnu.org ---
Confirmed with 4.6 to trunk.

Somewhat modified test case (using integers, 2x2 matrices, functions; without
random numbers):


program test
  implicit none

  integer, dimension(2,2), parameter :: A = reshape ((/1,2,3,4/), (/2,2/))
  integer, dimension(2,2) :: B1, B2

  ! Normal argument
  B1 = my_mul(A,A)
  B2 = my_mul_cont(A,A)
  print *,'Normal:    ',maxval(abs(B1-B2))
  print *,B1
  print *,B2

  ! Transposed argument
  B1 = my_mul(transpose(A),A)
  B2 = my_mul_cont(transpose(A),A)
  print *,'Transposed:',maxval(abs(B1-B2))
  print *,B1
  print *,B2

contains

  function my_mul(A,C) result (B)
    use, intrinsic :: ISO_Fortran_env
    integer, intent(in) :: A(2,2), C(2,2)
    integer :: B(2,2)
    B = matmul(A, C)
  end function

  function my_mul_cont(A,C) result (B)
    use, intrinsic :: ISO_Fortran_env
    integer, intent(in), contiguous :: A(:,:), C(:,:)
    integer :: B(2,2)
    B = matmul(A, C)
  end function

end program


^ permalink raw reply	[flat|nested] 12+ messages in thread

* [Bug fortran/60392] Problem with TRANSPOSE and CONTIGUOUS dummy arguments
  2014-03-02 21:45 [Bug fortran/60392] New: Problem with TRANSPOSE and CONTIGUOUS dummy arguments a.vogt at fulguritus dot com
  2014-03-02 21:45 ` [Bug fortran/60392] " a.vogt at fulguritus dot com
  2014-03-03  8:57 ` janus at gcc dot gnu.org
@ 2014-03-05 20:39 ` mikael at gcc dot gnu.org
  2014-03-05 20:45 ` mikael at gcc dot gnu.org
                   ` (7 subsequent siblings)
  10 siblings, 0 replies; 12+ messages in thread
From: mikael at gcc dot gnu.org @ 2014-03-05 20:39 UTC (permalink / raw)
  To: gcc-bugs

http://gcc.gnu.org/bugzilla/show_bug.cgi?id=60392

Mikael Morin <mikael at gcc dot gnu.org> changed:

           What    |Removed                     |Added
----------------------------------------------------------------------------
             Status|UNCONFIRMED                 |NEW
   Last reconfirmed|                            |2014-03-05
                 CC|                            |mikael at gcc dot gnu.org
     Ever confirmed|0                           |1

--- Comment #3 from Mikael Morin <mikael at gcc dot gnu.org> ---
for both calls (my_mul and my_mul_cont) we create a descriptor for a (with
transposed bounds as expected) and make a call to internal_pack.
After that the calls start to differ.
The pointer returned by internal_pack is passed directly to my_mul.
In the case of my_mul_cont, we have to create a descriptor around the pointer
to pass as argument, and we reuse the one passed to internal_pack, but that one
has the bounds transposed! So we pass the transposed array with transposed
bounds -> we pass the original array.


^ permalink raw reply	[flat|nested] 12+ messages in thread

* [Bug fortran/60392] Problem with TRANSPOSE and CONTIGUOUS dummy arguments
  2014-03-02 21:45 [Bug fortran/60392] New: Problem with TRANSPOSE and CONTIGUOUS dummy arguments a.vogt at fulguritus dot com
                   ` (2 preceding siblings ...)
  2014-03-05 20:39 ` mikael at gcc dot gnu.org
@ 2014-03-05 20:45 ` mikael at gcc dot gnu.org
  2014-03-07 21:01 ` mikael at gcc dot gnu.org
                   ` (6 subsequent siblings)
  10 siblings, 0 replies; 12+ messages in thread
From: mikael at gcc dot gnu.org @ 2014-03-05 20:45 UTC (permalink / raw)
  To: gcc-bugs

http://gcc.gnu.org/bugzilla/show_bug.cgi?id=60392

--- Comment #4 from Mikael Morin <mikael at gcc dot gnu.org> ---
(In reply to Mikael Morin from comment #3)
> So we pass the transposed array with
> transposed bounds -> we pass the original array.

Not exactly in fact:
In my_mul_cont, a.stride[0] == 2 and a.stride[1] == 1.
But a descriptor is created for the matmul call, and that one resets
a.stride[0] to 1, so the descriptor passed to matmul has a.stride[0] == 1 and
a.stride[1] == 1.


^ permalink raw reply	[flat|nested] 12+ messages in thread

* [Bug fortran/60392] Problem with TRANSPOSE and CONTIGUOUS dummy arguments
  2014-03-02 21:45 [Bug fortran/60392] New: Problem with TRANSPOSE and CONTIGUOUS dummy arguments a.vogt at fulguritus dot com
                   ` (3 preceding siblings ...)
  2014-03-05 20:45 ` mikael at gcc dot gnu.org
@ 2014-03-07 21:01 ` mikael at gcc dot gnu.org
  2014-03-07 21:23 ` mikael at gcc dot gnu.org
                   ` (5 subsequent siblings)
  10 siblings, 0 replies; 12+ messages in thread
From: mikael at gcc dot gnu.org @ 2014-03-07 21:01 UTC (permalink / raw)
  To: gcc-bugs

http://gcc.gnu.org/bugzilla/show_bug.cgi?id=60392

--- Comment #5 from Mikael Morin <mikael at gcc dot gnu.org> ---
Created attachment 32307
  --> http://gcc.gnu.org/bugzilla/attachment.cgi?id=32307&action=edit
preliminary patch

This removes the difference between my_mul/my_mul_cont.
However this is not yet correct, with the patch the program output is:

 Normal:               0
           7          10          15          22
           7          10          15          22
 Transposed:           0
           5          11          11          25
           5          11          11          25

and according to maxima (so rather accurate):
  matmul(transpose(a), a) == matrix([10, 14], [14, 20])
and
  matrix([5, 11], [11, 25]) == matmul(a, transpose(a))

So there remains a wrong transposition hiding somewhere.


^ permalink raw reply	[flat|nested] 12+ messages in thread

* [Bug fortran/60392] Problem with TRANSPOSE and CONTIGUOUS dummy arguments
  2014-03-02 21:45 [Bug fortran/60392] New: Problem with TRANSPOSE and CONTIGUOUS dummy arguments a.vogt at fulguritus dot com
                   ` (4 preceding siblings ...)
  2014-03-07 21:01 ` mikael at gcc dot gnu.org
@ 2014-03-07 21:23 ` mikael at gcc dot gnu.org
  2014-03-14 21:30 ` mikael at gcc dot gnu.org
                   ` (4 subsequent siblings)
  10 siblings, 0 replies; 12+ messages in thread
From: mikael at gcc dot gnu.org @ 2014-03-07 21:23 UTC (permalink / raw)
  To: gcc-bugs

http://gcc.gnu.org/bugzilla/show_bug.cgi?id=60392

--- Comment #6 from Mikael Morin <mikael at gcc dot gnu.org> ---
(In reply to Mikael Morin from comment #5)
> This removes the difference between my_mul/my_mul_cont.
> However this is not yet correct, with the patch the program output is:
> 
Maybe it's correct after all.
It's matter of matrix representation in memory.  I never have it right.


^ permalink raw reply	[flat|nested] 12+ messages in thread

* [Bug fortran/60392] Problem with TRANSPOSE and CONTIGUOUS dummy arguments
  2014-03-02 21:45 [Bug fortran/60392] New: Problem with TRANSPOSE and CONTIGUOUS dummy arguments a.vogt at fulguritus dot com
                   ` (5 preceding siblings ...)
  2014-03-07 21:23 ` mikael at gcc dot gnu.org
@ 2014-03-14 21:30 ` mikael at gcc dot gnu.org
  2014-03-14 21:32 ` a.vogt at fulguritus dot com
                   ` (3 subsequent siblings)
  10 siblings, 0 replies; 12+ messages in thread
From: mikael at gcc dot gnu.org @ 2014-03-14 21:30 UTC (permalink / raw)
  To: gcc-bugs

http://gcc.gnu.org/bugzilla/show_bug.cgi?id=60392

--- Comment #8 from Mikael Morin <mikael at gcc dot gnu.org> ---
Fixed on trunk.


^ permalink raw reply	[flat|nested] 12+ messages in thread

* [Bug fortran/60392] Problem with TRANSPOSE and CONTIGUOUS dummy arguments
  2014-03-02 21:45 [Bug fortran/60392] New: Problem with TRANSPOSE and CONTIGUOUS dummy arguments a.vogt at fulguritus dot com
                   ` (6 preceding siblings ...)
  2014-03-14 21:30 ` mikael at gcc dot gnu.org
@ 2014-03-14 21:32 ` a.vogt at fulguritus dot com
  2014-05-23 15:02 ` dominiq at lps dot ens.fr
                   ` (2 subsequent siblings)
  10 siblings, 0 replies; 12+ messages in thread
From: a.vogt at fulguritus dot com @ 2014-03-14 21:32 UTC (permalink / raw)
  To: gcc-bugs

http://gcc.gnu.org/bugzilla/show_bug.cgi?id=60392

--- Comment #9 from Alexander Vogt <a.vogt at fulguritus dot com> ---
Thanks a lot!


^ permalink raw reply	[flat|nested] 12+ messages in thread

* [Bug fortran/60392] Problem with TRANSPOSE and CONTIGUOUS dummy arguments
  2014-03-02 21:45 [Bug fortran/60392] New: Problem with TRANSPOSE and CONTIGUOUS dummy arguments a.vogt at fulguritus dot com
                   ` (7 preceding siblings ...)
  2014-03-14 21:32 ` a.vogt at fulguritus dot com
@ 2014-05-23 15:02 ` dominiq at lps dot ens.fr
  2015-05-16  9:37 ` tkoenig at gcc dot gnu.org
  2015-05-16  9:45 ` a.vogt at fulguritus dot com
  10 siblings, 0 replies; 12+ messages in thread
From: dominiq at lps dot ens.fr @ 2014-05-23 15:02 UTC (permalink / raw)
  To: gcc-bugs

https://gcc.gnu.org/bugzilla/show_bug.cgi?id=60392

Dominique d'Humieres <dominiq at lps dot ens.fr> changed:

           What    |Removed                     |Added
----------------------------------------------------------------------------
      Known to work|                            |4.10.0, 4.9.0
      Known to fail|                            |4.7.4, 4.8.3

--- Comment #10 from Dominique d'Humieres <dominiq at lps dot ens.fr> ---
> Fixed on trunk.

Any plan to back port the fix for 4.8.4? If needed I can do it.


^ permalink raw reply	[flat|nested] 12+ messages in thread

* [Bug fortran/60392] Problem with TRANSPOSE and CONTIGUOUS dummy arguments
  2014-03-02 21:45 [Bug fortran/60392] New: Problem with TRANSPOSE and CONTIGUOUS dummy arguments a.vogt at fulguritus dot com
                   ` (8 preceding siblings ...)
  2014-05-23 15:02 ` dominiq at lps dot ens.fr
@ 2015-05-16  9:37 ` tkoenig at gcc dot gnu.org
  2015-05-16  9:45 ` a.vogt at fulguritus dot com
  10 siblings, 0 replies; 12+ messages in thread
From: tkoenig at gcc dot gnu.org @ 2015-05-16  9:37 UTC (permalink / raw)
  To: gcc-bugs

https://gcc.gnu.org/bugzilla/show_bug.cgi?id=60392

Thomas Koenig <tkoenig at gcc dot gnu.org> changed:

           What    |Removed                     |Added
----------------------------------------------------------------------------
                 CC|                            |tkoenig at gcc dot gnu.org
      Known to work|4.10.0                      |5.0

--- Comment #11 from Thomas Koenig <tkoenig at gcc dot gnu.org> ---
I don't think backporting to 4.8 is necessary any more.

Time to close?


^ permalink raw reply	[flat|nested] 12+ messages in thread

* [Bug fortran/60392] Problem with TRANSPOSE and CONTIGUOUS dummy arguments
  2014-03-02 21:45 [Bug fortran/60392] New: Problem with TRANSPOSE and CONTIGUOUS dummy arguments a.vogt at fulguritus dot com
                   ` (9 preceding siblings ...)
  2015-05-16  9:37 ` tkoenig at gcc dot gnu.org
@ 2015-05-16  9:45 ` a.vogt at fulguritus dot com
  10 siblings, 0 replies; 12+ messages in thread
From: a.vogt at fulguritus dot com @ 2015-05-16  9:45 UTC (permalink / raw)
  To: gcc-bugs

https://gcc.gnu.org/bugzilla/show_bug.cgi?id=60392

Alexander Vogt <a.vogt at fulguritus dot com> changed:

           What    |Removed                     |Added
----------------------------------------------------------------------------
             Status|NEW                         |RESOLVED
         Resolution|---                         |FIXED

--- Comment #12 from Alexander Vogt <a.vogt at fulguritus dot com> ---
I don't think that is necessary... Thanks anyway!


^ permalink raw reply	[flat|nested] 12+ messages in thread

end of thread, other threads:[~2015-05-16  9:45 UTC | newest]

Thread overview: 12+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2014-03-02 21:45 [Bug fortran/60392] New: Problem with TRANSPOSE and CONTIGUOUS dummy arguments a.vogt at fulguritus dot com
2014-03-02 21:45 ` [Bug fortran/60392] " a.vogt at fulguritus dot com
2014-03-03  8:57 ` janus at gcc dot gnu.org
2014-03-05 20:39 ` mikael at gcc dot gnu.org
2014-03-05 20:45 ` mikael at gcc dot gnu.org
2014-03-07 21:01 ` mikael at gcc dot gnu.org
2014-03-07 21:23 ` mikael at gcc dot gnu.org
2014-03-14 21:30 ` mikael at gcc dot gnu.org
2014-03-14 21:32 ` a.vogt at fulguritus dot com
2014-05-23 15:02 ` dominiq at lps dot ens.fr
2015-05-16  9:37 ` tkoenig at gcc dot gnu.org
2015-05-16  9:45 ` a.vogt at fulguritus dot com

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).