Skip to content

Commit 4457102

Browse files
committed
upstream case opt changes
1 parent 28e22f6 commit 4457102

7 files changed

Lines changed: 71 additions & 19 deletions

File tree

CMakeLists.txt

Lines changed: 11 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -159,23 +159,27 @@ macro(HANDLE_SOURCES target)
159159
file(GLOB common_F90s CONFIGURE_DEPENDS "${common_DIR}/*.f90")
160160
set(${target}_SRCs ${${target}_F90s} ${common_F90s})
161161

162-
# src/[<DIR>,common]/FPP.fpp -> src/<DIR>/autogen/F90.f90
162+
# src/[<DIR>,common]/*.fpp -> src/<DIR>/autogen/*.f90
163163
file(GLOB ${target}_FPPs CONFIGURE_DEPENDS "${${target}_DIR}/*.fpp")
164164
file(GLOB common_FPPs CONFIGURE_DEPENDS "${common_DIR}/*.fpp")
165165

166+
# Locate src/[<DIR>,common]/include/*.fpp
167+
file(GLOB ${target}_incs CONFIGURE_DEPENDS "${${target}_DIR}/include/*.fpp")
168+
file(GLOB common_incs CONFIGURE_DEPENDS "${common_DIR}/include/*.fpp")
169+
166170
file(MAKE_DIRECTORY "${${target}_DIR}/autogen")
167171
foreach(fpp ${${target}_FPPs} ${common_FPPs})
168172
cmake_path(GET fpp FILENAME fpp_filename)
169173
set(f90 "${${target}_DIR}/autogen/${fpp_filename}.f90")
170-
set(dep "${fpp}")
171-
if (EXISTS "${${target}_DIR}/case.fpp")
172-
list(APPEND dep "${${target}_DIR}/case.fpp")
173-
endif()
174174

175175
add_custom_command(
176176
OUTPUT ${f90}
177-
COMMAND ${FYPP_EXE} -I ${common_DIR} ${fpp} ${f90}
178-
DEPENDS ${dep}
177+
COMMAND ${FYPP_EXE} -I "${common_DIR}"
178+
-I "${common_DIR}/include"
179+
-I "${${target}_DIR}/include"
180+
--line-numbering
181+
"${fpp}" "${f90}"
182+
DEPENDS "${fpp};${${target}_incs};${common_incs}"
179183
COMMENT "Preprocessing (Fypp) ${fpp_filename}"
180184
VERBATIM
181185
)

src/common/include/macros.fpp

Lines changed: 44 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,44 @@
1+
#:def LOG(expr)
2+
#ifdef MFC_DEBUG
3+
print *, '${_FILE_.split('/')[-1]}$:${_LINE_}$', ${expr}$
4+
#endif
5+
#:enddef
6+
7+
8+
#:def ALLOCATE(*args)
9+
10+
! ================================================
11+
! ==== BEGIN ALLOCATE (src/common/macros.fpp) ====
12+
! ================================================
13+
14+
#! @:LOG({'@:ALLOCATE(${', '.join(args)}$)'})
15+
16+
allocate(${', '.join(args)}$)
17+
18+
!$acc enter data create(${', '.join(args)}$)
19+
20+
! ================================================
21+
! ==== END ALLOCATE (src/common/macros.fpp) ====
22+
! ================================================
23+
24+
#:enddef ALLOCATE
25+
26+
27+
28+
#:def DEALLOCATE(*args)
29+
30+
! ==================================================
31+
! ==== BEGIN DEALLOCATE (src/common/macros.fpp) ====
32+
! ==================================================
33+
34+
#! @:LOG({'@:DEALLOCATE(${', '.join(args)}$)'})
35+
36+
deallocate(${', '.join(args)}$)
37+
38+
!$acc exit data delete(${', '.join(args)}$)
39+
40+
! ==================================================
41+
! ==== END DEALLOCATE (src/common/macros.fpp) ====
42+
! ==================================================
43+
44+
#:enddef DEALLOCATE

src/pre_process/m_check_patches.fpp

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,5 @@
11

22

