Skip to content

Commit e9156d5

Browse files
committed
#2846 rm duplicated module inlining from GameOfLife solution scripts
1 parent dc4e489 commit e9156d5

4 files changed

Lines changed: 8 additions & 28 deletions

File tree

tutorial/training/gocean/2.10-GameOfLife-mpi/solution/openmp_combined.py

Lines changed: 2 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -39,7 +39,6 @@
3939
encloses them all in an OpenMP parallel directive.
4040
'''
4141

42-
from psyclone.domain.common.transformations import KernelModuleInlineTrans
4342
from psyclone.gocean1p0 import GOLoop
4443
from psyclone.psyGen import InvokeSchedule
4544
from psyclone.psyir.nodes import FileContainer
@@ -61,15 +60,12 @@ def trans(psyir: FileContainer) -> None:
6160
omp_parallel = OMPParallelTrans()
6261
# Optional argument: schedule
6362
omp_do = OMPLoopTrans(omp_schedule="dynamic")
64-
module_inline = KernelModuleInlineTrans()
6563

6664
# We know that there is only one schedule
6765
schedule = psyir.walk(InvokeSchedule)[0]
6866

69-
# Module inline all kernels to help gfortran with inlining.
70-
for kern in schedule.kernels():
71-
module_inline.apply(kern)
72-
67+
# Module inline all kernels to help gfortran with inlining
68+
# and fuse loops.
7369
fuse_trans(psyir)
7470

7571
for loop in schedule.walk(GOLoop):

tutorial/training/gocean/2.16-GameOfLife-omp-offload/solution/omp_offload.py

Lines changed: 2 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -38,7 +38,6 @@
3838
It adds OpenMP offload directives to all kernels.
3939
'''
4040

41-
from psyclone.domain.common.transformations import KernelModuleInlineTrans
4241
from psyclone.gocean1p0 import GOKern
4342
from psyclone.psyir.nodes import Directive, FileContainer, Loop, Routine
4443
from psyclone.psyir.transformations import TransformationError, OMPTargetTrans
@@ -58,14 +57,11 @@ def trans(psyir: FileContainer) -> None:
5857

5958
declare_target = OMPDeclareTargetTrans()
6059

61-
# Use existing fuse script to fuse all loops
60+
# Use existing fuse script to inline all kernels and fuse all loops
6261
fuse_trans(psyir)
6362

64-
# Module inline all kernels (so they can be modified)
65-
# Then add an OpenMP routine statement to each of them:
66-
module_inline = KernelModuleInlineTrans()
63+
# Add an OpenMP routine statement to each of the kernels
6764
for kern in psyir.walk(GOKern):
68-
module_inline.apply(kern)
6965
# Put a ``declare target`` directive inside each kernel
7066
try:
7167
declare_target.apply(kern)

tutorial/training/gocean/2.8-GameOfLife-openmp/solution/openmp.py

Lines changed: 2 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -39,8 +39,7 @@
3939
to the code.
4040
'''
4141

42-
from psyclone.domain.common.transformations import KernelModuleInlineTrans
43-
from psyclone.gocean1p0 import GOKern, GOLoop
42+
from psyclone.gocean1p0 import GOLoop
4443
from psyclone.transformations import OMPParallelLoopTrans
4544
from psyclone.psyGen import InvokeSchedule
4645
from psyclone.psyir.nodes import FileContainer
@@ -58,16 +57,11 @@ def trans(psyir: FileContainer) -> None:
5857
'''
5958
omp_parallel = OMPParallelLoopTrans(omp_schedule="dynamic")
6059
omp_parallel.omp_schedule = "static"
61-
module_inline = KernelModuleInlineTrans()
6260

6361
# We know that there is only one schedule
6462
schedule = psyir.walk(InvokeSchedule)[0]
6563

66-
# Inline all kernels to help gfortran with inlining.
67-
for kern in schedule.walk(GOKern):
68-
module_inline.apply(kern)
69-
70-
# Optional:
64+
# Inline all kernels and fuse loops
7165
fuse_trans(psyir)
7266

7367
for loop in schedule.walk(GOLoop):

tutorial/training/gocean/2.8-GameOfLife-openmp/solution/openmp_combined.py

Lines changed: 2 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -39,8 +39,7 @@
3939
'omp do' to all loops and adds an outer `omp parallel`.
4040
'''
4141

42-
from psyclone.domain.common.transformations import KernelModuleInlineTrans
43-
from psyclone.gocean1p0 import GOKern, GOLoop
42+
from psyclone.gocean1p0 import GOLoop
4443
from psyclone.psyGen import InvokeSchedule
4544
from psyclone.psyir.nodes import FileContainer
4645
from psyclone.psyir.transformations import OMPParallelTrans
@@ -60,16 +59,11 @@ def trans(psyir: FileContainer) -> None:
6059
omp_parallel = OMPParallelTrans()
6160
# Optional argument: schedule
6261
omp_do = OMPLoopTrans(omp_schedule="dynamic")
63-
module_inline = KernelModuleInlineTrans()
6462

6563
# We know that there is only one schedule
6664
schedule = psyir.walk(InvokeSchedule)[0]
6765

68-
# Inline all kernels to help gfortran with inlining.
69-
for kern in schedule.walk(GOKern):
70-
module_inline.apply(kern)
71-
72-
# Optional:
66+
# Inline kernels and fuse loops
7367
fuse_trans(psyir)
7468

7569
# Both ways work - either specify the default in

0 commit comments

Comments
 (0)