Skip to content

Commit

Permalink
Merge pull request #2221 from DARMA-tasking/2216-fmt-library-incompat…
Browse files Browse the repository at this point in the history
…ibilities

2216: Allow `fmt` to be used as external lib
  • Loading branch information
lifflander authored Apr 30, 2024
2 parents 86a399f + 4a64c6e commit a4a29a2
Show file tree
Hide file tree
Showing 68 changed files with 318 additions and 54 deletions.
1 change: 1 addition & 0 deletions ci/azure/azure-clang-10-ubuntu-mpich.yml
Original file line number Diff line number Diff line change
Expand Up @@ -44,6 +44,7 @@ variables:
VT_POOL: 1
VT_EXTENDED_TESTS: 1
VT_TESTS_NUM_NODES: 4
VT_EXTERNAL_FMT: 0
VT_UNITY_BUILD: 1
VT_PRODUCTION_BUILD: 0
VT_FCONTEXT: 0
Expand Down
1 change: 1 addition & 0 deletions ci/azure/azure-clang-11-ubuntu-mpich.yml
Original file line number Diff line number Diff line change
Expand Up @@ -44,6 +44,7 @@ variables:
VT_POOL: 1
VT_EXTENDED_TESTS: 1
VT_TESTS_NUM_NODES: 2
VT_EXTERNAL_FMT: 0
VT_UNITY_BUILD: 1
VT_PRODUCTION_BUILD: 0
VT_FCONTEXT: 1
Expand Down
1 change: 1 addition & 0 deletions ci/azure/azure-clang-12-ubuntu-mpich.yml
Original file line number Diff line number Diff line change
Expand Up @@ -44,6 +44,7 @@ variables:
VT_POOL: 1
VT_EXTENDED_TESTS: 1
VT_TESTS_NUM_NODES: 2
VT_EXTERNAL_FMT: 0
VT_UNITY_BUILD: 1
VT_PRODUCTION_BUILD: 0
VT_FCONTEXT: 0
Expand Down
1 change: 1 addition & 0 deletions ci/azure/azure-clang-13-ubuntu-mpich.yml
Original file line number Diff line number Diff line change
Expand Up @@ -44,6 +44,7 @@ variables:
VT_POOL: 1
VT_EXTENDED_TESTS: 1
VT_TESTS_NUM_NODES: 2
VT_EXTERNAL_FMT: 0
VT_UNITY_BUILD: 1
VT_PRODUCTION_BUILD: 0
VT_FCONTEXT: 0
Expand Down
1 change: 1 addition & 0 deletions ci/azure/azure-clang-14-ubuntu-mpich.yml
Original file line number Diff line number Diff line change
Expand Up @@ -44,6 +44,7 @@ variables:
VT_POOL: 1
VT_EXTENDED_TESTS: 1
VT_TESTS_NUM_NODES: 2
VT_EXTERNAL_FMT: 0
VT_UNITY_BUILD: 1
VT_PRODUCTION_BUILD: 0
VT_FCONTEXT: 0
Expand Down
1 change: 1 addition & 0 deletions ci/azure/azure-clang-9-ubuntu-mpich.yml
Original file line number Diff line number Diff line change
Expand Up @@ -44,6 +44,7 @@ variables:
VT_POOL: 1
VT_EXTENDED_TESTS: 1
VT_TESTS_NUM_NODES: 2
VT_EXTERNAL_FMT: 0
VT_UNITY_BUILD: 1
VT_PRODUCTION_BUILD: 0
VT_FCONTEXT: 0
Expand Down
1 change: 1 addition & 0 deletions ci/azure/azure-clang-alpine-mpich.yml
Original file line number Diff line number Diff line change
Expand Up @@ -44,6 +44,7 @@ variables:
VT_POOL: 1
VT_EXTENDED_TESTS: 1
VT_TESTS_NUM_NODES: 2
VT_EXTERNAL_FMT: 0
VT_UNITY_BUILD: 1
VT_PRODUCTION_BUILD: 1
VT_FCONTEXT: 0
Expand Down
1 change: 1 addition & 0 deletions ci/azure/azure-gcc-10-ubuntu-openmpi.yml
Original file line number Diff line number Diff line change
Expand Up @@ -44,6 +44,7 @@ variables:
VT_POOL: 1
VT_EXTENDED_TESTS: 1
VT_TESTS_NUM_NODES: 4
VT_EXTERNAL_FMT: 0
VT_UNITY_BUILD: 1
VT_PRODUCTION_BUILD: 0
VT_FCONTEXT: 0
Expand Down
1 change: 1 addition & 0 deletions ci/azure/azure-gcc-11-ubuntu-mpich.yml
Original file line number Diff line number Diff line change
Expand Up @@ -44,6 +44,7 @@ variables:
VT_POOL: 1
VT_EXTENDED_TESTS: 1
VT_TESTS_NUM_NODES: 2
VT_EXTERNAL_FMT: 0
VT_UNITY_BUILD: 0
VT_PRODUCTION_BUILD: 0
VT_FCONTEXT: 0
Expand Down
1 change: 1 addition & 0 deletions ci/azure/azure-gcc-12-ubuntu-mpich.yml
Original file line number Diff line number Diff line change
Expand Up @@ -44,6 +44,7 @@ variables:
VT_POOL: 1
VT_EXTENDED_TESTS: 1
VT_TESTS_NUM_NODES: 2
VT_EXTERNAL_FMT: 0
VT_UNITY_BUILD: 1
VT_PRODUCTION_BUILD: 0
VT_FCONTEXT: 0
Expand Down
1 change: 1 addition & 0 deletions ci/azure/azure-gcc-8-ubuntu-mpich.yml
Original file line number Diff line number Diff line change
Expand Up @@ -44,6 +44,7 @@ variables:
VT_POOL: 0
VT_EXTENDED_TESTS: 1
VT_TESTS_NUM_NODES: 2
VT_EXTERNAL_FMT: 0
VT_UNITY_BUILD: 0
VT_PRODUCTION_BUILD: 0
VT_FCONTEXT: 0
Expand Down
1 change: 1 addition & 0 deletions ci/azure/azure-gcc-9-ubuntu-mpich.yml
Original file line number Diff line number Diff line change
Expand Up @@ -44,6 +44,7 @@ variables:
VT_POOL: 1
VT_EXTENDED_TESTS: 1
VT_TESTS_NUM_NODES: 2
VT_EXTERNAL_FMT: 0
VT_UNITY_BUILD: 1
VT_PRODUCTION_BUILD: 0
VT_FCONTEXT: 0
Expand Down
1 change: 1 addition & 0 deletions ci/azure/azure-intel-oneapi-icpc-ubuntu-mpich.yml
Original file line number Diff line number Diff line change
Expand Up @@ -44,6 +44,7 @@ variables:
VT_POOL: 1
VT_EXTENDED_TESTS: 0
VT_TESTS_NUM_NODES: 2
VT_EXTERNAL_FMT: 0
VT_UNITY_BUILD: 1
VT_PRODUCTION_BUILD: 0
VT_FCONTEXT: 0
Expand Down
1 change: 1 addition & 0 deletions ci/azure/azure-intel-oneapi-icpx-ubuntu-mpich.yml
Original file line number Diff line number Diff line change
Expand Up @@ -44,6 +44,7 @@ variables:
VT_POOL: 0
VT_EXTENDED_TESTS: 0
VT_TESTS_NUM_NODES: 2
VT_EXTERNAL_FMT: 0
VT_UNITY_BUILD: 1
VT_PRODUCTION_BUILD: 0
VT_FCONTEXT: 0
Expand Down
1 change: 1 addition & 0 deletions ci/azure/azure-nvidia-11-2-ubuntu-mpich.yml
Original file line number Diff line number Diff line change
Expand Up @@ -44,6 +44,7 @@ variables:
VT_POOL: 0
VT_EXTENDED_TESTS: 0
VT_TESTS_NUM_NODES: 4
VT_EXTERNAL_FMT: 1
VT_UNITY_BUILD: 1
VT_PRODUCTION_BUILD: 0
VT_FCONTEXT: 0
Expand Down
1 change: 1 addition & 0 deletions ci/azure/azure-nvidia-12-ubuntu-mpich.yml
Original file line number Diff line number Diff line change
Expand Up @@ -44,6 +44,7 @@ variables:
VT_POOL: 0
VT_EXTENDED_TESTS: 0
VT_TESTS_NUM_NODES: 4
VT_EXTERNAL_FMT: 0
VT_UNITY_BUILD: 1
VT_PRODUCTION_BUILD: 0
VT_FCONTEXT: 0
Expand Down
1 change: 1 addition & 0 deletions ci/build_cpp.sh
Original file line number Diff line number Diff line change
Expand Up @@ -126,6 +126,7 @@ cmake -G "${CMAKE_GENERATOR:-Ninja}" \
-Dvt_ci_build="${VT_CI_BUILD:-0}" \
-Dvt_debug_verbose="${VT_DEBUG_VERBOSE:-0}" \
-Dvt_tests_num_nodes="${VT_TESTS_NUM_NODES:-}" \
-Dvt_external_fmt="${VT_EXTERNAL_FMT:-0}" \
-Dvt_no_color_enabled="${VT_NO_COLOR_ENABLED:-0}" \
-DCMAKE_CXX_STANDARD="${CMAKE_CXX_STANDARD:-17}" \
-DBUILD_SHARED_LIBS="${BUILD_SHARED_LIBS:-0}" \
Expand Down
1 change: 1 addition & 0 deletions ci/build_vt_sample.sh
Original file line number Diff line number Diff line change
Expand Up @@ -50,6 +50,7 @@ then
-Dvt_trace_only="1" \
-Dvt_build_examples="0" \
-Dvt_build_tests="0" \
-Dvt_external_fmt="${VT_EXTERNAL_FMT:-0}" \
-DCMAKE_CXX_STANDARD="${CMAKE_CXX_STANDARD:-17}" \
-DCMAKE_EXPORT_COMPILE_COMMANDS=1 \
-DCMAKE_BUILD_TYPE="${CMAKE_BUILD_TYPE:-Release}" \
Expand Down
23 changes: 23 additions & 0 deletions ci/deps/fmt.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1,23 @@
#!/usr/bin/env bash

