Skip to content

Commit

Permalink
Allow using external fmt (#834)
Browse files Browse the repository at this point in the history
Co-authored-by: Kristi Belcher <[email protected]>
  • Loading branch information
adayton1 and kab163 committed Aug 1, 2024
1 parent df5a461 commit b3953ce
Show file tree
Hide file tree
Showing 83 changed files with 257 additions and 14,050 deletions.
1 change: 1 addition & 0 deletions .github/actions/abi-compat/entrypoint.sh
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,7 @@ git config --global --add safe.directory /github/workspace/blt
git config --global --add safe.directory /github/workspace/scripts/radiuss-spack-configs
git config --global --add safe.directory /github/workspace/scripts/uberenv
git config --global --add safe.directory /github/workspace/src/tpl/umpire/camp
git config --global --add safe.directory /github/workspace/src/tpl/umpire/fmt

git submodule update --init --recursive

Expand Down
2 changes: 2 additions & 0 deletions .github/actions/apply-style/entrypoint.sh
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,8 @@ git config --global --add safe.directory /github/workspace/blt
git config --global --add safe.directory /github/workspace/scripts/radiuss-spack-configs
git config --global --add safe.directory /github/workspace/scripts/uberenv
git config --global --add safe.directory /github/workspace/src/tpl/umpire/camp
git config --global --add safe.directory /github/workspace/src/tpl/umpire/fmt

git submodule update --init --recursive

mkdir build && cd build
Expand Down
1 change: 1 addition & 0 deletions .github/actions/shroud/entrypoint.sh
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,7 @@ git config --global --add safe.directory /github/workspace/blt
git config --global --add safe.directory /github/workspace/scripts/radiuss-spack-configs
git config --global --add safe.directory /github/workspace/scripts/uberenv
git config --global --add safe.directory /github/workspace/src/tpl/umpire/camp
git config --global --add safe.directory /github/workspace/src/tpl/umpire/fmt

git submodule update --init --recursive

Expand Down
4 changes: 2 additions & 2 deletions .gitlab/jobs/corona.yml
Original file line number Diff line number Diff line change
Expand Up @@ -25,8 +25,8 @@
# This job intentionally tests our umpire package.py because although this job does not
# explicitly have the ~tools, the package.py should still disable tools from being built.
###
rocmcc_5_6_0_hip_openmp_device_alloc:
rocmcc_5_6_1_hip_openmp_device_alloc:
variables:
SPEC: "~shared +fortran +openmp +rocm +device_alloc tests=basic amdgpu_target=gfx906 %[email protected].0 ^[email protected].0"
SPEC: "~shared +fortran +openmp +rocm +device_alloc tests=basic amdgpu_target=gfx906 %[email protected].1 ^[email protected].1"
extends: .job_on_corona

8 changes: 4 additions & 4 deletions .gitlab/jobs/tioga.yml
Original file line number Diff line number Diff line change
Expand Up @@ -13,9 +13,9 @@
# the comparison with the original job is easier.

# We override the cce job because we can’t use +device-alloc with it
cce_16_0_0:
cce_16_0_1:
variables:
SPEC: "~shared +fortran tests=basic %[email protected].0"
SPEC: "~shared +fortran tests=basic %[email protected].1"
extends: .job_on_tioga

############
Expand All @@ -29,8 +29,8 @@ cce_16_0_0:
# This job intentionally tests our umpire package.py because although this job does not
# explicitly have the ~tools, the package.py should still disable tools from being built.
###
rocmcc_5_6_0_hip_openmp_device_alloc:
rocmcc_5_6_1_hip_openmp_device_alloc:
variables:
SPEC: "~shared +fortran +openmp +rocm +device_alloc tests=basic amdgpu_target=gfx90a %[email protected].0 ^[email protected].0"
SPEC: "~shared +fortran +openmp +rocm +device_alloc tests=basic amdgpu_target=gfx90a %[email protected].1 ^[email protected].1"
extends: .job_on_tioga

3 changes: 3 additions & 0 deletions .gitmodules
Original file line number Diff line number Diff line change
Expand Up @@ -14,3 +14,6 @@
[submodule "scripts/uberenv"]
path = scripts/uberenv
url = https://github.com/LLNL/uberenv
[submodule "src/tpl/umpire/fmt"]
path = src/tpl/umpire/fmt
url = https://github.com/fmtlib/fmt
2 changes: 1 addition & 1 deletion examples/cookbook/recipe_coalesce_pool.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -27,7 +27,7 @@ int main(int, char**)
quick_pool->coalesce();
// _sphinx_tag_tut_call_coalesce_end
} else {
UMPIRE_ERROR(umpire::runtime_error, umpire::fmt::format("{} is not a QuickPool, cannot coalesce!", pool.getName()));
UMPIRE_ERROR(umpire::runtime_error, fmt::format("{} is not a QuickPool, cannot coalesce!", pool.getName()));
}

return 0;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -23,7 +23,7 @@ int main(int, char**)
// _sphinx_tag_tut_unwrap_end

if (quick_pool == nullptr) {
UMPIRE_ERROR(umpire::runtime_error, umpire::fmt::format("{} is not a QuickPool", pool.getName()));
UMPIRE_ERROR(umpire::runtime_error, fmt::format("{} is not a QuickPool", pool.getName()));
}

auto ptr = pool.allocate(1024);
Expand Down
8 changes: 4 additions & 4 deletions examples/cookbook/recipe_move_between_numa.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -48,15 +48,15 @@ int main(int, char**)
// The pointer shouldn't change even though the memory location changes
if (dst_ptr != src_ptr) {
UMPIRE_ERROR(umpire::runtime_error,
umpire::fmt::format("Pointers should match: dst_ptr: {} != src_ptr: {}", dst_ptr, src_ptr));
fmt::format("Pointers should match: dst_ptr: {} != src_ptr: {}", dst_ptr, src_ptr));
}

