Skip to content

Commit 2f69443

Browse files
committed
Summit fixes
1 parent daa3943 commit 2f69443

File tree

8 files changed

+55
-19
lines changed

8 files changed

+55
-19
lines changed

CMakeLists.txt

Lines changed: 33 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -94,11 +94,19 @@ ELSEIF ((CMAKE_Fortran_COMPILER_ID STREQUAL "NVHPC") OR
9494
(CMAKE_Fortran_COMPILER_ID STREQUAL "PGI"))
9595

9696
ADD_COMPILE_OPTIONS(-r8 -cpp -Mfreeform -Minfo=accel -Mr8intrinsics)
97+
98+
IF (MFC_WITH_OPEN_ACC)
99+
IF (CMAKE_BUILD_TYPE STREQUAL "Release")
100+
ADD_COMPILE_OPTIONS(-gpu=keep,ptxinfo,lineinfo)
101+
ELSEIF (CMAKE_BUILD_TYPE STREQUAL "Debug")
102+
ADD_COMPILE_OPTIONS(-gpu=keep,ptxinfo,lineinfo,autocompare,debug)
103+
ENDIF()
104+
ENDIF()
97105

98106
ENDIF()
99107

100108

101-
# === CMake Build Configurations
109+
# === Release Optimizations
102110
IF (CMAKE_BUILD_TYPE STREQUAL "Release")
103111

104112
# === === Processor tuning
@@ -235,15 +243,36 @@ IF (MFC_BUILD_SIMULATION)
235243

236244

237245
IF (CMAKE_Fortran_COMPILER_ID STREQUAL "NVHPC" OR CMAKE_Fortran_COMPILER_ID STREQUAL "PGI")
238-
TARGET_LINK_LIBRARIES(simulation PRIVATE CUDA::nvToolsExt cutensor)
246+
TARGET_LINK_LIBRARIES(simulation PRIVATE CUDA::nvToolsExt)
239247
ENDIF()
240248

241249

242250
IF (MFC_WITH_OPEN_ACC)
243251
TARGET_LINK_LIBRARIES(simulation PRIVATE OpenACC::OpenACC_Fortran)
244252

245253
IF (CMAKE_Fortran_COMPILER_ID STREQUAL "NVHPC" OR CMAKE_Fortran_COMPILER_ID STREQUAL "PGI")
246-
TARGET_LINK_LIBRARIES(simulation PRIVATE CUDA::cufft)
254+
TARGET_LINK_LIBRARIES(simulation PRIVATE CUDA::cudart CUDA::cufft cutensor)
255+
256+
# In the case of the NVHPC SDK, cuTENSOR can be found at a path similar to:
257+
# /opt/nvidia/hpc_sdk/Linux_x86_64/xx.yy/math_libs/lib64/ on a regular installation.
258+
# CUDAToolkit_LIBRARY_ROOT would then point to /opt/nvidia/hpc_sdk/Linux_x86_64/xx.yy/cuda/zz.ww.
259+
# Since the linker doesn't usually consider math_libs/ (for it wasn't told to),
260+
# we attempt to add it as a link directory.
261+
262+
SET(_warn_msg_begin "Can't automatically determine the location of cuTENSOR.")
263+
SET(_warn_msg_end "If linking fails, please explicitly specify a link directory.")
264+
265+
IF (EXISTS "${CUDAToolkit_LIBRARY_ROOT}/../../math_libs/lib")
266+
TARGET_LINK_DIRECTORIES(simulation PRIVATE "${CUDAToolkit_LIBRARY_ROOT}/../../math_libs/lib")
267+
268+
MESSAGE(WARNING "${_warn_msg_begin} Gave linker ${CUDAToolkit_LIBRARY_ROOT}/../../math_libs/lib as a potential search path for cuTENSOR (based on a regular NVHPC installation). ${_warn_msg_end} Fortunately, linking will likely succeed.")
269+
ELSEIF (EXISTS "${CUDAToolkit_LIBRARY_ROOT}/../../math_libs/lib64")
270+
TARGET_LINK_DIRECTORIES(simulation PRIVATE "${CUDAToolkit_LIBRARY_ROOT}/../../math_libs/lib64")
271+
272+
MESSAGE(WARNING "${_warn_msg_begin} Gave linker ${CUDAToolkit_LIBRARY_ROOT}/../../math_libs/lib64 as a potential search path for cuTENSOR (based on a regular NVHPC installation). ${_warn_msg_end} Fortunately, linking will likely succeed.")
273+
ELSE()
274+
MESSAGE(WARNING "${_warn_msg_begin} No common potential search directories were found. ${_warn_msg_end}")
275+
ENDIF()
247276
ENDIF()
248277
ENDIF()
249278

