Skip to content

Commit 838f61b

Browse files
authored
GH-200 Unified Memory Support (#470)
* bruh * Had to pass flag as a linker option too * Okay, looks like it works Just remember to add docs next * Fix formatting, add docs * remove tab character til 'or' also has the semantics of <|>
1 parent 596ef8b commit 838f61b

File tree

6 files changed

+43
-24
lines changed

6 files changed

+43
-24
lines changed

CMakeLists.txt

Lines changed: 21 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -16,15 +16,16 @@ project(MFC LANGUAGES C CXX Fortran)
1616

1717
# Build options exposed to users and their default values.
1818

19-
option(MFC_MPI "Build with MPI" ON)
20-
option(MFC_OpenACC "Build with OpenACC" OFF)
21-
option(MFC_GCov "Build with GCov" OFF)
22-
option(MFC_PRE_PROCESS "Build pre_process" OFF)
23-
option(MFC_SIMULATION "Build simulation" OFF)
24-
option(MFC_POST_PROCESS "Build post_process" OFF)
25-
option(MFC_SYSCHECK "Build syscheck" OFF)
26-
option(MFC_DOCUMENTATION "Build documentation" OFF)
27-
option(MFC_ALL "Build everything" OFF)
19+
option(MFC_MPI "Build with MPI" ON)
20+
option(MFC_OpenACC "Build with OpenACC" OFF)
21+
option(MFC_GCov "Build with GCov" OFF)
22+
option(MFC_Unified "Build with unified CPU & GPU memory (GH-200 only)" OFF)
23+
option(MFC_PRE_PROCESS "Build pre_process" OFF)
24+
option(MFC_SIMULATION "Build simulation" OFF)
25+
option(MFC_POST_PROCESS "Build post_process" OFF)
26+
option(MFC_SYSCHECK "Build syscheck" OFF)
27+
option(MFC_DOCUMENTATION "Build documentation" OFF)
28+
option(MFC_ALL "Build everything" OFF)
2829

2930
if (MFC_ALL)
3031
set(MFC_PRE_PROCESS ON FORCE)
@@ -454,6 +455,17 @@ function(MFC_SETUP_TARGET)
454455
PRIVATE -gpu=keep,ptxinfo,lineinfo
455456
)
456457

458+
# GH-200 Unified Memory Support
459+
if (MFC_Unified)
460+
target_compile_options(${ARGS_TARGET}
461+
PRIVATE -gpu=unified
462+
)
463+
# "This option must appear in both the compile and link lines" -- NVHPC Docs
464+
target_link_options(${ARGS_TARGET}
465+
PRIVATE -gpu=unified
466+
)
467+
endif()
468+
457469
if (CMAKE_BUILD_TYPE STREQUAL "Debug")
458470
target_compile_options(${ARGS_TARGET}
459471
PRIVATE -gpu=autocompare,debug

docs/documentation/getting-started.md

Lines changed: 7 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -172,12 +172,13 @@ session exit.
172172

173173
MFC can be built with support for various (compile-time) features:
174174

175-
| Feature | Enable | Disable | Default | Description |
176-
| :-------: | :-------: | :----------: | :-----: | --------------------------------------------------------------- |
177-
| **MPI** | `--mpi` | `--no-mpi` | On | Lets MFC run on multiple processors (and nodes) simultaneously. |
178-
| **GPU** | `--gpu` | `--no-gpu` | Off | Enables GPU acceleration via OpenACC. |
179-
| **Debug** | `--debug` | `--no-debug` | Off | Requests the compiler build MFC in debug mode. |
180-
| **GCov** | `--gcov` | `--no-gcov` | Off | Builds MFC with coverage flags on. |
175+
| Feature | Enable | Disable | Default | Description |
176+
| :----------------: | :---------: | :------------: | :-----: | --------------------------------------------------------------- |
177+
| **MPI** | `--mpi` | `--no-mpi` | On | Lets MFC run on multiple processors (and nodes) simultaneously. |
178+
| **GPU** | `--gpu` | `--no-gpu` | Off | Enables GPU acceleration via OpenACC. |
179+
| **Debug** | `--debug` | `--no-debug` | Off | Requests the compiler build MFC in debug mode. |
180+
| **GCov** | `--gcov` | `--no-gcov` | Off | Builds MFC with coverage flags on. |
181+
| **Unified Memory** | `--unified` | `--no-unified` | Off | Builds MFC with unified CPU/GPU memory (GH-200 superchip only) |
181182

182183
_⚠️ The `--gpu` option requires that your compiler supports OpenACC for Fortran for your target GPU architecture._
183184

src/simulation/m_riemann_solvers.fpp

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1542,6 +1542,7 @@ contains
15421542
pi_inf_L = 0d0
15431543
qv_L = 0d0
15441544
1545+
! Retain this in the refactor
15451546
if (mpp_lim .and. (num_fluids > 2)) then
15461547
!$acc loop seq
15471548
do i = 1, num_fluids
@@ -2005,6 +2006,8 @@ contains
20052006
alpha_L_sum = 0d0
20062007
alpha_R_sum = 0d0
20072008
2009+
! Change this by splitting it into the cases
2010+
! present in the bubbles
20082011
if (mpp_lim) then
20092012
!$acc loop seq
20102013
do i = 1, num_fluids

toolchain/main.py

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -31,8 +31,9 @@ def __print_greeting():
3131
]
3232

