Intel® Fortran Compiler
Build applications that can scale for the future with optimized code designed for Intel® Xeon® and compatible processors.
28543 Discussions

Wrong results using multirank coindexed object as MATMUL actual argument

NCarlson
New Contributor I
670 Views

This small example exposes an error with the executable code for a MATMUL reference when one of its actual arguments is a multirank coindexed object.  The example compares the result of that MATMUL with the value computed by first assigning the coindexed object to a local array and passing it instead. The error occurs for both ifort 2021.9 and ifx 2023.1

 

Judging from the output, I suspect that in the first case MATMUL is being handed the transpose

of the matrix by mistake (e.g., by mistaking the column-major data for row-major)

 

 

$ ifort -coarray -coarray-num-images=2 bug.f90
$ ./a.out
 error on image 1
 c1= 2.000000 4.000000 6.000000 8.000000
 c2= 4.000000 2.000000 8.000000 6.000000

 

real :: a(2,2), b(2,2)[*], c1(2,2), c2(2,2), tmp(2,2)
a = reshape([0,1,1,0], shape=[2,2])
b = this_image()*reshape([1,2,3,4], shape=[2,2])
sync all
if (this_image() < num_images()) then
  c1 = matmul(a, b(:,:)[this_image()+1]) ! EXCHANGES ROWS OF B
  tmp = b(:,:)[this_image()+1]
  c2 = matmul(a, tmp)
  if (any(c1 /= c2)) then
    print *, 'error on image', this_image()
    print *, 'c1=', c1
    print *, 'c2=', c2
    error stop
  end if
end if
end

 

 

 

 

  

6 Replies
NCarlson
New Contributor I
661 Views

@NCarlson wrote:

[...]

Judging from the output, I suspect that in the first case MATMUL is being handed the transpose

of the matrix by mistake (e.g., by mistaking the column-major data for row-major)

Scratch that.  I have no idea what it's doing.

0 Kudos
NCarlson
New Contributor I
651 Views

I forgot to add that this error seems to be specific to the MATMUL intrinsic.  If that function is replaced by a user-written function, its dummy array receives the correct matrix from the coindexed actual argument.

0 Kudos
Barbara_P_Intel
Employee
609 Views

Just to confirm, what is the expected output? I suspect there should be no output.

 

0 Kudos
NCarlson
New Contributor I
606 Views

C2 is the correct result, but yes, there should be no output.

0 Kudos
Barbara_P_Intel
Employee
602 Views

It's so great when you guys supply simple reproducers!

I filed a bug on this, CMPLRLLVM-48376. I'll let you know when I know more.


Barbara_P_Intel
Employee
399 Views

@NCarlson, I just compiled and ran your reproducer with the versions of ifx and ifort that were released this week. I have NO output!

Please check out these new versions!


Reply