@@ -261,7 +290,7 @@ IF (MFC_BUILD_POST_PROCESS)
261290

262291
ADD_EXECUTABLE(post_process "${post_process_srcs}" "${common_srcs}")
263292

264-
TARGET_LINK_LIBRARIES(post_process PRIVATE HDF5::HDF5 SILO::SILO FFTW::FFTW)
293+
TARGET_LINK_LIBRARIES(post_process PRIVATE SILO::SILO HDF5::HDF5 FFTW::FFTW)
265294

266295
IF (MFC_WITH_MPI)
267296
TARGET_COMPILE_DEFINITIONS(post_process PRIVATE MFC_MPI)

mfc.sh

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -64,7 +64,7 @@ if (($?)); then
6464
fi
6565

6666

67-
if ! command -v pip3 > /dev/null 2>&1; then
67+
if ! command -v pip3 > /dev/null 2>&1 && [ ! -f "$(pwd)/build/venv/bin/activate" ]; then
6868
wget -O "$(pwd)/build/get-pip.py" https://bootstrap.pypa.io/pip/get-pip.py
6969
if (($?)); then
7070
echo "[mfc.sh] Error: Couldn't download get-pip.py."

toolchain/cmake/FindFFTW.cmake

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -14,6 +14,7 @@ FIND_PATH(FFTW_INCLUDE_DIR
1414
FIND_LIBRARY(FFTW_LIBRARY
1515
NAMES fftw3
1616
PATH_SUFFIXES fftw fftw3
17+
NAMES_PER_DIR
1718
)
1819

1920

toolchain/cmake/FindHDF5.cmake

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -14,6 +14,7 @@ FIND_PATH(HDF5_INCLUDE_DIR
1414
FIND_LIBRARY(HDF5_LIBRARY
1515
NAMES libhdf5 hdf5
1616
PATH_SUFFIXES hdf5
17+
NAMES_PER_DIR
1718
)
1819

1920

toolchain/cmake/FindSILO.cmake

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -14,6 +14,7 @@ FIND_PATH(SILO_INCLUDE_DIR
1414
FIND_LIBRARY(SILO_LIBRARY
1515
NAMES siloh5 silo
1616
PATH_SUFFIXES silo
17+
NAMES_PER_DIR
1718
)
1819

1920

toolchain/mfc/tests/case.py

Lines changed: 8 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -112,10 +112,10 @@ def run(self, args: dict) -> subprocess.CompletedProcess:
112112
filepath = f'"{self.get_dirpath()}/case.py"'
113113
mode = f'-m "{args["mode"]}"'
114114
tasks = f"-n {self.ppn} "
115-
jobs = f"-j {args['jobs']}" if args["case_optimization"] else ""
116-
gpus = f"-g {self.ppn}" if "gpu" in args["mode"] else ""
117-
binary_option = f"-b {args['binary']}" if args["binary"] is not None else ""
118-
case_optimization = "--case-optimization" if args["case_optimization"] else "--no-build"
115+
jobs = f"-j {args['jobs']}" if args["case_optimization"] else ""
116+
gpus = f"-g {self.ppn}" if "gpu" in args["mode"] else ""
117+
binary_option = f"-b {args['binary']}" if args["binary"] is not None else ""
118+
case_optimization = "--case-optimization" if args["case_optimization"] else "--no-build"
119119
no_mpi = f"--no-mpi" if args["no_mpi"] else ""
120120

121121
mfc_script = ".\mfc.bat" if os.name == 'nt' else "./mfc.sh"
@@ -166,6 +166,10 @@ def __getitem__(self, key: str) -> str:
166166

167167
def __setitem__(self, key: str, val: str):
168168
self.params[key] = val
169+
170+
def __str__(self) -> str:
171+
return f"tests/[bold magenta]{self.get_uuid()}[/bold magenta]: {self.trace}"
172+
169173

170174

171175
@dataclasses.dataclass

toolchain/mfc/tests/pack.py

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -120,7 +120,7 @@ def generate(case: case.Case) -> Pack:
120120

121121
for double in doubles:
122122
if math.isnan(double):
123-
raise MFCException(f"A NaN was found while generating a pack file for test with UUID [bold magenta]{case.get_uuid()}[/bold magenta].")
123+
raise MFCException(f"Test {case}: A NaN was found while generating a pack file.")
124124

125125
entries.append(PackEntry(short_filepath,doubles))
126126

@@ -152,21 +152,21 @@ def check_tolerance(case: case.Case, candidate: Pack, golden: Pack, tol: float)
152152

153153
# Compare entry-count
154154
if len(candidate.entries) != len(golden.entries):
155-
raise MFCException(f"{os.sep.join(['tests', uuid])}: Line count didn't match.")
155+
raise MFCException(f"Test {case}: Line count didn't match.")
156156

157157
# For every entry in the golden's pack
158158
for gIndex, gEntry in enumerate(golden.entries):
159159
# Find the corresponding entry in the candidate's pack
160160
cIndex, cEntry = common.find(lambda i, e: e.filepath == gEntry.filepath, candidate.entries)
161161

162162
if cIndex == None:
163-
raise MFCException(f"{os.sep.join(['tests', uuid])}: No reference of {gEntry.filepath} in the candidate's pack.")
163+
raise MFCException(f"Test {case}: No reference of {gEntry.filepath} in the candidate's pack.")
164164

165165
filepath: str = gEntry.filepath
166166

167167
# Compare variable-count
168168
if len(gEntry.doubles) != len(cEntry.doubles):
169-
raise MFCException(f"{os.sep.join(['tests', uuid])}: Variable count didn't match for {filepath}.")
169+
raise MFCException(f"Test {case}: Variable count didn't match for {filepath}.")
170170

171171
# Check if each variable is within tolerance
172172
for valIndex, (gVal, cVal) in enumerate(zip(gEntry.doubles, cEntry.doubles)):
@@ -176,7 +176,7 @@ def check_tolerance(case: case.Case, candidate: Pack, golden: Pack, tol: float)
176176

177177
def raise_err(msg: str):
178178
raise MFCException(f"""\
179-
{os.sep.join(['tests', uuid])}: Variable n°{valIndex+1} (1-indexed) in {filepath} {msg}:
179+
Test {case}: Variable n°{valIndex+1} (1-indexed) in {filepath} {msg}:
180180
- Description: {case.trace}
181181
- Candidate: {cVal}
182182
- Golden: {gVal}

toolchain/mfc/tests/tests.py

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -131,7 +131,7 @@ def handle_case(self, test: Case):
131131
if test.params.get("qbmm", 'F') == 'T':
132132
tol = 1e-7
133133
elif test.params.get("bubbles", 'F') == 'T':
134-
tol = 1e-10
134+
tol = 1e-6
135135
else:
136136
tol = 1e-12
137137

@@ -144,8 +144,8 @@ def handle_case(self, test: Case):
144144
if cmd.returncode != 0:
145145
cons.print(cmd.stdout)
146146
raise MFCException(f"""\
147-
{os.sep.join(['tests', test.get_uuid()])}: Failed to execute MFC [{test.trace}]. Above is the output of MFC.
148-
You can find the output in {out_filepath}, and the case dictionary in {os.path.join(test.get_dirpath(), "case.py")}.""")
147+
Test {test}: Failed to execute MFC. Above is the output of MFC.
148+
You can find the output in {out_filepath}, and the case dictionary in {os.path.join(test.get_dirpath(), "case.py")}.""")
149149

150150
pack = packer.generate(test)
151151
pack.save(os.path.join(test.get_dirpath(), "pack.txt"))
@@ -157,7 +157,7 @@ def handle_case(self, test: Case):
157157
pack.save(golden_filepath)
158158
else:
159159
if not os.path.isfile(golden_filepath):
160-
raise MFCException(f"{os.sep.join(['tests', test.get_uuid()])}: Golden file doesn't exist! To generate golden files, use the '-g' flag. [{test.trace}]")
160+
raise MFCException(f"Test {test}: Golden file doesn't exist! To generate golden files, use the '-g' flag.")
161161

162162
packer.check_tolerance(test, pack, packer.load(golden_filepath), tol)
163163

@@ -168,5 +168,5 @@ def handle_case(self, test: Case):
168168
if not self.mfc.args["relentless"]:
169169
raise exc
170170

171-
cons.print(f"[bold red]Failed Test [bold magenta]{test.get_uuid()}[/bold magenta] ! [/bold red] ({test.trace})")
171+
cons.print(f"[bold red]Failed test {test}.[/bold red]")
172172
cons.print(f"{exc}")

0 commit comments

Comments
 (0)