3333
for a, b in itertools.zip_longest(MFC_LOGO_LINES, MFC_SIDEBAR_LINES):
34+
a = a or ''
3435
lhs = a.ljust(max_logo_line_length)
35-
rhs = b if b is not None else ''
36+
rhs = b or ''
3637
cons.print(
3738
f"[bold]{lhs}[/bold] | {rhs}",
3839
highlight=False

toolchain/mfc/build.py

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -142,9 +142,10 @@ def configure(self, case: input.MFCInputFile):
142142
flags.append('--debug-find')
143143

144144
if not self.isDependency:
145-
flags.append(f"-DMFC_MPI={ 'ON' if ARG('mpi') else 'OFF'}")
146-
flags.append(f"-DMFC_OpenACC={'ON' if ARG('gpu') else 'OFF'}")
145+
flags.append(f"-DMFC_MPI={ 'ON' if ARG('mpi') else 'OFF'}")
146+
flags.append(f"-DMFC_OpenACC={'ON' if ARG('gpu') else 'OFF'}")
147147
flags.append(f"-DMFC_GCov={ 'ON' if ARG('gcov') else 'OFF'}")
148+
flags.append(f"-DMFC_Unified={'ON' if ARG('unified') else 'OFF'}")
148149

149150
command = ["cmake"] + flags + ["-S", cmake_dirpath, "-B", build_dirpath]
150151

toolchain/mfc/state.py

Lines changed: 7 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -3,10 +3,11 @@
33

44
@dataclasses.dataclass
55
class MFCConfig:
6-
mpi: bool = True
7-
gpu: bool = False
8-
debug: bool = False
9-
gcov: bool = False
6+
mpi: bool = True
7+
gpu: bool = False
8+
debug: bool = False
9+
gcov: bool = False
10+
unified: bool = False
1011

1112
@staticmethod
1213
def from_dict(d: dict):
@@ -24,7 +25,7 @@ def items(self) -> typing.List[typing.Tuple[str, bool]]:
2425

2526
def make_options(self) -> typing.List[str]:
2627
""" Returns a list of options that could be passed to mfc.sh again.
27-
Example: --no-debug --mpi --no-gpu --no-gcov"""
28+
Example: --no-debug --mpi --no-gpu --no-gcov --no-unified"""
2829
return [ f"--{'no-' if not v else ''}{k}" for k, v in self.items() ]
2930

3031
def make_slug(self) -> str:
@@ -41,7 +42,7 @@ def __eq__(self, other) -> bool:
4142
return True
4243

4344
def __str__(self) -> str:
44-
""" Returns a string like "mpi=No & gpu=No & debug=No & gcov=No" """
45+
""" Returns a string like "mpi=No & gpu=No & debug=No & gcov=No & unified=No" """
4546

4647
return ' & '.join([ f"{k}={'Yes' if v else 'No'}" for k, v in self.items() ])
4748

0 commit comments

Comments
 (0)