set -exo pipefail

if test $# -lt 1
then
echo "usage: ./$0 <fmt-version> <make_flags>"
exit 1
fi

fmt_version=$1

base_dir=$(pwd)

git clone https://github.com/fmtlib/fmt.git
cd fmt
git checkout ${fmt_version}
mkdir build && cd build
cmake .. -D FMT_TEST=OFF
make ${make_flags}
make install
cd ${base_dir}
rm -rf fmt
8 changes: 8 additions & 0 deletions ci/docker/ubuntu-nvidia-cpp.dockerfile
Original file line number Diff line number Diff line change
Expand Up @@ -51,6 +51,14 @@ ENV LESSCHARSET=utf-8
COPY ./ci/deps/mpich.sh mpich.sh
RUN ./mpich.sh 3.3.2 -j4

ARG external_fmt
COPY ./ci/deps/fmt.sh fmt.sh

RUN if test ${external_fmt} -eq 1; then \
chmod +x ./fmt.sh && \
./fmt.sh 7.1.3 -j4; \
fi

RUN mkdir -p /nvcc_wrapper/build && \
wget https://raw.githubusercontent.com/kokkos/kokkos/master/bin/nvcc_wrapper -P /nvcc_wrapper/build && \
chmod +x /nvcc_wrapper/build/nvcc_wrapper
Expand Down
9 changes: 9 additions & 0 deletions cmake/configure_options.cmake
Original file line number Diff line number Diff line change
Expand Up @@ -151,6 +151,15 @@ define_option(vt_build_tests "tests" "Build VT tests" ON empty_feature)
define_option(vt_build_tools "tools" "Build VT tools" ON empty_feature)
define_option(vt_build_examples "examples" "Build VT examples" ON empty_feature)