// Touch it
rm.memset(dst_ptr, 0);

// Verify NUMA node
if (umpire::numa::get_location(dst_ptr) != host_nodes[1]) {
UMPIRE_ERROR(umpire::runtime_error, umpire::fmt::format("Move was unsuccessful: {}", dst_ptr));
UMPIRE_ERROR(umpire::runtime_error, fmt::format("Move was unsuccessful: {}", dst_ptr));
}
}

Expand All @@ -77,7 +77,7 @@ int main(int, char**)
// The pointer shouldn't change even though the memory location changes
if (dst_ptr != src_ptr) {
UMPIRE_ERROR(umpire::runtime_error,
umpire::fmt::format("Pointers should match: dst_ptr: {} != src_ptr: {}", dst_ptr, src_ptr));
fmt::format("Pointers should match: dst_ptr: {} != src_ptr: {}", dst_ptr, src_ptr));
}

// Touch it -- this currently uses the host memset operation (thus, copying
Expand All @@ -86,7 +86,7 @@ int main(int, char**)

// Verify NUMA node
if (umpire::numa::get_location(dst_ptr) != device_nodes[0]) {
UMPIRE_ERROR(umpire::runtime_error, umpire::fmt::format("Move was unsuccessful: {}", dst_ptr));
UMPIRE_ERROR(umpire::runtime_error, fmt::format("Move was unsuccessful: {}", dst_ptr));
}
}
#endif
Expand Down
79 changes: 16 additions & 63 deletions src/tpl/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -131,75 +131,28 @@ if (NOT TARGET camp)
SCOPE INTERFACE
TARGET_DEFINITIONS CAMP_HAVE_HIP)
endif()

endif ()

set(fmt_headers
umpire/fmt/fmt.hpp
umpire/fmt/args.h
umpire/fmt/chrono.h
umpire/fmt/color.h
umpire/fmt/compile.h
umpire/fmt/core.h
umpire/fmt/format-inl.h
umpire/fmt/format.h
umpire/fmt/locale.h
umpire/fmt/os.h
umpire/fmt/ostream.h
umpire/fmt/printf.h
umpire/fmt/ranges.h
)

blt_add_library(NAME umpire_tpl_fmt
HEADERS ${fmt_headers})


target_include_directories(
umpire_tpl_fmt
INTERFACE
$<BUILD_INTERFACE:${PROJECT_SOURCE_DIR}/src/tpl>
$<BUILD_INTERFACE:${CMAKE_BINARY_DIR}/include>)

# Avoid warnings from fmt (so we can still use -Werror)
blt_convert_to_system_includes(TARGET umpire_tpl_fmt)

target_include_directories(
umpire_tpl_fmt
INTERFACE
$<INSTALL_INTERFACE:${CMAKE_INSTALL_INCLUDEDIR}>)

if (C_COMPILER_FAMILY_IS_XL)
set(_fmt_warning_disable_flag
$<$<NOT:$<COMPILE_LANGUAGE:CUDA>>:-Wno-unknown-attributes>
$<$<COMPILE_LANGUAGE:CUDA>:-Xcompiler=-Wno-unknown-attributes>)

target_compile_options(umpire_tpl_fmt INTERFACE ${_fmt_warning_disable_flag})
endif ()
if (NOT TARGET fmt::fmt)
if (DEFINED fmt_DIR)
find_package(fmt REQUIRED
NO_DEFAULT_PATH
PATHS
${fmt_DIR}
${fmt_DIR}/lib64/cmake/fmt)

if (C_COMPILER_FAMILY_IS_PGI)
set(_fmt_warning_disable_flag
"--diag_suppress 1625;--diag_suppress 185;--diag_suppress 811;--diag_suppress 186")

if (ENABLE_FORTRAN)
target_compile_options(umpire_tpl_fmt
INTERFACE
$<$<NOT:$<COMPILE_LANGUAGE:Fortran>>:${_fmt_warning_disable_flag}>)
set_target_properties(fmt::fmt PROPERTIES IMPORTED_GLOBAL TRUE)
blt_convert_to_system_includes(TARGET fmt::fmt)
else ()
target_compile_options(umpire_tpl_fmt
INTERFACE
${_fmt_warning_disable_flag})
if (NOT EXISTS ${PROJECT_SOURCE_DIR}/src/tpl/umpire/fmt/CMakeLists.txt)
message(FATAL_ERROR "fmt submodule not initialized. Run 'git submodule update --init --recursive' in the git repository or set fmt_DIR to use an external build of fmt.")
else ()
set(FMT_INSTALL ON)
set(FMT_SYSTEM_HEADERS ON)
add_subdirectory(umpire/fmt)
endif ()
endif ()
endif ()

install(TARGETS
umpire_tpl_fmt
EXPORT umpire-targets
LIBRARY DESTINATION ${CMAKE_INSTALL_LIBDIR}
ARCHIVE DESTINATION ${CMAKE_INSTALL_LIBDIR})

install(FILES
${fmt_headers}
DESTINATION ${CMAKE_INSTALL_INCLUDEDIR}/umpire/fmt)

set(UMPIRE_ENABLE_TESTS ${OLD_ENABLE_TESTS})
set(UMPIRE_ENABLE_FORTRAN ${OLD_ENABLE_FORTRAN})
27 changes: 0 additions & 27 deletions src/tpl/umpire/fmt/LICENSE.rst

This file was deleted.

7 changes: 0 additions & 7 deletions src/tpl/umpire/fmt/README

This file was deleted.

Loading

0 comments on commit b3953ce

Please sign in to comment.