Skip to content

Commit e6bb418

Browse files
authored
Merge pull request #49 from CEED/gpu-opt
GPU + FOM
2 parents c9c5e05 + 1078738 commit e6bb418

15 files changed

Lines changed: 865 additions & 165 deletions

.gitignore

Lines changed: 7 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,10 @@
1-
*.o
21
remhos
2+
*.dat
33
*.mesh
4+
*.o
45
*.gf
6+
*.svg
7+
.DS_Store
8+
/build/
9+
/.cache/
10+
/.vscode/

CMakeLists.txt

Lines changed: 85 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,85 @@
1+
cmake_minimum_required(VERSION 3.18)
2+
3+
set(project remhos)
4+
project(${project} LANGUAGES CXX)
5+
set(CMAKE_CXX_STANDARD 17)
6+
set(CMAKE_CXX_STANDARD_REQUIRED ON)
7+
set(CMAKE_CXX_COMPILER_LAUNCHER ccache)
8+
set(CMAKE_EXPORT_COMPILE_COMMANDS ON)
9+
10+
# CXX flags *******************************************************************
11+
if (CMAKE_BUILD_TYPE STREQUAL "Debug")
12+
add_compile_options(-fsanitize=address -O0)
13+
add_link_options(-fsanitize=address)
14+
endif()
15+
16+
# remove -DNDEBUG from default RelWithDebInfo flags
17+
set(CMAKE_CXX_FLAGS_RELWITHDEBINFO "-O2" CACHE STRING "" FORCE)
18+
19+
# Verbosity options ***********************************************************
20+
set(CMAKE_VERBOSE_MAKEFILE OFF CACHE BOOL "" FORCE)
21+
# set(CUDA_VERBOSE_BUILD OFF CACHE BOOL "" FORCE)
22+
23+
# Include paths ***************************************************************
24+
include_directories(${CMAKE_CURRENT_SOURCE_DIR})
25+
include_directories(${CMAKE_CURRENT_SOURCE_DIR}/../mfem)
26+
if (${CMAKE_SYSTEM_NAME} MATCHES "Linux")
27+
include_directories(/usr/include/hypre /usr/include)
28+
elseif(${CMAKE_SYSTEM_NAME} MATCHES "Darwin")
29+
include_directories(/opt/homebrew/opt/fmt/include
30+
/opt/homebrew/opt/openmpi/include
31+
/opt/homebrew/opt/metis/include
32+
/opt/homebrew/opt/hypre/include)
33+
add_compile_definitions(MFEM_USE_CMAKE_TESTS)
34+
else()
35+
message(FATAL_ERROR "Unsupported system")
36+
endif()
37+
38+
# Copy mesh files *************************************************************
39+
file(GLOB SRC_MESH_FILES LIST_DIRECTORIES false data/*.mesh)
40+
set(BUILD_DATA_DIR ${CMAKE_CURRENT_BINARY_DIR}/data)
41+
add_custom_command(OUTPUT data_is_copied
42+
COMMAND ${CMAKE_COMMAND} -E make_directory ${BUILD_DATA_DIR}
43+
COMMAND ${CMAKE_COMMAND} -E copy_if_different ${SRC_MESH_FILES} ${BUILD_DATA_DIR}
44+
COMMAND ${CMAKE_COMMAND} -E touch data_is_copied
45+
COMMENT "Copying mesh files ...")
46+
add_custom_target(copy_mesh_files DEPENDS data_is_copied)
47+
48+
# Library source files ********************************************************
49+
add_library(Remhos STATIC remhos.cpp remhos_fct.cpp
50+
remhos_ho.cpp remhos_lo.cpp
51+
remhos_mono.cpp remhos_sync.cpp
52+
remhos_tools.cpp)
53+
54+
# Testing options *************************************************************
55+
enable_testing()
56+
function(add_remhos_test name)
57+
set(file ${name}.cpp)
58+
set(target ${name})
59+
list(LENGTH ARGN ARGN_COUNT)
60+
if(ARGN_COUNT GREATER 0)
61+
list(GET ARGN 0 extra)
62+
string(APPEND name "_" ${extra})
63+
string(APPEND target "_" ${extra})
64+
endif()
65+
message(STATUS "Adding target: ${target}")
66+
add_executable(${target} ${file})
67+
add_dependencies(${target} copy_mesh_files)
68+
target_link_libraries(${target} Remhos -lmpi -lmfem -lhypre -lmetis -lfmt)
69+
if (${CMAKE_SYSTEM_NAME} MATCHES "Linux")
70+
target_link_directories(${target} PUBLIC /usr/lib/x86_64-linux-gnu)
71+
elseif(${CMAKE_SYSTEM_NAME} MATCHES "Darwin")
72+
target_link_directories(${target} PUBLIC /opt/homebrew/opt/openmpi/lib
73+
/opt/homebrew/opt/metis/lib
74+
/opt/homebrew/opt/hypre/lib
75+
/opt/homebrew/opt/fmt/lib)
76+
endif()
77+
target_link_directories(${target} PUBLIC ${CMAKE_CURRENT_SOURCE_DIR}/../mfem)
78+
message(STATUS "Adding test: ${target}_n1")
79+
add_test(NAME ${target}_n1 COMMAND mpirun -n 1 ${target} ${extra})
80+
message(STATUS "Adding test: ${target}_n3")
81+
add_test(NAME ${target}_n3 COMMAND mpirun -n 3 ${target})
82+
endfunction()
83+
84+
add_remhos_test(remhos_main)
85+
add_remhos_test(remhos_tests)

README.md

Lines changed: 14 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -260,7 +260,19 @@ round-off distance from the above reference values.
260260

261261
## Performance Timing and FOM
262262

263-
To appear soon.
263+
Performance is tracked only for the configuration `-ho 3 -lo 5 -fct 2`.
264+
This configuration supports partial assembly and GPU execution.
265+
Remhos reports several FOMs in the terminal, based on the distinct phases of an
266+
advection-based remap calculation. All FOMs are reported in
267+
`(megaDOFs x time steps) per second`, reflecting the throughput of the calculation.
268+
269+
- FOM RHS: construction of the right-hand side of the system.
270+
- FOM INV: inverting the high-order operator, which is used to obtain a
271+
high-order unbounded (HO) solution.
272+
- FOM LO: computation of the low-order bounded (LO) approximation of the solution.
273+
- FOM FCT: computation of the FCT solution, combining the LO and HO solutions to
274+
obtain a bounded high-order solution.
275+
- **FOM**: performance metric combining all the above phases.
264276

265277
## Versions
266278

@@ -276,7 +288,7 @@ comment in the [issue tracker](https://github.com/CEED/Remhos/issues).
276288
The following copyright applies to each file in the CEED software suite,
277289
unless otherwise stated in the file:
278290

279-
> Copyright (c) 2017, Lawrence Livermore National Security, LLC. Produced at the
291+
> Copyright (c) 2026, Lawrence Livermore National Security, LLC. Produced at the
280292
> Lawrence Livermore National Laboratory. LLNL-CODE-734707. All Rights reserved.
281293
282294
See files LICENSE and NOTICE for details.

makefile

Lines changed: 17 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -64,6 +64,18 @@ TEST_MK = $(MFEM_DIR)/config/test.mk
6464
MFEM_DIR1 := $(MFEM_DIR)
6565
MFEM_DIR2 := $(realpath $(MFEM_DIR))
6666

67+
# Use Caliper annotations
68+
69+
ifdef CALIPER_DIR
70+
CALIPER_DIR = $(spack location --install-dir caliper)
71+
ADIAK_DIR = $(spack location --install-dir adiak)
72+
CALIPER_FLAGS = -I${CALIPER_DIR}/include -DUSE_CALIPER
73+
ADIAK_INCLUDE = -I${ADIAK_DIR}/include
74+
ADIAK_LDFLAGS = -L${ADIAK_DIR}/lib -ladiak
75+
CALIPER_LDFLAGS = -L${CALIPER_DIR}/lib64 -lcaliper
76+
endif
77+
78+
6779
# Use the compiler used by MFEM. Get the compiler and the options for compiling
6880
# and linking from MFEM's config.mk. (Skip this if the target does not require
6981
# building.)
@@ -73,15 +85,16 @@ ifeq (,$(filter help clean distclean style,$(MAKECMDGOALS)))
7385
endif
7486

7587
CXX = $(MFEM_CXX)
76-
CPPFLAGS = $(MFEM_CPPFLAGS)
88+
CPPFLAGS = $(MFEM_CPPFLAGS) $(CALIPER_FLAGS) $(ADIAK_FLAGS)
7789
CXXFLAGS = $(MFEM_CXXFLAGS)
7890

7991
# MFEM config does not define C compiler
8092
CC = gcc
8193
CFLAGS = -O3
8294

8395
# Optional link flags
84-
LDFLAGS =
96+
LDFLAGS = $(CALIPER_LDFLAGS) $(ADIAK_LDFLAGS)
97+
8598

8699
OPTIM_OPTS = -O3
87100
DEBUG_OPTS = -g -Wall -std=c++11
@@ -102,7 +115,8 @@ ifeq ($(REMHOS_DEBUG),YES)
102115
endif
103116

104117
LIBS = $(strip $(REMHOS_LIBS) $(LDFLAGS))
105-
CCC = $(strip $(CXX) $(REMHOS_FLAGS))
118+
EXTRA_INC_DIR = $(or $(wildcard $(MFEM_DIR)/include/mfem),$(MFEM_DIR))
119+
CCC = $(strip $(CXX) $(REMHOS_FLAGS) $(if $(EXTRA_INC_DIR),-I$(EXTRA_INC_DIR)))
106120
Ccc = $(strip $(CC) $(CFLAGS) $(GL_OPTS))
107121

108122
SOURCE_FILES = remhos.cpp remhos_tools.cpp remhos_lo.cpp remhos_ho.cpp \

0 commit comments

Comments
 (0)