option(vt_external_fmt "Build VT with external fmt" OFF)
if(${vt_external_fmt})
message(STATUS "Building vt with external fmt library")
set(vt_feature_cmake_external_fmt "1")
else()
message(STATUS "Building vt with included fmt library")
set(vt_feature_cmake_external_fmt "0")
endif()

list(POP_BACK CMAKE_MESSAGE_INDENT)

##########################################################################################################
14 changes: 11 additions & 3 deletions cmake/link_vt.cmake
Original file line number Diff line number Diff line change
Expand Up @@ -170,9 +170,17 @@ function(link_target_with_vt)
if (${ARG_DEBUG_LINK})
message(STATUS "link_target_with_vt: fmt=${ARG_LINK_FMT}")
endif()
target_link_libraries(
${ARG_TARGET} PUBLIC ${ARG_BUILD_TYPE} ${FMT_LIBRARY}
)

if(${vt_external_fmt})
target_link_libraries(
${ARG_TARGET} PUBLIC ${ARG_BUILD_TYPE} fmt::fmt
)
else()
target_link_libraries(
${ARG_TARGET} PUBLIC ${ARG_BUILD_TYPE} ${FMT_LIBRARY}
)
endif()

endif()

if (NOT DEFINED ARG_LINK_ENG_FORMAT AND ${ARG_DEFAULT_LINK_SET} OR ARG_LINK_ENG_FORMAT)
Expand Down
22 changes: 18 additions & 4 deletions cmake/load_bundled_libraries.cmake
Original file line number Diff line number Diff line change
Expand Up @@ -20,10 +20,24 @@ endif()
# CLI11 always included in the build
add_subdirectory(${PROJECT_LIB_DIR}/CLI)