3-
#:include 'case.fpp'
43

54
!> @brief This module contains subroutines that read, and check consistency
65
!! of, the user provided inputs and data.

src/pre_process/m_start_up.fpp

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,6 @@
22
!! @file m_start_up.f90
33
!! @brief Contains module m_start_up
44

5-
#:include 'case.fpp'
65

76
!> @brief This module contains subroutines that read, and check consistency
87
!! of, the user provided inputs and data.

src/simulation/include/case.fpp

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,5 @@
1+
! This file was generated by MFC. It is only used if the --case-optimization
2+
! option is passed to ./mfc.sh run or test, enabling a GPU-oriented optimization
3+
! that hard-codes certain case parameters from the input file.
4+
5+
#:set MFC_CASE_OPTIMIZATION = False

src/simulation/p_main.fpp

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -127,7 +127,7 @@ program p_main
127127

128128
#if defined(_OPENACC) && defined(MFC_MEMORY_DUMP)
129129
call acc_present_dump()
130-
#endif // defined(_OPENACC) && defined(MFC_MEMORY_DUMP)
130+
#endif
131131

132132
call s_initialize_mpi_proxy_module()
133133
call s_initialize_variables_conversion_module()
@@ -136,7 +136,7 @@ program p_main
136136

137137
#if defined(_OPENACC) && defined(MFC_MEMORY_DUMP)
138138
call acc_present_dump()
139-
#endif // defined(_OPENACC) && defined(MFC_MEMORY_DUMP)
139+
#endif
140140

141141
if (any(Re_size > 1)) then
142142
call s_initialize_viscous_module()
@@ -145,15 +145,15 @@ program p_main
145145

146146
#if defined(_OPENACC) && defined(MFC_MEMORY_DUMP)
147147
call acc_present_dump()
148-
#endif // defined(_OPENACC) && defined(MFC_MEMORY_DUMP)
148+
#endif
149149

150150
call s_initialize_data_output_module()
151151
call s_initialize_derived_variables_module()
152152
call s_initialize_time_steppers_module()
153153

154154
#if defined(_OPENACC) && defined(MFC_MEMORY_DUMP)
155155
call acc_present_dump()
156-
#endif // defined(_OPENACC) && defined(MFC_MEMORY_DUMP)
156+
#endif
157157

158158
! Associate pointers for serial or parallel I/O
159159
if (parallel_io .neqv. .true.) then
@@ -178,7 +178,7 @@ program p_main
178178
#if defined(_OPENACC) && defined(MFC_MEMORY_DUMP)
179179
print *, "[MEM-INST] After: s_initialize_weno_module"
180180
call acc_present_dump()
181-
#endif // defined(_OPENACC) && defined(MFC_MEMORY_DUMP)
181+
#endif
182182

183183

184184
call s_initialize_derived_variables()

toolchain/mfc/run/input.py

Lines changed: 6 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -33,19 +33,20 @@ def __generate_inp(self, target_name: str) -> None:
3333

3434

3535
def __generate_fpp(self, target_name: str) -> None:
36-
# === case.fpp ===
37-
use_case_optimization = ARG("case_optimization") and target_name == "simulation"
36+
if target_name != "simulation":
37+
return
3838

39-
filepath = os.path.join(os.getcwd(), "src", target_name, "case.fpp")
39+
# === case.fpp ===
40+
filepath = os.path.join(os.getcwd(), "src", target_name, "include", "case.fpp")
4041
content = f"""\
4142
! This file was generated by MFC. It is only used if the --case-optimization
4243
! option is passed to ./mfc.sh run or test, enabling a GPU-oriented optimization
4344
! that hard-codes certain case parameters from the input file.
4445
45-
#:set MFC_CASE_OPTIMIZATION = {use_case_optimization}
46+
#:set MFC_CASE_OPTIMIZATION = {ARG("case_optimization")}
4647
"""
4748

48-
if use_case_optimization:
49+
if ARG("case_optimization"):
4950
nterms = -100
5051

5152
bubble_model = int(self.case_dict.get("bubble_model", "-100"))

0 commit comments

Comments
 (0)