Skip to content

Commit 54e1ffb

Browse files
joewallworkCopilot
andauthored
IFX bugfix (take 3) (#2905)
* Skip second opt step; always require fortran; drop unnecessary loadFortran * Avoid module name collision --------- Co-authored-by: copilot-swe-agent[bot] <198982749+Copilot@users.noreply.github.com>
1 parent a8668c7 commit 54e1ffb

6 files changed

Lines changed: 70 additions & 74 deletions

enzyme/test/Fortran/ForwardMode/allocatableArraySimple_with_bindings.f90

Lines changed: 18 additions & 21 deletions
Original file line numberDiff line numberDiff line change
@@ -1,30 +1,14 @@
1-
! RUN: if [[ %fc != ifx ]]; then %fc -flto -O0 -c %loadFortran %s -o /dev/stdout | %opt %loadEnzyme %enzyme -o /dev/stdout | %opt -O0 -S -o %t.ll && %fc -flto -O0 %t.ll -o %t1 && %t1 | FileCheck %s; fi
2-
! RUN: %fc -flto -O1 -c %loadFortran %s -o /dev/stdout | %opt %loadEnzyme %enzyme -o /dev/stdout | %opt -O1 -S -o %t.ll && %fc -flto -O1 %t.ll -o %t1 && %t1 | FileCheck %s
3-
! RUN: %fc -flto -O2 -c %loadFortran %s -o /dev/stdout | %opt %loadEnzyme %enzyme -o /dev/stdout | %opt -O2 -S -o %t.ll && %fc -flto -O2 %t.ll -o %t1 && %t1 | FileCheck %s
4-
! RUN: %fc -flto -O3 -c %loadFortran %s -o /dev/stdout | %opt %loadEnzyme %enzyme -o /dev/stdout | %opt -O3 -S -o %t.ll && %fc -flto -O3 %t.ll -o %t1 && %t1 | FileCheck %s
1+
! REQUIRES: fortran
2+
! RUN: if [[ %fc != ifx ]]; then %fc -flto -O0 -c %loadFortran %s -o /dev/stdout | %opt %loadEnzyme %enzyme -o %t.ll && %fc -flto -O0 %t.ll -o %t1 && %t1 | FileCheck %s; fi
3+
! RUN: %fc -flto -O1 -c %loadFortran %s -o /dev/stdout | %opt %loadEnzyme %enzyme -o %t.ll && %fc -flto -O1 %t.ll -o %t1 && %t1 | FileCheck %s
4+
! RUN: %fc -flto -O2 -c %loadFortran %s -o /dev/stdout | %opt %loadEnzyme %enzyme -o %t.ll && %fc -flto -O2 %t.ll -o %t1 && %t1 | FileCheck %s
5+
! RUN: %fc -flto -O3 -c %loadFortran %s -o /dev/stdout | %opt %loadEnzyme %enzyme -o %t.ll && %fc -flto -O3 %t.ll -o %t1 && %t1 | FileCheck %s
56

67
! NOTE: This test is only configured to run with the flang compiler at -O0
78
! For it to work with the ifx compiler we will need to figure out how to
89
! handle the indirection involved in the enzyme_fwddiff binding
910

10-
module AD
11-
implicit none
12-
13-
contains
14-
15-
! TODO: Switch to assumed shape implementation once
16-
! https://github.com/EnzymeAD/Enzyme/issues/2820
17-
! has been addressed
18-
subroutine selectFirst(n, x, y)
19-
integer, intent(in) :: n
20-
real, intent(in) :: x(n)
21-
real, intent(inout) :: y
22-
y = x(1)
23-
end subroutine
24-
end module
25-
2611
program app
27-
use AD, only: selectFirst
2812
use enzyme, only: enzyme_const, enzyme_dup, enzyme_fwddiff
2913
implicit none
3014
integer :: n
@@ -48,6 +32,19 @@ program app
4832
print *, int(dx(2))
4933
print *, int(dx(3))
5034
print *, int(dy)
35+
36+
contains
37+
38+
! TODO: Switch to assumed shape implementation once
39+
! https://github.com/EnzymeAD/Enzyme/issues/2820
40+
! has been addressed
41+
subroutine selectFirst(n, x, y)
42+
integer, intent(in) :: n
43+
real, intent(in) :: x(n)
44+
real, intent(inout) :: y
45+
y = x(1)
46+
end subroutine
47+
5148
end program
5249

5350

enzyme/test/Fortran/ForwardMode/allocatableArraySimple_with_explicit_interface.f90

Lines changed: 7 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -1,14 +1,15 @@
1+
! REQUIRES: fortran
12
! REQUIRES: ifx
2-
! RUN: %fc -flto -O0 -c %loadFortran %s -o /dev/stdout | %opt %loadEnzyme %enzyme -o /dev/stdout | %opt -O0 -S -o %t.ll && %fc -flto -O0 %t.ll -o %t1 && %t1 | FileCheck %s
3-
! RUN: %fc -flto -O1 -c %loadFortran %s -o /dev/stdout | %opt %loadEnzyme %enzyme -o /dev/stdout | %opt -O1 -S -o %t.ll && %fc -flto -O1 %t.ll -o %t1 && %t1 | FileCheck %s
4-
! RUN: %fc -flto -O2 -c %loadFortran %s -o /dev/stdout | %opt %loadEnzyme %enzyme -o /dev/stdout | %opt -O2 -S -o %t.ll && %fc -flto -O2 %t.ll -o %t1 && %t1 | FileCheck %s
5-
! RUN: %fc -flto -O3 -c %loadFortran %s -o /dev/stdout | %opt %loadEnzyme %enzyme -o /dev/stdout | %opt -O3 -S -o %t.ll && %fc -flto -O3 %t.ll -o %t1 && %t1 | FileCheck %s
3+
! RUN: %fc -flto -O0 -c %s -o /dev/stdout | %opt %loadEnzyme %enzyme -o %t.ll && %fc -flto -O0 %t.ll -o %t1 && %t1 | FileCheck %s
4+
! RUN: %fc -flto -O1 -c %s -o /dev/stdout | %opt %loadEnzyme %enzyme -o %t.ll && %fc -flto -O1 %t.ll -o %t1 && %t1 | FileCheck %s
5+
! RUN: %fc -flto -O2 -c %s -o /dev/stdout | %opt %loadEnzyme %enzyme -o %t.ll && %fc -flto -O2 %t.ll -o %t1 && %t1 | FileCheck %s
6+
! RUN: %fc -flto -O3 -c %s -o /dev/stdout | %opt %loadEnzyme %enzyme -o %t.ll && %fc -flto -O3 %t.ll -o %t1 && %t1 | FileCheck %s
67

78
! NOTE: This test is only configured to run with the ifx compiler
89
! For it to work with the flang compiler we will need to address
910
! https://github.com/EnzymeAD/Enzyme/issues/2820
1011

11-
module AD
12+
module selectFirstForward
1213
implicit none
1314
interface
1415
subroutine selectFirst__enzyme_fwddiff(fnc, x, dx, y, dy)
@@ -36,7 +37,7 @@ subroutine selectFirst(x, y)
3637
end module
3738

3839
program app
39-
use AD
40+
use selectFirstForward, only: selectFirst, selectFirst__enzyme_fwddiff
4041
implicit none
4142
real, allocatable :: x(:), dx(:)
4243
real :: y, dy

enzyme/test/Fortran/ReverseMode/allocatableArraySimple_with_bindings.f90

Lines changed: 17 additions & 21 deletions
Original file line numberDiff line numberDiff line change
@@ -1,31 +1,14 @@
11
! REQUIRES: fortran
2-
! RUN: if [[ %fc != ifx ]]; then %fc -flto -O0 -c %loadFortran %s -o /dev/stdout | %opt %loadEnzyme %enzyme -o /dev/stdout | %opt -O0 -S -o %t.ll && %fc -flto -O0 %t.ll -o %t1 && %t1 | FileCheck %s; fi
3-
! RUN: %fc -flto -O1 -c %loadFortran %s -o /dev/stdout | %opt %loadEnzyme %enzyme -o /dev/stdout | %opt -O1 -S -o %t.ll && %fc -flto -O1 %t.ll -o %t1 && %t1 | FileCheck %s
4-
! RUN: %fc -flto -O2 -c %loadFortran %s -o /dev/stdout | %opt %loadEnzyme %enzyme -o /dev/stdout | %opt -O2 -S -o %t.ll && %fc -flto -O2 %t.ll -o %t1 && %t1 | FileCheck %s
5-
! RUN: %fc -flto -O3 -c %loadFortran %s -o /dev/stdout | %opt %loadEnzyme %enzyme -o /dev/stdout | %opt -O3 -S -o %t.ll && %fc -flto -O3 %t.ll -o %t1 && %t1 | FileCheck %s
2+
! RUN: if [[ %fc != ifx ]]; then %fc -flto -O0 -c %loadFortran %s -o /dev/stdout | %opt %loadEnzyme %enzyme -o %t.ll && %fc -flto -O0 %t.ll -o %t1 && %t1 | FileCheck %s; fi
3+
! RUN: %fc -flto -O1 -c %loadFortran %s -o /dev/stdout | %opt %loadEnzyme %enzyme -o %t.ll && %fc -flto -O1 %t.ll -o %t1 && %t1 | FileCheck %s
4+
! RUN: %fc -flto -O2 -c %loadFortran %s -o /dev/stdout | %opt %loadEnzyme %enzyme -o %t.ll && %fc -flto -O2 %t.ll -o %t1 && %t1 | FileCheck %s
5+
! RUN: %fc -flto -O3 -c %loadFortran %s -o /dev/stdout | %opt %loadEnzyme %enzyme -o %t.ll && %fc -flto -O3 %t.ll -o %t1 && %t1 | FileCheck %s
66

77
! NOTE: This test is only configured to run with the flang compiler at -O0
88
! For it to work with the ifx compiler we will need to figure out how to
99
! handle the indirection involved in the enzyme_autodiff binding
1010

11-
module AD
12-
implicit none
13-
14-
contains
15-
16-
! TODO: Switch to assumed shape implementation once
17-
! https://github.com/EnzymeAD/Enzyme/issues/2820
18-
! has been addressed
19-
subroutine selectFirst(n, x, y)
20-
integer, intent(in) :: n
21-
real, intent(in) :: x(n)
22-
real, intent(inout) :: y
23-
y = x(1)
24-
end subroutine
25-
end module
26-
2711
program app
28-
use AD, only: selectFirst
2912
use enzyme, only: enzyme_const, enzyme_dup, enzyme_autodiff
3013
implicit none
3114
integer :: n
@@ -49,6 +32,19 @@ program app
4932
print *, int(dx(2))
5033
print *, int(dx(3))
5134
print *, int(dy)
35+
36+
contains
37+
38+
! TODO: Switch to assumed shape implementation once
39+
! https://github.com/EnzymeAD/Enzyme/issues/2820
40+
! has been addressed
41+
subroutine selectFirst(n, x, y)
42+
integer, intent(in) :: n
43+
real, intent(in) :: x(n)
44+
real, intent(inout) :: y
45+
y = x(1)
46+
end subroutine
47+
5248
end program
5349

5450

enzyme/test/Fortran/ReverseMode/allocatableArraySimple_with_explicit_interface.f90

Lines changed: 7 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -1,14 +1,15 @@
1+
! REQUIRES: fortran
12
! REQUIRES: ifx
2-
! RUN: %fc -flto -O0 -c %loadFortran %s -o /dev/stdout | %opt %loadEnzyme %enzyme -o /dev/stdout | %opt -O0 -S -o %t.ll && %fc -flto -O0 %t.ll -o %t1 && %t1 | FileCheck %s
3-
! RUN: %fc -flto -O1 -c %loadFortran %s -o /dev/stdout | %opt %loadEnzyme %enzyme -o /dev/stdout | %opt -O1 -S -o %t.ll && %fc -flto -O1 %t.ll -o %t1 && %t1 | FileCheck %s
4-
! RUN: %fc -flto -O2 -c %loadFortran %s -o /dev/stdout | %opt %loadEnzyme %enzyme -o /dev/stdout | %opt -O2 -S -o %t.ll && %fc -flto -O2 %t.ll -o %t1 && %t1 | FileCheck %s
5-
! RUN: %fc -flto -O3 -c %loadFortran %s -o /dev/stdout | %opt %loadEnzyme %enzyme -o /dev/stdout | %opt -O3 -S -o %t.ll && %fc -flto -O3 %t.ll -o %t1 && %t1 | FileCheck %s
3+
! RUN: %fc -flto -O0 -c %s -o /dev/stdout | %opt %loadEnzyme %enzyme -o %t.ll && %fc -flto -O0 %t.ll -o %t1 && %t1 | FileCheck %s
4+
! RUN: %fc -flto -O1 -c %s -o /dev/stdout | %opt %loadEnzyme %enzyme -o %t.ll && %fc -flto -O1 %t.ll -o %t1 && %t1 | FileCheck %s
5+
! RUN: %fc -flto -O2 -c %s -o /dev/stdout | %opt %loadEnzyme %enzyme -o %t.ll && %fc -flto -O2 %t.ll -o %t1 && %t1 | FileCheck %s
6+
! RUN: %fc -flto -O3 -c %s -o /dev/stdout | %opt %loadEnzyme %enzyme -o %t.ll && %fc -flto -O3 %t.ll -o %t1 && %t1 | FileCheck %s
67

78
! NOTE: This test is only configured to run with the ifx compiler
89
! For it to work with the flang compiler we will need to address
910
! https://github.com/EnzymeAD/Enzyme/issues/2820
1011

11-
module AD
12+
module selectFirstReverse
1213
implicit none
1314
interface
1415
subroutine selectFirst__enzyme_autodiff(fnc, x, dx, y, dy)
@@ -36,7 +37,7 @@ subroutine selectFirst(x, y)
3637
end module
3738

3839
program app
39-
use AD
40+
use selectFirstReverse, only: selectFirst, selectFirst__enzyme_autodiff
4041
implicit none
4142
real, allocatable :: x(:), dx(:)
4243
real :: y, dy

enzyme/test/Fortran/ReverseMode/square_with_bindings.f90

Lines changed: 13 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -1,23 +1,15 @@
1-
! RUN: if [[ %fc != ifx ]]; then %fc -flto -O0 -c %loadFortran %s -o /dev/stdout | %opt %loadEnzyme %enzyme -o /dev/stdout | %opt -O0 -S -o %t.ll && %fc -flto -O0 %t.ll -o %t1 && %t1 | FileCheck %s; fi
2-
! RUN: %fc -flto -O1 -c %loadFortran %s -o /dev/stdout | %opt %loadEnzyme %enzyme -o /dev/stdout | %opt -O1 -S -o %t.ll && %fc -flto -O1 %t.ll -o %t1 && %t1 | FileCheck %s
3-
! RUN: %fc -flto -O2 -c %loadFortran %s -o /dev/stdout | %opt %loadEnzyme %enzyme -o /dev/stdout | %opt -O2 -S -o %t.ll && %fc -flto -O2 %t.ll -o %t1 && %t1 | FileCheck %s
4-
! RUN: %fc -flto -O3 -c %loadFortran %s -o /dev/stdout | %opt %loadEnzyme %enzyme -o /dev/stdout | %opt -O3 -S -o %t.ll && %fc -flto -O3 %t.ll -o %t1 && %t1 | FileCheck %s
1+
! REQUIRES: fortran
2+
! RUN: if [[ %fc != ifx ]]; then %fc -flto -O0 -c %loadFortran %s -o /dev/stdout | %opt %loadEnzyme %enzyme -o %t.ll && %fc -flto -O0 %t.ll -o %t1 && %t1 | FileCheck %s; fi
3+
! RUN: %fc -flto -O1 -c %loadFortran %s -o /dev/stdout | %opt %loadEnzyme %enzyme -o %t.ll && %fc -flto -O1 %t.ll -o %t1 && %t1 | FileCheck %s
4+
! RUN: %fc -flto -O2 -c %loadFortran %s -o /dev/stdout | %opt %loadEnzyme %enzyme -o %t.ll && %fc -flto -O2 %t.ll -o %t1 && %t1 | FileCheck %s
5+
! RUN: %fc -flto -O3 -c %loadFortran %s -o /dev/stdout | %opt %loadEnzyme %enzyme -o %t.ll && %fc -flto -O3 %t.ll -o %t1 && %t1 | FileCheck %s
56

67
! NOTE: This test is only configured to run with the flang compiler at -O0
78
! For it to work with the ifx compiler we will need to figure out how to
89
! handle the indirection involved in the enzyme_autodiff binding
910

10-
module math
11-
contains
12-
real function square( x )
13-
real, intent(in) :: x
14-
square = x**2
15-
end function
16-
end module math
17-
1811
program app
1912
use enzyme, only: enzyme_autodiff
20-
use math, only: square
2113
implicit none
2214
real :: x, dx
2315

@@ -28,6 +20,14 @@ program app
2820
call enzyme_autodiff(square, x, dx)
2921

3022
print *, dx
23+
24+
contains
25+
26+
real function square( x )
27+
real, intent(in) :: x
28+
square = x**2
29+
end function
30+
3131
end program app
3232

3333
! CHECK: 9

enzyme/test/Fortran/ReverseMode/square_with_explicit_interface.f90

Lines changed: 8 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -1,9 +1,10 @@
1-
! RUN: %fc -flto -O0 -c %loadFortran %s -o /dev/stdout | %opt %loadEnzyme %enzyme -o /dev/stdout | %opt -O0 -S -o %t.ll && %fc -flto -O0 %t.ll -o %t1 && %t1 | FileCheck %s
2-
! RUN: %fc -flto -O1 -c %loadFortran %s -o /dev/stdout | %opt %loadEnzyme %enzyme -o /dev/stdout | %opt -O1 -S -o %t.ll && %fc -flto -O1 %t.ll -o %t1 && %t1 | FileCheck %s
3-
! RUN: %fc -flto -O2 -c %loadFortran %s -o /dev/stdout | %opt %loadEnzyme %enzyme -o /dev/stdout | %opt -O2 -S -o %t.ll && %fc -flto -O2 %t.ll -o %t1 && %t1 | FileCheck %s
4-
! RUN: %fc -flto -O3 -c %loadFortran %s -o /dev/stdout | %opt %loadEnzyme %enzyme -o /dev/stdout | %opt -O3 -S -o %t.ll && %fc -flto -O3 %t.ll -o %t1 && %t1 | FileCheck %s
1+
! REQUIRES: fortran
2+
! RUN: %fc -flto -O0 -c %loadFortran %s -o /dev/stdout | %opt %loadEnzyme %enzyme -o %t.ll && %fc -flto -O0 %t.ll -o %t1 && %t1 | FileCheck %s
3+
! RUN: %fc -flto -O1 -c %loadFortran %s -o /dev/stdout | %opt %loadEnzyme %enzyme -o %t.ll && %fc -flto -O1 %t.ll -o %t1 && %t1 | FileCheck %s
4+
! RUN: %fc -flto -O2 -c %loadFortran %s -o /dev/stdout | %opt %loadEnzyme %enzyme -o %t.ll && %fc -flto -O2 %t.ll -o %t1 && %t1 | FileCheck %s
5+
! RUN: %fc -flto -O3 -c %loadFortran %s -o /dev/stdout | %opt %loadEnzyme %enzyme -o %t.ll && %fc -flto -O3 %t.ll -o %t1 && %t1 | FileCheck %s
56

6-
module math
7+
module squareForward
78
interface
89
subroutine square__enzyme_autodiff(fn, x, dx)
910
interface
@@ -21,10 +22,10 @@ real function square( x )
2122
real, intent(in) :: x
2223
square = x**2
2324
end function
24-
end module math
25+
end module
2526

2627
program app
27-
use math
28+
use squareForward, only: square, square__enzyme_autodiff
2829
implicit none
2930
real :: x, dx
3031

0 commit comments

Comments
 (0)