# fmt always included in the build
set(FMT_LIBRARY fmt)
add_subdirectory(${PROJECT_LIB_DIR}/fmt)
set_darma_compiler_flags(${FMT_LIBRARY})
# use included fmt or external one
if(${vt_external_fmt})
# user should provide 'fmt_DIR' or 'fmt_ROOT' to CMake (unless fmt is installed in system libs)
if(fmt_ROOT)
message(STATUS "vt_external_fmt = ON. Using fmt located at ${fmt_ROOT}")
elseif(fmt_DIR)
message(STATUS "vt_external_fmt = ON. Using fmt located at ${fmt_DIR}")
else()
message(STATUS "vt_external_fmt = ON but neither fmt_DIR nor fmt_ROOT is provided!")
endif()
find_package(fmt 7.1.0 REQUIRED)

else()
set(FMT_LIBRARY fmt)
add_subdirectory(${PROJECT_LIB_DIR}/fmt)
set_darma_compiler_flags(${FMT_LIBRARY})
endif()


# EngFormat-Cpp always included in the build
set(ENG_FORMAT_LIBRARY EngFormat-Cpp)
Expand Down
5 changes: 5 additions & 0 deletions cmake/vtConfig.cmake.in
Original file line number Diff line number Diff line change
Expand Up @@ -26,4 +26,9 @@ endif()
set (VT_INCLUDE_DIRS "@CMAKE_INSTALL_PREFIX@/include")
set (VT_CXX_COMPILER "@CMAKE_CXX_COMPILER@")

if (@vt_external_fmt@)
set (fmt_DIR @fmt_DIR@)
find_dependency(fmt REQUIRED HINTS @fmt_DIR@)
endif()

set(VT_HAS_FMT "TRUE")
18 changes: 17 additions & 1 deletion cmake_config.h.in
Original file line number Diff line number Diff line change
Expand Up @@ -65,7 +65,7 @@
#define vt_feature_cmake_production_build @vt_feature_cmake_production_build@
#define vt_feature_cmake_debug_verbose @vt_feature_cmake_debug_verbose@
#define vt_feature_cmake_rdma_tests @vt_feature_cmake_rdma_tests@

#define vt_feature_cmake_external_fmt @vt_feature_cmake_external_fmt@

#define vt_detected_max_num_nodes @cmake_detected_max_num_nodes@

Expand All @@ -91,3 +91,19 @@
#cmakedefine vt_has_sysconf
#cmakedefine vt_has_libunwind_h
#cmakedefine vt_has_execinfo_h

#if vt_feature_cmake_external_fmt
#define INCLUDE_FMT_CORE <fmt/core.h>
#define INCLUDE_FMT_FORMAT <fmt/format.h>
#define INCLUDE_FMT_OSTREAM <fmt/ostream.h>

#define VT_FMT_NAMESPACE_BEGIN namespace fmt {
#define VT_FMT_NAMESPACE_END }
#else
#define INCLUDE_FMT_CORE <fmt-vt/core.h>
#define INCLUDE_FMT_FORMAT <fmt-vt/format.h>
#define INCLUDE_FMT_OSTREAM <fmt-vt/ostream.h>

#define VT_FMT_NAMESPACE_BEGIN namespace fmt { inline namespace vt {
#define VT_FMT_NAMESPACE_END } }
#endif
2 changes: 2 additions & 0 deletions docker-compose.yml
Original file line number Diff line number Diff line change
Expand Up @@ -112,6 +112,7 @@ x-vtopts: &vtopts
VT_CI_BUILD: ${VT_CI_BUILD:-0}
VT_DEBUG_VERBOSE: ${VT_DEBUG_VERBOSE:-0}
VT_TESTS_NUM_NODES: ${VT_TESTS_NUM_NODES:-}
VT_EXTERNAL_FMT: ${VT_EXTERNAL_FMT:-0}
VT_NO_COLOR_ENABLED: ${VT_NO_COLOR:-0}
BUILD_SHARED_LIBS: ${VT_BUILD_SHARED_LIBS:-0}
VT_INCLUSION_TYPE: ${VT_INCLUSION:-TPL}
Expand All @@ -138,6 +139,7 @@ services:
ubuntu: ${UBUNTU}
ubsan_enabled: ${VT_UBSAN:-0}
zoltan_enabled: ${VT_ZOLTAN:-0}
external_fmt: ${VT_EXTERNAL_FMT:-0}
cache_from:
- ${REPO}:${ARCH}-ubuntu-${UBUNTU}-${HOST_COMPILER}-${COMPILER}-cpp
ulimits: &ulimits
Expand Down
1 change: 1 addition & 0 deletions scripts/workflow-azure-template.yml
Original file line number Diff line number Diff line change
Expand Up @@ -32,6 +32,7 @@ variables:
VT_POOL: [% vt_pool %]
VT_EXTENDED_TESTS: [% vt_extended_tests %]
VT_TESTS_NUM_NODES: [% vt_tests_num_nodes %]
VT_EXTERNAL_FMT: [% vt_external_fmt %]
VT_UNITY_BUILD: [% vt_unity_build %]
VT_PRODUCTION_BUILD: [% vt_production_build %]
VT_FCONTEXT: [% vt_fcontext %]
Expand Down
2 changes: 2 additions & 0 deletions scripts/workflows-azure.ini
Original file line number Diff line number Diff line change
Expand Up @@ -17,6 +17,7 @@ vt_fcontext = 0
vt_zoltan = 0
vt_ci_build = 1
vt_tests_num_nodes = 2
vt_external_fmt = 0
test_lb_schema = 0
ulimit_core = 0
vt_code_coverage = 0
Expand Down Expand Up @@ -93,6 +94,7 @@ vt_diagnostics = 0
vt_trace = 1
vt_pool = 0
vt_tests_num_nodes = 4
vt_external_fmt = 1

[PR-tests-gcc-8]
test_configuration = "gcc-8, ubuntu, mpich, address sanitizer"
Expand Down
1 change: 1 addition & 0 deletions src/vt/collective/reduce/reduce_manager.h
Original file line number Diff line number Diff line change
Expand Up @@ -47,6 +47,7 @@
#include "vt/collective/reduce/reduce_scope.h"
#include "vt/collective/tree/tree.h"

#include <memory>
namespace vt { namespace collective { namespace reduce {

struct Reduce;
Expand Down
2 changes: 1 addition & 1 deletion src/vt/configs/debug/debug_fmt.h
Original file line number Diff line number Diff line change
Expand Up @@ -46,7 +46,7 @@

#include "vt/config.h"

#include <fmt-vt/core.h>
#include INCLUDE_FMT_CORE

#include <iosfwd>

Expand Down
2 changes: 1 addition & 1 deletion src/vt/configs/debug/debug_print.h
Original file line number Diff line number Diff line change
Expand Up @@ -49,7 +49,7 @@
#include "vt/configs/debug/debug_colorize.h"
#include "vt/configs/debug/debug_var_unused.h"

#include <fmt-vt/core.h>
#include INCLUDE_FMT_CORE

/*
=== Debug file/line/func functionality ===
Expand Down
2 changes: 1 addition & 1 deletion src/vt/configs/error/assert_out.impl.h
Original file line number Diff line number Diff line change
Expand Up @@ -56,7 +56,7 @@
#include <string>
#include <cassert>

#include <fmt-vt/core.h>
#include INCLUDE_FMT_CORE

namespace vt { namespace debug { namespace assert {

Expand Down
2 changes: 1 addition & 1 deletion src/vt/configs/error/assert_out_info.impl.h
Original file line number Diff line number Diff line change
Expand Up @@ -57,7 +57,7 @@
#include <string>
#include <sstream>

#include <fmt-vt/core.h>
#include INCLUDE_FMT_CORE

namespace vt { namespace debug { namespace assert {

Expand Down
2 changes: 1 addition & 1 deletion src/vt/configs/error/error.impl.h
Original file line number Diff line number Diff line change
Expand Up @@ -55,7 +55,7 @@
#include <tuple>
#include <type_traits>

#include <fmt-vt/core.h>
#include INCLUDE_FMT_CORE

namespace vt { namespace error {

Expand Down
2 changes: 1 addition & 1 deletion src/vt/configs/error/keyval_printer.impl.h
Original file line number Diff line number Diff line change
Expand Up @@ -53,7 +53,7 @@
#include <string>
#include <vector>

#include <fmt-vt/core.h>
#include INCLUDE_FMT_CORE

namespace vt { namespace util { namespace error {

Expand Down
2 changes: 1 addition & 1 deletion src/vt/configs/error/pretty_print_message.cc
Original file line number Diff line number Diff line change
Expand Up @@ -50,7 +50,7 @@
#include <string>
#include <unistd.h> // gethostname

#include <fmt-vt/core.h>
#include INCLUDE_FMT_CORE

namespace vt { namespace debug {

Expand Down
Loading

0 comments on commit a4a29a2

Please sign in to comment.