diff --git a/.gitlab-ci.yml b/.gitlab-ci.yml index 0c07079fb..ac47634a0 100644 --- a/.gitlab-ci.yml +++ b/.gitlab-ci.yml @@ -22,6 +22,9 @@ # We define the following GitLab pipeline variables: variables: +# Required information about GitHub repository + GITHUB_PROJECT_NAME: "Umpire" + GITHUB_PROJECT_ORG: "LLNL" # Use the umdev LLNL service user to run CI. This prevents from running # pipelines as an actual user. LLNL_SERVICE_USER: umdev @@ -33,9 +36,14 @@ variables: # We build the projects in the CI clone directory. # TODO: add a clean-up mechanism BUILD_ROOT: ${CI_PROJECT_DIR} +# Set the build-and-test command. + BUILD_AND_TEST_CMD: "./scripts/gitlab/build_and_test.sh" +# Override the list of branch that will skip the "draft PR test". +# Add protected branches here. Defaults to "develop main master". +# ALWAYS_RUN_LIST: "" -# We organize the CI on Gitlab in sub-pipelines. Each sub-pipeline corresponds -# to a test phase on a given machine. +# We organize the build-and-test stage in sub-pipelines. Each sub-pipeline +# corresponds to a test batch on a given machine. # High level stages stages: @@ -50,13 +58,17 @@ stages: include: - local: '.gitlab/custom-jobs-and-variables.yml' - project: 'radiuss/radiuss-shared-ci' - ref: v2022.09.0 + ref: v2023.03.0rc file: '${CI_MACHINE}-build-and-test.yml' - local: '.gitlab/${CI_MACHINE}-build-and-test-extra.yml' strategy: depend forward: pipeline_variables: true -# pipelines subscribed by the project include: + # [Optional] checks preliminary to running the actual CI test + #- project: 'radiuss/radiuss-shared-ci' + # ref: v2023.03.0rc + # file: 'preliminary-ignore-draft-pr.yml' + # pipelines subscribed by the project - local: .gitlab/subscribed-pipelines.yml diff --git a/.gitlab/corona-build-and-test-extra.yml b/.gitlab/corona-build-and-test-extra.yml index 714d40088..6d0d4ea83 100644 --- a/.gitlab/corona-build-and-test-extra.yml +++ b/.gitlab/corona-build-and-test-extra.yml @@ -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. ### -rocm_5_1_1_openmp_clang_13_0_0: +rocmcc_5_4_1_hip_openmp: variables: - SPEC: "+fortran +openmp +rocm amdgpu_target=gfx906 %clang@13.0.0 ^hip@5.1.1 ^blt@develop" + SPEC: "~shared +fortran +openmp +rocm +device_alloc tests=basic amdgpu_target=gfx906 %rocmcc@5.4.1 ^hip@5.4.1 ^blt@develop" extends: .build_and_test_on_corona diff --git a/.gitlab/custom-jobs-and-variables.yml b/.gitlab/custom-jobs-and-variables.yml index 48ed4c6bb..628c0516a 100644 --- a/.gitlab/custom-jobs-and-variables.yml +++ b/.gitlab/custom-jobs-and-variables.yml @@ -7,7 +7,6 @@ # We define the following GitLab pipeline variables: variables: - # On LLNL's ruby, this pipeline creates only one allocation shared among jobs # in order to save time and resources. This allocation has to be uniquely named # so that we are sure to retrieve it and avoid collisions. @@ -15,35 +14,46 @@ variables: # Ruby # Arguments for top level allocation - RUBY_BUILD_AND_TEST_SHARED_ALLOC: "--exclusive --partition=pdebug --time=10 --nodes=1" + RUBY_BUILD_AND_TEST_SHARED_ALLOC: "--exclusive --reservation=ci --qos=ci_ruby --time=10 --nodes=1" # Arguments for job level allocation - RUBY_BUILD_AND_TEST_JOB_ALLOC: "--overlap --time=10 --nodes=1" + RUBY_BUILD_AND_TEST_JOB_ALLOC: "--overlap --reservation=ci --qos=ci_ruby --time=10 --nodes=1" # Project specific variants for ruby - PROJECT_RUBY_VARIANTS: "+fortran " + PROJECT_RUBY_VARIANTS: "~shared +fortran ~device_alloc +tools tests=basic " # Project specific deps for ruby PROJECT_RUBY_DEPS: "" # Corona # Arguments for top level allocation - CORONA_BUILD_AND_TEST_SHARED_ALLOC: "--time-limit=15m --nodes=1" + CORONA_BUILD_AND_TEST_SHARED_ALLOC: "--exclusive --time-limit=15m --nodes=1" # Arguments for job level allocation CORONA_BUILD_AND_TEST_JOB_ALLOC: "--time-limit=10m --nodes=1" # Project specific variants for corona - PROJECT_CORONA_VARIANTS: "+fortran " + PROJECT_CORONA_VARIANTS: "~shared +fortran ~device_alloc tests=basic " # Project specific deps for corona PROJECT_CORONA_DEPS: "^blt@develop" +# Tioga +# Arguments for top level allocation + TIOGA_BUILD_AND_TEST_SHARED_ALLOC: "--exclusive --time-limit=15m --nodes=1" +# Arguments for job level allocation + TIOGA_BUILD_AND_TEST_JOB_ALLOC: "--time-limit=10m --nodes=1" +# Project specific variants for tioga + PROJECT_TIOGA_VARIANTS: "~shared +fortran ~device_alloc tests=basic " +# Project specific deps for tioga + PROJECT_TIOGA_DEPS: "^blt@develop" + # Lassen and Butte use a different job scheduler (spectrum lsf) that does not # allow pre-allocation the same way slurm does. # Arguments for job level allocation LASSEN_BUILD_AND_TEST_JOB_ALLOC: "1 -W 18" # Project specific variants for lassen - PROJECT_LASSEN_VARIANTS: "+fortran " + PROJECT_LASSEN_VARIANTS: "~shared +fortran ~device_alloc +tools tests=basic " # Project specific deps for lassen PROJECT_LASSEN_DEPS: "" + # Configuration shared by build and test jobs specific to this project. -# Not all configuration can be shared, here is here projects can fine tune the +# Not all configuration can be shared. Here projects can fine tune the # CI behavior. .custom_build_and_test: artifacts: diff --git a/.gitlab/lassen-build-and-test-extra.yml b/.gitlab/lassen-build-and-test-extra.yml index bc6f8e2a8..a865e8f1c 100644 --- a/.gitlab/lassen-build-and-test-extra.yml +++ b/.gitlab/lassen-build-and-test-extra.yml @@ -12,81 +12,88 @@ # We keep ${PROJECT__VARIANTS} and ${PROJECT__DEPS} So that # the comparison with the original job is easier. -# No overridden jobs so far. +# Spec has test disabled in shared CI, conflicting with default test setting in Umpire +# TODO: This is likely an issue in RADIUSS Shared CI: why disable tests ?. +xl_16_1_1_12_gcc_8_3_1_cuda_11_0_2: + variables: + SPEC: "~shared +fortran ~device_alloc +tools +cuda tests=none %xl@16.1.1.12 cxxflags==\"--gcc-toolchain=/usr/tce/packages/gcc/gcc-8.3.1\" cflags==\"--gcc-toolchain=/usr/tce/packages/gcc/gcc-8.3.1\" ^cuda@11.0.2 ${PROJECT_LASSEN_DEPS}" + extends: .build_and_test_on_lassen + ############ # Extra jobs ############ # We do not recommend using ${PROJECT__VARIANTS} and -# ${PROJECT__DEPS} in the extra jobs. There is not reason not to fully +# ${PROJECT__DEPS} in the extra jobs. There is no reason not to fully # describe the spec here. ibm_clang_10_0_1_mpi_shmem: variables: - SPEC: "%clang@ibm.10.0.1 +ipc_shmem +mpi ^spectrum-mpi" + SPEC: "~shared ~device_alloc +tools tests=basic %clang@ibm.10.0.1 +ipc_shmem +mpi ^spectrum-mpi" extends: .build_and_test_on_lassen ibm_clang_10_0_1_mpi: variables: - SPEC: "+fortran %clang@ibm.10.0.1 +mpi ^spectrum-mpi" + SPEC: "~shared +fortran ~device_alloc +tools tests=basic %clang@ibm.10.0.1 +mpi ^spectrum-mpi" extends: .build_and_test_on_lassen ibm_clang_10_0_1_cuda_10_1_168_mpi_shmem: variables: - SPEC: "%clang@ibm.10.0.1 +cuda +ipc_shmem +mpi cxxflags=\"--gcc-toolchain=/usr/tce/packages/gcc/gcc-8.3.1\" cflags=\"--gcc-toolchain=/usr/tce/packages/gcc/gcc-8.3.1\" ^spectrum-mpi ^cuda@10.1.168" + SPEC: "~shared ~device_alloc +tools tests=basic %clang@ibm.10.0.1 +cuda +ipc_shmem +mpi cxxflags==\"--gcc-toolchain=/usr/tce/packages/gcc/gcc-8.3.1\" cflags==\"--gcc-toolchain=/usr/tce/packages/gcc/gcc-8.3.1\" ^spectrum-mpi ^cuda@10.1.168" extends: .build_and_test_on_lassen # Extras. clang_9_0_0_libcpp: variables: - SPEC: "%clang@9.0.0+libcpp cxxflags=\"-stdlib=libc++ -DGTEST_HAS_CXXABI_H_=0\" cflags=\"-DGTEST_HAS_CXXABI_H_=0\"" + SPEC: "~shared ~device_alloc +tools tests=basic %clang@9.0.0+libcpp cxxflags==\"-stdlib=libc++ -DGTEST_HAS_CXXABI_H_=0\" cflags==\"-DGTEST_HAS_CXXABI_H_=0\"" extends: .build_and_test_on_lassen clang_9_0_0_memleak: variables: - SPEC: "+asan +sanitizer_tests %clang@9.0.0 cxxflags=-fsanitize=address" + SPEC: "~shared +asan +sanitizer_tests +tools ~device_alloc tests=basic %clang@9.0.0 cxxflags==-fsanitize=address" ASAN_OPTIONS: "detect_leaks=1" extends: .build_and_test_on_lassen # clang_9_0_0_datarace (build and test on lassen): # variables: -# SPEC: "%clang@9.0.0 cxxflags=-fsanitize=thread" +# SPEC: "%clang@9.0.0 cxxflags==\"-fsanitize=thread\"" # allow_failure: true # extends: .build_and_test_on_lassen gcc_8_3_1_dev_benchmarks: variables: - SPEC: "+dev_benchmarks %gcc@8.3.1 build_type=Release" + SPEC: "~shared +dev_benchmarks +tools ~device_alloc %gcc@8.3.1 build_type=Release" extends: .build_and_test_on_lassen xl_default_omp_target: variables: - SPEC: "%xl@default+openmp+openmp_target ^cmake@3.14.5" + SPEC: "~shared ~device_alloc +tools tests=basic %xl@default+openmp+openmp_target" + allow_failure: true extends: .build_and_test_on_lassen gcc_8_3_1_numa: variables: - SPEC: "+fortran +numa%gcc@8.3.1" + SPEC: "~shared +fortran +numa +tools ~device_alloc tests=basic %gcc@8.3.1" extends: .build_and_test_on_lassen gcc_8_3_1_cuda_10_1_168: variables: - SPEC: "+fortran +cuda+shared+tools+backtrace %gcc@8.3.1 ^cuda@10.1.168" + SPEC: "+fortran +cuda +tools +backtrace ~device_alloc tests=basic %gcc@8.3.1 ^cuda@10.1.168" extends: .build_and_test_on_lassen # Develop/main builds against specific tpl versions. gcc_8_3_1_tpls: variables: - SPEC: "+fortran %gcc@8.3.1 ^blt@develop" + SPEC: "~shared +fortran ~device_alloc +tools tests=basic %gcc@8.3.1 ^blt@develop" extends: .build_and_test_on_lassen ibm_clang_9_0_0_gcc_8_3_1_cuda_10_1_168_tpls: variables: - SPEC: "+fortran +cuda %clang@ibm.9.0.0 cxxflags=\"--gcc-toolchain=/usr/tce/packages/gcc/gcc-8.3.1\" cflags=\"--gcc-toolchain=/usr/tce/packages/gcc/gcc-8.3.1\" ^cuda@10.1.168 ^blt@develop" + SPEC: "~shared +fortran +cuda ~device_alloc +tools tests=basic %clang@ibm.9.0.0 cxxflags==\"--gcc-toolchain=/usr/tce/packages/gcc/gcc-8.3.1\" cflags==\"--gcc-toolchain=/usr/tce/packages/gcc/gcc-8.3.1\" ^cuda@10.1.168 ^blt@develop" extends: .build_and_test_on_lassen xl_16_1_1_12_gcc_8_3_1_cuda_10_1_168_tpls: variables: - SPEC: "+fortran +cuda %xl@16.1.1.12 cxxflags=\"--gcc-toolchain=/usr/tce/packages/gcc/gcc-7.3.1\" cflags=\"--gcc-toolchain=/usr/tce/packages/gcc/gcc-7.3.1\" ^cuda@10.1.168 ^cmake@3.14.5 ^blt@develop" + SPEC: "~shared +fortran +cuda ~device_alloc +tools tests=basic %xl@16.1.1.12 cxxflags==\"--gcc-toolchain=/usr/tce/packages/gcc/gcc-7.3.1\" cflags==\"--gcc-toolchain=/usr/tce/packages/gcc/gcc-7.3.1\" ^cuda@10.1.168 ^blt@develop" extends: .build_and_test_on_lassen diff --git a/.gitlab/ruby-build-and-test-extra.yml b/.gitlab/ruby-build-and-test-extra.yml index c8142ed79..fc509c342 100644 --- a/.gitlab/ruby-build-and-test-extra.yml +++ b/.gitlab/ruby-build-and-test-extra.yml @@ -23,27 +23,27 @@ gcc_8_1_0_numa: variables: - SPEC: "+fortran+numa %gcc@8.1.0" + SPEC: "~shared +fortran +numa ~device_alloc +tools tests=basic %gcc@8.1.0" extends: .build_and_test_on_ruby clang_10_0_1_sqlite_experimental: variables: - SPEC: "+sqlite_experimental %clang@10.0.1" + SPEC: "~shared +sqlite_experimental ~device_alloc +tools tests=basic %clang@10.0.1" extends: .build_and_test_on_ruby # Develop builds against specific tpl version. pgi_20_1_gcc_local_8_3_1_tpls: variables: - SPEC: "+fortran %pgi@20.1 cxxflags=-rc=/usr/workspace/umpire/pgi/x86_64/local-gcc-8.3.1-rc cflags=-rc=/usr/workspace/umpire/pgi/x86_64/local-gcc-8.3.1-rc fflags=-rc=/usr/workspace/umpire/pgi/x86_64/local-gcc-8.3.1-rc ^blt@develop" + SPEC: "~shared +fortran ~device_alloc +tools tests=basic %pgi@20.1 cxxflags==\"-rc=/usr/workspace/umpire/pgi/x86_64/local-gcc-8.3.1-rc\" cflags==\"-rc=/usr/workspace/umpire/pgi/x86_64/local-gcc-8.3.1-rc\" fflags==\"-rc=/usr/workspace/umpire/pgi/x86_64/local-gcc-8.3.1-rc\" ^blt@develop" extends: .build_and_test_on_ruby clang_10_0_1_tpls: variables: - SPEC: "+fortran %clang@10.0.1 ^blt@develop" + SPEC: "~shared +fortran ~device_alloc +tools tests=basic %clang@10.0.1 ^blt@develop" extends: .build_and_test_on_ruby gcc_8_1_0_tpls: variables: - SPEC: "+fortran %gcc@8.1.0 ^blt@develop" + SPEC: "~shared +fortran ~device_alloc +tools tests=basic %gcc@8.1.0 ^blt@develop" extends: .build_and_test_on_ruby diff --git a/.gitlab/subscribed-pipelines.yml b/.gitlab/subscribed-pipelines.yml index f01c73d0c..ca4107ed4 100644 --- a/.gitlab/subscribed-pipelines.yml +++ b/.gitlab/subscribed-pipelines.yml @@ -16,6 +16,11 @@ corona-build-and-test: CI_MACHINE: "corona" extends: [.build-and-test] +tioga-build-and-test: + variables: + CI_MACHINE: "tioga" + extends: [.build-and-test] + lassen-build-and-test: variables: CI_MACHINE: "lassen" diff --git a/.gitlab/tioga-build-and-test-extra.yml b/.gitlab/tioga-build-and-test-extra.yml new file mode 100644 index 000000000..a4be5184f --- /dev/null +++ b/.gitlab/tioga-build-and-test-extra.yml @@ -0,0 +1,32 @@ +############################################################################### +# Copyright (c) 2022, Lawrence Livermore National Security, LLC and RADIUSS +# project contributors. See the COPYRIGHT file for details. +# +# SPDX-License-Identifier: (MIT) +############################################################################### + +######################## +# Overridden shared jobs +######################## +# We duplicate the shared jobs description and add necessary changes for RAJA. +# We keep ${PROJECT__VARIANTS} and ${PROJECT__DEPS} So that +# the comparison with the original job is easier. + +# No overridden jobs so far. + +############ +# Extra jobs +############ +# We do not recommend using ${PROJECT__VARIANTS} and +# ${PROJECT__DEPS} in the extra jobs. There is not reason not to fully +# describe the spec here. + +### +# 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_4_1_hip_openmp: + variables: + SPEC: "~shared +fortran +openmp +rocm +device_alloc tests=basic amdgpu_target=gfx90a %rocmcc@5.4.1 ^hip@5.4.1 ^blt@develop" + extends: .build_and_test_on_tioga + diff --git a/.uberenv_config.json b/.uberenv_config.json index 5b2a02d76..ba68cfe38 100644 --- a/.uberenv_config.json +++ b/.uberenv_config.json @@ -4,10 +4,10 @@ "package_final_phase" : "initconfig", "package_source_dir" : "../..", "spack_url": "https://github.com/spack/spack.git", -"spack_branch": "v0.18.1", +"spack_branch": "v0.19.0", "spack_activate" : {}, "spack_configs_path": "scripts/radiuss-spack-configs", -"spack_packages_path": "scripts/spack_packages", +"spack_packages_path": "scripts/radiuss-spack-configs/packages", "spack_concretizer": "clingo", "spack_setup_clingo": false, "debug": true diff --git a/CMakeLists.txt b/CMakeLists.txt index 1fc520e21..88025b7b9 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -1,5 +1,5 @@ ############################################################################## -# Copyright (c) 2016-22, Lawrence Livermore National Security, LLC and Umpire +# Copyright (c) 2016-23, Lawrence Livermore National Security, LLC and Umpire # project contributors. See the COPYRIGHT file for details. # # SPDX-License-Identifier: (MIT) diff --git a/RELEASE b/RELEASE index 67ce1e13d..30796f0d8 100644 --- a/RELEASE +++ b/RELEASE @@ -1,6 +1,6 @@ Umpire Version 2022.10.0 -Copyright (c) 2016-22, Lawrence Livermore National Security, LLC. +Copyright (c) 2016-23, Lawrence Livermore National Security, LLC. Produced at the Lawrence Livermore National Laboratory. All rights reserved. See details in Umpire/LICENSE. diff --git a/benchmarks/CMakeLists.txt b/benchmarks/CMakeLists.txt index 8fece7704..4f3a64e5b 100644 --- a/benchmarks/CMakeLists.txt +++ b/benchmarks/CMakeLists.txt @@ -1,5 +1,5 @@ ############################################################################## -# Copyright (c) 2016-22, Lawrence Livermore National Security, LLC and Umpire +# Copyright (c) 2016-23, Lawrence Livermore National Security, LLC and Umpire # project contributors. See the COPYRIGHT file for details. # # SPDX-License-Identifier: (MIT) @@ -17,7 +17,8 @@ blt_add_executable( SOURCES allocator_stress_test.cpp DEPENDS_ON ${stress_test_depends}) -if (ENABLE_CUDA AND UMPIRE_ENABLE_DEVICE_ALLOCATOR) +if (UMPIRE_ENABLE_DEVICE_ALLOCATOR) + if (UMPIRE_ENABLE_CUDA) blt_add_executable( NAME device_allocator_stress_test SOURCES device_allocator_stress_test.cpp @@ -30,6 +31,16 @@ if (ENABLE_CUDA AND UMPIRE_ENABLE_DEVICE_ALLOCATOR) set_target_properties( device_allocator_stress_test PROPERTIES CUDA_SEPARABLE_COMPILATION On) + elseif (UMPIRE_ENABLE_HIP) + blt_add_executable( + NAME device_allocator_stress_test + SOURCES device_allocator_stress_test.cpp + DEPENDS_ON umpire blt::hip blt::hip_runtime) + + set_target_properties( + device_allocator_stress_test + PROPERTIES LINK_FLAGS "-fgpu-rdc") + endif() endif() blt_add_executable( diff --git a/benchmarks/allocator_benchmarks.cpp b/benchmarks/allocator_benchmarks.cpp index 1464bb5ba..f1c7f7f3e 100644 --- a/benchmarks/allocator_benchmarks.cpp +++ b/benchmarks/allocator_benchmarks.cpp @@ -1,5 +1,5 @@ ////////////////////////////////////////////////////////////////////////////// -// Copyright (c) 2016-22, Lawrence Livermore National Security, LLC and Umpire +// Copyright (c) 2016-23, Lawrence Livermore National Security, LLC and Umpire // project contributors. See the COPYRIGHT file for details. // // SPDX-License-Identifier: (MIT) diff --git a/benchmarks/allocator_memory_cost_benchmark.cpp b/benchmarks/allocator_memory_cost_benchmark.cpp index 4b76ca2e9..02eddc590 100644 --- a/benchmarks/allocator_memory_cost_benchmark.cpp +++ b/benchmarks/allocator_memory_cost_benchmark.cpp @@ -1,5 +1,5 @@ ////////////////////////////////////////////////////////////////////////////// -// Copyright (c) 2016-22, Lawrence Livermore National Security, LLC and Umpire +// Copyright (c) 2016-23, Lawrence Livermore National Security, LLC and Umpire // project contributors. See the COPYRIGHT file for details. // // SPDX-License-Identifier: (MIT) diff --git a/benchmarks/allocator_stress_test.cpp b/benchmarks/allocator_stress_test.cpp index edf542e0c..7e7de6aa1 100644 --- a/benchmarks/allocator_stress_test.cpp +++ b/benchmarks/allocator_stress_test.cpp @@ -1,5 +1,5 @@ ////////////////////////////////////////////////////////////////////////////// -// Copyright (c) 2016-22, Lawrence Livermore National Security, LLC and Umpire +// Copyright (c) 2016-23, Lawrence Livermore National Security, LLC and Umpire // project contributors. See the COPYRIGHT file for details. // // SPDX-License-Identifier: (MIT) diff --git a/benchmarks/copy_benchmarks.cpp b/benchmarks/copy_benchmarks.cpp index c9c470241..3738679db 100644 --- a/benchmarks/copy_benchmarks.cpp +++ b/benchmarks/copy_benchmarks.cpp @@ -1,5 +1,5 @@ ////////////////////////////////////////////////////////////////////////////// -// Copyright (c) 2016-22, Lawrence Livermore National Security, LLC and Umpire +// Copyright (c) 2016-23, Lawrence Livermore National Security, LLC and Umpire // project contributors. See the COPYRIGHT file for details. // // SPDX-License-Identifier: (MIT) diff --git a/benchmarks/copy_stress_test.cpp b/benchmarks/copy_stress_test.cpp index abcf12db2..5a50d9428 100644 --- a/benchmarks/copy_stress_test.cpp +++ b/benchmarks/copy_stress_test.cpp @@ -1,5 +1,5 @@ ////////////////////////////////////////////////////////////////////////////// -// Copyright (c) 2016-22, Lawrence Livermore National Security, LLC and Umpire +// Copyright (c) 2016-23, Lawrence Livermore National Security, LLC and Umpire // project contributors. See the COPYRIGHT file for details. // // SPDX-License-Identifier: (MIT) diff --git a/benchmarks/debuglog_benchmarks.cpp b/benchmarks/debuglog_benchmarks.cpp index b2301994c..4ea8a06c8 100644 --- a/benchmarks/debuglog_benchmarks.cpp +++ b/benchmarks/debuglog_benchmarks.cpp @@ -1,5 +1,5 @@ ////////////////////////////////////////////////////////////////////////////// -// Copyright (c) 2016-22, Lawrence Livermore National Security, LLC and Umpire +// Copyright (c) 2016-23, Lawrence Livermore National Security, LLC and Umpire // project contributors. See the COPYRIGHT file for details. // // SPDX-License-Identifier: (MIT) diff --git a/benchmarks/device_allocator_stress_test.cpp b/benchmarks/device_allocator_stress_test.cpp index 47d9b8fc8..502892a8c 100644 --- a/benchmarks/device_allocator_stress_test.cpp +++ b/benchmarks/device_allocator_stress_test.cpp @@ -38,7 +38,7 @@ __global__ void only_first(double** data_ptr) } } -__global__ void each_thread(double** data_ptr, unsigned int N) +__global__ void each_thread(double** data_ptr, int N) { int idx = blockIdx.x * blockDim.x + threadIdx.x; if (idx < N) { @@ -49,6 +49,7 @@ __global__ void each_thread(double** data_ptr, unsigned int N) } } +#if defined(UMPIRE_ENABLE_CUDA) static void CudaTest(const char *msg) { cudaError_t e = cudaGetLastError(); @@ -59,7 +60,20 @@ static void CudaTest(const char *msg) exit(-1); } } +#elif defined(UMPIRE_ENABLE_HIP) +static void HipTest(const char *msg) +{ + hipError_t e = hipGetLastError(); + hipDeviceSynchronize(); + if (hipSuccess != e) { + fprintf(stderr, "%s: %d\n", msg, e); + fprintf(stderr, "%s\n", hipGetErrorString(e)); + exit(-1); + } +} +#endif +#if defined(UMPIRE_ENABLE_CUDA) void event_timing_reporting(cudaEvent_t start, cudaEvent_t stop, double** ptr, unsigned int total, std::string name) { float milliseconds {0}; @@ -72,6 +86,20 @@ void event_timing_reporting(cudaEvent_t start, cudaEvent_t stop, double** ptr, u std::cout << "Time per allocation: " << (milliseconds/total*1000.0) << "us" << std::endl; std::cout << "Retrieved value: " << *ptr[0] << std::endl << std::endl; } +#elif defined(UMPIRE_ENABLE_HIP) +void event_timing_reporting(hipEvent_t start, hipEvent_t stop, double** ptr, unsigned int total, std::string name) +{ + float milliseconds {0}; + hipEventSynchronize(stop); + hipEventElapsedTime(&milliseconds, start, stop); + HipTest("Checking for error just after kernel...\n"); + + std::cout << name << std::endl; + std::cout << "Total time: " << (milliseconds*1000.0) << "us" << std::endl; + std::cout << "Time per allocation: " << (milliseconds/total*1000.0) << "us" << std::endl; + std::cout << "Retrieved value: " << *ptr[0] << std::endl << std::endl; +} +#endif int main(int, char**) { @@ -79,13 +107,19 @@ int main(int, char**) auto allocator = rm.getAllocator("UM"); double** ptr_to_data = static_cast(allocator.allocate(sizeof(double*))); - unsigned int N {0}; + int N {0}; N = NUM_SM * BLOCKS_PER_SM * THREADS_PER_BLOCK; // Set up the device and get properties +#if defined(UMPIRE_ENABLE_CUDA) cudaDeviceProp devProp; cudaSetDevice(0); cudaGetDeviceProperties(&devProp, 0); +#elif defined(UMPIRE_ENABLE_HIP) + hipDeviceProp_t devProp; + hipSetDevice(0); + hipGetDeviceProperties(&devProp, 0); +#endif std::cout << "Running on device: " << devProp.name << std::endl; std::cout << "Number of threads: " << N << std::endl << std::endl; @@ -99,52 +133,93 @@ int main(int, char**) auto dev_alloc = umpire::make_device_allocator(allocator, N * sizeof(double), "dev_alloc"); UMPIRE_SET_UP_DEVICE_ALLOCATORS(); // Still required in case this is called on different translation unit. - // Create cuda streams and events + // Create streams and events +#if defined(UMPIRE_ENABLE_CUDA) cudaStream_t stream; cudaStreamCreate(&stream); cudaEvent_t start, stop; cudaEventCreate(&start); cudaEventCreate(&stop); +#elif defined(UMPIRE_ENABLE_HIP) + hipStream_t stream; + hipStreamCreate(&stream); + hipEvent_t start, stop; + hipEventCreate(&start); + hipEventCreate(&stop); +#endif // Run warm-up kernel ////////////////////////////////////////////////// +#if defined(UMPIRE_ENABLE_CUDA) cudaEventRecord(start); only_first<<>>(ptr_to_data); cudaEventRecord(stop); event_timing_reporting(start, stop, ptr_to_data, 1, "Kernel: Warm-up"); +#elif defined(UMPIRE_ENABLE_HIP) + hipEventRecord(start); + hipLaunchKernelGGL(only_first, dim3(N/THREADS_PER_BLOCK), dim3(THREADS_PER_BLOCK), 0, stream, ptr_to_data); + hipEventRecord(stop); + event_timing_reporting(start, stop, ptr_to_data, 1, "Kernel: Warm-up"); +#endif ////////////////////////////////////////////////// dev_alloc.reset(); // Run kernel to allocate per first thread per block ////////////////////////////////////////////////// +#if defined(UMPIRE_ENABLE_CUDA) cudaEventRecord(start); first_in_block<<>>(ptr_to_data); cudaEventRecord(stop); event_timing_reporting(start, stop, ptr_to_data, (N/THREADS_PER_BLOCK), "Kernel: First thread per block"); +#elif defined(UMPIRE_ENABLE_HIP) + hipEventRecord(start); + hipLaunchKernelGGL(first_in_block, dim3(N/THREADS_PER_BLOCK), dim3(THREADS_PER_BLOCK), 0, stream, ptr_to_data); + hipEventRecord(stop); + event_timing_reporting(start, stop, ptr_to_data, (N/THREADS_PER_BLOCK), "Kernel: First thread per block"); +#endif ////////////////////////////////////////////////// dev_alloc.reset(); // Run kernel to allocate with only thread 0 ////////////////////////////////////////////////// +#if defined(UMPIRE_ENABLE_CUDA) cudaEventRecord(start); only_first<<>>(ptr_to_data); cudaEventRecord(stop); event_timing_reporting(start, stop, ptr_to_data, 1, "Kernel: Only thread idx 0"); +#elif defined(UMPIRE_ENABLE_HIP) + hipEventRecord(start); + hipLaunchKernelGGL(only_first, dim3(N/THREADS_PER_BLOCK), dim3(THREADS_PER_BLOCK), 0, stream, ptr_to_data); + hipEventRecord(stop); + event_timing_reporting(start, stop, ptr_to_data, 1, "Kernel: Only thread idx 0"); +#endif ////////////////////////////////////////////////// dev_alloc.reset(); // Run kernel to allocate per each thread ////////////////////////////////////////////////// +#if defined(UMPIRE_ENABLE_CUDA) cudaEventRecord(start); each_thread<<>>(ptr_to_data, N); cudaEventRecord(stop); event_timing_reporting(start, stop, ptr_to_data, N, "Kernel: Each thread"); +#elif defined(UMPIRE_ENABLE_HIP) + hipEventRecord(start); + hipLaunchKernelGGL(each_thread, dim3(N/THREADS_PER_BLOCK), dim3(THREADS_PER_BLOCK), 0, stream, ptr_to_data, N); + hipEventRecord(stop); + event_timing_reporting(start, stop, ptr_to_data, N, "Kernel: Each thread"); +#endif ////////////////////////////////////////////////// +#if defined(UMPIRE_ENABLE_CUDA) cudaFree(ptr_to_data); cudaStreamDestroy(stream); +#elif defined(UMPIRE_ENABLE_HIP) + hipFree(ptr_to_data); + hipStreamDestroy(stream); +#endif return 0; } diff --git a/benchmarks/file_resource_benchmarks.cpp b/benchmarks/file_resource_benchmarks.cpp index cb7f44456..6d812fbdc 100644 --- a/benchmarks/file_resource_benchmarks.cpp +++ b/benchmarks/file_resource_benchmarks.cpp @@ -1,5 +1,5 @@ ////////////////////////////////////////////////////////////////////////////// -// Copyright (c) 2016-22, Lawrence Livermore National Security, LLC and Umpire +// Copyright (c) 2016-23, Lawrence Livermore National Security, LLC and Umpire // project contributors. See the COPYRIGHT file for details. // // SPDX-License-Identifier: (MIT) @@ -10,11 +10,12 @@ #include "umpire/ResourceManager.hpp" #include "umpire/Allocator.hpp" +#include +#include #include -#include -#include #include -#include +#include +#include int iterations; size_t Scalar = 5; @@ -63,7 +64,9 @@ void Initialized(std::size_t* A, std::size_t* B, std::size_t* C){ index[i] = i; } - std::random_shuffle(index.begin(), index.end()); + unsigned seed = std::chrono::system_clock::now().time_since_epoch().count(); + + std::shuffle(index.begin(), index.end(), std::default_random_engine(seed)); #pragma omp parallel for for (int i = 0; i < index.size(); i++) { diff --git a/benchmarks/fixed_pool_stress_test.cpp b/benchmarks/fixed_pool_stress_test.cpp index 50aa15669..f1887e47d 100644 --- a/benchmarks/fixed_pool_stress_test.cpp +++ b/benchmarks/fixed_pool_stress_test.cpp @@ -1,5 +1,5 @@ ////////////////////////////////////////////////////////////////////////////// -// Copyright (c) 2016-22, Lawrence Livermore National Security, LLC and Umpire +// Copyright (c) 2016-23, Lawrence Livermore National Security, LLC and Umpire // project contributors. See the COPYRIGHT file for details. // // SPDX-License-Identifier: (MIT) diff --git a/benchmarks/inspector_benchmarks.cpp b/benchmarks/inspector_benchmarks.cpp index 25d2abb96..40cff76fd 100644 --- a/benchmarks/inspector_benchmarks.cpp +++ b/benchmarks/inspector_benchmarks.cpp @@ -1,5 +1,5 @@ ////////////////////////////////////////////////////////////////////////////// -// Copyright (c) 2016-22, Lawrence Livermore National Security, LLC and Umpire +// Copyright (c) 2016-23, Lawrence Livermore National Security, LLC and Umpire // project contributors. See the COPYRIGHT file for details. // // SPDX-License-Identifier: (MIT) diff --git a/benchmarks/no-op_stress_test.cpp b/benchmarks/no-op_stress_test.cpp index 5d8f83486..77dec7e28 100644 --- a/benchmarks/no-op_stress_test.cpp +++ b/benchmarks/no-op_stress_test.cpp @@ -1,5 +1,5 @@ ////////////////////////////////////////////////////////////////////////////// -// Copyright (c) 2016-22, Lawrence Livermore National Security, LLC and Umpire +// Copyright (c) 2016-23, Lawrence Livermore National Security, LLC and Umpire // project contributors. See the COPYRIGHT file for details. // // SPDX-License-Identifier: (MIT) diff --git a/benchmarks/pool_stress_test.cpp b/benchmarks/pool_stress_test.cpp index 97118ef34..4bc495cc9 100644 --- a/benchmarks/pool_stress_test.cpp +++ b/benchmarks/pool_stress_test.cpp @@ -1,5 +1,5 @@ ////////////////////////////////////////////////////////////////////////////// -// Copyright (c) 2016-22, Lawrence Livermore National Security, LLC and Umpire +// Copyright (c) 2016-23, Lawrence Livermore National Security, LLC and Umpire // project contributors. See the COPYRIGHT file for details. // // SPDX-License-Identifier: (MIT) diff --git a/benchmarks/vendor_allocator_benchmarks.cpp b/benchmarks/vendor_allocator_benchmarks.cpp index c1f7b9cf2..98c5ff0e9 100644 --- a/benchmarks/vendor_allocator_benchmarks.cpp +++ b/benchmarks/vendor_allocator_benchmarks.cpp @@ -1,5 +1,5 @@ ////////////////////////////////////////////////////////////////////////////// -// Copyright (c) 2016-22, Lawrence Livermore National Security, LLC and Umpire +// Copyright (c) 2016-23, Lawrence Livermore National Security, LLC and Umpire // project contributors. See the COPYRIGHT file for details. // // SPDX-License-Identifier: (MIT) diff --git a/cmake/SetupCMakeBasics.cmake b/cmake/SetupCMakeBasics.cmake index c296002ea..411942bf5 100644 --- a/cmake/SetupCMakeBasics.cmake +++ b/cmake/SetupCMakeBasics.cmake @@ -1,5 +1,5 @@ ############################################################################## -# Copyright (c) 2016-22, Lawrence Livermore National Security, LLC and Umpire +# Copyright (c) 2016-23, Lawrence Livermore National Security, LLC and Umpire # project contributors. See the COPYRIGHT file for details. # # SPDX-License-Identifier: (MIT) diff --git a/cmake/SetupCompilerFlags.cmake b/cmake/SetupCompilerFlags.cmake index 6d7ec7f1e..db63aeb4a 100644 --- a/cmake/SetupCompilerFlags.cmake +++ b/cmake/SetupCompilerFlags.cmake @@ -1,5 +1,5 @@ ############################################################################## -# Copyright (c) 2016-22, Lawrence Livermore National Security, LLC and Umpire +# Copyright (c) 2016-23, Lawrence Livermore National Security, LLC and Umpire # project contributors. See the COPYRIGHT file for details. # # SPDX-License-Identifier: (MIT) diff --git a/cmake/SetupUmpireThirdParty.cmake b/cmake/SetupUmpireThirdParty.cmake index 5441a18bf..fc3513690 100644 --- a/cmake/SetupUmpireThirdParty.cmake +++ b/cmake/SetupUmpireThirdParty.cmake @@ -1,5 +1,5 @@ ############################################################################## -# Copyright (c) 2016-22, Lawrence Livermore National Security, LLC and Umpire +# Copyright (c) 2016-23, Lawrence Livermore National Security, LLC and Umpire # project contributors. See the COPYRIGHT file for details. # # SPDX-License-Identifier: (MIT) @@ -85,7 +85,7 @@ if (UMPIRE_ENABLE_MPI OR UMPIRE_ENABLE_HIP OR UMPIRE_ENABLE_OPENMP OR UMPIRE_ENA set(UMPIRE_NEEDS_BLT_TPLS True) if (NOT BLT_EXPORTED) - set(BLT_EXPORTED On) + set(BLT_EXPORTED On CACHE BOOL "" FORCE) blt_import_library(NAME blt_stub EXPORTABLE On) set_target_properties(blt_stub PROPERTIES EXPORT_NAME blt::blt_stub) install(TARGETS blt_stub diff --git a/cmake/UmpireMacros.cmake b/cmake/UmpireMacros.cmake index 3b9bdcadd..a45480163 100644 --- a/cmake/UmpireMacros.cmake +++ b/cmake/UmpireMacros.cmake @@ -1,5 +1,5 @@ ############################################################################## -# Copyright (c) 2016-22, Lawrence Livermore National Security, LLC and Umpire +# Copyright (c) 2016-23, Lawrence Livermore National Security, LLC and Umpire # project contributors. See the COPYRIGHT file for details. # # SPDX-License-Identifier: (MIT) diff --git a/cmake/valgrind.supp b/cmake/valgrind.supp index 3fd45010d..06bc77a75 100644 --- a/cmake/valgrind.supp +++ b/cmake/valgrind.supp @@ -1,5 +1,5 @@ ############################################################################## -# Copyright (c) 2016-22, Lawrence Livermore National Security, LLC and Umpire +# Copyright (c) 2016-23, Lawrence Livermore National Security, LLC and Umpire # project contributors. See the COPYRIGHT file for details. # # SPDX-License-Identifier: (MIT) diff --git a/docs/CMakeLists.txt b/docs/CMakeLists.txt index 258846682..9250c1896 100644 --- a/docs/CMakeLists.txt +++ b/docs/CMakeLists.txt @@ -1,5 +1,5 @@ ############################################################################## -# Copyright (c) 2016-22, Lawrence Livermore National Security, LLC and Umpire +# Copyright (c) 2016-23, Lawrence Livermore National Security, LLC and Umpire # project contributors. See the COPYRIGHT file for details. # # SPDX-License-Identifier: (MIT) diff --git a/docs/conf.py b/docs/conf.py index b7a1aa312..06168546b 100644 --- a/docs/conf.py +++ b/docs/conf.py @@ -1,5 +1,5 @@ ############################################################################## -# Copyright (c) 2016-22, Lawrence Livermore National Security, LLC and Umpire +# Copyright (c) 2016-23, Lawrence Livermore National Security, LLC and Umpire # project contributors. See the COPYRIGHT file for details. # # SPDX-License-Identifier: (MIT) @@ -84,7 +84,7 @@ # General information about the project. project = u'Umpire' -copyright = u'2016-22, Lawrence Livermore National Security, LLC and Umpire project contributors' +copyright = u'2016-23, Lawrence Livermore National Security, LLC and Umpire project contributors' author = u'David Beckingsale' # The version info for the project you're documenting, acts as replacement for diff --git a/docs/doxygen/CMakeLists.txt b/docs/doxygen/CMakeLists.txt index 8ef910c5d..072aff3c8 100644 --- a/docs/doxygen/CMakeLists.txt +++ b/docs/doxygen/CMakeLists.txt @@ -1,5 +1,5 @@ ############################################################################## -# Copyright (c) 2016-22, Lawrence Livermore National Security, LLC and Umpire +# Copyright (c) 2016-23, Lawrence Livermore National Security, LLC and Umpire # project contributors. See the COPYRIGHT file for details. # # SPDX-License-Identifier: (MIT) diff --git a/docs/doxygen/Doxyfile b/docs/doxygen/Doxyfile index a91330e7c..0cacb09a7 100644 --- a/docs/doxygen/Doxyfile +++ b/docs/doxygen/Doxyfile @@ -1,5 +1,5 @@ ############################################################################## -# Copyright (c) 2016-22, Lawrence Livermore National Security, LLC and Umpire +# Copyright (c) 2016-23, Lawrence Livermore National Security, LLC and Umpire # project contributors. See the COPYRIGHT file for details. # # SPDX-License-Identifier: (MIT) diff --git a/docs/doxygen/Doxyfile.in b/docs/doxygen/Doxyfile.in index 8759b683b..c986ab40e 100644 --- a/docs/doxygen/Doxyfile.in +++ b/docs/doxygen/Doxyfile.in @@ -1,5 +1,5 @@ ############################################################################## -# Copyright (c) 2016-22, Lawrence Livermore National Security, LLC and Umpire +# Copyright (c) 2016-23, Lawrence Livermore National Security, LLC and Umpire # project contributors. See the COPYRIGHT file for details. # # SPDX-License-Identifier: (MIT) diff --git a/docs/sphinx/CMakeLists.txt b/docs/sphinx/CMakeLists.txt index 2802a9d37..ed7913d11 100644 --- a/docs/sphinx/CMakeLists.txt +++ b/docs/sphinx/CMakeLists.txt @@ -1,5 +1,5 @@ ############################################################################## -# Copyright (c) 2016-22, Lawrence Livermore National Security, LLC and Umpire +# Copyright (c) 2016-23, Lawrence Livermore National Security, LLC and Umpire # project contributors. See the COPYRIGHT file for details. # # SPDX-License-Identifier: (MIT) diff --git a/docs/sphinx/conf.py.in b/docs/sphinx/conf.py.in index 2b948cd57..4c863e5ae 100644 --- a/docs/sphinx/conf.py.in +++ b/docs/sphinx/conf.py.in @@ -1,5 +1,5 @@ ############################################################################## -# Copyright (c) 2016-22, Lawrence Livermore National Security, LLC and Umpire +# Copyright (c) 2016-23, Lawrence Livermore National Security, LLC and Umpire # project contributors. See the COPYRIGHT file for details. # # SPDX-License-Identifier: (MIT) diff --git a/docs/sphinx/cookbook/coalesce_pool.rst b/docs/sphinx/cookbook/coalesce_pool.rst index 1a70e1bce..672206083 100644 --- a/docs/sphinx/cookbook/coalesce_pool.rst +++ b/docs/sphinx/cookbook/coalesce_pool.rst @@ -4,10 +4,54 @@ Coalescing Pool Memory ====================== -The :class:`umpire::strategy::QuickPool` provides a -:func:`umpire::strategy::QuickPool::coalesce` that can be used to release +Umpire's memory pools provide a more performant way to allocate large +amounts of memory with fewer calls to the underlying API. +Memory pools allocate and manage a pool of large memory blocks. When application +allocations are requested, the memory pool allocator will service the allocation from +these memory blocks rather than making (many) allocation requests of the underlying API +which can ... +at once instead of making multiple, smaller memory allocations which can +become quite expensive. However, the performance of memory pools +varies widely depending upon how the memory blocks within the pool are managed. +Each application allocation within a memory pool must fit within a `memory block`. +As memory is allocated and deallocated, those blocks must be properly +adjusted in order to handle new, incoming memory allocations. + +Umpire's solution for managing blocks of memory within a pool is to use a +`coalescing function`. The coalescing function will deallocate a certain amount +of unused memory and reallocate it, creating a new memory block which can handle new allocations. +When Umpire is unable to find a block with sufficient memory for the applications' allocation +request, it will allocate a new block from the allocation resource and add that block to the pool. +As application memory use grows, the pool will fill up with many blocks. Umpire has a `coalescing function` that will deallocate all of the unused (free) blocks in its pool and then reallocate a single block of memory that is large enough to contain all of the freed blocks. +The figure below attempts to describe how a particular pool ("Current Pool") +will handle a new incoming allocation into the pool with and without coalescing. + +.. image:: ./memory-pool-with-without-coalesce.png + +.. note:: + Some helpful hints: The entire size of the "Current Pool" depicted above + is also known as the "actual_size". Note how the actual size grows or does + not grow when there is or is not a coalesce. The "Used" portion depicted + within the "Current Pool" is also referred to as the "current_size". The + "actual_size" and the "current_size" may differ a lot in practice. Lastly, + the first depiction of the "Current Pool" has a "high_watermark" size + which is equal to the "current_size". However, the "high_watermark" size + will grow more or less according to the new value of "current_size". + +As depicted, if the memory pool can coalesce, it will deallocate those "free" (i.e. unused) blocks +of memory and reallocate one, larger memory block that can handle the new allocation. +Otherwise, if the pool can't coalesce, it will need to grow to accomodate the new allocation. +In this particular example, the free blocks are all too small to handle the new +allocation, so they can't be reused to accomodate that new chunk of memory until a +coalesce has happened. If the pool can't coalesce as much as it needs to, it can +grow too big and prematurely run out of memory. + +In Umpire, the QuickPool memory pool (:class:`umpire::strategy::QuickPool`) provides a coalescing +function (:func:`umpire::strategy::QuickPool::coalesce`) that can be used to release unused memory and allocate a single large block that will be able to satisfy -allocations up to the previously observed high-watermark. To call this +allocations up to the previously observed high-watermark. + +To call this function, you must get the pointer to the :class:`umpire::strategy::AllocationStrategy` from the :class:`umpire::Allocator`: @@ -25,6 +69,23 @@ function: :end-before: _sphinx_tag_tut_call_coalesce_end :language: C++ -The complete example is included below: +The complete example is included at the bottom of this page. + +Coalescing a Pool Automatically +=============================== + +Wouldn't it be great if we didn't have to make sure we called the coalescing function +manually every time? Well, we don't! Umpire provides coalescing heuristics which are supposed +to determine when to coalesce and with how many bytes. + +Users can create their own coalescing heuristic function or they can rely on the heuristics +that Umpire provides. Umpire provides two heuristic functions: Blocks-Releasable and +Percent-Releasable. The Blocks-Releasable heuristic is passed an integer value for the +number of blocks that should be deemed "releasable" before coalescing. Similarly, the +Percent-Releasable heuristic is passed an integer value for the percent of bytes that +should be "releasable" before coalescing. + +More information about how to use these functions can be found in the Doxygen references. +There is also an example of using the coalescing heuristic to improve DynamicPool performance `here `_. .. literalinclude:: ../../../examples/cookbook/recipe_coalesce_pool.cpp diff --git a/docs/sphinx/cookbook/dynamic_pool_heuristics.rst b/docs/sphinx/cookbook/dynamic_pool_heuristics.rst index 8af8d1b68..b82b15497 100644 --- a/docs/sphinx/cookbook/dynamic_pool_heuristics.rst +++ b/docs/sphinx/cookbook/dynamic_pool_heuristics.rst @@ -4,8 +4,7 @@ Improving DynamicPoolList Performance with a Coalesce Heuristic =========================================================== -As needed, the -:class:`umpire::strategy::DynamicPoolList` +As needed, the DynamicPoolList memory pool (:class:`umpire::strategy::DynamicPoolList`) will continue to allocate blocks to satisfy allocation requests that cannot be satisfied by blocks currently in the pool it is managing. Under certain application-specific @@ -15,6 +14,24 @@ the pool to grow too large. For example, a problematic allocation pattern is when an application makes several allocations of incrementing size where each allocation is larger than the previous block size allocated. +The Umpire library provides **Coalescing Heuristics** to help manage the blocks +of memory within a memory pool. The purpose of a coalescing heuristic is to +ensure that the memory pool is properly maintained through the duration of +an application so that it does not grow too large and prematurely run out +of memory. There are two coalescing heuristics: **Percent Releasable** and +**Blocks Releasable**. By default, a memory pool will use the Percent Releasable +heuristic. Additionally, Umpire +provides an optional tuning parameter. This tuning is called the `HighWatermark` tuning and +it uses the pool's HighWatermark value when coalescing the +pool. By default, coalescing heuristics **DO NOT** use the `HighWatermark` tuning. +Instead, they use the pool's Actual Size value. Go to Umpire's RZ Confluence page under +"Design Documents" and refer to the "Umpire Pool Usage and Control" documentation for +more information. You can also refer to `Coalescing Pool Memory `_. + +.. note:: + To turn on the HighWatermark heuristic tuning, use the coalescing + heuristic with the "_hwm" suffix (e.g. :func:`umpire::strategy::DynamicPoolList::blocks_releasable_hwm(num_blocks)`). + The :func:`umpire::strategy::DynamicPoolList::coalesce` method may be used to cause the @@ -24,6 +41,10 @@ accomplished by: tallying the size of all blocks without allocations against them, releasing those blocks back to the memory resource, and creating a new block of the previously tallied size. +.. note:: + If the HighWatermark heuristic tuning is used, then the new block + will be allocated to the pool's HighWatermark instead. + Applications may offer a heuristic function to the :class:`umpire::strategy::DynamicPoolList` during instantiation that will return true whenever a pool reaches a @@ -48,8 +69,8 @@ Creation of the heuristic function is accomplished by: :end-before: _sphinx_tag_tut_creat_heuristic_fun_end :language: C++ -The heuristic function is then provided as a parameter when the object is -instantiated: +In this example, we are using the `Percent Releasable` heuristic. The heuristic +function is then provided as a parameter when the object is instantiated: .. literalinclude:: ../../../examples/cookbook/recipe_dynamic_pool_heuristic.cpp :start-after: _sphinx_tag_tut_use_heuristic_fun_start diff --git a/docs/sphinx/cookbook/memory-pool-with-without-coalesce.png b/docs/sphinx/cookbook/memory-pool-with-without-coalesce.png new file mode 100644 index 000000000..a7a630353 Binary files /dev/null and b/docs/sphinx/cookbook/memory-pool-with-without-coalesce.png differ diff --git a/examples/CMakeLists.txt b/examples/CMakeLists.txt index 61d6c162d..330a51a1b 100644 --- a/examples/CMakeLists.txt +++ b/examples/CMakeLists.txt @@ -1,5 +1,5 @@ ############################################################################## -# Copyright (c) 2016-22, Lawrence Livermore National Security, LLC and Umpire +# Copyright (c) 2016-23, Lawrence Livermore National Security, LLC and Umpire # project contributors. See the COPYRIGHT file for details. # # SPDX-License-Identifier: (MIT) @@ -30,6 +30,17 @@ blt_add_executable( list(APPEND umpire_examples malloc) if (UMPIRE_ENABLE_HIP) + if (UMPIRE_ENABLE_DEVICE_ALLOCATOR) + blt_add_executable( + NAME device_allocator_example + SOURCES device-allocator.cpp + DEPENDS_ON umpire blt::hip) + list(APPEND umpire_examples device_allocator_example) + + target_compile_options(device_allocator_example PUBLIC -fgpu-rdc) + blt_add_target_link_flags( TO device_allocator_example FLAGS -fgpu-rdc) + endif() + blt_add_executable( NAME multi_device SOURCES multi_device.cpp diff --git a/examples/aligned_allocator.cpp b/examples/aligned_allocator.cpp index bdb24927e..310b8eac6 100644 --- a/examples/aligned_allocator.cpp +++ b/examples/aligned_allocator.cpp @@ -1,5 +1,5 @@ ////////////////////////////////////////////////////////////////////////////// -// Copyright (c) 2016-22, Lawrence Livermore National Security, LLC and Umpire +// Copyright (c) 2016-23, Lawrence Livermore National Security, LLC and Umpire // project contributors. See the COPYRIGHT file for details. // // SPDX-License-Identifier: (MIT) diff --git a/examples/allocator.c b/examples/allocator.c index dda132c11..25c054202 100644 --- a/examples/allocator.c +++ b/examples/allocator.c @@ -1,5 +1,5 @@ ////////////////////////////////////////////////////////////////////////////// -// Copyright (c) 2016-22, Lawrence Livermore National Security, LLC and Umpire +// Copyright (c) 2016-23, Lawrence Livermore National Security, LLC and Umpire // project contributors. See the COPYRIGHT file for details. // // SPDX-License-Identifier: (MIT) diff --git a/examples/allocator.cxx b/examples/allocator.cxx index 33068d205..faeee2d20 100644 --- a/examples/allocator.cxx +++ b/examples/allocator.cxx @@ -1,5 +1,5 @@ ////////////////////////////////////////////////////////////////////////////// -// Copyright (c) 2016-22, Lawrence Livermore National Security, LLC and Umpire +// Copyright (c) 2016-23, Lawrence Livermore National Security, LLC and Umpire // project contributors. See the COPYRIGHT file for details. // // SPDX-License-Identifier: (MIT) diff --git a/examples/allocator_access.cpp b/examples/allocator_access.cpp index df042301a..4594e9fcf 100644 --- a/examples/allocator_access.cpp +++ b/examples/allocator_access.cpp @@ -1,5 +1,5 @@ ////////////////////////////////////////////////////////////////////////////// -// Copyright (c) 2016-22, Lawrence Livermore National Security, LLC and Umpire +// Copyright (c) 2016-23, Lawrence Livermore National Security, LLC and Umpire // project contributors. See the COPYRIGHT file for details. // // SPDX-License-Identifier: (MIT) diff --git a/examples/backtrace_example.cpp b/examples/backtrace_example.cpp index 0747c73c3..2994e4983 100644 --- a/examples/backtrace_example.cpp +++ b/examples/backtrace_example.cpp @@ -1,5 +1,5 @@ ////////////////////////////////////////////////////////////////////////////// -// Copyright (c) 2016-22, Lawrence Livermore National Security, LLC and Umpire +// Copyright (c) 2016-23, Lawrence Livermore National Security, LLC and Umpire // project contributors. See the COPYRIGHT file for details. // // SPDX-License-Identifier: (MIT) diff --git a/examples/cookbook/CMakeLists.txt b/examples/cookbook/CMakeLists.txt index 783c6342c..80fd6facc 100644 --- a/examples/cookbook/CMakeLists.txt +++ b/examples/cookbook/CMakeLists.txt @@ -1,5 +1,5 @@ ############################################################################## -# Copyright (c) 2016-22, Lawrence Livermore National Security, LLC and Umpire +# Copyright (c) 2016-23, Lawrence Livermore National Security, LLC and Umpire # project contributors. See the COPYRIGHT file for details. # # SPDX-License-Identifier: (MIT) diff --git a/examples/cookbook/recipe_advice_device_id.cpp b/examples/cookbook/recipe_advice_device_id.cpp index 04ac524d0..944353ea5 100644 --- a/examples/cookbook/recipe_advice_device_id.cpp +++ b/examples/cookbook/recipe_advice_device_id.cpp @@ -1,5 +1,5 @@ ////////////////////////////////////////////////////////////////////////////// -// Copyright (c) 2016-22, Lawrence Livermore National Security, LLC and Umpire +// Copyright (c) 2016-23, Lawrence Livermore National Security, LLC and Umpire // project contributors. See the COPYRIGHT file for details. // // SPDX-License-Identifier: (MIT) diff --git a/examples/cookbook/recipe_coalesce_pool.cpp b/examples/cookbook/recipe_coalesce_pool.cpp index d3fe6d082..9d2e0d132 100644 --- a/examples/cookbook/recipe_coalesce_pool.cpp +++ b/examples/cookbook/recipe_coalesce_pool.cpp @@ -1,5 +1,5 @@ ////////////////////////////////////////////////////////////////////////////// -// Copyright (c) 2016-22, Lawrence Livermore National Security, LLC and Umpire +// Copyright (c) 2016-23, Lawrence Livermore National Security, LLC and Umpire // project contributors. See the COPYRIGHT file for details. // // SPDX-License-Identifier: (MIT) diff --git a/examples/cookbook/recipe_dynamic_pool_heuristic.cpp b/examples/cookbook/recipe_dynamic_pool_heuristic.cpp index 9843deb03..3c3d39de0 100644 --- a/examples/cookbook/recipe_dynamic_pool_heuristic.cpp +++ b/examples/cookbook/recipe_dynamic_pool_heuristic.cpp @@ -1,5 +1,5 @@ ////////////////////////////////////////////////////////////////////////////// -// Copyright (c) 2016-22, Lawrence Livermore National Security, LLC and Umpire +// Copyright (c) 2016-23, Lawrence Livermore National Security, LLC and Umpire // project contributors. See the COPYRIGHT file for details. // // SPDX-License-Identifier: (MIT) diff --git a/examples/cookbook/recipe_filesystem_memory_allocation.cpp b/examples/cookbook/recipe_filesystem_memory_allocation.cpp index 257c28c1c..544bc919b 100644 --- a/examples/cookbook/recipe_filesystem_memory_allocation.cpp +++ b/examples/cookbook/recipe_filesystem_memory_allocation.cpp @@ -1,5 +1,5 @@ ////////////////////////////////////////////////////////////////////////////// -// Copyright (c) 2016-22, Lawrence Livermore National Security, LLC and Umpire +// Copyright (c) 2016-23, Lawrence Livermore National Security, LLC and Umpire // project contributors. See the COPYRIGHT file for details. // // SPDX-License-Identifier: (MIT) diff --git a/examples/cookbook/recipe_get_largest_available_block_in_pool.cpp b/examples/cookbook/recipe_get_largest_available_block_in_pool.cpp index 2f15b4d36..8cc8d8628 100644 --- a/examples/cookbook/recipe_get_largest_available_block_in_pool.cpp +++ b/examples/cookbook/recipe_get_largest_available_block_in_pool.cpp @@ -1,5 +1,5 @@ ////////////////////////////////////////////////////////////////////////////// -// Copyright (c) 2016-22, Lawrence Livermore National Security, LLC and Umpire +// Copyright (c) 2016-23, Lawrence Livermore National Security, LLC and Umpire // project contributors. See the COPYRIGHT file for details. // // SPDX-License-Identifier: (MIT) diff --git a/examples/cookbook/recipe_memprefetch_pool.cpp b/examples/cookbook/recipe_memprefetch_pool.cpp index eed517ea4..765012a71 100644 --- a/examples/cookbook/recipe_memprefetch_pool.cpp +++ b/examples/cookbook/recipe_memprefetch_pool.cpp @@ -1,5 +1,5 @@ ////////////////////////////////////////////////////////////////////////////// -// Copyright (c) 2016-22, Lawrence Livermore National Security, LLC and Umpire +// Copyright (c) 2016-23, Lawrence Livermore National Security, LLC and Umpire // project contributors. See the COPYRIGHT file for details. // // SPDX-License-Identifier: (MIT) diff --git a/examples/cookbook/recipe_mixed_pool.cpp b/examples/cookbook/recipe_mixed_pool.cpp index cea405d3a..bd1dcd53b 100644 --- a/examples/cookbook/recipe_mixed_pool.cpp +++ b/examples/cookbook/recipe_mixed_pool.cpp @@ -1,5 +1,5 @@ ////////////////////////////////////////////////////////////////////////////// -// Copyright (c) 2016-22, Lawrence Livermore National Security, LLC and Umpire +// Copyright (c) 2016-23, Lawrence Livermore National Security, LLC and Umpire // project contributors. See the COPYRIGHT file for details. // // SPDX-License-Identifier: (MIT) diff --git a/examples/cookbook/recipe_move_between_numa.cpp b/examples/cookbook/recipe_move_between_numa.cpp index d64c48b19..16e498ce5 100644 --- a/examples/cookbook/recipe_move_between_numa.cpp +++ b/examples/cookbook/recipe_move_between_numa.cpp @@ -1,5 +1,5 @@ ////////////////////////////////////////////////////////////////////////////// -// Copyright (c) 2016-22, Lawrence Livermore National Security, LLC and Umpire +// Copyright (c) 2016-23, Lawrence Livermore National Security, LLC and Umpire // project contributors. See the COPYRIGHT file for details. // // SPDX-License-Identifier: (MIT) diff --git a/examples/cookbook/recipe_move_to_managed.cpp b/examples/cookbook/recipe_move_to_managed.cpp index 986921a27..b918e817a 100644 --- a/examples/cookbook/recipe_move_to_managed.cpp +++ b/examples/cookbook/recipe_move_to_managed.cpp @@ -1,5 +1,5 @@ ////////////////////////////////////////////////////////////////////////////// -// Copyright (c) 2016-22, Lawrence Livermore National Security, LLC and Umpire +// Copyright (c) 2016-23, Lawrence Livermore National Security, LLC and Umpire // project contributors. See the COPYRIGHT file for details. // // SPDX-License-Identifier: (MIT) diff --git a/examples/cookbook/recipe_no_introspection.cpp b/examples/cookbook/recipe_no_introspection.cpp index f4f0b2753..9786b6678 100644 --- a/examples/cookbook/recipe_no_introspection.cpp +++ b/examples/cookbook/recipe_no_introspection.cpp @@ -1,5 +1,5 @@ ////////////////////////////////////////////////////////////////////////////// -// Copyright (c) 2016-22, Lawrence Livermore National Security, LLC and Umpire +// Copyright (c) 2016-23, Lawrence Livermore National Security, LLC and Umpire // project contributors. See the COPYRIGHT file for details. // // SPDX-License-Identifier: (MIT) diff --git a/examples/cookbook/recipe_pinned_pool.F b/examples/cookbook/recipe_pinned_pool.F index 83b731c05..e47b4d1df 100644 --- a/examples/cookbook/recipe_pinned_pool.F +++ b/examples/cookbook/recipe_pinned_pool.F @@ -1,5 +1,5 @@ !!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!! -! Copyright (c) 2016-22, Lawrence Livermore National Security, LLC and Umpire +! Copyright (c) 2016-23, Lawrence Livermore National Security, LLC and Umpire ! project contributors. See the COPYRIGHT file for details. ! ! SPDX-License-Identifier: (MIT) diff --git a/examples/cookbook/recipe_plot_allocations.cpp b/examples/cookbook/recipe_plot_allocations.cpp index 27eed77ee..10c6b310f 100644 --- a/examples/cookbook/recipe_plot_allocations.cpp +++ b/examples/cookbook/recipe_plot_allocations.cpp @@ -1,5 +1,5 @@ ////////////////////////////////////////////////////////////////////////////// -// Copyright (c) 2016-22, Lawrence Livermore National Security, LLC and Umpire +// Copyright (c) 2016-23, Lawrence Livermore National Security, LLC and Umpire // project contributors. See the COPYRIGHT file for details. // // SPDX-License-Identifier: (MIT) diff --git a/examples/cookbook/recipe_pool_advice.cpp b/examples/cookbook/recipe_pool_advice.cpp index fdc96ee56..942c01292 100644 --- a/examples/cookbook/recipe_pool_advice.cpp +++ b/examples/cookbook/recipe_pool_advice.cpp @@ -1,5 +1,5 @@ ////////////////////////////////////////////////////////////////////////////// -// Copyright (c) 2016-22, Lawrence Livermore National Security, LLC and Umpire +// Copyright (c) 2016-23, Lawrence Livermore National Security, LLC and Umpire // project contributors. See the COPYRIGHT file for details. // // SPDX-License-Identifier: (MIT) diff --git a/examples/cookbook/recipe_prefetch_pool.F b/examples/cookbook/recipe_prefetch_pool.F index e0431b75b..61c1c5015 100644 --- a/examples/cookbook/recipe_prefetch_pool.F +++ b/examples/cookbook/recipe_prefetch_pool.F @@ -1,5 +1,5 @@ !!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!! -! Copyright (c) 2016-22, Lawrence Livermore National Security, LLC and Umpire +! Copyright (c) 2016-23, Lawrence Livermore National Security, LLC and Umpire ! project contributors. See the COPYRIGHT file for details. ! ! SPDX-License-Identifier: (MIT) diff --git a/examples/cookbook/recipe_shared_memory.cpp b/examples/cookbook/recipe_shared_memory.cpp index 3eab62818..b6e5c982d 100644 --- a/examples/cookbook/recipe_shared_memory.cpp +++ b/examples/cookbook/recipe_shared_memory.cpp @@ -1,5 +1,5 @@ ////////////////////////////////////////////////////////////////////////////// -// Copyright (c) 2016-22, Lawrence Livermore National Security, LLC and Umpire +// Copyright (c) 2016-23, Lawrence Livermore National Security, LLC and Umpire // project contributors. See the COPYRIGHT file for details. // // SPDX-License-Identifier: (MIT) diff --git a/examples/cookbook/recipe_shrink.cpp b/examples/cookbook/recipe_shrink.cpp index bc6bab6cb..c6ae58ddf 100644 --- a/examples/cookbook/recipe_shrink.cpp +++ b/examples/cookbook/recipe_shrink.cpp @@ -1,5 +1,5 @@ ////////////////////////////////////////////////////////////////////////////// -// Copyright (c) 2016-22, Lawrence Livermore National Security, LLC and Umpire +// Copyright (c) 2016-23, Lawrence Livermore National Security, LLC and Umpire // project contributors. See the COPYRIGHT file for details. // // SPDX-License-Identifier: (MIT) diff --git a/examples/cookbook/recipe_strategy_name.cpp b/examples/cookbook/recipe_strategy_name.cpp index 57c44a127..3e4c218e0 100644 --- a/examples/cookbook/recipe_strategy_name.cpp +++ b/examples/cookbook/recipe_strategy_name.cpp @@ -1,5 +1,5 @@ ////////////////////////////////////////////////////////////////////////////// -// Copyright (c) 2016-22, Lawrence Livermore National Security, LLC and Umpire +// Copyright (c) 2016-23, Lawrence Livermore National Security, LLC and Umpire // project contributors. See the COPYRIGHT file for details. // // SPDX-License-Identifier: (MIT) diff --git a/examples/cookbook/recipe_thread_safe.F b/examples/cookbook/recipe_thread_safe.F index 71b5a4ae0..116d9995a 100644 --- a/examples/cookbook/recipe_thread_safe.F +++ b/examples/cookbook/recipe_thread_safe.F @@ -1,5 +1,5 @@ !!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!! -! Copyright (c) 2016-22, Lawrence Livermore National Security, LLC and Umpire +! Copyright (c) 2016-23, Lawrence Livermore National Security, LLC and Umpire ! project contributors. See the COPYRIGHT file for details. ! ! SPDX-License-Identifier: (MIT) diff --git a/examples/cookbook/recipe_thread_safe.cpp b/examples/cookbook/recipe_thread_safe.cpp index f0b851c01..3d123b332 100644 --- a/examples/cookbook/recipe_thread_safe.cpp +++ b/examples/cookbook/recipe_thread_safe.cpp @@ -1,5 +1,5 @@ ////////////////////////////////////////////////////////////////////////////// -// Copyright (c) 2016-22, Lawrence Livermore National Security, LLC and Umpire +// Copyright (c) 2016-23, Lawrence Livermore National Security, LLC and Umpire // project contributors. See the COPYRIGHT file for details. // // SPDX-License-Identifier: (MIT) diff --git a/examples/cookbook/recipe_use_advice_ops.cpp b/examples/cookbook/recipe_use_advice_ops.cpp index 01fbd6c21..f283cfd8d 100644 --- a/examples/cookbook/recipe_use_advice_ops.cpp +++ b/examples/cookbook/recipe_use_advice_ops.cpp @@ -1,5 +1,5 @@ ////////////////////////////////////////////////////////////////////////////// -// Copyright (c) 2016-22, Lawrence Livermore National Security, LLC and Umpire +// Copyright (c) 2016-23, Lawrence Livermore National Security, LLC and Umpire // project contributors. See the COPYRIGHT file for details. // // SPDX-License-Identifier: (MIT) diff --git a/examples/device-allocator.cpp b/examples/device-allocator.cpp index 38a37f574..6c7acc646 100644 --- a/examples/device-allocator.cpp +++ b/examples/device-allocator.cpp @@ -1,5 +1,5 @@ ////////////////////////////////////////////////////////////////////////////// -// Copyright (c) 2016-22, Lawrence Livermore National Security, LLC and Umpire +// Copyright (c) 2016-23, Lawrence Livermore National Security, LLC and Umpire // project contributors. See the COPYRIGHT file for details. // // SPDX-License-Identifier: (MIT) @@ -32,7 +32,7 @@ __global__ void my_kernel(double** data_ptr) } } -int main(int argc, char const* argv[]) +int main() { auto resource = camp::resources::Resource{resource_type{}}; @@ -54,7 +54,12 @@ int main(int argc, char const* argv[]) // See ReadTheDocs DeviceAllocator documentation for more info about macro usage! UMPIRE_SET_UP_DEVICE_ALLOCATORS(); +#if defined(UMPIRE_ENABLE_CUDA) my_kernel<<<1, 16>>>(ptr_to_data); +#elif defined(UMPIRE_ENABLE_HIP) + hipLaunchKernelGGL(my_kernel, dim3(1), dim3(16), 0, 0, ptr_to_data); +#endif + resource.get_event().wait(); std::cout << "After calling kernel, found value: " << (*ptr_to_data)[0] << std::endl; @@ -62,7 +67,12 @@ int main(int argc, char const* argv[]) device_allocator.reset(); std::cout << "After calling reset, the current size is: " << device_allocator.getCurrentSize() << std::endl; +#if defined(UMPIRE_ENABLE_CUDA) my_kernel<<<1, 16>>>(ptr_to_data); +#elif defined(UMPIRE_ENABLE_HIP) + hipLaunchKernelGGL(my_kernel, dim3(1), dim3(16), 0, 0, ptr_to_data); +#endif + resource.get_event().wait(); std::cout << "After calling kernel again, found value: " << (*ptr_to_data)[0] << std::endl; diff --git a/examples/get_parent.cpp b/examples/get_parent.cpp index 5a8b54c97..2e4c6b553 100644 --- a/examples/get_parent.cpp +++ b/examples/get_parent.cpp @@ -1,5 +1,5 @@ ////////////////////////////////////////////////////////////////////////////// -// Copyright (c) 2016-22, Lawrence Livermore National Security, LLC and Umpire +// Copyright (c) 2016-23, Lawrence Livermore National Security, LLC and Umpire // project contributors. See the COPYRIGHT file for details. // // SPDX-License-Identifier: (MIT) diff --git a/examples/malloc.cxx b/examples/malloc.cxx index abbfb614f..0be4da926 100644 --- a/examples/malloc.cxx +++ b/examples/malloc.cxx @@ -1,5 +1,5 @@ ////////////////////////////////////////////////////////////////////////////// -// Copyright (c) 2016-22, Lawrence Livermore National Security, LLC and Umpire +// Copyright (c) 2016-23, Lawrence Livermore National Security, LLC and Umpire // project contributors. See the COPYRIGHT file for details. // // SPDX-License-Identifier: (MIT) diff --git a/examples/multi_device.cpp b/examples/multi_device.cpp index 49385f573..42d400433 100644 --- a/examples/multi_device.cpp +++ b/examples/multi_device.cpp @@ -1,5 +1,5 @@ ////////////////////////////////////////////////////////////////////////////// -// Copyright (c) 2016-22, Lawrence Livermore National Security, LLC and Umpire +// Copyright (c) 2016-23, Lawrence Livermore National Security, LLC and Umpire // project contributors. See the COPYRIGHT file for details. // // SPDX-License-Identifier: (MIT) diff --git a/examples/size_limiter.cpp b/examples/size_limiter.cpp index b654ea6ef..0e4e17618 100644 --- a/examples/size_limiter.cpp +++ b/examples/size_limiter.cpp @@ -1,5 +1,5 @@ ////////////////////////////////////////////////////////////////////////////// -// Copyright (c) 2016-22, Lawrence Livermore National Security, LLC and Umpire +// Copyright (c) 2016-23, Lawrence Livermore National Security, LLC and Umpire // project contributors. See the COPYRIGHT file for details. // // SPDX-License-Identifier: (MIT) diff --git a/examples/strategy_example.cpp b/examples/strategy_example.cpp index 0d3131c94..6a3c2e2a3 100644 --- a/examples/strategy_example.cpp +++ b/examples/strategy_example.cpp @@ -1,5 +1,5 @@ ////////////////////////////////////////////////////////////////////////////// -// Copyright (c) 2016-22, Lawrence Livermore National Security, LLC and Umpire +// Copyright (c) 2016-23, Lawrence Livermore National Security, LLC and Umpire // project contributors. See the COPYRIGHT file for details. // // SPDX-License-Identifier: (MIT) diff --git a/examples/tutorial/CMakeLists.txt b/examples/tutorial/CMakeLists.txt index f6561d706..b8983e6f5 100644 --- a/examples/tutorial/CMakeLists.txt +++ b/examples/tutorial/CMakeLists.txt @@ -1,5 +1,5 @@ ############################################################################## -# Copyright (c) 2016-22, Lawrence Livermore National Security, LLC and Umpire +# Copyright (c) 2016-23, Lawrence Livermore National Security, LLC and Umpire # project contributors. See the COPYRIGHT file for details. # # SPDX-License-Identifier: (MIT) diff --git a/examples/tutorial/c/CMakeLists.txt b/examples/tutorial/c/CMakeLists.txt index 106a9a24a..c12ab5a00 100644 --- a/examples/tutorial/c/CMakeLists.txt +++ b/examples/tutorial/c/CMakeLists.txt @@ -1,5 +1,5 @@ ############################################################################## -# Copyright (c) 2016-22, Lawrence Livermore National Security, LLC and Umpire +# Copyright (c) 2016-23, Lawrence Livermore National Security, LLC and Umpire # project contributors. See the COPYRIGHT file for details. # # SPDX-License-Identifier: (MIT) diff --git a/examples/tutorial/c/tut_allocator.c b/examples/tutorial/c/tut_allocator.c index 3033fcc90..86b754dbc 100644 --- a/examples/tutorial/c/tut_allocator.c +++ b/examples/tutorial/c/tut_allocator.c @@ -1,5 +1,5 @@ ////////////////////////////////////////////////////////////////////////////// -// Copyright (c) 2016-22, Lawrence Livermore National Security, LLC and Umpire +// Copyright (c) 2016-23, Lawrence Livermore National Security, LLC and Umpire // project contributors. See the COPYRIGHT file for details. // // SPDX-License-Identifier: (MIT) diff --git a/examples/tutorial/c/tut_pool.c b/examples/tutorial/c/tut_pool.c index 25ec8e161..b79772f29 100644 --- a/examples/tutorial/c/tut_pool.c +++ b/examples/tutorial/c/tut_pool.c @@ -1,5 +1,5 @@ ////////////////////////////////////////////////////////////////////////////// -// Copyright (c) 2016-22, Lawrence Livermore National Security, LLC and Umpire +// Copyright (c) 2016-23, Lawrence Livermore National Security, LLC and Umpire // project contributors. See the COPYRIGHT file for details. // // SPDX-License-Identifier: (MIT) diff --git a/examples/tutorial/c/tut_resources.c b/examples/tutorial/c/tut_resources.c index dd2feea77..71897cf15 100644 --- a/examples/tutorial/c/tut_resources.c +++ b/examples/tutorial/c/tut_resources.c @@ -1,5 +1,5 @@ ////////////////////////////////////////////////////////////////////////////// -// Copyright (c) 2016-22, Lawrence Livermore National Security, LLC and Umpire +// Copyright (c) 2016-23, Lawrence Livermore National Security, LLC and Umpire // project contributors. See the COPYRIGHT file for details. // // SPDX-License-Identifier: (MIT) diff --git a/examples/tutorial/fortran/CMakeLists.txt b/examples/tutorial/fortran/CMakeLists.txt index 3c7c904d3..a18c15d81 100644 --- a/examples/tutorial/fortran/CMakeLists.txt +++ b/examples/tutorial/fortran/CMakeLists.txt @@ -1,5 +1,5 @@ ############################################################################## -# Copyright (c) 2016-22, Lawrence Livermore National Security, LLC and Umpire +# Copyright (c) 2016-23, Lawrence Livermore National Security, LLC and Umpire # project contributors. See the COPYRIGHT file for details. # # SPDX-License-Identifier: (MIT) diff --git a/examples/tutorial/fortran/tut_allocator.F b/examples/tutorial/fortran/tut_allocator.F index cceacf7b6..c765f5af8 100644 --- a/examples/tutorial/fortran/tut_allocator.F +++ b/examples/tutorial/fortran/tut_allocator.F @@ -1,5 +1,5 @@ !!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!! -! Copyright (c) 2016-22, Lawrence Livermore National Security, LLC and Umpire +! Copyright (c) 2016-23, Lawrence Livermore National Security, LLC and Umpire ! project contributors. See the COPYRIGHT file for details. ! ! SPDX-License-Identifier: (MIT) diff --git a/examples/tutorial/tut_allocator.cpp b/examples/tutorial/tut_allocator.cpp index 41f479d59..0559fa51c 100644 --- a/examples/tutorial/tut_allocator.cpp +++ b/examples/tutorial/tut_allocator.cpp @@ -1,5 +1,5 @@ ////////////////////////////////////////////////////////////////////////////// -// Copyright (c) 2016-22, Lawrence Livermore National Security, LLC and Umpire +// Copyright (c) 2016-23, Lawrence Livermore National Security, LLC and Umpire // project contributors. See the COPYRIGHT file for details. // // SPDX-License-Identifier: (MIT) diff --git a/examples/tutorial/tut_copy.cpp b/examples/tutorial/tut_copy.cpp index e227110ac..c7d60f346 100644 --- a/examples/tutorial/tut_copy.cpp +++ b/examples/tutorial/tut_copy.cpp @@ -1,5 +1,5 @@ ////////////////////////////////////////////////////////////////////////////// -// Copyright (c) 2016-22, Lawrence Livermore National Security, LLC and Umpire +// Copyright (c) 2016-23, Lawrence Livermore National Security, LLC and Umpire // project contributors. See the COPYRIGHT file for details. // // SPDX-License-Identifier: (MIT) diff --git a/examples/tutorial/tut_dynamic_pool_1.cpp b/examples/tutorial/tut_dynamic_pool_1.cpp index 23e403f70..4194bebc9 100644 --- a/examples/tutorial/tut_dynamic_pool_1.cpp +++ b/examples/tutorial/tut_dynamic_pool_1.cpp @@ -1,5 +1,5 @@ ////////////////////////////////////////////////////////////////////////////// -// Copyright (c) 2016-22, Lawrence Livermore National Security, LLC and Umpire +// Copyright (c) 2016-23, Lawrence Livermore National Security, LLC and Umpire // project contributors. See the COPYRIGHT file for details. // // SPDX-License-Identifier: (MIT) diff --git a/examples/tutorial/tut_dynamic_pool_2.cpp b/examples/tutorial/tut_dynamic_pool_2.cpp index f88509887..745dbf930 100644 --- a/examples/tutorial/tut_dynamic_pool_2.cpp +++ b/examples/tutorial/tut_dynamic_pool_2.cpp @@ -1,5 +1,5 @@ ////////////////////////////////////////////////////////////////////////////// -// Copyright (c) 2016-22, Lawrence Livermore National Security, LLC and Umpire +// Copyright (c) 2016-23, Lawrence Livermore National Security, LLC and Umpire // project contributors. See the COPYRIGHT file for details. // // SPDX-License-Identifier: (MIT) diff --git a/examples/tutorial/tut_introspection.cpp b/examples/tutorial/tut_introspection.cpp index f322135e6..7208bf04d 100644 --- a/examples/tutorial/tut_introspection.cpp +++ b/examples/tutorial/tut_introspection.cpp @@ -1,5 +1,5 @@ ////////////////////////////////////////////////////////////////////////////// -// Copyright (c) 2016-22, Lawrence Livermore National Security, LLC and Umpire +// Copyright (c) 2016-23, Lawrence Livermore National Security, LLC and Umpire // project contributors. See the COPYRIGHT file for details. // // SPDX-License-Identifier: (MIT) diff --git a/examples/tutorial/tut_memset.cpp b/examples/tutorial/tut_memset.cpp index 03a15d778..03a29ed0c 100644 --- a/examples/tutorial/tut_memset.cpp +++ b/examples/tutorial/tut_memset.cpp @@ -1,5 +1,5 @@ ////////////////////////////////////////////////////////////////////////////// -// Copyright (c) 2016-22, Lawrence Livermore National Security, LLC and Umpire +// Copyright (c) 2016-23, Lawrence Livermore National Security, LLC and Umpire // project contributors. See the COPYRIGHT file for details. // // SPDX-License-Identifier: (MIT) diff --git a/examples/tutorial/tut_move.cpp b/examples/tutorial/tut_move.cpp index fc61c83c4..6ad41ce8e 100644 --- a/examples/tutorial/tut_move.cpp +++ b/examples/tutorial/tut_move.cpp @@ -1,5 +1,5 @@ ////////////////////////////////////////////////////////////////////////////// -// Copyright (c) 2016-22, Lawrence Livermore National Security, LLC and Umpire +// Copyright (c) 2016-23, Lawrence Livermore National Security, LLC and Umpire // project contributors. See the COPYRIGHT file for details. // // SPDX-License-Identifier: (MIT) diff --git a/examples/tutorial/tut_reallocate.cpp b/examples/tutorial/tut_reallocate.cpp index 7c56a6343..2bfd2431c 100644 --- a/examples/tutorial/tut_reallocate.cpp +++ b/examples/tutorial/tut_reallocate.cpp @@ -1,5 +1,5 @@ ////////////////////////////////////////////////////////////////////////////// -// Copyright (c) 2016-22, Lawrence Livermore National Security, LLC and Umpire +// Copyright (c) 2016-23, Lawrence Livermore National Security, LLC and Umpire // project contributors. See the COPYRIGHT file for details. // // SPDX-License-Identifier: (MIT) diff --git a/examples/tutorial/tut_replay.cpp b/examples/tutorial/tut_replay.cpp index 8e442cd96..59345582f 100644 --- a/examples/tutorial/tut_replay.cpp +++ b/examples/tutorial/tut_replay.cpp @@ -1,5 +1,5 @@ ////////////////////////////////////////////////////////////////////////////// -// Copyright (c) 2016-22, Lawrence Livermore National Security, LLC and Umpire +// Copyright (c) 2016-23, Lawrence Livermore National Security, LLC and Umpire // project contributors. See the COPYRIGHT file for details. // // SPDX-License-Identifier: (MIT) diff --git a/examples/tutorial/tut_replay_log.json b/examples/tutorial/tut_replay_log.json index 2d95592da..66a57be82 100644 --- a/examples/tutorial/tut_replay_log.json +++ b/examples/tutorial/tut_replay_log.json @@ -1,5 +1,5 @@ ############################################################################## -# Copyright (c) 2016-22, Lawrence Livermore National Security, LLC and Umpire +# Copyright (c) 2016-23, Lawrence Livermore National Security, LLC and Umpire # project contributors. See the COPYRIGHT file for details. # # SPDX-License-Identifier: (MIT) diff --git a/examples/tutorial/tut_resources.cpp b/examples/tutorial/tut_resources.cpp index bd863c139..016eae3b2 100644 --- a/examples/tutorial/tut_resources.cpp +++ b/examples/tutorial/tut_resources.cpp @@ -1,5 +1,5 @@ ////////////////////////////////////////////////////////////////////////////// -// Copyright (c) 2016-22, Lawrence Livermore National Security, LLC and Umpire +// Copyright (c) 2016-23, Lawrence Livermore National Security, LLC and Umpire // project contributors. See the COPYRIGHT file for details. // // SPDX-License-Identifier: (MIT) diff --git a/examples/tutorial/tut_typed_allocator.cpp b/examples/tutorial/tut_typed_allocator.cpp index 8f7d30af0..2a5659f45 100644 --- a/examples/tutorial/tut_typed_allocator.cpp +++ b/examples/tutorial/tut_typed_allocator.cpp @@ -1,5 +1,5 @@ ////////////////////////////////////////////////////////////////////////////// -// Copyright (c) 2016-22, Lawrence Livermore National Security, LLC and Umpire +// Copyright (c) 2016-23, Lawrence Livermore National Security, LLC and Umpire // project contributors. See the COPYRIGHT file for details. // // SPDX-License-Identifier: (MIT) diff --git a/examples/use_after_free.cpp b/examples/use_after_free.cpp index 5059b6e2a..52b85462e 100644 --- a/examples/use_after_free.cpp +++ b/examples/use_after_free.cpp @@ -1,5 +1,5 @@ ////////////////////////////////////////////////////////////////////////////// -// Copyright (c) 2016-22, Lawrence Livermore National Security, LLC and Umpire +// Copyright (c) 2016-23, Lawrence Livermore National Security, LLC and Umpire // project contributors. See the COPYRIGHT file for details. // // SPDX-License-Identifier: (MIT) diff --git a/examples/vector_allocator.cpp b/examples/vector_allocator.cpp index 81e0d6b63..69be62cc0 100644 --- a/examples/vector_allocator.cpp +++ b/examples/vector_allocator.cpp @@ -1,5 +1,5 @@ ////////////////////////////////////////////////////////////////////////////// -// Copyright (c) 2016-22, Lawrence Livermore National Security, LLC and Umpire +// Copyright (c) 2016-23, Lawrence Livermore National Security, LLC and Umpire // project contributors. See the COPYRIGHT file for details. // // SPDX-License-Identifier: (MIT) diff --git a/scripts/apply-license-info.sh b/scripts/apply-license-info.sh index e0e16c8e8..50eef7043 100755 --- a/scripts/apply-license-info.sh +++ b/scripts/apply-license-info.sh @@ -1,6 +1,6 @@ #!/usr/bin/env zsh ############################################################################## -# Copyright (c) 2016-22, Lawrence Livermore National Security, LLC and Umpire +# Copyright (c) 2016-23, Lawrence Livermore National Security, LLC and Umpire # project contributors. See the COPYRIGHT file for details. # # SPDX-License-Identifier: (MIT) diff --git a/scripts/bamboo/build_and_benchmark.sh b/scripts/bamboo/build_and_benchmark.sh index 627ca6cce..9b04094a6 100755 --- a/scripts/bamboo/build_and_benchmark.sh +++ b/scripts/bamboo/build_and_benchmark.sh @@ -1,6 +1,6 @@ #!/bin/bash ############################################################################## -# Copyright (c) 2016-22, Lawrence Livermore National Security, LLC and Umpire +# Copyright (c) 2016-23, Lawrence Livermore National Security, LLC and Umpire # project contributors. See the COPYRIGHT file for details. # # SPDX-License-Identifier: (MIT) diff --git a/scripts/bamboo/build_and_test.sh b/scripts/bamboo/build_and_test.sh index 5e0f96445..302924815 100755 --- a/scripts/bamboo/build_and_test.sh +++ b/scripts/bamboo/build_and_test.sh @@ -1,6 +1,6 @@ #!/bin/bash ############################################################################## -# Copyright (c) 2016-22, Lawrence Livermore National Security, LLC and Umpire +# Copyright (c) 2016-23, Lawrence Livermore National Security, LLC and Umpire # project contributors. See the COPYRIGHT file for details. # # SPDX-License-Identifier: (MIT) diff --git a/scripts/bamboo/build_and_test_all_disabled.sh b/scripts/bamboo/build_and_test_all_disabled.sh index a95903e9a..6c6f007e8 100755 --- a/scripts/bamboo/build_and_test_all_disabled.sh +++ b/scripts/bamboo/build_and_test_all_disabled.sh @@ -1,6 +1,6 @@ #!/bin/bash ############################################################################## -# Copyright (c) 2016-22, Lawrence Livermore National Security, LLC and Umpire +# Copyright (c) 2016-23, Lawrence Livermore National Security, LLC and Umpire # project contributors. See the COPYRIGHT file for details. # # SPDX-License-Identifier: (MIT) diff --git a/scripts/bamboo/build_and_test_all_enabled.sh b/scripts/bamboo/build_and_test_all_enabled.sh index 41656a425..450a5e876 100755 --- a/scripts/bamboo/build_and_test_all_enabled.sh +++ b/scripts/bamboo/build_and_test_all_enabled.sh @@ -1,6 +1,6 @@ #!/bin/bash ############################################################################## -# Copyright (c) 2016-22, Lawrence Livermore National Security, LLC and Umpire +# Copyright (c) 2016-23, Lawrence Livermore National Security, LLC and Umpire # project contributors. See the COPYRIGHT file for details. # # SPDX-License-Identifier: (MIT) diff --git a/scripts/bamboo/run_build_and_test.sh b/scripts/bamboo/run_build_and_test.sh index a4f548131..c2a1b627f 100755 --- a/scripts/bamboo/run_build_and_test.sh +++ b/scripts/bamboo/run_build_and_test.sh @@ -1,6 +1,6 @@ #!/bin/bash ############################################################################## -# Copyright (c) 2016-22, Lawrence Livermore National Security, LLC and Umpire +# Copyright (c) 2016-23, Lawrence Livermore National Security, LLC and Umpire # project contributors. See the COPYRIGHT file for details. # # SPDX-License-Identifier: (MIT) diff --git a/scripts/check-license-info.sh b/scripts/check-license-info.sh index 500462370..ec8c75d59 100755 --- a/scripts/check-license-info.sh +++ b/scripts/check-license-info.sh @@ -1,6 +1,6 @@ #!/usr/bin/env zsh ############################################################################## -# Copyright (c) 2016-22, Lawrence Livermore National Security, LLC and Umpire +# Copyright (c) 2016-23, Lawrence Livermore National Security, LLC and Umpire # project contributors. See the COPYRIGHT file for details. # # SPDX-License-Identifier: (MIT) diff --git a/scripts/docker/apply-style.sh b/scripts/docker/apply-style.sh index e44e85b3d..06f3c600d 100755 --- a/scripts/docker/apply-style.sh +++ b/scripts/docker/apply-style.sh @@ -1,6 +1,6 @@ #!/bin/bash ############################################################################## -# Copyright (c) 2016-22, Lawrence Livermore National Security, LLC and Umpire +# Copyright (c) 2016-23, Lawrence Livermore National Security, LLC and Umpire # project contributors. See the COPYRIGHT file for details. # # SPDX-License-Identifier: (MIT) diff --git a/scripts/gitlab/build_and_test.sh b/scripts/gitlab/build_and_test.sh index a63d5bee6..7e3f14e1b 100755 --- a/scripts/gitlab/build_and_test.sh +++ b/scripts/gitlab/build_and_test.sh @@ -7,7 +7,7 @@ then fi ############################################################################### -# Copyright (c) 2016-22, Lawrence Livermore National Security, LLC and Umpire +# Copyright (c) 2016-23, Lawrence Livermore National Security, LLC and Umpire # project contributors. See the COPYRIGHT file for details. # # SPDX-License-Identifier: (MIT) diff --git a/scripts/make_release_tarball.sh b/scripts/make_release_tarball.sh index 5781e8841..c4f9ce0d4 100755 --- a/scripts/make_release_tarball.sh +++ b/scripts/make_release_tarball.sh @@ -1,6 +1,6 @@ #!/bin/bash ############################################################################## -# Copyright (c) 2016-22, Lawrence Livermore National Security, LLC and Umpire +# Copyright (c) 2016-23, Lawrence Livermore National Security, LLC and Umpire # project contributors. See the COPYRIGHT file for details. # # SPDX-License-Identifier: (MIT) diff --git a/scripts/radiuss-spack-configs b/scripts/radiuss-spack-configs index 1ce0f4421..d674c30ba 160000 --- a/scripts/radiuss-spack-configs +++ b/scripts/radiuss-spack-configs @@ -1 +1 @@ -Subproject commit 1ce0f4421cfe6be4200ae9aa8abd113e09ee4c2d +Subproject commit d674c30babee357e5c98bb396d6b7978ba3c8c64 diff --git a/scripts/spack_packages/blt/package.py b/scripts/spack_packages/blt/package.py deleted file mode 100644 index 0707d22da..000000000 --- a/scripts/spack_packages/blt/package.py +++ /dev/null @@ -1,40 +0,0 @@ -# Copyright 2013-2022 Lawrence Livermore National Security, LLC and other -# Spack Project Developers. See the top-level COPYRIGHT file for details. -# -# SPDX-License-Identifier: (Apache-2.0 OR MIT) - -from spack import * - - -class Blt(Package): - """BLT is a streamlined CMake-based foundation for Building, Linking and - Testing large-scale high performance computing (HPC) applications.""" - - homepage = "https://github.com/LLNL/blt" - url = "https://github.com/LLNL/blt/archive/v0.4.0.tar.gz" - git = "https://github.com/LLNL/blt.git" - tags = ['radiuss'] - - maintainers = ['white238', 'davidbeckingsale'] - - version('develop', branch='develop') - version('main', branch='main') - # Note: 0.4.0+ contains a breaking change to BLT created targets - # if you export targets this could cause problems in downstream - # projects if not handled properly. More info here: - # https://llnl-blt.readthedocs.io/en/develop/tutorial/exporting_targets.html - version("0.5.2", sha256="95b924cfbb2bddd9b1a92e96603b2fd485a19721d59ddf8ff50baefc1714d7ea") - version('0.5.1', sha256='ff7e87eefc48704a0721b66174612b945955adaa0a56aa69dd0473074fa4badf') - version('0.5.0', sha256='5f680ef922d0e0a7ff1b1a5fc8aa107cd4f543ad888cbc9b12639bea72a6ab1f') - version('0.4.1', sha256='16cc3e067ddcf48b99358107e5035a17549f52dcc701a35cd18a9d9f536826c1') - version('0.4.0', sha256='f3bc45d28b9b2eb6df43b75d4f6f89a1557d73d012da7b75bac1be0574767193') - version('0.3.6', sha256='6276317c29e7ff8524fbea47d9288ddb40ac06e9f9da5e878bf9011e2c99bf71') - version('0.3.5', sha256='68a1c224bb9203461ae6f5ab0ff3c50b4a58dcce6c2d2799489a1811f425fb84') - version('0.3.0', sha256='bb917a67cb7335d6721c997ba9c5dca70506006d7bba5e0e50033dd0836481a5') - version('0.2.5', sha256='3a000f60194e47b3e5623cc528cbcaf88f7fea4d9620b3c7446ff6658dc582a5') - version('0.2.0', sha256='c0cadf1269c2feb189e398a356e3c49170bc832df95e5564e32bdbb1eb0fa1b3') - - depends_on('cmake', type='run') - - def install(self, spec, prefix): - install_tree('.', prefix) diff --git a/scripts/spack_packages/camp/package.py b/scripts/spack_packages/camp/package.py deleted file mode 100644 index 3bff14ef6..000000000 --- a/scripts/spack_packages/camp/package.py +++ /dev/null @@ -1,83 +0,0 @@ -# Copyright 2013-2022 Lawrence Livermore National Security, LLC and other -# Spack Project Developers. See the top-level COPYRIGHT file for details. -# -# SPDX-License-Identifier: (Apache-2.0 OR MIT) - -import glob - -from spack.package import * - - -class Camp(CMakePackage, CudaPackage, ROCmPackage): - """ - Compiler agnostic metaprogramming library providing concepts, - type operations and tuples for C++ and cuda - """ - - homepage = "https://github.com/LLNL/camp" - git = "https://github.com/LLNL/camp.git" - url = "https://github.com/LLNL/camp/archive/v0.1.0.tar.gz" - - maintainers = ['trws'] - - version('main', branch='main', submodules='True') - version('2022.03.0', sha256='e9090d5ee191ea3a8e36b47a8fe78f3ac95d51804f1d986d931e85b8f8dad721') - version('0.3.0', sha256='129431a049ca5825443038ad5a37a86ba6d09b2618d5fe65d35f83136575afdb') - version('0.2.3', sha256='58a0f3bd5eadb588d7dc83f3d050aff8c8db639fc89e8d6553f9ce34fc2421a7') - version('0.2.2', sha256='194d38b57e50e3494482a7f94940b27f37a2bee8291f2574d64db342b981d819') - version('0.1.0', sha256='fd4f0f2a60b82a12a1d9f943f8893dc6fe770db493f8fae5ef6f7d0c439bebcc') - - # TODO: figure out gtest dependency and then set this default True. - variant('tests', default=False, description='Build tests') - variant('openmp', default=False, description='Build with OpenMP support') - - depends_on('cub', when='+cuda') - - depends_on('blt') - - def cmake_args(self): - spec = self.spec - - options = [] - - options.append("-DBLT_SOURCE_DIR={0}".format(spec['blt'].prefix)) - - if '+cuda' in spec: - options.extend([ - '-DENABLE_CUDA=ON', - '-DCUDA_TOOLKIT_ROOT_DIR=%s' % (spec['cuda'].prefix)]) - - if not spec.satisfies('cuda_arch=none'): - cuda_arch = spec.variants['cuda_arch'].value - options.append('-DCMAKE_CUDA_ARCHITECTURES={0}'.format(cuda_arch[0])) - options.append('-DCUDA_ARCH=sm_{0}'.format(cuda_arch[0])) - flag = '-arch sm_{0}'.format(cuda_arch[0]) - options.append('-DCMAKE_CUDA_FLAGS:STRING={0}'.format(flag)) - else: - options.append('-DENABLE_CUDA=OFF') - - if '+rocm' in spec: - options.extend([ - '-DENABLE_HIP=ON', - '-DHIP_ROOT_DIR={0}'.format(spec['hip'].prefix) - ]) - archs = self.spec.variants['amdgpu_target'].value - if archs != 'none': - arch_str = ",".join(archs) - options.append( - '-DHIP_HIPCC_FLAGS=--amdgpu-target={0}'.format(arch_str) - ) - # there is only one dir like this, but the version component is unknown - options.append( - "-DHIP_CLANG_INCLUDE_PATH=" + glob.glob( - "{}/lib/clang/*/include".format(spec['llvm-amdgpu'].prefix) - )[0] - ) - else: - options.append('-DENABLE_HIP=OFF') - - options.append(self.define_from_variant('ENABLE_TESTS', 'tests')) - options.append(self.define_from_variant('ENABLE_OPENMP', 'openmp')) - - - return options diff --git a/scripts/spack_packages/umpire/camp_target_umpire_3.0.0.patch b/scripts/spack_packages/umpire/camp_target_umpire_3.0.0.patch deleted file mode 100644 index 2deb565cd..000000000 --- a/scripts/spack_packages/umpire/camp_target_umpire_3.0.0.patch +++ /dev/null @@ -1,18 +0,0 @@ -diff --git a/umpire-config.cmake.in b/umpire-config.cmake.in -index a98ad5fe..4e54e173 100644 ---- a/umpire-config.cmake.in -+++ b/umpire-config.cmake.in -@@ -7,6 +7,13 @@ - get_filename_component(UMPIRE_CMAKE_DIR "${CMAKE_CURRENT_LIST_FILE}" PATH) - set(UMPIRE_INCLUDE_DIRS "@CMAKE_INSTALL_PREFIX@/include") - -+if (NOT TARGET camp) -+ if (NOT DEFINED camp_DIR) -+ set(camp_DIR @CMAKE_INSTALL_PREFIX@/lib/cmake/camp) -+ endif () -+ find_package(camp REQUIRED) -+endif () -+ - set(Umpire_VERSION_MAJOR @Umpire_VERSION_MAJOR@) - set(Umpire_VERSION_MINOR @Umpire_VERSION_MINOR@) - set(Umpire_VERSION_PATCH @Umpire_VERSION_PATCH@) diff --git a/scripts/spack_packages/umpire/package.py b/scripts/spack_packages/umpire/package.py deleted file mode 100644 index bd454e224..000000000 --- a/scripts/spack_packages/umpire/package.py +++ /dev/null @@ -1,267 +0,0 @@ -# Copyright 2013-2022 Lawrence Livermore National Security, LLC and other -# Spack Project Developers. See the top-level COPYRIGHT file for details. -# -# SPDX-License-Identifier: (Apache-2.0 OR MIT) -import glob - -from spack import * - -import socket -import os - -from os import environ as env -from os.path import join as pjoin - -import re - - -class Umpire(CachedCMakePackage, CudaPackage, ROCmPackage): - """An application-focused API for memory management on NUMA & GPU - architectures""" - - homepage = 'https://github.com/LLNL/Umpire' - git = 'https://github.com/LLNL/Umpire.git' - - version('develop', branch='develop', submodules='True') - version('main', branch='main', submodules='True') - version('3.0.0', tag='v3.0.0', submodules='True') - version('2.1.0', tag='v2.1.0', submodules='True') - version('2.0.0', tag='v2.0.0', submodules='True') - version('1.1.0', tag='v1.1.0', submodules='True') - version('1.0.1', tag='v1.0.1', submodules='True') - version('1.0.0', tag='v1.0.0', submodules='True') - version('0.3.5', tag='v0.3.5', submodules='True') - version('0.3.4', tag='v0.3.4', submodules='True') - version('0.3.3', tag='v0.3.3', submodules='True') - version('0.3.2', tag='v0.3.2', submodules='True') - version('0.3.1', tag='v0.3.1', submodules='True') - version('0.3.0', tag='v0.3.0', submodules='True') - version('0.2.4', tag='v0.2.4', submodules='True') - version('0.2.3', tag='v0.2.3', submodules='True') - version('0.2.2', tag='v0.2.2', submodules='True') - version('0.2.1', tag='v0.2.1', submodules='True') - version('0.2.0', tag='v0.2.0', submodules='True') - version('0.1.4', tag='v0.1.4', submodules='True') - version('0.1.3', tag='v0.1.3', submodules='True') - - patch('camp_target_umpire_3.0.0.patch', when='@3.0.0') - - variant('fortran', default=False, description='Build C/Fortran API') - variant('c', default=True, description='Build C API') - variant('mpi', default=False, description='Enable MPI support') - variant('ipc_shmem', default=False, description='Enable POSIX shared memory') - variant('sqlite_experimental', default=False, description='Enable sqlite integration with umpire events (Experimental)') - variant('numa', default=False, description='Enable NUMA support') - variant('shared', default=False, description='Enable Shared libs') - variant('openmp', default=False, description='Build with OpenMP support') - variant('openmp_target', default=False, description='Build with OpenMP 4.5 support') - variant('deviceconst', default=False, - description='Enables support for constant device memory') - variant('tests', default='basic', values=('none', 'basic', 'benchmarks'), - multi=False, description='Tests to run') - - variant('libcpp', default=False, description='Uses libc++ instead of libstdc++') - variant('tools', default=True, description='Enable tools') - variant('backtrace', default=False, description='Enable backtrace tools') - variant('dev_benchmarks', default=False, description='Enable Developer Benchmarks') - variant('device_alloc', default=False, description='Enable the DeviceAllocator') - variant('werror', default=True, description='Enable warnings as errors') - variant('asan', default=False, description='Enable ASAN') - variant('sanitizer_tests', default=False, description='Enable address sanitizer tests') - - depends_on('cmake@3.14:', type='build') - depends_on('sqlite', when='+sqlite_experimental') - depends_on('mpi', when='+mpi') - - depends_on('blt@0.5.0', type='build', when='@main') - depends_on('blt@0.5.2:', type='build') - - # variants +rocm and amdgpu_targets are not automatically passed to - # dependencies, so do it manually. - depends_on('camp+rocm', when='+rocm') - for val in ROCmPackage.amdgpu_targets: - depends_on('camp amdgpu_target=%s' % val, when='amdgpu_target=%s' % val) - - depends_on('camp+cuda', when='+cuda') - for sm_ in CudaPackage.cuda_arch_values: - depends_on('camp cuda_arch={0}'.format(sm_), - when='cuda_arch={0}'.format(sm_)) - - depends_on('camp@main') - - conflicts('+numa', when='@:0.3.2') - conflicts('~c', when='+fortran', msg='Fortran API requires C API') - conflicts('~openmp', when='+openmp_target', msg='OpenMP target requires OpenMP') - conflicts('+cuda', when='+rocm') - conflicts('+rocm', when='+openmp_target', msg='Cant support both rocm and openmp device backends at once') - conflicts('+deviceconst', when='~rocm~cuda') - conflicts('+device_alloc', when='~rocm~cuda') - conflicts('~mpi', when='+ipc_shmem', msg='Shared Memory Allocator requires MPI') - conflicts('+ipc_shmem', when='@:5.0.1') - conflicts('+sqlite_experimental', when='@:6.0.0') - conflicts('+sanitizer_tests', when='~asan') - - def _get_sys_type(self, spec): - sys_type = str(spec.architecture) - # if on llnl systems, we can use the SYS_TYPE - if "SYS_TYPE" in env: - sys_type = env["SYS_TYPE"] - return sys_type - - @property - def cache_name(self): - hostname = socket.gethostname() - if "SYS_TYPE" in env: - hostname = hostname.rstrip('1234567890') - return "{0}-{1}-{2}@{3}.cmake".format( - hostname, - self._get_sys_type(self.spec), - self.spec.compiler.name, - self.spec.compiler.version - ) - - def spec_uses_toolchain(self, spec): - gcc_toolchain_regex = re.compile(".*gcc-toolchain.*") - using_toolchain = list(filter(gcc_toolchain_regex.match, spec.compiler_flags['cxxflags'])) - - return using_toolchain - - def spec_uses_gccname(self, spec): - gcc_name_regex = re.compile(".*gcc-name.*") - using_gcc_name = list(filter(gcc_name_regex.match, spec.compiler_flags['cxxflags'])) - - return using_gcc_name - - - - def initconfig_compiler_entries(self): - spec = self.spec - entries = super(Umpire, self).initconfig_compiler_entries() - - entries.append(cmake_cache_option("ENABLE_FORTRAN", - ('+fortran' in spec) and (self.compiler.fc is not None))) - entries.append(cmake_cache_option("UMPIRE_ENABLE_C", '+c' in spec)) - - fortran_compilers = ["gfortran", "xlf"] - if any(compiler in self.compiler.fc for compiler in fortran_compilers) and ("clang" in self.compiler.cxx): - entries.append(cmake_cache_string("BLT_CMAKE_IMPLICIT_LINK_DIRECTORIES_EXCLUDE", - "/usr/tce/packages/gcc/gcc-4.9.3/lib64;/usr/tce/packages/gcc/gcc-4.9.3/gnu/lib64/gcc/powerpc64le-unknown-linux-gnu/4.9.3;/usr/tce/packages/gcc/gcc-4.9.3/gnu/lib64;/usr/tce/packages/gcc/gcc-4.9.3/lib64/gcc/x86_64-unknown-linux-gnu/4.9.3")) - - libdir = pjoin(os.path.dirname( - os.path.dirname(self.compiler.fc)), "lib") - flags = "" - for _libpath in [libdir, libdir + "64"]: - if os.path.exists(_libpath): - flags += " -Wl,-rpath,{0}".format(_libpath) - description = ("Adds a missing libstdc++ rpath") - if flags: - entries.append(cmake_cache_string("BLT_EXE_LINKER_FLAGS", flags, description)) - - - compilers_using_toolchain = ["pgi", "xl", "icpc"] - if any(compiler in self.compiler.cxx for compiler in compilers_using_toolchain): - if self.spec_uses_toolchain(self.spec) or self.spec_uses_gccname(self.spec): - entries.append(cmake_cache_string("BLT_CMAKE_IMPLICIT_LINK_DIRECTORIES_EXCLUDE", - "/usr/tce/packages/gcc/gcc-4.9.3/lib64;/usr/tce/packages/gcc/gcc-4.9.3/gnu/lib64/gcc/powerpc64le-unknown-linux-gnu/4.9.3;/usr/tce/packages/gcc/gcc-4.9.3/gnu/lib64;/usr/tce/packages/gcc/gcc-4.9.3/lib64/gcc/x86_64-unknown-linux-gnu/4.9.3")) - - entries = [x for x in entries if not 'COMPILER_ID' in x] - return entries - - - def initconfig_hardware_entries(self): - spec = self.spec - entries = super(Umpire, self).initconfig_hardware_entries() - - entries.append(cmake_cache_option("ENABLE_CUDA", "+cuda" in spec)) - if "+cuda" in spec: - cuda_flags = [] - if not spec.satisfies('cuda_arch=none'): - cuda_arch = spec.variants['cuda_arch'].value - cuda_flags.append('-arch sm_{0}'.format(cuda_arch[0])) - - if self.spec_uses_toolchain(self.spec): - cuda_flags.append("-Xcompiler {}".format(self.spec_uses_toolchain(self.spec)[0])) - - if (spec.satisfies('%gcc@8.1: target=ppc64le')): - cuda_flags.append('-Xcompiler -mno-float128') - - entries.append(cmake_cache_string("CMAKE_CUDA_FLAGS", ' '.join(cuda_flags))) - - entries.append(cmake_cache_option("ENABLE_HIP", "+rocm" in spec)) - if "+rocm" in spec: - hip_root = spec['hip'].prefix - rocm_root = hip_root + "/.." - hip_arch = spec.variants['amdgpu_target'].value - entries.append(cmake_cache_path("HIP_ROOT_DIR", - hip_root)) - entries.append(cmake_cache_path("ROCM_ROOT_DIR", - rocm_root)) - entries.append(cmake_cache_string("CMAKE_HIP_ARCHITECTURES", - hip_arch[0])) - entries.append(cmake_cache_option("UMPIRE_ENABLE_TOOLS", False)) - # there is only one dir like this, but the version component is unknown - - entries.append( - cmake_cache_path("HIP_CLANG_INCLUDE_PATH", glob.glob( - "{}/lib/clang/*/include".format(spec['llvm-amdgpu'].prefix) - )[0]) - ) - hip_link_flags = "" - if '%gcc' in spec: - gcc_bin = os.path.dirname(self.compiler.cxx) - gcc_prefix = join_path(gcc_bin, '..') - entries.append(cmake_cache_string("HIP_CLANG_FLAGS", "--gcc-toolchain={0}".format(gcc_prefix))) - entries.append(cmake_cache_string("CMAKE_EXE_LINKER_FLAGS", hip_link_flags + " -Wl,-rpath {}/lib64".format(gcc_prefix))) - else: - entries.append(cmake_cache_string("CMAKE_EXE_LINKER_FLAGS", "-Wl,-rpath={0}/llvm/lib/".format(rocm_root))) - - entries.append(cmake_cache_option("UMPIRE_ENABLE_DEVICE_CONST", "+deviceconst" in spec)) - - entries.append(cmake_cache_option("UMPIRE_ENABLE_OPENMP_TARGET", "+openmp_target" in spec)) - if "+openmp_target" in spec: - if ('%xl' in spec): - entries.append(cmake_cache_string("OpenMP_CXX_FLAGS", "-qsmp;-qoffload")) - - return entries - - - def initconfig_mpi_entries(self): - spec = self.spec - - entries = super(Umpire, self).initconfig_mpi_entries() - entries.append(cmake_cache_option("ENABLE_MPI", '+mpi' in spec)) - - return entries - - - def initconfig_package_entries(self): - spec = self.spec - entries = [] - - entries.append(cmake_cache_path("BLT_SOURCE_DIR", spec['blt'].prefix)) - entries.append(cmake_cache_path("camp_DIR" ,spec['camp'].prefix)) - entries.append(cmake_cache_string("CMAKE_BUILD_TYPE", spec.variants['build_type'].value)) - entries.append(cmake_cache_option("ENABLE_BENCHMARKS", 'tests=benchmarks' in spec or '+dev_benchmarks' in spec)) - entries.append(cmake_cache_option("UMPIRE_ENABLE_DEVELOPER_BENCHMARKS", '+dev_benchmarks' in spec)) - entries.append(cmake_cache_option("UMPIRE_ENABLE_DEVICE_ALLOCATOR", '+device_alloc' in spec)) - entries.append(cmake_cache_option("ENABLE_TESTS", not 'tests=none' in spec)) - entries.append(cmake_cache_option("UMPIRE_ENABLE_TOOLS", '+tools' in spec)) - entries.append(cmake_cache_option("UMPIRE_ENABLE_BACKTRACE", '+backtrace' in spec)) - entries.append(cmake_cache_option("ENABLE_WARNINGS_AS_ERRORS", '+werror' in spec)) - entries.append(cmake_cache_option("UMPIRE_ENABLE_ASAN", '+asan' in spec)) - entries.append(cmake_cache_option("BUILD_SHARED_LIBS", '+shared' in spec)) - entries.append(cmake_cache_option("UMPIRE_ENABLE_SANITIZER_TESTS", '+sanitizer_tests' in spec)) - entries.append(cmake_cache_option("UMPIRE_ENABLE_NUMA", '+numa' in spec)) - entries.append(cmake_cache_option("ENABLE_OPENMP", '+openmp' in spec)) - entries.append(cmake_cache_option("UMPIRE_ENABLE_IPC_SHARED_MEMORY", '+ipc_shmem' in spec)) - entries.append(cmake_cache_option("UMPIRE_ENABLE_SQLITE_EXPERIMENTAL", '+sqlite_experimental' in spec)) - if "+sqlite_experimental" in spec: - entries.append(cmake_cache_path("SQLite3_ROOT" ,spec['sqlite'].prefix)) - - return entries - - - def cmake_args(self): - spec = self.spec - options = [] - return options diff --git a/scripts/travis/build_and_test.sh b/scripts/travis/build_and_test.sh index ec7ba28c1..126b3dddf 100755 --- a/scripts/travis/build_and_test.sh +++ b/scripts/travis/build_and_test.sh @@ -1,6 +1,6 @@ #!/bin/bash ############################################################################## -# Copyright (c) 2016-22, Lawrence Livermore National Security, LLC and Umpire +# Copyright (c) 2016-23, Lawrence Livermore National Security, LLC and Umpire # project contributors. See the COPYRIGHT file for details. # # SPDX-License-Identifier: (MIT) diff --git a/scripts/umpire-license.txt b/scripts/umpire-license.txt index 4e1bd1757..1129e3b1d 100644 --- a/scripts/umpire-license.txt +++ b/scripts/umpire-license.txt @@ -1,4 +1,4 @@ -Copyright (c) 2016-22, Lawrence Livermore National Security, LLC and Umpire +Copyright (c) 2016-23, Lawrence Livermore National Security, LLC and Umpire project contributors. See the COPYRIGHT file for details. SPDX-License-Identifier: (MIT) diff --git a/scripts/update-copyright-date.sh b/scripts/update-copyright-date.sh index 549f00451..fcd38470c 100755 --- a/scripts/update-copyright-date.sh +++ b/scripts/update-copyright-date.sh @@ -1,6 +1,6 @@ #!/bin/bash ############################################################################## -# Copyright (c) 2016-22, Lawrence Livermore National Security, LLC and Umpire +# Copyright (c) 2016-23, Lawrence Livermore National Security, LLC and Umpire # project contributors. See the COPYRIGHT file for details. # # SPDX-License-Identifier: (MIT) @@ -11,12 +11,11 @@ for f in `git ls-tree -r develop --name-only` do if [ -f $f ] then - if grep -q 2016-22 $f + if grep -q 2016-23 $f then - # grep 2016-22 $f echo "Updating $f" - sed -i -e 's/2016-22/2016-22/g' $f + sed -i.bak -e 's/2016-23/2016-23/g' $f + rm $f.bak fi fi - # for i in `grep 2016-19 * -R -l`; do sed -i.bak 's/2016-19/2016-20/g' $i; done done diff --git a/src/CMakeLists.txt b/src/CMakeLists.txt index 123a8c5f9..e76ac2d72 100644 --- a/src/CMakeLists.txt +++ b/src/CMakeLists.txt @@ -1,5 +1,5 @@ ############################################################################## -# Copyright (c) 2016-22, Lawrence Livermore National Security, LLC and Umpire +# Copyright (c) 2016-23, Lawrence Livermore National Security, LLC and Umpire # project contributors. See the COPYRIGHT file for details. # # SPDX-License-Identifier: (MIT) diff --git a/src/tpl/CMakeLists.txt b/src/tpl/CMakeLists.txt index 6803f0a41..60269f882 100644 --- a/src/tpl/CMakeLists.txt +++ b/src/tpl/CMakeLists.txt @@ -50,7 +50,13 @@ target_include_directories( umpire_tpl_json INTERFACE $ - $ + $) + +blt_convert_to_system_includes(TARGET umpire_tpl_json) + +target_include_directories( + umpire_tpl_json + INTERFACE $) install(FILES @@ -64,8 +70,6 @@ install(TARGETS LIBRARY DESTINATION lib ARCHIVE DESTINATION lib) -blt_patch_target(NAME umpire_tpl_json - TREAT_INCLUDES_AS_SYSTEM ON) # # CLI11 Option Parsing Headers @@ -82,7 +86,13 @@ target_include_directories( umpire_tpl_CLI11 INTERFACE $ - $ + $) + +blt_convert_to_system_includes(TARGET umpire_tpl_CLI11) + +target_include_directories( + umpire_tpl_CLI11 + INTERFACE $) install(FILES @@ -96,9 +106,6 @@ install(TARGETS LIBRARY DESTINATION lib ARCHIVE DESTINATION lib) -blt_patch_target(NAME umpire_tpl_CLI11 - TREAT_INCLUDES_AS_SYSTEM ON) - add_subdirectory(umpire/judy) if (NOT TARGET camp) @@ -153,7 +160,14 @@ target_include_directories( umpire_tpl_fmt INTERFACE $ - $ + $) + +# 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 $) if (C_COMPILER_FAMILY_IS_XL) @@ -168,21 +182,17 @@ 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) + if (ENABLE_FORTRAN) target_compile_options(umpire_tpl_fmt INTERFACE $<$>:${_fmt_warning_disable_flag}>) - else () - target_compile_options(umpire_tpl_fmt - INTERFACE - ${_fmt_warning_disable_flag}) - endif () + else () + target_compile_options(umpire_tpl_fmt + INTERFACE + ${_fmt_warning_disable_flag}) + endif () endif () -# Avoid warnings from fmt (so we can still use -Werror) -blt_patch_target(NAME umpire_tpl_fmt - TREAT_INCLUDES_AS_SYSTEM ON) - if (C_COMPILER_FAMILY_IS_GNU) target_compile_options(umpire_tpl_fmt INTERFACE diff --git a/src/tpl/umpire/fmt/args.h b/src/tpl/umpire/fmt/args.h index 24dbec930..33fa9fc5c 100644 --- a/src/tpl/umpire/fmt/args.h +++ b/src/tpl/umpire/fmt/args.h @@ -5,8 +5,8 @@ // // For the license information refer to format.h. -#ifndef FMT_ARGS_H_ -#define FMT_ARGS_H_ +#ifndef UMPIRE_FMT_ARGS_H_ +#define UMPIRE_FMT_ARGS_H_ #include // std::reference_wrapper #include // std::unique_ptr @@ -14,7 +14,7 @@ #include "core.h" -FMT_BEGIN_NAMESPACE +UMPIRE_FMT_BEGIN_NAMESPACE namespace detail { @@ -40,10 +40,10 @@ class dynamic_arg_list { T value; template - FMT_CONSTEXPR typed_node(const Arg& arg) : value(arg) {} + UMPIRE_FMT_CONSTEXPR typed_node(const Arg& arg) : value(arg) {} template - FMT_CONSTEXPR typed_node(const basic_string_view& arg) + UMPIRE_FMT_CONSTEXPR typed_node(const basic_string_view& arg) : value(arg.data(), arg.size()) {} }; @@ -72,7 +72,7 @@ class dynamic_arg_list { */ template class dynamic_format_arg_store -#if FMT_GCC_VERSION && FMT_GCC_VERSION < 409 +#if UMPIRE_FMT_GCC_VERSION && UMPIRE_FMT_GCC_VERSION < 409 // Workaround a GCC template argument substitution bug. : public basic_format_args #endif @@ -220,13 +220,13 @@ class dynamic_format_arg_store \endrst */ void reserve(size_t new_cap, size_t new_cap_named) { - FMT_ASSERT(new_cap >= new_cap_named, + UMPIRE_FMT_ASSERT(new_cap >= new_cap_named, "Set of arguments includes set of named arguments"); data_.reserve(new_cap); named_info_.reserve(new_cap_named); } }; -FMT_END_NAMESPACE +UMPIRE_FMT_END_NAMESPACE -#endif // FMT_ARGS_H_ +#endif // UMPIRE_FMT_ARGS_H_ diff --git a/src/tpl/umpire/fmt/chrono.h b/src/tpl/umpire/fmt/chrono.h index e7909e7b5..7772d9aae 100644 --- a/src/tpl/umpire/fmt/chrono.h +++ b/src/tpl/umpire/fmt/chrono.h @@ -5,8 +5,8 @@ // // For the license information refer to format.h. -#ifndef FMT_CHRONO_H_ -#define FMT_CHRONO_H_ +#ifndef UMPIRE_FMT_CHRONO_H_ +#define UMPIRE_FMT_CHRONO_H_ #include #include @@ -17,13 +17,13 @@ #include "format.h" #include "locale.h" -FMT_BEGIN_NAMESPACE +UMPIRE_FMT_BEGIN_NAMESPACE // Enable safe chrono durations, unless explicitly disabled. -#ifndef FMT_SAFE_DURATION_CAST -# define FMT_SAFE_DURATION_CAST 1 +#ifndef UMPIRE_FMT_SAFE_DURATION_CAST +# define UMPIRE_FMT_SAFE_DURATION_CAST 1 #endif -#if FMT_SAFE_DURATION_CAST +#if UMPIRE_FMT_SAFE_DURATION_CAST // For conversion between std::chrono::durations without undefined // behaviour or erroneous results. @@ -34,10 +34,10 @@ FMT_BEGIN_NAMESPACE namespace safe_duration_cast { template ::value && + UMPIRE_FMT_ENABLE_IF(!std::is_same::value && std::numeric_limits::is_signed == std::numeric_limits::is_signed)> -FMT_CONSTEXPR To lossless_integral_conversion(const From from, int& ec) { +UMPIRE_FMT_CONSTEXPR To lossless_integral_conversion(const From from, int& ec) { ec = 0; using F = std::numeric_limits; using T = std::numeric_limits; @@ -63,10 +63,10 @@ FMT_CONSTEXPR To lossless_integral_conversion(const From from, int& ec) { * can't be converted to To without loss, ec is set. */ template ::value && + UMPIRE_FMT_ENABLE_IF(!std::is_same::value && std::numeric_limits::is_signed != std::numeric_limits::is_signed)> -FMT_CONSTEXPR To lossless_integral_conversion(const From from, int& ec) { +UMPIRE_FMT_CONSTEXPR To lossless_integral_conversion(const From from, int& ec) { ec = 0; using F = std::numeric_limits; using T = std::numeric_limits; @@ -96,8 +96,8 @@ FMT_CONSTEXPR To lossless_integral_conversion(const From from, int& ec) { } template ::value)> -FMT_CONSTEXPR To lossless_integral_conversion(const From from, int& ec) { + UMPIRE_FMT_ENABLE_IF(std::is_same::value)> +UMPIRE_FMT_CONSTEXPR To lossless_integral_conversion(const From from, int& ec) { ec = 0; return from; } // function @@ -117,8 +117,8 @@ FMT_CONSTEXPR To lossless_integral_conversion(const From from, int& ec) { */ // clang-format on template ::value)> -FMT_CONSTEXPR To safe_float_conversion(const From from, int& ec) { + UMPIRE_FMT_ENABLE_IF(!std::is_same::value)> +UMPIRE_FMT_CONSTEXPR To safe_float_conversion(const From from, int& ec) { ec = 0; using T = std::numeric_limits; static_assert(std::is_floating_point::value, "From must be floating"); @@ -139,8 +139,8 @@ FMT_CONSTEXPR To safe_float_conversion(const From from, int& ec) { } // function template ::value)> -FMT_CONSTEXPR To safe_float_conversion(const From from, int& ec) { + UMPIRE_FMT_ENABLE_IF(std::is_same::value)> +UMPIRE_FMT_CONSTEXPR To safe_float_conversion(const From from, int& ec) { ec = 0; static_assert(std::is_floating_point::value, "From must be floating"); return from; @@ -150,8 +150,8 @@ FMT_CONSTEXPR To safe_float_conversion(const From from, int& ec) { * safe duration cast between integral durations */ template ::value), - FMT_ENABLE_IF(std::is_integral::value)> + UMPIRE_FMT_ENABLE_IF(std::is_integral::value), + UMPIRE_FMT_ENABLE_IF(std::is_integral::value)> To safe_duration_cast(std::chrono::duration from, int& ec) { using From = std::chrono::duration; @@ -201,8 +201,8 @@ To safe_duration_cast(std::chrono::duration from, * safe duration_cast between floating point durations */ template ::value), - FMT_ENABLE_IF(std::is_floating_point::value)> + UMPIRE_FMT_ENABLE_IF(std::is_floating_point::value), + UMPIRE_FMT_ENABLE_IF(std::is_floating_point::value)> To safe_duration_cast(std::chrono::duration from, int& ec) { using From = std::chrono::duration; @@ -279,11 +279,11 @@ To safe_duration_cast(std::chrono::duration from, #endif // Prevents expansion of a preceding token as a function-style macro. -// Usage: f FMT_NOMACRO() -#define FMT_NOMACRO +// Usage: f UMPIRE_FMT_NOMACRO() +#define UMPIRE_FMT_NOMACRO namespace detail { -inline null<> localtime_r FMT_NOMACRO(...) { return null<>(); } +inline null<> localtime_r UMPIRE_FMT_NOMACRO(...) { return null<>(); } inline null<> localtime_s(...) { return null<>(); } inline null<> gmtime_r(...) { return null<>(); } inline null<> gmtime_s(...) { return null<>(); } @@ -315,7 +315,7 @@ inline std::tm localtime(std::time_t time) { bool fallback(int res) { return res == 0; } -#if !FMT_MSC_VER +#if !UMPIRE_FMT_MSC_VER bool fallback(detail::null<>) { using namespace umpire::fmt::detail; std::tm* tm = std::localtime(&time_); @@ -326,7 +326,7 @@ inline std::tm localtime(std::time_t time) { }; dispatcher lt(time); // Too big time values may be unsupported. - if (!lt.run()) FMT_THROW(format_error("time_t value out of range")); + if (!lt.run()) UMPIRE_FMT_THROW(format_error("time_t value out of range")); return lt.tm_; } @@ -361,7 +361,7 @@ inline std::tm gmtime(std::time_t time) { bool fallback(int res) { return res == 0; } -#if !FMT_MSC_VER +#if !UMPIRE_FMT_MSC_VER bool fallback(detail::null<>) { std::tm* tm = std::gmtime(&time_); if (tm) tm_ = *tm; @@ -371,7 +371,7 @@ inline std::tm gmtime(std::time_t time) { }; dispatcher gt(time); // Too big time values may be unsupported. - if (!gt.run()) FMT_THROW(format_error("time_t value out of range")); + if (!gt.run()) UMPIRE_FMT_THROW(format_error("time_t value out of range")); return gt.tm_; } @@ -414,7 +414,7 @@ struct formatter, Char> template struct formatter { template - FMT_CONSTEXPR auto parse(ParseContext& ctx) -> decltype(ctx.begin()) { + UMPIRE_FMT_CONSTEXPR auto parse(ParseContext& ctx) -> decltype(ctx.begin()) { auto it = ctx.begin(); if (it != ctx.end() && *it == ':') ++it; auto end = it; @@ -455,64 +455,64 @@ template struct formatter { }; namespace detail { -template FMT_CONSTEXPR const char* get_units() { +template UMPIRE_FMT_CONSTEXPR const char* get_units() { return nullptr; } -template <> FMT_CONSTEXPR inline const char* get_units() { +template <> UMPIRE_FMT_CONSTEXPR inline const char* get_units() { return "as"; } -template <> FMT_CONSTEXPR inline const char* get_units() { +template <> UMPIRE_FMT_CONSTEXPR inline const char* get_units() { return "fs"; } -template <> FMT_CONSTEXPR inline const char* get_units() { +template <> UMPIRE_FMT_CONSTEXPR inline const char* get_units() { return "ps"; } -template <> FMT_CONSTEXPR inline const char* get_units() { +template <> UMPIRE_FMT_CONSTEXPR inline const char* get_units() { return "ns"; } -template <> FMT_CONSTEXPR inline const char* get_units() { +template <> UMPIRE_FMT_CONSTEXPR inline const char* get_units() { return "µs"; } -template <> FMT_CONSTEXPR inline const char* get_units() { +template <> UMPIRE_FMT_CONSTEXPR inline const char* get_units() { return "ms"; } -template <> FMT_CONSTEXPR inline const char* get_units() { +template <> UMPIRE_FMT_CONSTEXPR inline const char* get_units() { return "cs"; } -template <> FMT_CONSTEXPR inline const char* get_units() { +template <> UMPIRE_FMT_CONSTEXPR inline const char* get_units() { return "ds"; } -template <> FMT_CONSTEXPR inline const char* get_units>() { +template <> UMPIRE_FMT_CONSTEXPR inline const char* get_units>() { return "s"; } -template <> FMT_CONSTEXPR inline const char* get_units() { +template <> UMPIRE_FMT_CONSTEXPR inline const char* get_units() { return "das"; } -template <> FMT_CONSTEXPR inline const char* get_units() { +template <> UMPIRE_FMT_CONSTEXPR inline const char* get_units() { return "hs"; } -template <> FMT_CONSTEXPR inline const char* get_units() { +template <> UMPIRE_FMT_CONSTEXPR inline const char* get_units() { return "ks"; } -template <> FMT_CONSTEXPR inline const char* get_units() { +template <> UMPIRE_FMT_CONSTEXPR inline const char* get_units() { return "Ms"; } -template <> FMT_CONSTEXPR inline const char* get_units() { +template <> UMPIRE_FMT_CONSTEXPR inline const char* get_units() { return "Gs"; } -template <> FMT_CONSTEXPR inline const char* get_units() { +template <> UMPIRE_FMT_CONSTEXPR inline const char* get_units() { return "Ts"; } -template <> FMT_CONSTEXPR inline const char* get_units() { +template <> UMPIRE_FMT_CONSTEXPR inline const char* get_units() { return "Ps"; } -template <> FMT_CONSTEXPR inline const char* get_units() { +template <> UMPIRE_FMT_CONSTEXPR inline const char* get_units() { return "Es"; } -template <> FMT_CONSTEXPR inline const char* get_units>() { +template <> UMPIRE_FMT_CONSTEXPR inline const char* get_units>() { return "m"; } -template <> FMT_CONSTEXPR inline const char* get_units>() { +template <> UMPIRE_FMT_CONSTEXPR inline const char* get_units>() { return "h"; } @@ -524,7 +524,7 @@ enum class numeric_system { // Parses a put_time-like format string and invokes handler actions. template -FMT_CONSTEXPR const Char* parse_chrono_format(const Char* begin, +UMPIRE_FMT_CONSTEXPR const Char* parse_chrono_format(const Char* begin, const Char* end, Handler&& handler) { auto ptr = begin; @@ -537,7 +537,7 @@ FMT_CONSTEXPR const Char* parse_chrono_format(const Char* begin, } if (begin != ptr) handler.on_text(begin, ptr); ++ptr; // consume '%' - if (ptr == end) FMT_THROW(format_error("invalid format")); + if (ptr == end) UMPIRE_FMT_THROW(format_error("invalid format")); c = *ptr++; switch (c) { case '%': @@ -628,7 +628,7 @@ FMT_CONSTEXPR const Char* parse_chrono_format(const Char* begin, break; // Alternative representation: case 'E': { - if (ptr == end) FMT_THROW(format_error("invalid format")); + if (ptr == end) UMPIRE_FMT_THROW(format_error("invalid format")); c = *ptr++; switch (c) { case 'c': @@ -641,12 +641,12 @@ FMT_CONSTEXPR const Char* parse_chrono_format(const Char* begin, handler.on_loc_time(numeric_system::alternative); break; default: - FMT_THROW(format_error("invalid format")); + UMPIRE_FMT_THROW(format_error("invalid format")); } break; } case 'O': - if (ptr == end) FMT_THROW(format_error("invalid format")); + if (ptr == end) UMPIRE_FMT_THROW(format_error("invalid format")); c = *ptr++; switch (c) { case 'w': @@ -668,11 +668,11 @@ FMT_CONSTEXPR const Char* parse_chrono_format(const Char* begin, handler.on_second(numeric_system::alternative); break; default: - FMT_THROW(format_error("invalid format")); + UMPIRE_FMT_THROW(format_error("invalid format")); } break; default: - FMT_THROW(format_error("invalid format")); + UMPIRE_FMT_THROW(format_error("invalid format")); } begin = ptr; } @@ -681,75 +681,75 @@ FMT_CONSTEXPR const Char* parse_chrono_format(const Char* begin, } struct chrono_format_checker { - FMT_NORETURN void report_no_date() { FMT_THROW(format_error("no date")); } + UMPIRE_FMT_NORETURN void report_no_date() { UMPIRE_FMT_THROW(format_error("no date")); } template - FMT_CONSTEXPR void on_text(const Char*, const Char*) {} - FMT_NORETURN void on_abbr_weekday() { report_no_date(); } - FMT_NORETURN void on_full_weekday() { report_no_date(); } - FMT_NORETURN void on_dec0_weekday(numeric_system) { report_no_date(); } - FMT_NORETURN void on_dec1_weekday(numeric_system) { report_no_date(); } - FMT_NORETURN void on_abbr_month() { report_no_date(); } - FMT_NORETURN void on_full_month() { report_no_date(); } - FMT_CONSTEXPR void on_24_hour(numeric_system) {} - FMT_CONSTEXPR void on_12_hour(numeric_system) {} - FMT_CONSTEXPR void on_minute(numeric_system) {} - FMT_CONSTEXPR void on_second(numeric_system) {} - FMT_NORETURN void on_datetime(numeric_system) { report_no_date(); } - FMT_NORETURN void on_loc_date(numeric_system) { report_no_date(); } - FMT_NORETURN void on_loc_time(numeric_system) { report_no_date(); } - FMT_NORETURN void on_us_date() { report_no_date(); } - FMT_NORETURN void on_iso_date() { report_no_date(); } - FMT_CONSTEXPR void on_12_hour_time() {} - FMT_CONSTEXPR void on_24_hour_time() {} - FMT_CONSTEXPR void on_iso_time() {} - FMT_CONSTEXPR void on_am_pm() {} - FMT_CONSTEXPR void on_duration_value() {} - FMT_CONSTEXPR void on_duration_unit() {} - FMT_NORETURN void on_utc_offset() { report_no_date(); } - FMT_NORETURN void on_tz_name() { report_no_date(); } + UMPIRE_FMT_CONSTEXPR void on_text(const Char*, const Char*) {} + UMPIRE_FMT_NORETURN void on_abbr_weekday() { report_no_date(); } + UMPIRE_FMT_NORETURN void on_full_weekday() { report_no_date(); } + UMPIRE_FMT_NORETURN void on_dec0_weekday(numeric_system) { report_no_date(); } + UMPIRE_FMT_NORETURN void on_dec1_weekday(numeric_system) { report_no_date(); } + UMPIRE_FMT_NORETURN void on_abbr_month() { report_no_date(); } + UMPIRE_FMT_NORETURN void on_full_month() { report_no_date(); } + UMPIRE_FMT_CONSTEXPR void on_24_hour(numeric_system) {} + UMPIRE_FMT_CONSTEXPR void on_12_hour(numeric_system) {} + UMPIRE_FMT_CONSTEXPR void on_minute(numeric_system) {} + UMPIRE_FMT_CONSTEXPR void on_second(numeric_system) {} + UMPIRE_FMT_NORETURN void on_datetime(numeric_system) { report_no_date(); } + UMPIRE_FMT_NORETURN void on_loc_date(numeric_system) { report_no_date(); } + UMPIRE_FMT_NORETURN void on_loc_time(numeric_system) { report_no_date(); } + UMPIRE_FMT_NORETURN void on_us_date() { report_no_date(); } + UMPIRE_FMT_NORETURN void on_iso_date() { report_no_date(); } + UMPIRE_FMT_CONSTEXPR void on_12_hour_time() {} + UMPIRE_FMT_CONSTEXPR void on_24_hour_time() {} + UMPIRE_FMT_CONSTEXPR void on_iso_time() {} + UMPIRE_FMT_CONSTEXPR void on_am_pm() {} + UMPIRE_FMT_CONSTEXPR void on_duration_value() {} + UMPIRE_FMT_CONSTEXPR void on_duration_unit() {} + UMPIRE_FMT_NORETURN void on_utc_offset() { report_no_date(); } + UMPIRE_FMT_NORETURN void on_tz_name() { report_no_date(); } }; -template ::value)> +template ::value)> inline bool isnan(T) { return false; } -template ::value)> +template ::value)> inline bool isnan(T value) { return std::isnan(value); } -template ::value)> +template ::value)> inline bool isfinite(T) { return true; } -template ::value)> +template ::value)> inline bool isfinite(T value) { return std::isfinite(value); } // Converts value to int and checks that it's in the range [0, upper). -template ::value)> +template ::value)> inline int to_nonnegative_int(T value, int upper) { - FMT_ASSERT(value >= 0 && to_unsigned(value) <= to_unsigned(upper), + UMPIRE_FMT_ASSERT(value >= 0 && to_unsigned(value) <= to_unsigned(upper), "invalid value"); (void)upper; return static_cast(value); } -template ::value)> +template ::value)> inline int to_nonnegative_int(T value, int upper) { - FMT_ASSERT( + UMPIRE_FMT_ASSERT( std::isnan(value) || (value >= 0 && value <= static_cast(upper)), "invalid value"); (void)upper; return static_cast(value); } -template ::value)> +template ::value)> inline T mod(T x, int y) { return x % static_cast(y); } -template ::value)> +template ::value)> inline T mod(T x, int y) { return std::fmod(x, static_cast(y)); } @@ -765,24 +765,24 @@ template struct make_unsigned_or_unchanged { using type = typename std::make_unsigned::type; }; -#if FMT_SAFE_DURATION_CAST +#if UMPIRE_FMT_SAFE_DURATION_CAST // throwing version of safe_duration_cast template To fmt_safe_duration_cast(std::chrono::duration from) { int ec; To to = safe_duration_cast::safe_duration_cast(from, ec); - if (ec) FMT_THROW(format_error("cannot format duration")); + if (ec) UMPIRE_FMT_THROW(format_error("cannot format duration")); return to; } #endif template ::value)> + UMPIRE_FMT_ENABLE_IF(std::is_integral::value)> inline std::chrono::duration get_milliseconds( std::chrono::duration d) { // this may overflow and/or the result may not fit in the // target type. -#if FMT_SAFE_DURATION_CAST +#if UMPIRE_FMT_SAFE_DURATION_CAST using CommonSecondsType = typename std::common_type::type; const auto d_as_common = fmt_safe_duration_cast(d); @@ -800,7 +800,7 @@ inline std::chrono::duration get_milliseconds( } template ::value)> + UMPIRE_FMT_ENABLE_IF(std::is_floating_point::value)> inline std::chrono::duration get_milliseconds( std::chrono::duration d) { using common_type = typename std::common_type::type; @@ -811,13 +811,13 @@ inline std::chrono::duration get_milliseconds( } template ::value)> + UMPIRE_FMT_ENABLE_IF(std::is_integral::value)> OutputIt format_duration_value(OutputIt out, Rep val, int) { return write(out, val); } template ::value)> + UMPIRE_FMT_ENABLE_IF(std::is_floating_point::value)> OutputIt format_duration_value(OutputIt out, Rep val, int precision) { auto specs = basic_format_specs(); specs.precision = precision; @@ -884,7 +884,7 @@ struct chrono_formatter { // this may overflow and/or the result may not fit in the // target type. -#if FMT_SAFE_DURATION_CAST +#if UMPIRE_FMT_SAFE_DURATION_CAST // might need checked conversion (rep!=Rep) auto tmpval = std::chrono::duration(val); s = fmt_safe_duration_cast(tmpval); @@ -1013,7 +1013,7 @@ struct chrono_formatter { if (ns == numeric_system::standard) { write(second(), 2); -#if FMT_SAFE_DURATION_CAST +#if UMPIRE_FMT_SAFE_DURATION_CAST // convert rep->Rep using duration_rep = std::chrono::duration; using duration_Rep = std::chrono::duration; @@ -1090,36 +1090,36 @@ struct formatter, Char> { basic_format_parse_context& context; basic_string_view format_str; - template FMT_CONSTEXPR arg_ref_type make_arg_ref(Id arg_id) { + template UMPIRE_FMT_CONSTEXPR arg_ref_type make_arg_ref(Id arg_id) { context.check_arg_id(arg_id); return arg_ref_type(arg_id); } - FMT_CONSTEXPR arg_ref_type make_arg_ref(basic_string_view arg_id) { + UMPIRE_FMT_CONSTEXPR arg_ref_type make_arg_ref(basic_string_view arg_id) { context.check_arg_id(arg_id); return arg_ref_type(arg_id); } - FMT_CONSTEXPR arg_ref_type make_arg_ref(detail::auto_id) { + UMPIRE_FMT_CONSTEXPR arg_ref_type make_arg_ref(detail::auto_id) { return arg_ref_type(context.next_arg_id()); } - void on_error(const char* msg) { FMT_THROW(format_error(msg)); } - FMT_CONSTEXPR void on_fill(basic_string_view fill) { + void on_error(const char* msg) { UMPIRE_FMT_THROW(format_error(msg)); } + UMPIRE_FMT_CONSTEXPR void on_fill(basic_string_view fill) { f.specs.fill = fill; } - FMT_CONSTEXPR void on_align(align_t align) { f.specs.align = align; } - FMT_CONSTEXPR void on_width(int width) { f.specs.width = width; } - FMT_CONSTEXPR void on_precision(int _precision) { + UMPIRE_FMT_CONSTEXPR void on_align(align_t align) { f.specs.align = align; } + UMPIRE_FMT_CONSTEXPR void on_width(int width) { f.specs.width = width; } + UMPIRE_FMT_CONSTEXPR void on_precision(int _precision) { f.precision = _precision; } - FMT_CONSTEXPR void end_precision() {} + UMPIRE_FMT_CONSTEXPR void end_precision() {} - template FMT_CONSTEXPR void on_dynamic_width(Id arg_id) { + template UMPIRE_FMT_CONSTEXPR void on_dynamic_width(Id arg_id) { f.width_ref = make_arg_ref(arg_id); } - template FMT_CONSTEXPR void on_dynamic_precision(Id arg_id) { + template UMPIRE_FMT_CONSTEXPR void on_dynamic_precision(Id arg_id) { f.precision_ref = make_arg_ref(arg_id); } }; @@ -1130,7 +1130,7 @@ struct formatter, Char> { iterator end; }; - FMT_CONSTEXPR parse_range do_parse(basic_format_parse_context& ctx) { + UMPIRE_FMT_CONSTEXPR parse_range do_parse(basic_format_parse_context& ctx) { auto begin = ctx.begin(), end = ctx.end(); if (begin == end || *begin == '}') return {begin, begin}; spec_handler handler{*this, ctx, format_str}; @@ -1149,7 +1149,7 @@ struct formatter, Char> { } public: - FMT_CONSTEXPR auto parse(basic_format_parse_context& ctx) + UMPIRE_FMT_CONSTEXPR auto parse(basic_format_parse_context& ctx) -> decltype(ctx.begin()) { auto range = do_parse(ctx); format_str = basic_string_view( @@ -1185,6 +1185,6 @@ struct formatter, Char> { } }; -FMT_END_NAMESPACE +UMPIRE_FMT_END_NAMESPACE -#endif // FMT_CHRONO_H_ +#endif // UMPIRE_FMT_CHRONO_H_ diff --git a/src/tpl/umpire/fmt/color.h b/src/tpl/umpire/fmt/color.h index 73e62b855..21037c37d 100644 --- a/src/tpl/umpire/fmt/color.h +++ b/src/tpl/umpire/fmt/color.h @@ -5,19 +5,19 @@ // // For the license information refer to format.h. -#ifndef FMT_COLOR_H_ -#define FMT_COLOR_H_ +#ifndef UMPIRE_FMT_COLOR_H_ +#define UMPIRE_FMT_COLOR_H_ #include "format.h" // __declspec(deprecated) is broken in some MSVC versions. -#if FMT_MSC_VER -# define FMT_DEPRECATED_NONMSVC +#if UMPIRE_FMT_MSC_VER +# define UMPIRE_FMT_DEPRECATED_NONMSVC #else -# define FMT_DEPRECATED_NONMSVC FMT_DEPRECATED +# define UMPIRE_FMT_DEPRECATED_NONMSVC UMPIRE_FMT_DEPRECATED #endif -FMT_BEGIN_NAMESPACE +UMPIRE_FMT_BEGIN_NAMESPACE enum class color : uint32_t { alice_blue = 0xF0F8FF, // rgb(240,248,255) @@ -192,11 +192,11 @@ enum class emphasis : uint8_t { // rgb is a struct for red, green and blue colors. // Using the name "rgb" makes some editors show the color in a tooltip. struct rgb { - FMT_CONSTEXPR rgb() : r(0), g(0), b(0) {} - FMT_CONSTEXPR rgb(uint8_t r_, uint8_t g_, uint8_t b_) : r(r_), g(g_), b(b_) {} - FMT_CONSTEXPR rgb(uint32_t hex) + UMPIRE_FMT_CONSTEXPR rgb() : r(0), g(0), b(0) {} + UMPIRE_FMT_CONSTEXPR rgb(uint8_t r_, uint8_t g_, uint8_t b_) : r(r_), g(g_), b(b_) {} + UMPIRE_FMT_CONSTEXPR rgb(uint32_t hex) : r((hex >> 16) & 0xFF), g((hex >> 8) & 0xFF), b(hex & 0xFF) {} - FMT_CONSTEXPR rgb(color hex) + UMPIRE_FMT_CONSTEXPR rgb(color hex) : r((uint32_t(hex) >> 16) & 0xFF), g((uint32_t(hex) >> 8) & 0xFF), b(uint32_t(hex) & 0xFF) {} @@ -209,16 +209,16 @@ namespace detail { // color is a struct of either a rgb color or a terminal color. struct color_type { - FMT_CONSTEXPR color_type() FMT_NOEXCEPT : is_rgb(), value{} {} - FMT_CONSTEXPR color_type(color rgb_color) FMT_NOEXCEPT : is_rgb(true), + UMPIRE_FMT_CONSTEXPR color_type() UMPIRE_FMT_NOEXCEPT : is_rgb(), value{} {} + UMPIRE_FMT_CONSTEXPR color_type(color rgb_color) UMPIRE_FMT_NOEXCEPT : is_rgb(true), value{} { value.rgb_color = static_cast(rgb_color); } - FMT_CONSTEXPR color_type(rgb rgb_color) FMT_NOEXCEPT : is_rgb(true), value{} { + UMPIRE_FMT_CONSTEXPR color_type(rgb rgb_color) UMPIRE_FMT_NOEXCEPT : is_rgb(true), value{} { value.rgb_color = (static_cast(rgb_color.r) << 16) | (static_cast(rgb_color.g) << 8) | rgb_color.b; } - FMT_CONSTEXPR color_type(terminal_color term_color) FMT_NOEXCEPT : is_rgb(), + UMPIRE_FMT_CONSTEXPR color_type(terminal_color term_color) UMPIRE_FMT_NOEXCEPT : is_rgb(), value{} { value.term_color = static_cast(term_color); } @@ -233,18 +233,18 @@ struct color_type { /** A text style consisting of foreground and background colors and emphasis. */ class text_style { public: - FMT_CONSTEXPR text_style(emphasis em = emphasis()) FMT_NOEXCEPT + UMPIRE_FMT_CONSTEXPR text_style(emphasis em = emphasis()) UMPIRE_FMT_NOEXCEPT : set_foreground_color(), set_background_color(), ems(em) {} - FMT_CONSTEXPR text_style& operator|=(const text_style& rhs) { + UMPIRE_FMT_CONSTEXPR text_style& operator|=(const text_style& rhs) { if (!set_foreground_color) { set_foreground_color = rhs.set_foreground_color; foreground_color = rhs.foreground_color; } else if (rhs.set_foreground_color) { if (!foreground_color.is_rgb || !rhs.foreground_color.is_rgb) - FMT_THROW(format_error("can't OR a terminal color")); + UMPIRE_FMT_THROW(format_error("can't OR a terminal color")); foreground_color.value.rgb_color |= rhs.foreground_color.value.rgb_color; } @@ -253,7 +253,7 @@ class text_style { background_color = rhs.background_color; } else if (rhs.set_background_color) { if (!background_color.is_rgb || !rhs.background_color.is_rgb) - FMT_THROW(format_error("can't OR a terminal color")); + UMPIRE_FMT_THROW(format_error("can't OR a terminal color")); background_color.value.rgb_color |= rhs.background_color.value.rgb_color; } @@ -262,46 +262,46 @@ class text_style { return *this; } - friend FMT_CONSTEXPR text_style operator|(text_style lhs, + friend UMPIRE_FMT_CONSTEXPR text_style operator|(text_style lhs, const text_style& rhs) { return lhs |= rhs; } - FMT_DEPRECATED_NONMSVC FMT_CONSTEXPR text_style& operator&=( + UMPIRE_FMT_DEPRECATED_NONMSVC UMPIRE_FMT_CONSTEXPR text_style& operator&=( const text_style& rhs) { return and_assign(rhs); } - FMT_DEPRECATED_NONMSVC friend FMT_CONSTEXPR text_style + UMPIRE_FMT_DEPRECATED_NONMSVC friend UMPIRE_FMT_CONSTEXPR text_style operator&(text_style lhs, const text_style& rhs) { return lhs.and_assign(rhs); } - FMT_CONSTEXPR bool has_foreground() const FMT_NOEXCEPT { + UMPIRE_FMT_CONSTEXPR bool has_foreground() const UMPIRE_FMT_NOEXCEPT { return set_foreground_color; } - FMT_CONSTEXPR bool has_background() const FMT_NOEXCEPT { + UMPIRE_FMT_CONSTEXPR bool has_background() const UMPIRE_FMT_NOEXCEPT { return set_background_color; } - FMT_CONSTEXPR bool has_emphasis() const FMT_NOEXCEPT { + UMPIRE_FMT_CONSTEXPR bool has_emphasis() const UMPIRE_FMT_NOEXCEPT { return static_cast(ems) != 0; } - FMT_CONSTEXPR detail::color_type get_foreground() const FMT_NOEXCEPT { - FMT_ASSERT(has_foreground(), "no foreground specified for this style"); + UMPIRE_FMT_CONSTEXPR detail::color_type get_foreground() const UMPIRE_FMT_NOEXCEPT { + UMPIRE_FMT_ASSERT(has_foreground(), "no foreground specified for this style"); return foreground_color; } - FMT_CONSTEXPR detail::color_type get_background() const FMT_NOEXCEPT { - FMT_ASSERT(has_background(), "no background specified for this style"); + UMPIRE_FMT_CONSTEXPR detail::color_type get_background() const UMPIRE_FMT_NOEXCEPT { + UMPIRE_FMT_ASSERT(has_background(), "no background specified for this style"); return background_color; } - FMT_CONSTEXPR emphasis get_emphasis() const FMT_NOEXCEPT { - FMT_ASSERT(has_emphasis(), "no emphasis specified for this style"); + UMPIRE_FMT_CONSTEXPR emphasis get_emphasis() const UMPIRE_FMT_NOEXCEPT { + UMPIRE_FMT_ASSERT(has_emphasis(), "no emphasis specified for this style"); return ems; } private: - FMT_CONSTEXPR text_style(bool is_foreground, - detail::color_type text_color) FMT_NOEXCEPT + UMPIRE_FMT_CONSTEXPR text_style(bool is_foreground, + detail::color_type text_color) UMPIRE_FMT_NOEXCEPT : set_foreground_color(), set_background_color(), ems() { @@ -315,13 +315,13 @@ class text_style { } // DEPRECATED! - FMT_CONSTEXPR text_style& and_assign(const text_style& rhs) { + UMPIRE_FMT_CONSTEXPR text_style& and_assign(const text_style& rhs) { if (!set_foreground_color) { set_foreground_color = rhs.set_foreground_color; foreground_color = rhs.foreground_color; } else if (rhs.set_foreground_color) { if (!foreground_color.is_rgb || !rhs.foreground_color.is_rgb) - FMT_THROW(format_error("can't AND a terminal color")); + UMPIRE_FMT_THROW(format_error("can't AND a terminal color")); foreground_color.value.rgb_color &= rhs.foreground_color.value.rgb_color; } @@ -330,7 +330,7 @@ class text_style { background_color = rhs.background_color; } else if (rhs.set_background_color) { if (!background_color.is_rgb || !rhs.background_color.is_rgb) - FMT_THROW(format_error("can't AND a terminal color")); + UMPIRE_FMT_THROW(format_error("can't AND a terminal color")); background_color.value.rgb_color &= rhs.background_color.value.rgb_color; } @@ -339,11 +339,11 @@ class text_style { return *this; } - friend FMT_CONSTEXPR_DECL text_style fg(detail::color_type foreground) - FMT_NOEXCEPT; + friend UMPIRE_FMT_CONSTEXPR_DECL text_style fg(detail::color_type foreground) + UMPIRE_FMT_NOEXCEPT; - friend FMT_CONSTEXPR_DECL text_style bg(detail::color_type background) - FMT_NOEXCEPT; + friend UMPIRE_FMT_CONSTEXPR_DECL text_style bg(detail::color_type background) + UMPIRE_FMT_NOEXCEPT; detail::color_type foreground_color; detail::color_type background_color; @@ -353,25 +353,25 @@ class text_style { }; /** Creates a text style from the foreground (text) color. */ -FMT_CONSTEXPR inline text_style fg(detail::color_type foreground) FMT_NOEXCEPT { +UMPIRE_FMT_CONSTEXPR inline text_style fg(detail::color_type foreground) UMPIRE_FMT_NOEXCEPT { return text_style(true, foreground); } /** Creates a text style from the background color. */ -FMT_CONSTEXPR inline text_style bg(detail::color_type background) FMT_NOEXCEPT { +UMPIRE_FMT_CONSTEXPR inline text_style bg(detail::color_type background) UMPIRE_FMT_NOEXCEPT { return text_style(false, background); } -FMT_CONSTEXPR inline text_style operator|(emphasis lhs, - emphasis rhs) FMT_NOEXCEPT { +UMPIRE_FMT_CONSTEXPR inline text_style operator|(emphasis lhs, + emphasis rhs) UMPIRE_FMT_NOEXCEPT { return text_style(lhs) | rhs; } namespace detail { template struct ansi_color_escape { - FMT_CONSTEXPR ansi_color_escape(detail::color_type text_color, - const char* esc) FMT_NOEXCEPT { + UMPIRE_FMT_CONSTEXPR ansi_color_escape(detail::color_type text_color, + const char* esc) UMPIRE_FMT_NOEXCEPT { // If we have a terminal color, we need to output another escape code // sequence. if (!text_color.is_rgb) { @@ -406,7 +406,7 @@ template struct ansi_color_escape { to_esc(color.b, buffer + 15, 'm'); buffer[19] = static_cast(0); } - FMT_CONSTEXPR ansi_color_escape(emphasis em) FMT_NOEXCEPT { + UMPIRE_FMT_CONSTEXPR ansi_color_escape(emphasis em) UMPIRE_FMT_NOEXCEPT { uint8_t em_codes[4] = {}; uint8_t em_bits = static_cast(em); if (em_bits & static_cast(emphasis::bold)) em_codes[0] = 1; @@ -425,18 +425,18 @@ template struct ansi_color_escape { } buffer[index++] = static_cast(0); } - FMT_CONSTEXPR operator const Char*() const FMT_NOEXCEPT { return buffer; } + UMPIRE_FMT_CONSTEXPR operator const Char*() const UMPIRE_FMT_NOEXCEPT { return buffer; } - FMT_CONSTEXPR const Char* begin() const FMT_NOEXCEPT { return buffer; } - FMT_CONSTEXPR const Char* end() const FMT_NOEXCEPT { + UMPIRE_FMT_CONSTEXPR const Char* begin() const UMPIRE_FMT_NOEXCEPT { return buffer; } + UMPIRE_FMT_CONSTEXPR const Char* end() const UMPIRE_FMT_NOEXCEPT { return buffer + std::char_traits::length(buffer); } private: Char buffer[7u + 3u * 4u + 1u]; - static FMT_CONSTEXPR void to_esc(uint8_t c, Char* out, - char delimiter) FMT_NOEXCEPT { + static UMPIRE_FMT_CONSTEXPR void to_esc(uint8_t c, Char* out, + char delimiter) UMPIRE_FMT_NOEXCEPT { out[0] = static_cast('0' + c / 100); out[1] = static_cast('0' + c / 10 % 10); out[2] = static_cast('0' + c % 10); @@ -445,42 +445,42 @@ template struct ansi_color_escape { }; template -FMT_CONSTEXPR ansi_color_escape make_foreground_color( - detail::color_type foreground) FMT_NOEXCEPT { +UMPIRE_FMT_CONSTEXPR ansi_color_escape make_foreground_color( + detail::color_type foreground) UMPIRE_FMT_NOEXCEPT { return ansi_color_escape(foreground, detail::data::foreground_color); } template -FMT_CONSTEXPR ansi_color_escape make_background_color( - detail::color_type background) FMT_NOEXCEPT { +UMPIRE_FMT_CONSTEXPR ansi_color_escape make_background_color( + detail::color_type background) UMPIRE_FMT_NOEXCEPT { return ansi_color_escape(background, detail::data::background_color); } template -FMT_CONSTEXPR ansi_color_escape make_emphasis(emphasis em) FMT_NOEXCEPT { +UMPIRE_FMT_CONSTEXPR ansi_color_escape make_emphasis(emphasis em) UMPIRE_FMT_NOEXCEPT { return ansi_color_escape(em); } template -inline void fputs(const Char* chars, FILE* stream) FMT_NOEXCEPT { +inline void fputs(const Char* chars, FILE* stream) UMPIRE_FMT_NOEXCEPT { std::fputs(chars, stream); } template <> -inline void fputs(const wchar_t* chars, FILE* stream) FMT_NOEXCEPT { +inline void fputs(const wchar_t* chars, FILE* stream) UMPIRE_FMT_NOEXCEPT { std::fputws(chars, stream); } -template inline void reset_color(FILE* stream) FMT_NOEXCEPT { +template inline void reset_color(FILE* stream) UMPIRE_FMT_NOEXCEPT { fputs(detail::data::reset_color, stream); } -template <> inline void reset_color(FILE* stream) FMT_NOEXCEPT { +template <> inline void reset_color(FILE* stream) UMPIRE_FMT_NOEXCEPT { fputs(detail::data::wreset_color, stream); } template -inline void reset_color(buffer& buffer) FMT_NOEXCEPT { +inline void reset_color(buffer& buffer) UMPIRE_FMT_NOEXCEPT { const char* begin = data::reset_color; const char* end = begin + sizeof(data::reset_color) - 1; buffer.append(begin, end); @@ -532,7 +532,7 @@ void vprint(std::FILE* f, const text_style& ts, const S& format, \endrst */ template ::value)> + UMPIRE_FMT_ENABLE_IF(detail::is_string::value)> void print(std::FILE* f, const text_style& ts, const S& format_str, const Args&... args) { vprint(f, ts, format_str, @@ -551,7 +551,7 @@ void print(std::FILE* f, const text_style& ts, const S& format_str, \endrst */ template ::value)> + UMPIRE_FMT_ENABLE_IF(detail::is_string::value)> void print(const text_style& ts, const S& format_str, const Args&... args) { return print(stdout, ts, format_str, args...); } @@ -588,7 +588,7 @@ inline std::basic_string format(const text_style& ts, const S& format_str, Formats a string with the given text_style and writes the output to ``out``. */ template ::value)> + UMPIRE_FMT_ENABLE_IF(detail::is_output_iterator::value)> OutputIt vformat_to( OutputIt out, const text_style& ts, basic_string_view format_str, basic_format_args>> args) { @@ -619,6 +619,6 @@ inline auto format_to(OutputIt out, const text_style& ts, const S& format_str, umpire::fmt::make_args_checked(format_str, args...)); } -FMT_END_NAMESPACE +UMPIRE_FMT_END_NAMESPACE -#endif // FMT_COLOR_H_ +#endif // UMPIRE_FMT_COLOR_H_ diff --git a/src/tpl/umpire/fmt/compile.h b/src/tpl/umpire/fmt/compile.h index 3bcad028d..f9ef346c0 100644 --- a/src/tpl/umpire/fmt/compile.h +++ b/src/tpl/umpire/fmt/compile.h @@ -5,24 +5,24 @@ // // For the license information refer to format.h. -#ifndef FMT_COMPILE_H_ -#define FMT_COMPILE_H_ +#ifndef UMPIRE_FMT_COMPILE_H_ +#define UMPIRE_FMT_COMPILE_H_ #include #include #include "format.h" -#ifndef FMT_USE_NONTYPE_TEMPLATE_PARAMETERS +#ifndef UMPIRE_FMT_USE_NONTYPE_TEMPLATE_PARAMETERS # if defined(__cpp_nontype_template_parameter_class) && \ - (!FMT_GCC_VERSION || FMT_GCC_VERSION >= 903) -# define FMT_USE_NONTYPE_TEMPLATE_PARAMETERS 1 + (!UMPIRE_FMT_GCC_VERSION || UMPIRE_FMT_GCC_VERSION >= 903) +# define UMPIRE_FMT_USE_NONTYPE_TEMPLATE_PARAMETERS 1 # else -# define FMT_USE_NONTYPE_TEMPLATE_PARAMETERS 0 +# define UMPIRE_FMT_USE_NONTYPE_TEMPLATE_PARAMETERS 0 # endif #endif -FMT_BEGIN_NAMESPACE +UMPIRE_FMT_BEGIN_NAMESPACE namespace detail { template class truncating_iterator_base { @@ -120,12 +120,12 @@ struct is_compiled_string : std::is_base_of {}; // Converts 42 into std::string using the most efficient method and no // runtime format string processing. - std::string s = umpire::fmt::format(FMT_COMPILE("{}"), 42); + std::string s = umpire::fmt::format(UMPIRE_FMT_COMPILE("{}"), 42); \endrst */ -#define FMT_COMPILE(s) FMT_STRING_IMPL(s, umpire::fmt::detail::compiled_string) +#define UMPIRE_FMT_COMPILE(s) UMPIRE_FMT_STRING_IMPL(s, umpire::fmt::detail::compiled_string) -#if FMT_USE_NONTYPE_TEMPLATE_PARAMETERS +#if UMPIRE_FMT_USE_NONTYPE_TEMPLATE_PARAMETERS template struct fixed_string { constexpr fixed_string(const Char (&str)[N]) { copy_str(static_cast(str), str + N, @@ -164,26 +164,26 @@ template struct format_part { basic_string_view str; replacement repl; - FMT_CONSTEXPR value(int index = 0) : arg_index(index) {} - FMT_CONSTEXPR value(basic_string_view s) : str(s) {} - FMT_CONSTEXPR value(replacement r) : repl(r) {} + UMPIRE_FMT_CONSTEXPR value(int index = 0) : arg_index(index) {} + UMPIRE_FMT_CONSTEXPR value(basic_string_view s) : str(s) {} + UMPIRE_FMT_CONSTEXPR value(replacement r) : repl(r) {} } val; // Position past the end of the argument id. const Char* arg_id_end = nullptr; - FMT_CONSTEXPR format_part(kind k = kind::arg_index, value v = {}) + UMPIRE_FMT_CONSTEXPR format_part(kind k = kind::arg_index, value v = {}) : part_kind(k), val(v) {} - static FMT_CONSTEXPR format_part make_arg_index(int index) { + static UMPIRE_FMT_CONSTEXPR format_part make_arg_index(int index) { return format_part(kind::arg_index, index); } - static FMT_CONSTEXPR format_part make_arg_name(basic_string_view name) { + static UMPIRE_FMT_CONSTEXPR format_part make_arg_name(basic_string_view name) { return format_part(kind::arg_name, name); } - static FMT_CONSTEXPR format_part make_text(basic_string_view text) { + static UMPIRE_FMT_CONSTEXPR format_part make_text(basic_string_view text) { return format_part(kind::text, text); } - static FMT_CONSTEXPR format_part make_replacement(replacement repl) { + static UMPIRE_FMT_CONSTEXPR format_part make_replacement(replacement repl) { return format_part(kind::replacement, repl); } }; @@ -191,19 +191,19 @@ template struct format_part { template struct part_counter { unsigned num_parts = 0; - FMT_CONSTEXPR void on_text(const Char* begin, const Char* end) { + UMPIRE_FMT_CONSTEXPR void on_text(const Char* begin, const Char* end) { if (begin != end) ++num_parts; } - FMT_CONSTEXPR int on_arg_id() { return ++num_parts, 0; } - FMT_CONSTEXPR int on_arg_id(int) { return ++num_parts, 0; } - FMT_CONSTEXPR int on_arg_id(basic_string_view) { + UMPIRE_FMT_CONSTEXPR int on_arg_id() { return ++num_parts, 0; } + UMPIRE_FMT_CONSTEXPR int on_arg_id(int) { return ++num_parts, 0; } + UMPIRE_FMT_CONSTEXPR int on_arg_id(basic_string_view) { return ++num_parts, 0; } - FMT_CONSTEXPR void on_replacement_field(int, const Char*) {} + UMPIRE_FMT_CONSTEXPR void on_replacement_field(int, const Char*) {} - FMT_CONSTEXPR const Char* on_format_specs(int, const Char* begin, + UMPIRE_FMT_CONSTEXPR const Char* on_format_specs(int, const Char* begin, const Char* end) { // Find the matching brace. unsigned brace_counter = 0; @@ -218,12 +218,12 @@ template struct part_counter { return begin; } - FMT_CONSTEXPR void on_error(const char*) {} + UMPIRE_FMT_CONSTEXPR void on_error(const char*) {} }; // Counts the number of parts in a format string. template -FMT_CONSTEXPR unsigned count_parts(basic_string_view format_str) { +UMPIRE_FMT_CONSTEXPR unsigned count_parts(basic_string_view format_str) { part_counter counter; parse_format_string(format_str, counter); return counter.num_parts; @@ -240,39 +240,39 @@ class format_string_compiler : public error_handler { basic_format_parse_context parse_context_; public: - FMT_CONSTEXPR format_string_compiler(basic_string_view format_str, + UMPIRE_FMT_CONSTEXPR format_string_compiler(basic_string_view format_str, PartHandler handler) : handler_(handler), format_str_(format_str), parse_context_(format_str) {} - FMT_CONSTEXPR void on_text(const Char* begin, const Char* end) { + UMPIRE_FMT_CONSTEXPR void on_text(const Char* begin, const Char* end) { if (begin != end) handler_(part::make_text({begin, to_unsigned(end - begin)})); } - FMT_CONSTEXPR int on_arg_id() { + UMPIRE_FMT_CONSTEXPR int on_arg_id() { part_ = part::make_arg_index(parse_context_.next_arg_id()); return 0; } - FMT_CONSTEXPR int on_arg_id(int id) { + UMPIRE_FMT_CONSTEXPR int on_arg_id(int id) { parse_context_.check_arg_id(id); part_ = part::make_arg_index(id); return 0; } - FMT_CONSTEXPR int on_arg_id(basic_string_view id) { + UMPIRE_FMT_CONSTEXPR int on_arg_id(basic_string_view id) { part_ = part::make_arg_name(id); return 0; } - FMT_CONSTEXPR void on_replacement_field(int, const Char* ptr) { + UMPIRE_FMT_CONSTEXPR void on_replacement_field(int, const Char* ptr) { part_.arg_id_end = ptr; handler_(part_); } - FMT_CONSTEXPR const Char* on_format_specs(int, const Char* begin, + UMPIRE_FMT_CONSTEXPR const Char* on_format_specs(int, const Char* begin, const Char* end) { auto repl = typename part::replacement(); dynamic_specs_handler> handler( @@ -291,7 +291,7 @@ class format_string_compiler : public error_handler { // Compiles a format string and invokes handler(part) for each parsed part. template -FMT_CONSTEXPR void compile_format_string(basic_string_view format_str, +UMPIRE_FMT_CONSTEXPR void compile_format_string(basic_string_view format_str, PartHandler handler) { parse_format_string( format_str, @@ -402,11 +402,11 @@ struct compiled_format_base : basic_compiled_format { template struct format_part_array { format_part data[N] = {}; - FMT_CONSTEXPR format_part_array() = default; + UMPIRE_FMT_CONSTEXPR format_part_array() = default; }; template -FMT_CONSTEXPR format_part_array compile_to_parts( +UMPIRE_FMT_CONSTEXPR format_part_array compile_to_parts( basic_string_view format_str) { format_part_array parts; unsigned counter = 0; @@ -414,7 +414,7 @@ FMT_CONSTEXPR format_part_array compile_to_parts( struct { format_part* parts; unsigned* counter; - FMT_CONSTEXPR void operator()(const format_part& part) { + UMPIRE_FMT_CONSTEXPR void operator()(const format_part& part) { parts[(*counter)++] = part; } } collector{parts.data, &counter}; @@ -435,12 +435,12 @@ struct compiled_format_base::value>> : basic_compiled_format { using char_type = char_t; - FMT_CONSTEXPR explicit compiled_format_base(basic_string_view) {} + UMPIRE_FMT_CONSTEXPR explicit compiled_format_base(basic_string_view) {} // Workaround for old compilers. Format string compilation will not be // performed there anyway. -#if FMT_USE_CONSTEXPR - static FMT_CONSTEXPR_DECL const unsigned num_format_parts = +#if UMPIRE_FMT_USE_CONSTEXPR + static UMPIRE_FMT_CONSTEXPR_DECL const unsigned num_format_parts = constexpr_max(count_parts(to_string_view(S())), 1u); #else static const unsigned num_format_parts = 1; @@ -449,7 +449,7 @@ struct compiled_format_base::value>> using parts_container = format_part[num_format_parts]; const parts_container& parts() const { - static FMT_CONSTEXPR_DECL const auto compiled_parts = + static UMPIRE_FMT_CONSTEXPR_DECL const auto compiled_parts = compile_to_parts( detail::to_string_view(S())); return compiled_parts.data; @@ -676,7 +676,7 @@ template struct arg_id_handler { constexpr void on_error(const char* message) { throw format_error(message); } constexpr int on_arg_id() { - FMT_ASSERT(false, "handler cannot be used with automatic indexing"); + UMPIRE_FMT_ASSERT(false, "handler cannot be used with automatic indexing"); return 0; } @@ -781,7 +781,7 @@ constexpr auto compile_format_string(S format_str) { } template ::value || + UMPIRE_FMT_ENABLE_IF(is_compile_string::value || detail::is_compiled_string::value)> constexpr auto compile(S format_str) { constexpr basic_string_view str = format_str; @@ -796,7 +796,7 @@ constexpr auto compile(S format_str) { } #else template ::value)> + UMPIRE_FMT_ENABLE_IF(is_compile_string::value)> constexpr auto compile(S format_str) -> detail::compiled_format { return detail::compiled_format(to_string_view(format_str)); } @@ -813,20 +813,20 @@ auto compile(const Char (&format_str)[N]) } } // namespace detail -// DEPRECATED! use FMT_COMPILE instead. +// DEPRECATED! use UMPIRE_FMT_COMPILE instead. template -FMT_DEPRECATED auto compile(const Args&... args) +UMPIRE_FMT_DEPRECATED auto compile(const Args&... args) -> decltype(detail::compile(args...)) { return detail::compile(args...); } -#if FMT_USE_CONSTEXPR +#if UMPIRE_FMT_USE_CONSTEXPR # ifdef __cpp_if_constexpr template ::value)> -FMT_INLINE std::basic_string format(const CompiledFormat& cf, + UMPIRE_FMT_ENABLE_IF(detail::is_compiled_format::value)> +UMPIRE_FMT_INLINE std::basic_string format(const CompiledFormat& cf, const Args&... args) { basic_memory_buffer buffer; cf.format(detail::buffer_appender(buffer), args...); @@ -834,17 +834,17 @@ FMT_INLINE std::basic_string format(const CompiledFormat& cf, } template ::value)> + UMPIRE_FMT_ENABLE_IF(detail::is_compiled_format::value)> constexpr OutputIt format_to(OutputIt out, const CompiledFormat& cf, const Args&... args) { return cf.format(out, args...); } # endif // __cpp_if_constexpr -#endif // FMT_USE_CONSTEXPR +#endif // UMPIRE_FMT_USE_CONSTEXPR template ::value)> std::basic_string format(const CompiledFormat& cf, const Args&... args) { basic_memory_buffer buffer; @@ -855,8 +855,8 @@ std::basic_string format(const CompiledFormat& cf, const Args&... args) { } template ::value)> -FMT_INLINE std::basic_string format(const S&, + UMPIRE_FMT_ENABLE_IF(detail::is_compiled_string::value)> +UMPIRE_FMT_INLINE std::basic_string format(const S&, Args&&... args) { #ifdef __cpp_if_constexpr if constexpr (std::is_same::value) { @@ -887,7 +887,7 @@ FMT_INLINE std::basic_string format(const S&, } template ::value)> constexpr OutputIt format_to(OutputIt out, const CompiledFormat& cf, const Args&... args) { @@ -898,8 +898,8 @@ constexpr OutputIt format_to(OutputIt out, const CompiledFormat& cf, } template ::value)> -FMT_CONSTEXPR OutputIt format_to(OutputIt out, const S&, Args&&... args) { + UMPIRE_FMT_ENABLE_IF(detail::is_compiled_string::value)> +UMPIRE_FMT_CONSTEXPR OutputIt format_to(OutputIt out, const S&, Args&&... args) { constexpr auto compiled = detail::compile(S()); #ifdef __cpp_if_constexpr if constexpr (std::is_same, @@ -930,7 +930,7 @@ auto format_to_n(OutputIt out, size_t n, const CompiledFormat& cf, } template ::value)> + UMPIRE_FMT_ENABLE_IF(detail::is_compiled_string::value)> format_to_n_result format_to_n(OutputIt out, size_t n, const S&, Args&&... args) { auto it = format_to(detail::truncating_iterator(out, n), S(), @@ -939,14 +939,14 @@ format_to_n_result format_to_n(OutputIt out, size_t n, const S&, } template ::value || detail::is_compiled_string::value)> size_t formatted_size(const CompiledFormat& cf, const Args&... args) { return format_to(detail::counting_iterator(), cf, args...).count(); } -#if FMT_USE_NONTYPE_TEMPLATE_PARAMETERS +#if UMPIRE_FMT_USE_NONTYPE_TEMPLATE_PARAMETERS inline namespace literals { template constexpr detail::udl_compiled_string, @@ -957,6 +957,6 @@ operator""_cf() { } // namespace literals #endif -FMT_END_NAMESPACE +UMPIRE_FMT_END_NAMESPACE -#endif // FMT_COMPILE_H_ +#endif // UMPIRE_FMT_COMPILE_H_ diff --git a/src/tpl/umpire/fmt/core.h b/src/tpl/umpire/fmt/core.h index 14530ede0..cbf228bfc 100644 --- a/src/tpl/umpire/fmt/core.h +++ b/src/tpl/umpire/fmt/core.h @@ -5,8 +5,8 @@ // // For the license information refer to format.h. -#ifndef FMT_CORE_H_ -#define FMT_CORE_H_ +#ifndef UMPIRE_FMT_CORE_H_ +#define UMPIRE_FMT_CORE_H_ #include // std::FILE #include @@ -15,245 +15,245 @@ #include // The fmt library version in the form major * 10000 + minor * 100 + patch. -#define FMT_VERSION 70103 +#define UMPIRE_FMT_VERSION 70103 #ifdef __clang__ -# define FMT_CLANG_VERSION (__clang_major__ * 100 + __clang_minor__) +# define UMPIRE_FMT_CLANG_VERSION (__clang_major__ * 100 + __clang_minor__) #else -# define FMT_CLANG_VERSION 0 +# define UMPIRE_FMT_CLANG_VERSION 0 #endif #if defined(__GNUC__) && !defined(__clang__) -# define FMT_GCC_VERSION (__GNUC__ * 100 + __GNUC_MINOR__) +# define UMPIRE_FMT_GCC_VERSION (__GNUC__ * 100 + __GNUC_MINOR__) #else -# define FMT_GCC_VERSION 0 +# define UMPIRE_FMT_GCC_VERSION 0 #endif #if defined(__INTEL_COMPILER) -# define FMT_ICC_VERSION __INTEL_COMPILER +# define UMPIRE_FMT_ICC_VERSION __INTEL_COMPILER #else -# define FMT_ICC_VERSION 0 +# define UMPIRE_FMT_ICC_VERSION 0 #endif #if __cplusplus >= 201103L || defined(__GXX_EXPERIMENTAL_CXX0X__) -# define FMT_HAS_GXX_CXX11 FMT_GCC_VERSION +# define UMPIRE_FMT_HAS_GXX_CXX11 UMPIRE_FMT_GCC_VERSION #else -# define FMT_HAS_GXX_CXX11 0 +# define UMPIRE_FMT_HAS_GXX_CXX11 0 #endif #ifdef __NVCC__ -# define FMT_NVCC __NVCC__ +# define UMPIRE_FMT_NVCC __NVCC__ #else -# define FMT_NVCC 0 +# define UMPIRE_FMT_NVCC 0 #endif #ifdef _MSC_VER -# define FMT_MSC_VER _MSC_VER -# define FMT_MSC_WARNING(...) __pragma(warning(__VA_ARGS__)) +# define UMPIRE_FMT_MSC_VER _MSC_VER +# define UMPIRE_FMT_MSC_WARNING(...) __pragma(warning(__VA_ARGS__)) #else -# define FMT_MSC_VER 0 -# define FMT_MSC_WARNING(...) +# define UMPIRE_FMT_MSC_VER 0 +# define UMPIRE_FMT_MSC_WARNING(...) #endif #ifdef __has_feature -# define FMT_HAS_FEATURE(x) __has_feature(x) +# define UMPIRE_FMT_HAS_FEATURE(x) __has_feature(x) #else -# define FMT_HAS_FEATURE(x) 0 +# define UMPIRE_FMT_HAS_FEATURE(x) 0 #endif #if defined(__has_include) && !defined(__INTELLISENSE__) && \ - (!FMT_ICC_VERSION || FMT_ICC_VERSION >= 1600) -# define FMT_HAS_INCLUDE(x) __has_include(x) + (!UMPIRE_FMT_ICC_VERSION || UMPIRE_FMT_ICC_VERSION >= 1600) +# define UMPIRE_FMT_HAS_INCLUDE(x) __has_include(x) #else -# define FMT_HAS_INCLUDE(x) 0 +# define UMPIRE_FMT_HAS_INCLUDE(x) 0 #endif #ifdef __has_cpp_attribute -# define FMT_HAS_CPP_ATTRIBUTE(x) __has_cpp_attribute(x) +# define UMPIRE_FMT_HAS_CPP_ATTRIBUTE(x) __has_cpp_attribute(x) #else -# define FMT_HAS_CPP_ATTRIBUTE(x) 0 +# define UMPIRE_FMT_HAS_CPP_ATTRIBUTE(x) 0 #endif -#define FMT_HAS_CPP14_ATTRIBUTE(attribute) \ - (__cplusplus >= 201402L && FMT_HAS_CPP_ATTRIBUTE(attribute)) +#define UMPIRE_FMT_HAS_CPP14_ATTRIBUTE(attribute) \ + (__cplusplus >= 201402L && UMPIRE_FMT_HAS_CPP_ATTRIBUTE(attribute)) -#define FMT_HAS_CPP17_ATTRIBUTE(attribute) \ - (__cplusplus >= 201703L && FMT_HAS_CPP_ATTRIBUTE(attribute)) +#define UMPIRE_FMT_HAS_CPP17_ATTRIBUTE(attribute) \ + (__cplusplus >= 201703L && UMPIRE_FMT_HAS_CPP_ATTRIBUTE(attribute)) // Check if relaxed C++14 constexpr is supported. // GCC doesn't allow throw in constexpr until version 6 (bug 67371). -#ifndef FMT_USE_CONSTEXPR -# define FMT_USE_CONSTEXPR \ - (FMT_HAS_FEATURE(cxx_relaxed_constexpr) || FMT_MSC_VER >= 1910 || \ - (FMT_GCC_VERSION >= 600 && __cplusplus >= 201402L)) && \ - !FMT_NVCC && !FMT_ICC_VERSION +#ifndef UMPIRE_FMT_USE_CONSTEXPR +# define UMPIRE_FMT_USE_CONSTEXPR \ + (UMPIRE_FMT_HAS_FEATURE(cxx_relaxed_constexpr) || UMPIRE_FMT_MSC_VER >= 1910 || \ + (UMPIRE_FMT_GCC_VERSION >= 600 && __cplusplus >= 201402L)) && \ + !UMPIRE_FMT_NVCC && !UMPIRE_FMT_ICC_VERSION #endif -#if FMT_USE_CONSTEXPR -# define FMT_CONSTEXPR constexpr -# define FMT_CONSTEXPR_DECL constexpr +#if UMPIRE_FMT_USE_CONSTEXPR +# define UMPIRE_FMT_CONSTEXPR constexpr +# define UMPIRE_FMT_CONSTEXPR_DECL constexpr #else -# define FMT_CONSTEXPR -# define FMT_CONSTEXPR_DECL +# define UMPIRE_FMT_CONSTEXPR +# define UMPIRE_FMT_CONSTEXPR_DECL #endif -#ifndef FMT_OVERRIDE -# if FMT_HAS_FEATURE(cxx_override_control) || \ - (FMT_GCC_VERSION >= 408 && FMT_HAS_GXX_CXX11) || FMT_MSC_VER >= 1900 -# define FMT_OVERRIDE override +#ifndef UMPIRE_FMT_OVERRIDE +# if UMPIRE_FMT_HAS_FEATURE(cxx_override_control) || \ + (UMPIRE_FMT_GCC_VERSION >= 408 && UMPIRE_FMT_HAS_GXX_CXX11) || UMPIRE_FMT_MSC_VER >= 1900 +# define UMPIRE_FMT_OVERRIDE override # else -# define FMT_OVERRIDE +# define UMPIRE_FMT_OVERRIDE # endif #endif // Check if exceptions are disabled. -#ifndef FMT_EXCEPTIONS +#ifndef UMPIRE_FMT_EXCEPTIONS # if (defined(__GNUC__) && !defined(__EXCEPTIONS)) || \ - FMT_MSC_VER && !_HAS_EXCEPTIONS -# define FMT_EXCEPTIONS 0 + UMPIRE_FMT_MSC_VER && !_HAS_EXCEPTIONS +# define UMPIRE_FMT_EXCEPTIONS 0 # else -# define FMT_EXCEPTIONS 1 +# define UMPIRE_FMT_EXCEPTIONS 1 # endif #endif -// Define FMT_USE_NOEXCEPT to make fmt use noexcept (C++11 feature). -#ifndef FMT_USE_NOEXCEPT -# define FMT_USE_NOEXCEPT 0 +// Define UMPIRE_FMT_USE_NOEXCEPT to make fmt use noexcept (C++11 feature). +#ifndef UMPIRE_FMT_USE_NOEXCEPT +# define UMPIRE_FMT_USE_NOEXCEPT 0 #endif -#if FMT_USE_NOEXCEPT || FMT_HAS_FEATURE(cxx_noexcept) || \ - (FMT_GCC_VERSION >= 408 && FMT_HAS_GXX_CXX11) || FMT_MSC_VER >= 1900 -# define FMT_DETECTED_NOEXCEPT noexcept -# define FMT_HAS_CXX11_NOEXCEPT 1 +#if UMPIRE_FMT_USE_NOEXCEPT || UMPIRE_FMT_HAS_FEATURE(cxx_noexcept) || \ + (UMPIRE_FMT_GCC_VERSION >= 408 && UMPIRE_FMT_HAS_GXX_CXX11) || UMPIRE_FMT_MSC_VER >= 1900 +# define UMPIRE_FMT_DETECTED_NOEXCEPT noexcept +# define UMPIRE_FMT_HAS_CXX11_NOEXCEPT 1 #else -# define FMT_DETECTED_NOEXCEPT throw() -# define FMT_HAS_CXX11_NOEXCEPT 0 +# define UMPIRE_FMT_DETECTED_NOEXCEPT throw() +# define UMPIRE_FMT_HAS_CXX11_NOEXCEPT 0 #endif -#ifndef FMT_NOEXCEPT -# if FMT_EXCEPTIONS || FMT_HAS_CXX11_NOEXCEPT -# define FMT_NOEXCEPT FMT_DETECTED_NOEXCEPT +#ifndef UMPIRE_FMT_NOEXCEPT +# if UMPIRE_FMT_EXCEPTIONS || UMPIRE_FMT_HAS_CXX11_NOEXCEPT +# define UMPIRE_FMT_NOEXCEPT UMPIRE_FMT_DETECTED_NOEXCEPT # else -# define FMT_NOEXCEPT +# define UMPIRE_FMT_NOEXCEPT # endif #endif // [[noreturn]] is disabled on MSVC and NVCC because of bogus unreachable code // warnings. -#if FMT_EXCEPTIONS && FMT_HAS_CPP_ATTRIBUTE(noreturn) && !FMT_MSC_VER && \ - !FMT_NVCC -# define FMT_NORETURN [[noreturn]] +#if UMPIRE_FMT_EXCEPTIONS && UMPIRE_FMT_HAS_CPP_ATTRIBUTE(noreturn) && !UMPIRE_FMT_MSC_VER && \ + !UMPIRE_FMT_NVCC +# define UMPIRE_FMT_NORETURN [[noreturn]] #else -# define FMT_NORETURN +# define UMPIRE_FMT_NORETURN #endif -#ifndef FMT_DEPRECATED -# if FMT_HAS_CPP14_ATTRIBUTE(deprecated) || FMT_MSC_VER >= 1900 -# define FMT_DEPRECATED [[deprecated]] +#ifndef UMPIRE_FMT_DEPRECATED +# if UMPIRE_FMT_HAS_CPP14_ATTRIBUTE(deprecated) || UMPIRE_FMT_MSC_VER >= 1900 +# define UMPIRE_FMT_DEPRECATED [[deprecated]] # else # if (defined(__GNUC__) && !defined(__LCC__)) || defined(__clang__) -# define FMT_DEPRECATED __attribute__((deprecated)) -# elif FMT_MSC_VER -# define FMT_DEPRECATED __declspec(deprecated) +# define UMPIRE_FMT_DEPRECATED __attribute__((deprecated)) +# elif UMPIRE_FMT_MSC_VER +# define UMPIRE_FMT_DEPRECATED __declspec(deprecated) # else -# define FMT_DEPRECATED /* deprecated */ +# define UMPIRE_FMT_DEPRECATED /* deprecated */ # endif # endif #endif // Workaround broken [[deprecated]] in the Intel, PGI and NVCC compilers. -#if FMT_ICC_VERSION || defined(__PGI) || FMT_NVCC -# define FMT_DEPRECATED_ALIAS +#if UMPIRE_FMT_ICC_VERSION || defined(__PGI) || UMPIRE_FMT_NVCC +# define UMPIRE_FMT_DEPRECATED_ALIAS #else -# define FMT_DEPRECATED_ALIAS FMT_DEPRECATED +# define UMPIRE_FMT_DEPRECATED_ALIAS UMPIRE_FMT_DEPRECATED #endif -#ifndef FMT_INLINE -# if FMT_GCC_VERSION || FMT_CLANG_VERSION -# define FMT_INLINE inline __attribute__((always_inline)) +#ifndef UMPIRE_FMT_INLINE +# if UMPIRE_FMT_GCC_VERSION || UMPIRE_FMT_CLANG_VERSION +# define UMPIRE_FMT_INLINE inline __attribute__((always_inline)) # else -# define FMT_INLINE inline +# define UMPIRE_FMT_INLINE inline # endif #endif -#ifndef FMT_USE_INLINE_NAMESPACES -# if FMT_HAS_FEATURE(cxx_inline_namespaces) || FMT_GCC_VERSION >= 404 || \ - (FMT_MSC_VER >= 1900 && (!defined(_MANAGED) || !_MANAGED)) -# define FMT_USE_INLINE_NAMESPACES 1 +#ifndef UMPIRE_FMT_USE_INLINE_NAMESPACES +# if UMPIRE_FMT_HAS_FEATURE(cxx_inline_namespaces) || UMPIRE_FMT_GCC_VERSION >= 404 || \ + (UMPIRE_FMT_MSC_VER >= 1900 && (!defined(_MANAGED) || !_MANAGED)) +# define UMPIRE_FMT_USE_INLINE_NAMESPACES 1 # else -# define FMT_USE_INLINE_NAMESPACES 0 +# define UMPIRE_FMT_USE_INLINE_NAMESPACES 0 # endif #endif -#ifndef FMT_BEGIN_NAMESPACE -# if FMT_USE_INLINE_NAMESPACES -# define FMT_INLINE_NAMESPACE inline namespace -# define FMT_END_NAMESPACE \ +#ifndef UMPIRE_FMT_BEGIN_NAMESPACE +# if UMPIRE_FMT_USE_INLINE_NAMESPACES +# define UMPIRE_FMT_INLINE_NAMESPACE inline namespace +# define UMPIRE_FMT_END_NAMESPACE \ } \ } \ } # else -# define FMT_INLINE_NAMESPACE namespace -# define FMT_END_NAMESPACE \ +# define UMPIRE_FMT_INLINE_NAMESPACE namespace +# define UMPIRE_FMT_END_NAMESPACE \ } \ using namespace v7; \ } \ } # endif -# define FMT_BEGIN_NAMESPACE \ +# define UMPIRE_FMT_BEGIN_NAMESPACE \ namespace umpire { \ namespace fmt { \ - FMT_INLINE_NAMESPACE v7 { + UMPIRE_FMT_INLINE_NAMESPACE v7 { #endif -#if !defined(FMT_HEADER_ONLY) && defined(_WIN32) -# define FMT_CLASS_API FMT_MSC_WARNING(suppress : 4275) -# ifdef FMT_EXPORT -# define FMT_API __declspec(dllexport) -# define FMT_EXTERN_TEMPLATE_API FMT_API -# define FMT_EXPORTED -# elif defined(FMT_SHARED) -# define FMT_API __declspec(dllimport) -# define FMT_EXTERN_TEMPLATE_API FMT_API +#if !defined(UMPIRE_FMT_HEADER_ONLY) && defined(_WIN32) +# define UMPIRE_FMT_CLASS_API UMPIRE_FMT_MSC_WARNING(suppress : 4275) +# ifdef UMPIRE_FMT_EXPORT +# define UMPIRE_FMT_API __declspec(dllexport) +# define UMPIRE_FMT_EXTERN_TEMPLATE_API UMPIRE_FMT_API +# define UMPIRE_FMT_EXPORTED +# elif defined(UMPIRE_FMT_SHARED) +# define UMPIRE_FMT_API __declspec(dllimport) +# define UMPIRE_FMT_EXTERN_TEMPLATE_API UMPIRE_FMT_API # endif #else -# define FMT_CLASS_API +# define UMPIRE_FMT_CLASS_API #endif -#ifndef FMT_API -# define FMT_API +#ifndef UMPIRE_FMT_API +# define UMPIRE_FMT_API #endif -#ifndef FMT_EXTERN_TEMPLATE_API -# define FMT_EXTERN_TEMPLATE_API +#ifndef UMPIRE_FMT_EXTERN_TEMPLATE_API +# define UMPIRE_FMT_EXTERN_TEMPLATE_API #endif -#ifndef FMT_INSTANTIATION_DEF_API -# define FMT_INSTANTIATION_DEF_API FMT_API +#ifndef UMPIRE_FMT_INSTANTIATION_DEF_API +# define UMPIRE_FMT_INSTANTIATION_DEF_API UMPIRE_FMT_API #endif -#ifndef FMT_HEADER_ONLY -# define FMT_EXTERN extern +#ifndef UMPIRE_FMT_HEADER_ONLY +# define UMPIRE_FMT_EXTERN extern #else -# define FMT_EXTERN +# define UMPIRE_FMT_EXTERN #endif // libc++ supports string_view in pre-c++17. -#if (FMT_HAS_INCLUDE() && \ +#if (UMPIRE_FMT_HAS_INCLUDE() && \ (__cplusplus > 201402L || defined(_LIBCPP_VERSION))) || \ (defined(_MSVC_LANG) && _MSVC_LANG > 201402L && _MSC_VER >= 1910) # include -# define FMT_USE_STRING_VIEW -#elif FMT_HAS_INCLUDE("experimental/string_view") && __cplusplus >= 201402L +# define UMPIRE_FMT_USE_STRING_VIEW +#elif UMPIRE_FMT_HAS_INCLUDE("experimental/string_view") && __cplusplus >= 201402L # include -# define FMT_USE_EXPERIMENTAL_STRING_VIEW +# define UMPIRE_FMT_USE_EXPERIMENTAL_STRING_VIEW #endif -#ifndef FMT_UNICODE -# define FMT_UNICODE !FMT_MSC_VER +#ifndef UMPIRE_FMT_UNICODE +# define UMPIRE_FMT_UNICODE !UMPIRE_FMT_MSC_VER #endif -#ifndef FMT_COMPILE_TIME_CHECKS -# define FMT_COMPILE_TIME_CHECKS 0 +#ifndef UMPIRE_FMT_COMPILE_TIME_CHECKS +# define UMPIRE_FMT_COMPILE_TIME_CHECKS 0 #endif -FMT_BEGIN_NAMESPACE +UMPIRE_FMT_BEGIN_NAMESPACE // Implementations of enable_if_t and other metafunctions for older systems. template @@ -275,15 +275,15 @@ struct monostate {}; // An enable_if helper to be used in template parameters which results in much // shorter symbols: https://godbolt.org/z/sWw4vP. Extra parentheses are needed // to workaround a bug in MSVC 2019 (see #1140 and #1186). -#ifdef FMT_DOC -# define FMT_ENABLE_IF(...) +#ifdef UMPIRE_FMT_DOC +# define UMPIRE_FMT_ENABLE_IF(...) #else -# define FMT_ENABLE_IF(...) enable_if_t<(__VA_ARGS__), int> = 0 +# define UMPIRE_FMT_ENABLE_IF(...) enable_if_t<(__VA_ARGS__), int> = 0 #endif namespace detail { -constexpr bool is_constant_evaluated() FMT_NOEXCEPT { +constexpr bool is_constant_evaluated() UMPIRE_FMT_NOEXCEPT { #ifdef __cpp_lib_is_constant_evaluated return std::is_constant_evaluated(); #else @@ -294,56 +294,56 @@ constexpr bool is_constant_evaluated() FMT_NOEXCEPT { // A helper function to suppress "conditional expression is constant" warnings. template constexpr T const_check(T value) { return value; } -FMT_NORETURN FMT_API void assert_fail(const char* file, int line, +UMPIRE_FMT_NORETURN UMPIRE_FMT_API void assert_fail(const char* file, int line, const char* message); -#ifndef FMT_ASSERT +#ifndef UMPIRE_FMT_ASSERT # ifdef NDEBUG -// FMT_ASSERT is not empty to avoid -Werror=empty-body. -# define FMT_ASSERT(condition, message) ((void)0) +// UMPIRE_FMT_ASSERT is not empty to avoid -Werror=empty-body. +# define UMPIRE_FMT_ASSERT(condition, message) ((void)0) # else -# define FMT_ASSERT(condition, message) \ +# define UMPIRE_FMT_ASSERT(condition, message) \ ((condition) /* void() fails with -Winvalid-constexpr on clang 4.0.1 */ \ ? (void)0 \ : ::umpire::fmt::detail::assert_fail(__FILE__, __LINE__, (message))) # endif #endif -#if defined(FMT_USE_STRING_VIEW) +#if defined(UMPIRE_FMT_USE_STRING_VIEW) template using std_string_view = std::basic_string_view; -#elif defined(FMT_USE_EXPERIMENTAL_STRING_VIEW) +#elif defined(UMPIRE_FMT_USE_EXPERIMENTAL_STRING_VIEW) template using std_string_view = std::experimental::basic_string_view; #else template struct std_string_view {}; #endif -#ifdef FMT_USE_INT128 +#ifdef UMPIRE_FMT_USE_INT128 // Do nothing. -#elif defined(__SIZEOF_INT128__) && !FMT_NVCC && \ - !(FMT_CLANG_VERSION && FMT_MSC_VER) -# define FMT_USE_INT128 1 +#elif defined(__SIZEOF_INT128__) && !UMPIRE_FMT_NVCC && \ + !(UMPIRE_FMT_CLANG_VERSION && UMPIRE_FMT_MSC_VER) +# define UMPIRE_FMT_USE_INT128 1 using int128_t = __int128_t; using uint128_t = __uint128_t; #else -# define FMT_USE_INT128 0 +# define UMPIRE_FMT_USE_INT128 0 #endif -#if !FMT_USE_INT128 +#if !UMPIRE_FMT_USE_INT128 struct int128_t {}; struct uint128_t {}; #endif // Casts a nonnegative integer to unsigned. template -FMT_CONSTEXPR typename std::make_unsigned::type to_unsigned(Int value) { - FMT_ASSERT(value >= 0, "negative value"); +UMPIRE_FMT_CONSTEXPR typename std::make_unsigned::type to_unsigned(Int value) { + UMPIRE_FMT_ASSERT(value >= 0, "negative value"); return static_cast::type>(value); } -FMT_MSC_WARNING(suppress : 4566) constexpr unsigned char micro[] = "\u00B5"; +UMPIRE_FMT_MSC_WARNING(suppress : 4566) constexpr unsigned char micro[] = "\u00B5"; template constexpr bool is_unicode() { - return FMT_UNICODE || sizeof(Char) != 1 || + return UMPIRE_FMT_UNICODE || sizeof(Char) != 1 || (sizeof(micro) == 3 && micro[0] == 0xC2 && micro[1] == 0xB5); } @@ -354,7 +354,7 @@ enum char8_type : unsigned char {}; #endif } // namespace detail -#ifdef FMT_USE_INTERNAL +#ifdef UMPIRE_FMT_USE_INTERNAL namespace internal = detail; // DEPRECATED #endif @@ -374,10 +374,10 @@ template class basic_string_view { using value_type = Char; using iterator = const Char*; - constexpr basic_string_view() FMT_NOEXCEPT : data_(nullptr), size_(0) {} + constexpr basic_string_view() UMPIRE_FMT_NOEXCEPT : data_(nullptr), size_(0) {} /** Constructs a string reference object from a C string and a size. */ - constexpr basic_string_view(const Char* s, size_t count) FMT_NOEXCEPT + constexpr basic_string_view(const Char* s, size_t count) UMPIRE_FMT_NOEXCEPT : data_(s), size_(count) {} @@ -388,21 +388,21 @@ template class basic_string_view { \endrst */ #if __cplusplus >= 201703L // C++17's char_traits::length() is constexpr. - FMT_CONSTEXPR + UMPIRE_FMT_CONSTEXPR #endif basic_string_view(const Char* s) : data_(s), size_(std::char_traits::length(s)) {} /** Constructs a string reference from a ``std::basic_string`` object. */ template - FMT_CONSTEXPR basic_string_view( - const std::basic_string& s) FMT_NOEXCEPT + UMPIRE_FMT_CONSTEXPR basic_string_view( + const std::basic_string& s) UMPIRE_FMT_NOEXCEPT : data_(s.data()), size_(s.size()) {} - template >::value)> - FMT_CONSTEXPR basic_string_view(S s) FMT_NOEXCEPT : data_(s.data()), + UMPIRE_FMT_CONSTEXPR basic_string_view(S s) UMPIRE_FMT_NOEXCEPT : data_(s.data()), size_(s.size()) {} /** Returns a pointer to the string data. */ @@ -416,7 +416,7 @@ template class basic_string_view { constexpr const Char& operator[](size_t pos) const { return data_[pos]; } - FMT_CONSTEXPR void remove_prefix(size_t n) { + UMPIRE_FMT_CONSTEXPR void remove_prefix(size_t n) { data_ += n; size_ -= n; } @@ -477,7 +477,7 @@ template <> struct is_char : std::true_type {}; std::string message = umpire::fmt::format(my_string("The answer is {}"), 42); \endrst */ -template ::value)> +template ::value)> inline basic_string_view to_string_view(const Char* s) { return s; } @@ -494,19 +494,19 @@ constexpr basic_string_view to_string_view(basic_string_view s) { } template >::value)> + UMPIRE_FMT_ENABLE_IF(!std::is_empty>::value)> inline basic_string_view to_string_view(detail::std_string_view s) { return s; } // A base class for compile-time strings. It is defined in the fmt namespace to -// make formatting functions visible via ADL, e.g. format(FMT_STRING("{}"), 42). +// make formatting functions visible via ADL, e.g. format(UMPIRE_FMT_STRING("{}"), 42). struct compile_string {}; template struct is_compile_string : std::is_base_of {}; -template ::value)> +template ::value)> constexpr basic_string_view to_string_view(const S& s) { return s; } @@ -529,15 +529,15 @@ template struct char_t_impl::value>> { }; // Reports a compile-time error if S is not a valid format string. -template ::value)> -FMT_INLINE void check_format_string(const S&) { -#ifdef FMT_ENFORCE_COMPILE_STRING +template ::value)> +UMPIRE_FMT_INLINE void check_format_string(const S&) { +#ifdef UMPIRE_FMT_ENFORCE_COMPILE_STRING static_assert(is_compile_string::value, - "FMT_ENFORCE_COMPILE_STRING requires all format strings to use " - "FMT_STRING."); + "UMPIRE_FMT_ENFORCE_COMPILE_STRING requires all format strings to use " + "UMPIRE_FMT_STRING."); #endif } -template ::value)> +template ::value)> void check_format_string(S); struct error_handler { @@ -545,7 +545,7 @@ struct error_handler { constexpr error_handler(const error_handler&) = default; // This function is intentionally not constexpr to give a compile-time error. - FMT_NORETURN FMT_API void on_error(const char* message); + UMPIRE_FMT_NORETURN UMPIRE_FMT_API void on_error(const char* message); }; } // namespace detail @@ -587,15 +587,15 @@ class basic_format_parse_context : private ErrorHandler { Returns an iterator to the beginning of the format string range being parsed. */ - constexpr iterator begin() const FMT_NOEXCEPT { return format_str_.begin(); } + constexpr iterator begin() const UMPIRE_FMT_NOEXCEPT { return format_str_.begin(); } /** Returns an iterator past the end of the format string range being parsed. */ - constexpr iterator end() const FMT_NOEXCEPT { return format_str_.end(); } + constexpr iterator end() const UMPIRE_FMT_NOEXCEPT { return format_str_.end(); } /** Advances the begin iterator to ``it``. */ - FMT_CONSTEXPR void advance_to(iterator it) { + UMPIRE_FMT_CONSTEXPR void advance_to(iterator it) { format_str_.remove_prefix(detail::to_unsigned(it - begin())); } @@ -603,7 +603,7 @@ class basic_format_parse_context : private ErrorHandler { Reports an error if using the manual argument indexing; otherwise returns the next argument index and switches to the automatic indexing. */ - FMT_CONSTEXPR int next_arg_id() { + UMPIRE_FMT_CONSTEXPR int next_arg_id() { // Don't check if the argument id is valid to avoid overhead and because it // will be checked during formatting anyway. if (next_arg_id_ >= 0) return next_arg_id_++; @@ -615,16 +615,16 @@ class basic_format_parse_context : private ErrorHandler { Reports an error if using the automatic argument indexing; otherwise switches to the manual indexing. */ - FMT_CONSTEXPR void check_arg_id(int) { + UMPIRE_FMT_CONSTEXPR void check_arg_id(int) { if (next_arg_id_ > 0) on_error("cannot switch from automatic to manual argument indexing"); else next_arg_id_ = -1; } - FMT_CONSTEXPR void check_arg_id(basic_string_view) {} + UMPIRE_FMT_CONSTEXPR void check_arg_id(basic_string_view) {} - FMT_CONSTEXPR void on_error(const char* message) { + UMPIRE_FMT_CONSTEXPR void on_error(const char* message) { ErrorHandler::on_error(message); } @@ -683,10 +683,10 @@ template class buffer { protected: // Don't initialize ptr_ since it is not accessed to save a few cycles. - FMT_MSC_WARNING(suppress : 26495) - buffer(size_t sz) FMT_NOEXCEPT : size_(sz), capacity_(sz) {} + UMPIRE_FMT_MSC_WARNING(suppress : 26495) + buffer(size_t sz) UMPIRE_FMT_NOEXCEPT : size_(sz), capacity_(sz) {} - buffer(T* p = nullptr, size_t sz = 0, size_t cap = 0) FMT_NOEXCEPT + buffer(T* p = nullptr, size_t sz = 0, size_t cap = 0) UMPIRE_FMT_NOEXCEPT : ptr_(p), size_(sz), capacity_(cap) {} @@ -694,7 +694,7 @@ template class buffer { ~buffer() = default; /** Sets the buffer data and capacity. */ - void set(T* buf_data, size_t buf_capacity) FMT_NOEXCEPT { + void set(T* buf_data, size_t buf_capacity) UMPIRE_FMT_NOEXCEPT { ptr_ = buf_data; capacity_ = buf_capacity; } @@ -709,23 +709,23 @@ template class buffer { buffer(const buffer&) = delete; void operator=(const buffer&) = delete; - T* begin() FMT_NOEXCEPT { return ptr_; } - T* end() FMT_NOEXCEPT { return ptr_ + size_; } + T* begin() UMPIRE_FMT_NOEXCEPT { return ptr_; } + T* end() UMPIRE_FMT_NOEXCEPT { return ptr_ + size_; } - const T* begin() const FMT_NOEXCEPT { return ptr_; } - const T* end() const FMT_NOEXCEPT { return ptr_ + size_; } + const T* begin() const UMPIRE_FMT_NOEXCEPT { return ptr_; } + const T* end() const UMPIRE_FMT_NOEXCEPT { return ptr_ + size_; } /** Returns the size of this buffer. */ - size_t size() const FMT_NOEXCEPT { return size_; } + size_t size() const UMPIRE_FMT_NOEXCEPT { return size_; } /** Returns the capacity of this buffer. */ - size_t capacity() const FMT_NOEXCEPT { return capacity_; } + size_t capacity() const UMPIRE_FMT_NOEXCEPT { return capacity_; } /** Returns a pointer to the buffer data. */ - T* data() FMT_NOEXCEPT { return ptr_; } + T* data() UMPIRE_FMT_NOEXCEPT { return ptr_; } /** Returns a pointer to the buffer data. */ - const T* data() const FMT_NOEXCEPT { return ptr_; } + const T* data() const UMPIRE_FMT_NOEXCEPT { return ptr_; } /** Clears this buffer. */ void clear() { size_ = 0; } @@ -789,7 +789,7 @@ class iterator_buffer final : public Traits, public buffer { T data_[buffer_size]; protected: - void grow(size_t) final FMT_OVERRIDE { + void grow(size_t) final UMPIRE_FMT_OVERRIDE { if (this->size() == buffer_size) flush(); } void flush(); @@ -808,7 +808,7 @@ class iterator_buffer final : public Traits, public buffer { template class iterator_buffer final : public buffer { protected: - void grow(size_t) final FMT_OVERRIDE {} + void grow(size_t) final UMPIRE_FMT_OVERRIDE {} public: explicit iterator_buffer(T* out, size_t = 0) : buffer(out, 0, ~size_t()) {} @@ -826,7 +826,7 @@ class iterator_buffer, Container& container_; protected: - void grow(size_t capacity) final FMT_OVERRIDE { + void grow(size_t capacity) final UMPIRE_FMT_OVERRIDE { container_.resize(capacity); this->set(&container_[0], capacity); } @@ -849,7 +849,7 @@ template class counting_buffer final : public buffer { size_t count_ = 0; protected: - void grow(size_t) final FMT_OVERRIDE { + void grow(size_t) final UMPIRE_FMT_OVERRIDE { if (this->size() != buffer_size) return; count_ += this->size(); this->clear(); @@ -946,9 +946,9 @@ struct arg_data { T args_[NUM_ARGS != 0 ? NUM_ARGS : +1]; template - FMT_CONSTEXPR FMT_INLINE arg_data(const U&... init) : args_{init...} {} - FMT_CONSTEXPR FMT_INLINE const T* args() const { return args_; } - FMT_CONSTEXPR FMT_INLINE std::nullptr_t named_args() { return nullptr; } + UMPIRE_FMT_CONSTEXPR UMPIRE_FMT_INLINE arg_data(const U&... init) : args_{init...} {} + UMPIRE_FMT_CONSTEXPR UMPIRE_FMT_INLINE const T* args() const { return args_; } + UMPIRE_FMT_CONSTEXPR UMPIRE_FMT_INLINE std::nullptr_t named_args() { return nullptr; } }; template @@ -969,7 +969,7 @@ void init_named_args(named_arg_info* named_args, int arg_count, } template -FMT_CONSTEXPR FMT_INLINE void init_named_args(std::nullptr_t, int, int, +UMPIRE_FMT_CONSTEXPR UMPIRE_FMT_INLINE void init_named_args(std::nullptr_t, int, int, const Args&...) {} template struct is_named_arg : std::false_type {}; @@ -1013,25 +1013,25 @@ enum class type { template struct type_constant : std::integral_constant {}; -#define FMT_TYPE_CONSTANT(Type, constant) \ +#define UMPIRE_FMT_TYPE_CONSTANT(Type, constant) \ template \ struct type_constant \ : std::integral_constant {} -FMT_TYPE_CONSTANT(int, int_type); -FMT_TYPE_CONSTANT(unsigned, uint_type); -FMT_TYPE_CONSTANT(long long, long_long_type); -FMT_TYPE_CONSTANT(unsigned long long, ulong_long_type); -FMT_TYPE_CONSTANT(int128_t, int128_type); -FMT_TYPE_CONSTANT(uint128_t, uint128_type); -FMT_TYPE_CONSTANT(bool, bool_type); -FMT_TYPE_CONSTANT(Char, char_type); -FMT_TYPE_CONSTANT(float, float_type); -FMT_TYPE_CONSTANT(double, double_type); -FMT_TYPE_CONSTANT(long double, long_double_type); -FMT_TYPE_CONSTANT(const Char*, cstring_type); -FMT_TYPE_CONSTANT(basic_string_view, string_type); -FMT_TYPE_CONSTANT(const void*, pointer_type); +UMPIRE_FMT_TYPE_CONSTANT(int, int_type); +UMPIRE_FMT_TYPE_CONSTANT(unsigned, uint_type); +UMPIRE_FMT_TYPE_CONSTANT(long long, long_long_type); +UMPIRE_FMT_TYPE_CONSTANT(unsigned long long, ulong_long_type); +UMPIRE_FMT_TYPE_CONSTANT(int128_t, int128_type); +UMPIRE_FMT_TYPE_CONSTANT(uint128_t, uint128_type); +UMPIRE_FMT_TYPE_CONSTANT(bool, bool_type); +UMPIRE_FMT_TYPE_CONSTANT(Char, char_type); +UMPIRE_FMT_TYPE_CONSTANT(float, float_type); +UMPIRE_FMT_TYPE_CONSTANT(double, double_type); +UMPIRE_FMT_TYPE_CONSTANT(long double, long_double_type); +UMPIRE_FMT_TYPE_CONSTANT(const Char*, cstring_type); +UMPIRE_FMT_TYPE_CONSTANT(basic_string_view, string_type); +UMPIRE_FMT_TYPE_CONSTANT(const void*, pointer_type); constexpr bool is_integral_type(type t) { return t > type::none_type && t <= type::last_integer_type; @@ -1080,30 +1080,30 @@ template class value { named_arg_value named_args; }; - constexpr FMT_INLINE value(int val = 0) : int_value(val) {} - constexpr FMT_INLINE value(unsigned val) : uint_value(val) {} - constexpr FMT_INLINE value(long long val) : long_long_value(val) {} - constexpr FMT_INLINE value(unsigned long long val) : ulong_long_value(val) {} - FMT_INLINE value(int128_t val) : int128_value(val) {} - FMT_INLINE value(uint128_t val) : uint128_value(val) {} - FMT_INLINE value(float val) : float_value(val) {} - FMT_INLINE value(double val) : double_value(val) {} - FMT_INLINE value(long double val) : long_double_value(val) {} - constexpr FMT_INLINE value(bool val) : bool_value(val) {} - constexpr FMT_INLINE value(char_type val) : char_value(val) {} - FMT_CONSTEXPR FMT_INLINE value(const char_type* val) { + constexpr UMPIRE_FMT_INLINE value(int val = 0) : int_value(val) {} + constexpr UMPIRE_FMT_INLINE value(unsigned val) : uint_value(val) {} + constexpr UMPIRE_FMT_INLINE value(long long val) : long_long_value(val) {} + constexpr UMPIRE_FMT_INLINE value(unsigned long long val) : ulong_long_value(val) {} + UMPIRE_FMT_INLINE value(int128_t val) : int128_value(val) {} + UMPIRE_FMT_INLINE value(uint128_t val) : uint128_value(val) {} + UMPIRE_FMT_INLINE value(float val) : float_value(val) {} + UMPIRE_FMT_INLINE value(double val) : double_value(val) {} + UMPIRE_FMT_INLINE value(long double val) : long_double_value(val) {} + constexpr UMPIRE_FMT_INLINE value(bool val) : bool_value(val) {} + constexpr UMPIRE_FMT_INLINE value(char_type val) : char_value(val) {} + UMPIRE_FMT_CONSTEXPR UMPIRE_FMT_INLINE value(const char_type* val) { string.data = val; if (is_constant_evaluated()) string.size = {}; } - FMT_CONSTEXPR FMT_INLINE value(basic_string_view val) { + UMPIRE_FMT_CONSTEXPR UMPIRE_FMT_INLINE value(basic_string_view val) { string.data = val.data(); string.size = val.size(); } - FMT_INLINE value(const void* val) : pointer(val) {} - FMT_INLINE value(const named_arg_info* args, size_t size) + UMPIRE_FMT_INLINE value(const void* val) : pointer(val) {} + UMPIRE_FMT_INLINE value(const named_arg_info* args, size_t size) : named_args{args, size} {} - template FMT_INLINE value(const T& val) { + template UMPIRE_FMT_INLINE value(const T& val) { custom.value = &val; // Get the formatter type through the context to allow different contexts // have different extension points, e.g. `formatter` for `format` and @@ -1127,7 +1127,7 @@ template class value { }; template -FMT_CONSTEXPR basic_format_arg make_arg(const T& value); +UMPIRE_FMT_CONSTEXPR basic_format_arg make_arg(const T& value); // To minimize the number of types we need to deal with, long is translated // either to int or to long long depending on its size. @@ -1141,83 +1141,83 @@ struct unformattable {}; template struct arg_mapper { using char_type = typename Context::char_type; - FMT_CONSTEXPR int map(signed char val) { return val; } - FMT_CONSTEXPR unsigned map(unsigned char val) { return val; } - FMT_CONSTEXPR int map(short val) { return val; } - FMT_CONSTEXPR unsigned map(unsigned short val) { return val; } - FMT_CONSTEXPR int map(int val) { return val; } - FMT_CONSTEXPR unsigned map(unsigned val) { return val; } - FMT_CONSTEXPR long_type map(long val) { return val; } - FMT_CONSTEXPR ulong_type map(unsigned long val) { return val; } - FMT_CONSTEXPR long long map(long long val) { return val; } - FMT_CONSTEXPR unsigned long long map(unsigned long long val) { return val; } - FMT_CONSTEXPR int128_t map(int128_t val) { return val; } - FMT_CONSTEXPR uint128_t map(uint128_t val) { return val; } - FMT_CONSTEXPR bool map(bool val) { return val; } - - template ::value)> - FMT_CONSTEXPR char_type map(T val) { + UMPIRE_FMT_CONSTEXPR int map(signed char val) { return val; } + UMPIRE_FMT_CONSTEXPR unsigned map(unsigned char val) { return val; } + UMPIRE_FMT_CONSTEXPR int map(short val) { return val; } + UMPIRE_FMT_CONSTEXPR unsigned map(unsigned short val) { return val; } + UMPIRE_FMT_CONSTEXPR int map(int val) { return val; } + UMPIRE_FMT_CONSTEXPR unsigned map(unsigned val) { return val; } + UMPIRE_FMT_CONSTEXPR long_type map(long val) { return val; } + UMPIRE_FMT_CONSTEXPR ulong_type map(unsigned long val) { return val; } + UMPIRE_FMT_CONSTEXPR long long map(long long val) { return val; } + UMPIRE_FMT_CONSTEXPR unsigned long long map(unsigned long long val) { return val; } + UMPIRE_FMT_CONSTEXPR int128_t map(int128_t val) { return val; } + UMPIRE_FMT_CONSTEXPR uint128_t map(uint128_t val) { return val; } + UMPIRE_FMT_CONSTEXPR bool map(bool val) { return val; } + + template ::value)> + UMPIRE_FMT_CONSTEXPR char_type map(T val) { static_assert( std::is_same::value || std::is_same::value, "mixing character types is disallowed"); return val; } - FMT_CONSTEXPR float map(float val) { return val; } - FMT_CONSTEXPR double map(double val) { return val; } - FMT_CONSTEXPR long double map(long double val) { return val; } + UMPIRE_FMT_CONSTEXPR float map(float val) { return val; } + UMPIRE_FMT_CONSTEXPR double map(double val) { return val; } + UMPIRE_FMT_CONSTEXPR long double map(long double val) { return val; } - FMT_CONSTEXPR const char_type* map(char_type* val) { return val; } - FMT_CONSTEXPR const char_type* map(const char_type* val) { return val; } - template ::value)> - FMT_CONSTEXPR basic_string_view map(const T& val) { + UMPIRE_FMT_CONSTEXPR const char_type* map(char_type* val) { return val; } + UMPIRE_FMT_CONSTEXPR const char_type* map(const char_type* val) { return val; } + template ::value)> + UMPIRE_FMT_CONSTEXPR basic_string_view map(const T& val) { static_assert(std::is_same>::value, "mixing character types is disallowed"); return to_string_view(val); } template , T>::value && !is_string::value && !has_formatter::value && !has_fallback_formatter::value)> - FMT_CONSTEXPR basic_string_view map(const T& val) { + UMPIRE_FMT_CONSTEXPR basic_string_view map(const T& val) { return basic_string_view(val); } template < typename T, - FMT_ENABLE_IF( + UMPIRE_FMT_ENABLE_IF( std::is_constructible, T>::value && !std::is_constructible, T>::value && !is_string::value && !has_formatter::value && !has_fallback_formatter::value)> - FMT_CONSTEXPR basic_string_view map(const T& val) { + UMPIRE_FMT_CONSTEXPR basic_string_view map(const T& val) { return std_string_view(val); } - FMT_CONSTEXPR const char* map(const signed char* val) { + UMPIRE_FMT_CONSTEXPR const char* map(const signed char* val) { static_assert(std::is_same::value, "invalid string type"); return reinterpret_cast(val); } - FMT_CONSTEXPR const char* map(const unsigned char* val) { + UMPIRE_FMT_CONSTEXPR const char* map(const unsigned char* val) { static_assert(std::is_same::value, "invalid string type"); return reinterpret_cast(val); } - FMT_CONSTEXPR const char* map(signed char* val) { + UMPIRE_FMT_CONSTEXPR const char* map(signed char* val) { const auto* const_val = val; return map(const_val); } - FMT_CONSTEXPR const char* map(unsigned char* val) { + UMPIRE_FMT_CONSTEXPR const char* map(unsigned char* val) { const auto* const_val = val; return map(const_val); } - FMT_CONSTEXPR const void* map(void* val) { return val; } - FMT_CONSTEXPR const void* map(const void* val) { return val; } - FMT_CONSTEXPR const void* map(std::nullptr_t val) { return val; } + UMPIRE_FMT_CONSTEXPR const void* map(void* val) { return val; } + UMPIRE_FMT_CONSTEXPR const void* map(const void* val) { return val; } + UMPIRE_FMT_CONSTEXPR const void* map(std::nullptr_t val) { return val; } // We use SFINAE instead of a const T* parameter to avoid conflicting with // the C array overload. template - FMT_CONSTEXPR auto map(T) -> enable_if_t::value, int> { + UMPIRE_FMT_CONSTEXPR auto map(T) -> enable_if_t::value, int> { // Formatting of arbitrary pointers is disallowed. If you want to output // a pointer cast it to "void *" or "const void *". In particular, this // forbids formatting of "[const] volatile char *" which is printed as bool @@ -1227,29 +1227,29 @@ template struct arg_mapper { } template - FMT_CONSTEXPR auto map(const T (&values)[N]) -> const T (&)[N] { + UMPIRE_FMT_CONSTEXPR auto map(const T (&values)[N]) -> const T (&)[N] { return values; } template ::value && + UMPIRE_FMT_ENABLE_IF(std::is_enum::value && !has_formatter::value && !has_fallback_formatter::value)> - FMT_CONSTEXPR auto map(const T& val) + UMPIRE_FMT_CONSTEXPR auto map(const T& val) -> decltype(std::declval().map( static_cast::type>(val))) { return map(static_cast::type>(val)); } template ::value && !is_char::value && + UMPIRE_FMT_ENABLE_IF(!is_string::value && !is_char::value && (has_formatter::value || has_fallback_formatter::value))> - FMT_CONSTEXPR const T& map(const T& val) { + UMPIRE_FMT_CONSTEXPR const T& map(const T& val) { return val; } template - FMT_CONSTEXPR auto map(const named_arg& val) + UMPIRE_FMT_CONSTEXPR auto map(const named_arg& val) -> decltype(std::declval().map(val.value)) { return map(val.value); } @@ -1278,11 +1278,11 @@ template class basic_format_arg { detail::type type_; template - friend FMT_CONSTEXPR basic_format_arg detail::make_arg( + friend UMPIRE_FMT_CONSTEXPR basic_format_arg detail::make_arg( const T& value); template - friend FMT_CONSTEXPR auto visit_format_arg(Visitor&& vis, + friend UMPIRE_FMT_CONSTEXPR auto visit_format_arg(Visitor&& vis, const basic_format_arg& arg) -> decltype(vis(0)); @@ -1313,7 +1313,7 @@ template class basic_format_arg { constexpr basic_format_arg() : type_(detail::type::none_type) {} - constexpr explicit operator bool() const FMT_NOEXCEPT { + constexpr explicit operator bool() const UMPIRE_FMT_NOEXCEPT { return type_ != detail::type::none_type; } @@ -1331,7 +1331,7 @@ template class basic_format_arg { \endrst */ template -FMT_CONSTEXPR_DECL FMT_INLINE auto visit_format_arg( +UMPIRE_FMT_CONSTEXPR_DECL UMPIRE_FMT_INLINE auto visit_format_arg( Visitor&& vis, const basic_format_arg& arg) -> decltype(vis(0)) { using char_type = typename Context::char_type; switch (arg.type_) { @@ -1345,7 +1345,7 @@ FMT_CONSTEXPR_DECL FMT_INLINE auto visit_format_arg( return vis(arg.value_.long_long_value); case detail::type::ulong_long_type: return vis(arg.value_.ulong_long_value); -#if FMT_USE_INT128 +#if UMPIRE_FMT_USE_INT128 case detail::type::int128_type: return vis(arg.value_.int128_value); case detail::type::uint128_type: @@ -1382,7 +1382,7 @@ template struct formattable : std::false_type {}; namespace detail { -#if FMT_GCC_VERSION && FMT_GCC_VERSION < 500 +#if UMPIRE_FMT_GCC_VERSION && UMPIRE_FMT_GCC_VERSION < 500 // A workaround for gcc 4.8 to make void_t work in a SFINAE context. template struct void_t_impl { using type = void; }; template @@ -1425,7 +1425,7 @@ class locale_ref { constexpr locale_ref() : locale_(nullptr) {} template explicit locale_ref(const Locale& loc); - explicit operator bool() const FMT_NOEXCEPT { return locale_ != nullptr; } + explicit operator bool() const UMPIRE_FMT_NOEXCEPT { return locale_ != nullptr; } template Locale get() const; }; @@ -1439,7 +1439,7 @@ constexpr unsigned long long encode_types() { } template -FMT_CONSTEXPR basic_format_arg make_arg(const T& value) { +UMPIRE_FMT_CONSTEXPR basic_format_arg make_arg(const T& value) { basic_format_arg arg; arg.type_ = mapped_type_constant::value; arg.value_ = arg_mapper().map(value); @@ -1461,13 +1461,13 @@ template constexpr const U& check(const U& val) { // a fallback formatter in one translation unit and an implicit conversion in // another (not recommended). template + UMPIRE_FMT_ENABLE_IF(IS_PACKED)> constexpr value make_arg(const T& val) { return detail::check(arg_mapper().map(val)); } template + UMPIRE_FMT_ENABLE_IF(!IS_PACKED)> inline basic_format_arg make_arg(const T& value) { return make_arg(value); } @@ -1502,24 +1502,24 @@ template class basic_format_context { : out_(out), args_(ctx_args), loc_(loc) {} constexpr format_arg arg(int id) const { return args_.get(id); } - FMT_CONSTEXPR format_arg arg(basic_string_view name) { + UMPIRE_FMT_CONSTEXPR format_arg arg(basic_string_view name) { return args_.get(name); } int arg_id(basic_string_view name) { return args_.get_id(name); } const basic_format_args& args() const { return args_; } - FMT_CONSTEXPR detail::error_handler error_handler() { return {}; } + UMPIRE_FMT_CONSTEXPR detail::error_handler error_handler() { return {}; } void on_error(const char* message) { error_handler().on_error(message); } // Returns an iterator to the beginning of the output range. - FMT_CONSTEXPR iterator out() { return out_; } + UMPIRE_FMT_CONSTEXPR iterator out() { return out_; } // Advances the begin iterator to ``it``. void advance_to(iterator it) { if (!detail::is_back_insert_iterator()) out_ = it; } - FMT_CONSTEXPR detail::locale_ref locale() { return loc_; } + UMPIRE_FMT_CONSTEXPR detail::locale_ref locale() { return loc_; } }; template @@ -1529,7 +1529,7 @@ using format_context = buffer_context; using wformat_context = buffer_context; // Workaround an alias issue: https://stackoverflow.com/q/62767544/471164. -#define FMT_BUFFER_CONTEXT(Char) \ +#define UMPIRE_FMT_BUFFER_CONTEXT(Char) \ basic_format_context, Char> template @@ -1546,7 +1546,7 @@ using is_formattable = bool_constant class format_arg_store -#if FMT_GCC_VERSION && FMT_GCC_VERSION < 409 +#if UMPIRE_FMT_GCC_VERSION && UMPIRE_FMT_GCC_VERSION < 409 // Workaround a GCC template argument substitution bug. : public basic_format_args #endif @@ -1573,9 +1573,9 @@ class format_arg_store : 0); public: - FMT_CONSTEXPR format_arg_store(const Args&... args) + UMPIRE_FMT_CONSTEXPR format_arg_store(const Args&... args) : -#if FMT_GCC_VERSION && FMT_GCC_VERSION < 409 +#if UMPIRE_FMT_GCC_VERSION && UMPIRE_FMT_GCC_VERSION < 409 basic_format_args(*this), #endif data_{detail::make_arg< @@ -1675,7 +1675,7 @@ template class basic_format_args { return (desc_ & detail::has_named_args_bit) != 0; } - FMT_CONSTEXPR detail::type type(int index) const { + UMPIRE_FMT_CONSTEXPR detail::type type(int index) const { int shift = index * detail::packed_arg_bits; unsigned int mask = (1 << detail::packed_arg_bits) - 1; return static_cast((desc_ >> shift) & mask); @@ -1696,7 +1696,7 @@ template class basic_format_args { \endrst */ template - constexpr FMT_INLINE basic_format_args( + constexpr UMPIRE_FMT_INLINE basic_format_args( const format_arg_store& store) : basic_format_args(format_arg_store::desc, store.data_.args()) {} @@ -1707,7 +1707,7 @@ template class basic_format_args { `~umpire::fmt::dynamic_format_arg_store`. \endrst */ - constexpr FMT_INLINE basic_format_args( + constexpr UMPIRE_FMT_INLINE basic_format_args( const dynamic_format_arg_store& store) : basic_format_args(store.get_types(), store.data()) {} @@ -1721,7 +1721,7 @@ template class basic_format_args { args) {} /** Returns the argument with the specified id. */ - FMT_CONSTEXPR format_arg get(int id) const { + UMPIRE_FMT_CONSTEXPR format_arg get(int id) const { format_arg arg; if (!is_packed()) { if (id < max_size()) arg = args_[id]; @@ -1756,7 +1756,7 @@ template class basic_format_args { } }; -#ifdef FMT_ARM_ABI_COMPATIBILITY +#ifdef UMPIRE_FMT_ARM_ABI_COMPATIBILITY /** An alias to ``basic_format_args``. */ // Separate types would result in shorter symbols but break ABI compatibility // between clang and gcc on ARM (#1919). @@ -1767,7 +1767,7 @@ using wformat_args = basic_format_args; // It is a separate type rather than an alias to make symbols readable. struct format_args : basic_format_args { template - FMT_INLINE format_args(const Args&... args) : basic_format_args(args...) {} + UMPIRE_FMT_INLINE format_args(const Args&... args) : basic_format_args(args...) {} }; struct wformat_args : basic_format_args { using basic_format_args::basic_format_args; @@ -1776,24 +1776,24 @@ struct wformat_args : basic_format_args { namespace detail { -template ::value)> +template ::value)> std::basic_string vformat( basic_string_view format_str, basic_format_args>> args); -FMT_API std::string vformat(string_view format_str, format_args args); +UMPIRE_FMT_API std::string vformat(string_view format_str, format_args args); template void vformat_to( buffer& buf, basic_string_view format_str, - basic_format_args)> args, + basic_format_args)> args, detail::locale_ref loc = {}); template ::value)> + UMPIRE_FMT_ENABLE_IF(!std::is_same::value)> inline void vprint_mojibake(std::FILE*, basic_string_view, const Args&) {} -FMT_API void vprint_mojibake(std::FILE*, string_view, format_args); +UMPIRE_FMT_API void vprint_mojibake(std::FILE*, string_view, format_args); #ifndef _WIN32 inline void vprint_mojibake(std::FILE*, string_view, format_args) {} #endif @@ -1823,7 +1823,7 @@ auto vformat_to(OutputIt out, const S& format_str, umpire::fmt::format_to(std::back_inserter(out), "{}", 42); \endrst */ -// We cannot use FMT_ENABLE_IF because of a bug in gcc 8.3. +// We cannot use UMPIRE_FMT_ENABLE_IF because of a bug in gcc 8.3. template >::value> inline auto format_to(OutputIt out, const S& format_str, Args&&... args) -> @@ -1840,7 +1840,7 @@ template struct format_to_n_result { }; template ::value)> + UMPIRE_FMT_ENABLE_IF(detail::is_output_iterator::value)> inline format_to_n_result vformat_to_n( OutputIt out, size_t n, basic_string_view format_str, basic_format_args>> args) { @@ -1879,7 +1879,7 @@ inline size_t formatted_size(const S& format_str, Args&&... args) { } template > -FMT_INLINE std::basic_string vformat( +UMPIRE_FMT_INLINE std::basic_string vformat( const S& format_str, basic_format_args>> args) { return detail::vformat(to_string_view(format_str), args); @@ -1898,21 +1898,21 @@ FMT_INLINE std::basic_string vformat( // Pass char_t as a default template parameter instead of using // std::basic_string> to reduce the symbol size. template , - FMT_ENABLE_IF(!FMT_COMPILE_TIME_CHECKS || + UMPIRE_FMT_ENABLE_IF(!UMPIRE_FMT_COMPILE_TIME_CHECKS || !std::is_same::value)> -FMT_INLINE std::basic_string format(const S& format_str, Args&&... args) { +UMPIRE_FMT_INLINE std::basic_string format(const S& format_str, Args&&... args) { const auto& vargs = umpire::fmt::make_args_checked(format_str, args...); return detail::vformat(to_string_view(format_str), vargs); } -FMT_API void vprint(string_view, format_args); -FMT_API void vprint(std::FILE*, string_view, format_args); +UMPIRE_FMT_API void vprint(string_view, format_args); +UMPIRE_FMT_API void vprint(std::FILE*, string_view, format_args); /** \rst Formats ``args`` according to specifications in ``format_str`` and writes the output to the file ``f``. Strings are assumed to be Unicode-encoded unless the - ``FMT_UNICODE`` macro is set to 0. + ``UMPIRE_FMT_UNICODE`` macro is set to 0. **Example**:: @@ -1931,7 +1931,7 @@ inline void print(std::FILE* f, const S& format_str, Args&&... args) { \rst Formats ``args`` according to specifications in ``format_str`` and writes the output to ``stdout``. Strings are assumed to be Unicode-encoded unless - the ``FMT_UNICODE`` macro is set to 0. + the ``UMPIRE_FMT_UNICODE`` macro is set to 0. **Example**:: @@ -1946,12 +1946,12 @@ inline void print(const S& format_str, Args&&... args) { : detail::vprint_mojibake(stdout, to_string_view(format_str), vargs); } -FMT_END_NAMESPACE +UMPIRE_FMT_END_NAMESPACE -#endif // FMT_CORE_H_ +#endif // UMPIRE_FMT_CORE_H_ -// Define FMT_DYNAMIC_ARGS to make core.h provide dynamic_format_arg_store +// Define UMPIRE_FMT_DYNAMIC_ARGS to make core.h provide dynamic_format_arg_store // DEPRECATED! Include fmt/args.h directly instead. -#ifdef FMT_DYNAMIC_ARGS +#ifdef UMPIRE_FMT_DYNAMIC_ARGS #include "args.h" #endif diff --git a/src/tpl/umpire/fmt/fmt.hpp b/src/tpl/umpire/fmt/fmt.hpp index 6a9e70f42..a1d92bb63 100644 --- a/src/tpl/umpire/fmt/fmt.hpp +++ b/src/tpl/umpire/fmt/fmt.hpp @@ -6,9 +6,9 @@ #ifndef UMPIRE_fmt_HPP #define UMPIRE_fmt_HPP -#define FMT_EXCEPTIONS 0 -#define FMT_HEADER_ONLY 1 -#define FMT_DEPRECATED +#define UMPIRE_FMT_EXCEPTIONS 0 +#define UMPIRE_FMT_HEADER_ONLY 1 +#define UMPIRE_FMT_DEPRECATED #include "args.h" #include "chrono.h" diff --git a/src/tpl/umpire/fmt/format-inl.h b/src/tpl/umpire/fmt/format-inl.h index 568f17db5..0a76aa784 100644 --- a/src/tpl/umpire/fmt/format-inl.h +++ b/src/tpl/umpire/fmt/format-inl.h @@ -5,8 +5,8 @@ // // For the license information refer to format.h. -#ifndef FMT_FORMAT_INL_H_ -#define FMT_FORMAT_INL_H_ +#ifndef UMPIRE_FMT_FORMAT_INL_H_ +#define UMPIRE_FMT_FORMAT_INL_H_ #include #include @@ -17,7 +17,7 @@ #include #include -#ifndef FMT_STATIC_THOUSANDS_SEPARATOR +#ifndef UMPIRE_FMT_STATIC_THOUSANDS_SEPARATOR # include #endif @@ -32,10 +32,10 @@ inline umpire::fmt::detail::null<> strerror_r(int, char*, ...) { return {}; } inline umpire::fmt::detail::null<> strerror_s(char*, size_t, ...) { return {}; } -FMT_BEGIN_NAMESPACE +UMPIRE_FMT_BEGIN_NAMESPACE namespace detail { -FMT_FUNC void assert_fail(const char* file, int line, const char* message) { +UMPIRE_FMT_FUNC void assert_fail(const char* file, int line, const char* message) { // Use unchecked std::fprintf to avoid triggering another assertion when // writing to stderr fails std::fprintf(stderr, "%s:%d: assertion failed: %s", file, line, message); @@ -45,7 +45,7 @@ FMT_FUNC void assert_fail(const char* file, int line, const char* message) { } #ifndef _MSC_VER -# define FMT_SNPRINTF snprintf +# define UMPIRE_FMT_SNPRINTF snprintf #else // _MSC_VER inline int fmt_snprintf(char* buffer, size_t size, const char* format, ...) { va_list args; @@ -54,7 +54,7 @@ inline int fmt_snprintf(char* buffer, size_t size, const char* format, ...) { va_end(args); return result; } -# define FMT_SNPRINTF fmt_snprintf +# define UMPIRE_FMT_SNPRINTF fmt_snprintf #endif // _MSC_VER // A portable thread-safe version of strerror. @@ -67,8 +67,8 @@ inline int fmt_snprintf(char* buffer, size_t size, const char* format, ...) { // other - failure // Buffer should be at least of size 1. inline int safe_strerror(int error_code, char*& buffer, - size_t buffer_size) FMT_NOEXCEPT { - FMT_ASSERT(buffer != nullptr && buffer_size != 0, "invalid buffer"); + size_t buffer_size) UMPIRE_FMT_NOEXCEPT { + UMPIRE_FMT_ASSERT(buffer != nullptr && buffer_size != 0, "invalid buffer"); class dispatcher { private: @@ -86,7 +86,7 @@ inline int safe_strerror(int error_code, char*& buffer, } // Handle the result of GNU-specific version of strerror_r. - FMT_MAYBE_UNUSED + UMPIRE_FMT_MAYBE_UNUSED int handle(char* message) { // If the buffer is full then the message is probably truncated. if (message == buffer_ && strlen(buffer_) == buffer_size_ - 1) @@ -96,20 +96,20 @@ inline int safe_strerror(int error_code, char*& buffer, } // Handle the case when strerror_r is not available. - FMT_MAYBE_UNUSED + UMPIRE_FMT_MAYBE_UNUSED int handle(detail::null<>) { return fallback(strerror_s(buffer_, buffer_size_, error_code_)); } // Fallback to strerror_s when strerror_r is not available. - FMT_MAYBE_UNUSED + UMPIRE_FMT_MAYBE_UNUSED int fallback(int result) { // If the buffer is full then the message is probably truncated. return result == 0 && strlen(buffer_) == buffer_size_ - 1 ? ERANGE : result; } -#if !FMT_MSC_VER +#if !UMPIRE_FMT_MSC_VER // Fallback to strerror if strerror_r and strerror_s are not available. int fallback(detail::null<>) { errno = 0; @@ -127,8 +127,8 @@ inline int safe_strerror(int error_code, char*& buffer, return dispatcher(error_code, buffer, buffer_size).run(); } -FMT_FUNC void format_error_code(detail::buffer& out, int error_code, - string_view message) FMT_NOEXCEPT { +UMPIRE_FMT_FUNC void format_error_code(detail::buffer& out, int error_code, + string_view message) UMPIRE_FMT_NOEXCEPT { // Report error code making sure that the output fits into // inline_buffer_size to avoid dynamic memory allocation and potential // bad_alloc. @@ -145,13 +145,13 @@ FMT_FUNC void format_error_code(detail::buffer& out, int error_code, error_code_size += detail::to_unsigned(detail::count_digits(abs_value)); auto it = buffer_appender(out); if (message.size() <= inline_buffer_size - error_code_size) - format_to(it, FMT_STRING("{}{}"), message, SEP); - format_to(it, FMT_STRING("{}{}"), ERROR_STR, error_code); - FMT_ASSERT(out.size() <= inline_buffer_size, ""); + format_to(it, UMPIRE_FMT_STRING("{}{}"), message, SEP); + format_to(it, UMPIRE_FMT_STRING("{}{}"), ERROR_STR, error_code); + UMPIRE_FMT_ASSERT(out.size() <= inline_buffer_size, ""); } -FMT_FUNC void report_error(format_func func, int error_code, - string_view message) FMT_NOEXCEPT { +UMPIRE_FMT_FUNC void report_error(format_func func, int error_code, + string_view message) UMPIRE_FMT_NOEXCEPT { memory_buffer full_message; func(full_message, error_code, message); // Don't use fwrite_fully because the latter may throw. @@ -163,10 +163,10 @@ FMT_FUNC void report_error(format_func func, int error_code, inline void fwrite_fully(const void* ptr, size_t size, size_t count, FILE* stream) { size_t written = std::fwrite(ptr, size, count, stream); - if (written < count) FMT_THROW(system_error(errno, "cannot write to file")); + if (written < count) UMPIRE_FMT_THROW(system_error(errno, "cannot write to file")); } -#ifndef FMT_STATIC_THOUSANDS_SEPARATOR +#ifndef UMPIRE_FMT_STATIC_THOUSANDS_SEPARATOR template locale_ref::locale_ref(const Locale& loc) : locale_(&loc) { static_assert(std::is_same::value, ""); @@ -177,34 +177,34 @@ template Locale locale_ref::get() const { return locale_ ? *static_cast(locale_) : std::locale(); } -template FMT_FUNC std::string grouping_impl(locale_ref loc) { +template UMPIRE_FMT_FUNC std::string grouping_impl(locale_ref loc) { return std::use_facet>(loc.get()).grouping(); } -template FMT_FUNC Char thousands_sep_impl(locale_ref loc) { +template UMPIRE_FMT_FUNC Char thousands_sep_impl(locale_ref loc) { return std::use_facet>(loc.get()) .thousands_sep(); } -template FMT_FUNC Char decimal_point_impl(locale_ref loc) { +template UMPIRE_FMT_FUNC Char decimal_point_impl(locale_ref loc) { return std::use_facet>(loc.get()) .decimal_point(); } #else -template FMT_FUNC std::string grouping_impl(locale_ref) { +template UMPIRE_FMT_FUNC std::string grouping_impl(locale_ref) { return "\03"; } -template FMT_FUNC Char thousands_sep_impl(locale_ref) { - return FMT_STATIC_THOUSANDS_SEPARATOR; +template UMPIRE_FMT_FUNC Char thousands_sep_impl(locale_ref) { + return UMPIRE_FMT_STATIC_THOUSANDS_SEPARATOR; } -template FMT_FUNC Char decimal_point_impl(locale_ref) { +template UMPIRE_FMT_FUNC Char decimal_point_impl(locale_ref) { return '.'; } #endif } // namespace detail -FMT_API FMT_FUNC format_error::~format_error() FMT_NOEXCEPT = default; -FMT_API FMT_FUNC system_error::~system_error() FMT_NOEXCEPT = default; +UMPIRE_FMT_API UMPIRE_FMT_FUNC format_error::~format_error() UMPIRE_FMT_NOEXCEPT = default; +UMPIRE_FMT_API UMPIRE_FMT_FUNC system_error::~system_error() UMPIRE_FMT_NOEXCEPT = default; -FMT_FUNC void system_error::init(int err_code, string_view format_str, +UMPIRE_FMT_FUNC void system_error::init(int err_code, string_view format_str, format_args args) { error_code_ = err_code; memory_buffer buffer; @@ -215,7 +215,7 @@ FMT_FUNC void system_error::init(int err_code, string_view format_str, namespace detail { -template <> FMT_FUNC int count_digits<4>(detail::fallback_uintptr n) { +template <> UMPIRE_FMT_FUNC int count_digits<4>(detail::fallback_uintptr n) { // fallback_uintptr is always stored in little endian. int i = static_cast(sizeof(void*)) - 1; while (i > 0 && n.value[i] == 0) --i; @@ -243,31 +243,31 @@ const typename basic_data::digit_pair basic_data::digits[] = { {'9', '0'}, {'9', '1'}, {'9', '2'}, {'9', '3'}, {'9', '4'}, {'9', '5'}, {'9', '6'}, {'9', '7'}, {'9', '8'}, {'9', '9'}}; -#define FMT_POWERS_OF_10(factor) \ +#define UMPIRE_FMT_POWERS_OF_10(factor) \ factor * 10, (factor)*100, (factor)*1000, (factor)*10000, (factor)*100000, \ (factor)*1000000, (factor)*10000000, (factor)*100000000, \ (factor)*1000000000 template const uint64_t basic_data::powers_of_10_64[] = { - 1, FMT_POWERS_OF_10(1), FMT_POWERS_OF_10(1000000000ULL), + 1, UMPIRE_FMT_POWERS_OF_10(1), UMPIRE_FMT_POWERS_OF_10(1000000000ULL), 10000000000000000000ULL}; template const uint32_t basic_data::zero_or_powers_of_10_32[] = {0, - FMT_POWERS_OF_10(1)}; + UMPIRE_FMT_POWERS_OF_10(1)}; template const uint64_t basic_data::zero_or_powers_of_10_64[] = { - 0, FMT_POWERS_OF_10(1), FMT_POWERS_OF_10(1000000000ULL), + 0, UMPIRE_FMT_POWERS_OF_10(1), UMPIRE_FMT_POWERS_OF_10(1000000000ULL), 10000000000000000000ULL}; template const uint32_t basic_data::zero_or_powers_of_10_32_new[] = { - 0, 0, FMT_POWERS_OF_10(1)}; + 0, 0, UMPIRE_FMT_POWERS_OF_10(1)}; template const uint64_t basic_data::zero_or_powers_of_10_64_new[] = { - 0, 0, FMT_POWERS_OF_10(1), FMT_POWERS_OF_10(1000000000ULL), + 0, 0, UMPIRE_FMT_POWERS_OF_10(1), UMPIRE_FMT_POWERS_OF_10(1000000000ULL), 10000000000000000000ULL}; // Normalized 64-bit significands of pow(10, k), for k = -348, -340, ..., 340. @@ -385,7 +385,7 @@ const uint64_t basic_data::dragonbox_pow10_significands_64[] = { template const uint128_wrapper basic_data::dragonbox_pow10_significands_128[] = { -#if FMT_USE_FULL_CACHE_DRAGONBOX +#if UMPIRE_FMT_USE_FULL_CACHE_DRAGONBOX {0xff77b1fcbebcdc4f, 0x25e8e89c13bb0f7b}, {0x9faacf3df73609b1, 0x77b191618c54e9ad}, {0xc795830d75038c1d, 0xd59df5b9ef6a2418}, @@ -1032,7 +1032,7 @@ const uint128_wrapper basic_data::dragonbox_pow10_significands_128[] = { #endif }; -#if !FMT_USE_FULL_CACHE_DRAGONBOX +#if !UMPIRE_FMT_USE_FULL_CACHE_DRAGONBOX template const uint64_t basic_data::powers_of_5_64[] = { 0x0000000000000001, 0x0000000000000005, 0x0000000000000019, @@ -1073,7 +1073,7 @@ constexpr const char basic_data::right_padding_shifts[]; #endif template struct bits { - static FMT_CONSTEXPR_DECL const int value = + static UMPIRE_FMT_CONSTEXPR_DECL const int value = static_cast(sizeof(T) * std::numeric_limits::digits); }; @@ -1104,11 +1104,11 @@ class fp { // All sizes are in bits. // Subtract 1 to account for an implicit most significant bit in the // normalized form. - static FMT_CONSTEXPR_DECL const int double_significand_size = + static UMPIRE_FMT_CONSTEXPR_DECL const int double_significand_size = std::numeric_limits::digits - 1; - static FMT_CONSTEXPR_DECL const uint64_t implicit_bit = + static UMPIRE_FMT_CONSTEXPR_DECL const uint64_t implicit_bit = 1ULL << double_significand_size; - static FMT_CONSTEXPR_DECL const int significand_size = + static UMPIRE_FMT_CONSTEXPR_DECL const int significand_size = bits::value; fp() : f(0), e(0) {} @@ -1119,7 +1119,7 @@ class fp { template explicit fp(Double d) { assign(d); } // Assigns d to this and return true iff predecessor is closer than successor. - template ::value)> + template ::value)> bool assign(Float d) { // Assume float is in the format [sign][exponent][significand]. using limits = std::numeric_limits; @@ -1146,7 +1146,7 @@ class fp { return is_predecessor_closer; } - template ::value)> + template ::value)> bool assign(Float) { *this = fp(); return false; @@ -1173,7 +1173,7 @@ inline bool operator==(fp x, fp y) { return x.f == y.f && x.e == y.e; } // Computes lhs * rhs / pow(2, 64) rounded to nearest with half-up tie breaking. inline uint64_t multiply(uint64_t lhs, uint64_t rhs) { -#if FMT_USE_INT128 +#if UMPIRE_FMT_USE_INT128 auto product = static_cast<__uint128_t>(lhs) * rhs; auto f = static_cast(product >> 64); return (static_cast(product) & (1ULL << 63)) != 0 ? f + 1 : f; @@ -1225,7 +1225,7 @@ struct accumulator { if (lower < n) ++upper; } void operator>>=(int shift) { - FMT_ASSERT(shift == 32, ""); + UMPIRE_FMT_ASSERT(shift == 32, ""); (void)shift; lower = (upper << 32) | (lower >> 32); upper >>= 32; @@ -1245,7 +1245,7 @@ class bigint { bigit operator[](int index) const { return bigits_[to_unsigned(index)]; } bigit& operator[](int index) { return bigits_[to_unsigned(index)]; } - static FMT_CONSTEXPR_DECL const int bigit_bits = bits::value; + static UMPIRE_FMT_CONSTEXPR_DECL const int bigit_bits = bits::value; friend struct formatter; @@ -1263,8 +1263,8 @@ class bigint { // Computes *this -= other assuming aligned bigints and *this >= other. void subtract_aligned(const bigint& other) { - FMT_ASSERT(other.exp_ >= exp_, "unaligned bigints"); - FMT_ASSERT(compare(*this, other) >= 0, ""); + UMPIRE_FMT_ASSERT(other.exp_ >= exp_, "unaligned bigints"); + UMPIRE_FMT_ASSERT(compare(*this, other) >= 0, ""); bigit borrow = 0; int i = other.exp_ - exp_; for (size_t j = 0, n = other.bigits_.size(); j != n; ++i, ++j) @@ -1304,7 +1304,7 @@ class bigint { public: bigint() : exp_(0) {} explicit bigint(uint64_t n) { assign(n); } - ~bigint() { FMT_ASSERT(bigits_.capacity() <= bigits_capacity, ""); } + ~bigint() { UMPIRE_FMT_ASSERT(bigits_.capacity() <= bigits_capacity, ""); } bigint(const bigint&) = delete; void operator=(const bigint&) = delete; @@ -1329,8 +1329,8 @@ class bigint { int num_bigits() const { return static_cast(bigits_.size()) + exp_; } - FMT_NOINLINE bigint& operator<<=(int shift) { - FMT_ASSERT(shift >= 0, ""); + UMPIRE_FMT_NOINLINE bigint& operator<<=(int shift) { + UMPIRE_FMT_ASSERT(shift >= 0, ""); exp_ += shift / bigit_bits; shift %= bigit_bits; if (shift == 0) return *this; @@ -1345,7 +1345,7 @@ class bigint { } template bigint& operator*=(Int value) { - FMT_ASSERT(value > 0, ""); + UMPIRE_FMT_ASSERT(value > 0, ""); multiply(uint32_or_64_or_128_t(value)); return *this; } @@ -1392,7 +1392,7 @@ class bigint { // Assigns pow(10, exp) to this bigint. void assign_pow10(int exp) { - FMT_ASSERT(exp >= 0, ""); + UMPIRE_FMT_ASSERT(exp >= 0, ""); if (exp == 0) return assign(1); // Find the top bit. int bitmask = 1; @@ -1415,7 +1415,7 @@ class bigint { int num_bigits = static_cast(bigits_.size()); int num_result_bigits = 2 * num_bigits; bigits_.resize(to_unsigned(num_result_bigits)); - using accumulator_t = conditional_t; + using accumulator_t = conditional_t; auto sum = accumulator_t(); for (int bigit_index = 0; bigit_index < num_bigits; ++bigit_index) { // Compute bigit at position bigit_index of the result by adding @@ -1456,9 +1456,9 @@ class bigint { // Divides this bignum by divisor, assigning the remainder to this and // returning the quotient. int divmod_assign(const bigint& divisor) { - FMT_ASSERT(this != &divisor, ""); + UMPIRE_FMT_ASSERT(this != &divisor, ""); if (compare(*this, divisor) < 0) return 0; - FMT_ASSERT(divisor.bigits_[divisor.bigits_.size() - 1u] != 0, ""); + UMPIRE_FMT_ASSERT(divisor.bigits_[divisor.bigits_.size() - 1u] != 0, ""); align(divisor); int quotient = 0; do { @@ -1477,9 +1477,9 @@ enum class round_direction { unknown, up, down }; // error should be less than divisor / 2. inline round_direction get_round_direction(uint64_t divisor, uint64_t remainder, uint64_t error) { - FMT_ASSERT(remainder < divisor, ""); // divisor - remainder won't overflow. - FMT_ASSERT(error < divisor, ""); // divisor - error won't overflow. - FMT_ASSERT(error < divisor - error, ""); // error * 2 won't overflow. + UMPIRE_FMT_ASSERT(remainder < divisor, ""); // divisor - remainder won't overflow. + UMPIRE_FMT_ASSERT(error < divisor, ""); // divisor - error won't overflow. + UMPIRE_FMT_ASSERT(error < divisor - error, ""); // error * 2 won't overflow. // Round down if (remainder + error) * 2 <= divisor. if (remainder <= divisor - remainder && error * 2 <= divisor - remainder * 2) return round_direction::down; @@ -1503,15 +1503,15 @@ enum result { // error: the size of the region (lower, upper) outside of which numbers // definitely do not round to value (Delta in Grisu3). template -FMT_ALWAYS_INLINE digits::result grisu_gen_digits(fp value, uint64_t error, +UMPIRE_FMT_ALWAYS_INLINE digits::result grisu_gen_digits(fp value, uint64_t error, int& exp, Handler& handler) { const fp one(1ULL << -value.e, value.e); // The integral part of scaled value (p1 in Grisu) = value / one. It cannot be // zero because it contains a product of two 64-bit numbers with MSB set (due // to normalization) - 1, shifted right by at most 60 bits. auto integral = static_cast(value.f >> -one.e); - FMT_ASSERT(integral != 0, ""); - FMT_ASSERT(integral == value.f >> -one.e, ""); + UMPIRE_FMT_ASSERT(integral != 0, ""); + UMPIRE_FMT_ASSERT(integral == value.f >> -one.e, ""); // The fractional part of scaled value (p2 in Grisu) c = value % one. uint64_t fractional = value.f & (one.f - 1); exp = count_digits(integral); // kappa in Grisu. @@ -1561,7 +1561,7 @@ FMT_ALWAYS_INLINE digits::result grisu_gen_digits(fp value, uint64_t error, integral = 0; break; default: - FMT_ASSERT(false, "invalid number of digits"); + UMPIRE_FMT_ASSERT(false, "invalid number of digits"); } --exp; auto remainder = (static_cast(integral) << -one.e) + fractional; @@ -1609,7 +1609,7 @@ struct fixed_handler { digits::result on_digit(char digit, uint64_t divisor, uint64_t remainder, uint64_t error, int, bool integral) { - FMT_ASSERT(remainder < divisor, ""); + UMPIRE_FMT_ASSERT(remainder < divisor, ""); buf[size++] = digit; if (!integral && error >= remainder) return digits::error; if (size < precision) return digits::more; @@ -1619,7 +1619,7 @@ struct fixed_handler { // and divisor > (1 << 32) there. if (error >= divisor || error >= divisor - error) return digits::error; } else { - FMT_ASSERT(error == 1 && divisor > 2, ""); + UMPIRE_FMT_ASSERT(error == 1 && divisor > 2, ""); } auto dir = get_round_direction(divisor, remainder, error); if (dir != round_direction::up) @@ -1643,8 +1643,8 @@ struct fixed_handler { // Implementation of Dragonbox algorithm: https://github.com/jk-jeon/dragonbox. namespace dragonbox { // Computes 128-bit result of multiplication of two 64-bit unsigned integers. -inline uint128_wrapper umul128(uint64_t x, uint64_t y) FMT_NOEXCEPT { -#if FMT_USE_INT128 +inline uint128_wrapper umul128(uint64_t x, uint64_t y) UMPIRE_FMT_NOEXCEPT { +#if UMPIRE_FMT_USE_INT128 return static_cast(x) * static_cast(y); #elif defined(_MSC_VER) && defined(_M_X64) uint128_wrapper result; @@ -1671,8 +1671,8 @@ inline uint128_wrapper umul128(uint64_t x, uint64_t y) FMT_NOEXCEPT { } // Computes upper 64 bits of multiplication of two 64-bit unsigned integers. -inline uint64_t umul128_upper64(uint64_t x, uint64_t y) FMT_NOEXCEPT { -#if FMT_USE_INT128 +inline uint64_t umul128_upper64(uint64_t x, uint64_t y) UMPIRE_FMT_NOEXCEPT { +#if UMPIRE_FMT_USE_INT128 auto p = static_cast(x) * static_cast(y); return static_cast(p >> 64); #elif defined(_MSC_VER) && defined(_M_X64) @@ -1684,7 +1684,7 @@ inline uint64_t umul128_upper64(uint64_t x, uint64_t y) FMT_NOEXCEPT { // Computes upper 64 bits of multiplication of a 64-bit unsigned integer and a // 128-bit unsigned integer. -inline uint64_t umul192_upper64(uint64_t x, uint128_wrapper y) FMT_NOEXCEPT { +inline uint64_t umul192_upper64(uint64_t x, uint128_wrapper y) UMPIRE_FMT_NOEXCEPT { uint128_wrapper g0 = umul128(x, y.high()); g0 += umul128_upper64(x, y.low()); return g0.high(); @@ -1692,13 +1692,13 @@ inline uint64_t umul192_upper64(uint64_t x, uint128_wrapper y) FMT_NOEXCEPT { // Computes upper 32 bits of multiplication of a 32-bit unsigned integer and a // 64-bit unsigned integer. -inline uint32_t umul96_upper32(uint32_t x, uint64_t y) FMT_NOEXCEPT { +inline uint32_t umul96_upper32(uint32_t x, uint64_t y) UMPIRE_FMT_NOEXCEPT { return static_cast(umul128_upper64(x, y)); } // Computes middle 64 bits of multiplication of a 64-bit unsigned integer and a // 128-bit unsigned integer. -inline uint64_t umul192_middle64(uint64_t x, uint128_wrapper y) FMT_NOEXCEPT { +inline uint64_t umul192_middle64(uint64_t x, uint128_wrapper y) UMPIRE_FMT_NOEXCEPT { uint64_t g01 = x * y.high(); uint64_t g10 = umul128_upper64(x, y.low()); return g01 + g10; @@ -1706,22 +1706,22 @@ inline uint64_t umul192_middle64(uint64_t x, uint128_wrapper y) FMT_NOEXCEPT { // Computes lower 64 bits of multiplication of a 32-bit unsigned integer and a // 64-bit unsigned integer. -inline uint64_t umul96_lower64(uint32_t x, uint64_t y) FMT_NOEXCEPT { +inline uint64_t umul96_lower64(uint32_t x, uint64_t y) UMPIRE_FMT_NOEXCEPT { return x * y; } // Computes floor(log10(pow(2, e))) for e in [-1700, 1700] using the method from // https://fmt.dev/papers/Grisu-Exact.pdf#page=5, section 3.4. -inline int floor_log10_pow2(int e) FMT_NOEXCEPT { - FMT_ASSERT(e <= 1700 && e >= -1700, "too large exponent"); +inline int floor_log10_pow2(int e) UMPIRE_FMT_NOEXCEPT { + UMPIRE_FMT_ASSERT(e <= 1700 && e >= -1700, "too large exponent"); const int shift = 22; return (e * static_cast(data::log10_2_significand >> (64 - shift))) >> shift; } // Various fast log computations. -inline int floor_log2_pow10(int e) FMT_NOEXCEPT { - FMT_ASSERT(e <= 1233 && e >= -1233, "too large exponent"); +inline int floor_log2_pow10(int e) UMPIRE_FMT_NOEXCEPT { + UMPIRE_FMT_ASSERT(e <= 1233 && e >= -1233, "too large exponent"); const uint64_t log2_10_integer_part = 3; const uint64_t log2_10_fractional_digits = 0x5269e12f346e2bf9; const int shift_amount = 19; @@ -1730,8 +1730,8 @@ inline int floor_log2_pow10(int e) FMT_NOEXCEPT { (log2_10_fractional_digits >> (64 - shift_amount)))) >> shift_amount; } -inline int floor_log10_pow2_minus_log10_4_over_3(int e) FMT_NOEXCEPT { - FMT_ASSERT(e <= 1700 && e >= -1700, "too large exponent"); +inline int floor_log10_pow2_minus_log10_4_over_3(int e) UMPIRE_FMT_NOEXCEPT { + UMPIRE_FMT_ASSERT(e <= 1700 && e >= -1700, "too large exponent"); const uint64_t log10_4_over_3_fractional_digits = 0x1ffbfc2bbc780375; const int shift_amount = 22; return (e * static_cast(data::log10_2_significand >> @@ -1742,33 +1742,33 @@ inline int floor_log10_pow2_minus_log10_4_over_3(int e) FMT_NOEXCEPT { } // Returns true iff x is divisible by pow(2, exp). -inline bool divisible_by_power_of_2(uint32_t x, int exp) FMT_NOEXCEPT { - FMT_ASSERT(exp >= 1, ""); - FMT_ASSERT(x != 0, ""); -#ifdef FMT_BUILTIN_CTZ - return FMT_BUILTIN_CTZ(x) >= exp; +inline bool divisible_by_power_of_2(uint32_t x, int exp) UMPIRE_FMT_NOEXCEPT { + UMPIRE_FMT_ASSERT(exp >= 1, ""); + UMPIRE_FMT_ASSERT(x != 0, ""); +#ifdef UMPIRE_FMT_BUILTIN_CTZ + return UMPIRE_FMT_BUILTIN_CTZ(x) >= exp; #else return exp < num_bits() && x == ((x >> exp) << exp); #endif } -inline bool divisible_by_power_of_2(uint64_t x, int exp) FMT_NOEXCEPT { - FMT_ASSERT(exp >= 1, ""); - FMT_ASSERT(x != 0, ""); -#ifdef FMT_BUILTIN_CTZLL - return FMT_BUILTIN_CTZLL(x) >= exp; +inline bool divisible_by_power_of_2(uint64_t x, int exp) UMPIRE_FMT_NOEXCEPT { + UMPIRE_FMT_ASSERT(exp >= 1, ""); + UMPIRE_FMT_ASSERT(x != 0, ""); +#ifdef UMPIRE_FMT_BUILTIN_CTZLL + return UMPIRE_FMT_BUILTIN_CTZLL(x) >= exp; #else return exp < num_bits() && x == ((x >> exp) << exp); #endif } // Returns true iff x is divisible by pow(5, exp). -inline bool divisible_by_power_of_5(uint32_t x, int exp) FMT_NOEXCEPT { - FMT_ASSERT(exp <= 10, "too large exponent"); +inline bool divisible_by_power_of_5(uint32_t x, int exp) UMPIRE_FMT_NOEXCEPT { + UMPIRE_FMT_ASSERT(exp <= 10, "too large exponent"); return x * data::divtest_table_for_pow5_32[exp].mod_inv <= data::divtest_table_for_pow5_32[exp].max_quotient; } -inline bool divisible_by_power_of_5(uint64_t x, int exp) FMT_NOEXCEPT { - FMT_ASSERT(exp <= 23, "too large exponent"); +inline bool divisible_by_power_of_5(uint64_t x, int exp) UMPIRE_FMT_NOEXCEPT { + UMPIRE_FMT_ASSERT(exp <= 23, "too large exponent"); return x * data::divtest_table_for_pow5_64[exp].mod_inv <= data::divtest_table_for_pow5_64[exp].max_quotient; } @@ -1777,7 +1777,7 @@ inline bool divisible_by_power_of_5(uint64_t x, int exp) FMT_NOEXCEPT { // divisible by pow(5, N). // Precondition: n <= 2 * pow(5, N + 1). template -bool check_divisibility_and_divide_by_pow5(uint32_t& n) FMT_NOEXCEPT { +bool check_divisibility_and_divide_by_pow5(uint32_t& n) UMPIRE_FMT_NOEXCEPT { static constexpr struct { uint32_t magic_number; int bits_for_comparison; @@ -1794,23 +1794,23 @@ bool check_divisibility_and_divide_by_pow5(uint32_t& n) FMT_NOEXCEPT { // Computes floor(n / pow(10, N)) for small n and N. // Precondition: n <= pow(10, N + 1). -template uint32_t small_division_by_pow10(uint32_t n) FMT_NOEXCEPT { +template uint32_t small_division_by_pow10(uint32_t n) UMPIRE_FMT_NOEXCEPT { static constexpr struct { uint32_t magic_number; int shift_amount; uint32_t divisor_times_10; } infos[] = {{0xcccd, 19, 100}, {0xa3d8, 22, 1000}}; constexpr auto info = infos[N - 1]; - FMT_ASSERT(n <= info.divisor_times_10, "n is too large"); + UMPIRE_FMT_ASSERT(n <= info.divisor_times_10, "n is too large"); return n * info.magic_number >> info.shift_amount; } // Computes floor(n / 10^(kappa + 1)) (float) -inline uint32_t divide_by_10_to_kappa_plus_1(uint32_t n) FMT_NOEXCEPT { +inline uint32_t divide_by_10_to_kappa_plus_1(uint32_t n) UMPIRE_FMT_NOEXCEPT { return n / float_info::big_divisor; } // Computes floor(n / 10^(kappa + 1)) (double) -inline uint64_t divide_by_10_to_kappa_plus_1(uint64_t n) FMT_NOEXCEPT { +inline uint64_t divide_by_10_to_kappa_plus_1(uint64_t n) UMPIRE_FMT_NOEXCEPT { return umul128_upper64(n, 0x83126e978d4fdf3c) >> 9; } @@ -1821,47 +1821,47 @@ template <> struct cache_accessor { using carrier_uint = float_info::carrier_uint; using cache_entry_type = uint64_t; - static uint64_t get_cached_power(int k) FMT_NOEXCEPT { - FMT_ASSERT(k >= float_info::min_k && k <= float_info::max_k, + static uint64_t get_cached_power(int k) UMPIRE_FMT_NOEXCEPT { + UMPIRE_FMT_ASSERT(k >= float_info::min_k && k <= float_info::max_k, "k is out of range"); return data::dragonbox_pow10_significands_64[k - float_info::min_k]; } static carrier_uint compute_mul(carrier_uint u, - const cache_entry_type& cache) FMT_NOEXCEPT { + const cache_entry_type& cache) UMPIRE_FMT_NOEXCEPT { return umul96_upper32(u, cache); } static uint32_t compute_delta(const cache_entry_type& cache, - int beta_minus_1) FMT_NOEXCEPT { + int beta_minus_1) UMPIRE_FMT_NOEXCEPT { return static_cast(cache >> (64 - 1 - beta_minus_1)); } static bool compute_mul_parity(carrier_uint two_f, const cache_entry_type& cache, - int beta_minus_1) FMT_NOEXCEPT { - FMT_ASSERT(beta_minus_1 >= 1, ""); - FMT_ASSERT(beta_minus_1 < 64, ""); + int beta_minus_1) UMPIRE_FMT_NOEXCEPT { + UMPIRE_FMT_ASSERT(beta_minus_1 >= 1, ""); + UMPIRE_FMT_ASSERT(beta_minus_1 < 64, ""); return ((umul96_lower64(two_f, cache) >> (64 - beta_minus_1)) & 1) != 0; } static carrier_uint compute_left_endpoint_for_shorter_interval_case( - const cache_entry_type& cache, int beta_minus_1) FMT_NOEXCEPT { + const cache_entry_type& cache, int beta_minus_1) UMPIRE_FMT_NOEXCEPT { return static_cast( (cache - (cache >> (float_info::significand_bits + 2))) >> (64 - float_info::significand_bits - 1 - beta_minus_1)); } static carrier_uint compute_right_endpoint_for_shorter_interval_case( - const cache_entry_type& cache, int beta_minus_1) FMT_NOEXCEPT { + const cache_entry_type& cache, int beta_minus_1) UMPIRE_FMT_NOEXCEPT { return static_cast( (cache + (cache >> (float_info::significand_bits + 1))) >> (64 - float_info::significand_bits - 1 - beta_minus_1)); } static carrier_uint compute_round_up_for_shorter_interval_case( - const cache_entry_type& cache, int beta_minus_1) FMT_NOEXCEPT { + const cache_entry_type& cache, int beta_minus_1) UMPIRE_FMT_NOEXCEPT { return (static_cast( cache >> (64 - float_info::significand_bits - 2 - beta_minus_1)) + @@ -1874,11 +1874,11 @@ template <> struct cache_accessor { using carrier_uint = float_info::carrier_uint; using cache_entry_type = uint128_wrapper; - static uint128_wrapper get_cached_power(int k) FMT_NOEXCEPT { - FMT_ASSERT(k >= float_info::min_k && k <= float_info::max_k, + static uint128_wrapper get_cached_power(int k) UMPIRE_FMT_NOEXCEPT { + UMPIRE_FMT_ASSERT(k >= float_info::min_k && k <= float_info::max_k, "k is out of range"); -#if FMT_USE_FULL_CACHE_DRAGONBOX +#if UMPIRE_FMT_USE_FULL_CACHE_DRAGONBOX return data::dragonbox_pow10_significands_128[k - float_info::min_k]; #else @@ -1896,7 +1896,7 @@ template <> struct cache_accessor { // Compute the required amount of bit-shift. int alpha = floor_log2_pow10(kb + offset) - floor_log2_pow10(kb) - offset; - FMT_ASSERT(alpha > 0 && alpha < 64, "shifting error detected"); + UMPIRE_FMT_ASSERT(alpha > 0 && alpha < 64, "shifting error detected"); // Try to recover the real cache. uint64_t pow5 = data::powers_of_5_64[offset]; @@ -1922,46 +1922,46 @@ template <> struct cache_accessor { 0x3; // Add the error back. - FMT_ASSERT(recovered_cache.low() + error >= recovered_cache.low(), ""); + UMPIRE_FMT_ASSERT(recovered_cache.low() + error >= recovered_cache.low(), ""); return {recovered_cache.high(), recovered_cache.low() + error}; #endif } static carrier_uint compute_mul(carrier_uint u, - const cache_entry_type& cache) FMT_NOEXCEPT { + const cache_entry_type& cache) UMPIRE_FMT_NOEXCEPT { return umul192_upper64(u, cache); } static uint32_t compute_delta(cache_entry_type const& cache, - int beta_minus_1) FMT_NOEXCEPT { + int beta_minus_1) UMPIRE_FMT_NOEXCEPT { return static_cast(cache.high() >> (64 - 1 - beta_minus_1)); } static bool compute_mul_parity(carrier_uint two_f, const cache_entry_type& cache, - int beta_minus_1) FMT_NOEXCEPT { - FMT_ASSERT(beta_minus_1 >= 1, ""); - FMT_ASSERT(beta_minus_1 < 64, ""); + int beta_minus_1) UMPIRE_FMT_NOEXCEPT { + UMPIRE_FMT_ASSERT(beta_minus_1 >= 1, ""); + UMPIRE_FMT_ASSERT(beta_minus_1 < 64, ""); return ((umul192_middle64(two_f, cache) >> (64 - beta_minus_1)) & 1) != 0; } static carrier_uint compute_left_endpoint_for_shorter_interval_case( - const cache_entry_type& cache, int beta_minus_1) FMT_NOEXCEPT { + const cache_entry_type& cache, int beta_minus_1) UMPIRE_FMT_NOEXCEPT { return (cache.high() - (cache.high() >> (float_info::significand_bits + 2))) >> (64 - float_info::significand_bits - 1 - beta_minus_1); } static carrier_uint compute_right_endpoint_for_shorter_interval_case( - const cache_entry_type& cache, int beta_minus_1) FMT_NOEXCEPT { + const cache_entry_type& cache, int beta_minus_1) UMPIRE_FMT_NOEXCEPT { return (cache.high() + (cache.high() >> (float_info::significand_bits + 1))) >> (64 - float_info::significand_bits - 1 - beta_minus_1); } static carrier_uint compute_round_up_for_shorter_interval_case( - const cache_entry_type& cache, int beta_minus_1) FMT_NOEXCEPT { + const cache_entry_type& cache, int beta_minus_1) UMPIRE_FMT_NOEXCEPT { return ((cache.high() >> (64 - float_info::significand_bits - 2 - beta_minus_1)) + 1) / @@ -1971,7 +1971,7 @@ template <> struct cache_accessor { // Various integer checks template -bool is_left_endpoint_integer_shorter_interval(int exponent) FMT_NOEXCEPT { +bool is_left_endpoint_integer_shorter_interval(int exponent) UMPIRE_FMT_NOEXCEPT { return exponent >= float_info< T>::case_shorter_interval_left_endpoint_lower_threshold && @@ -1980,7 +1980,7 @@ bool is_left_endpoint_integer_shorter_interval(int exponent) FMT_NOEXCEPT { } template bool is_endpoint_integer(typename float_info::carrier_uint two_f, - int exponent, int minus_k) FMT_NOEXCEPT { + int exponent, int minus_k) UMPIRE_FMT_NOEXCEPT { if (exponent < float_info::case_fc_pm_half_lower_threshold) return false; // For k >= 0. if (exponent <= float_info::case_fc_pm_half_upper_threshold) return true; @@ -1991,7 +1991,7 @@ bool is_endpoint_integer(typename float_info::carrier_uint two_f, template bool is_center_integer(typename float_info::carrier_uint two_f, int exponent, - int minus_k) FMT_NOEXCEPT { + int minus_k) UMPIRE_FMT_NOEXCEPT { // Exponent for 5 is negative. if (exponent > float_info::divisibility_check_by_5_threshold) return false; if (exponent > float_info::case_fc_upper_threshold) @@ -2003,9 +2003,9 @@ bool is_center_integer(typename float_info::carrier_uint two_f, int exponent, } // Remove trailing zeros from n and return the number of zeros removed (float) -FMT_ALWAYS_INLINE int remove_trailing_zeros(uint32_t& n) FMT_NOEXCEPT { -#ifdef FMT_BUILTIN_CTZ - int t = FMT_BUILTIN_CTZ(n); +UMPIRE_FMT_ALWAYS_INLINE int remove_trailing_zeros(uint32_t& n) UMPIRE_FMT_NOEXCEPT { +#ifdef UMPIRE_FMT_BUILTIN_CTZ + int t = UMPIRE_FMT_BUILTIN_CTZ(n); #else int t = ctz(n); #endif @@ -2031,9 +2031,9 @@ FMT_ALWAYS_INLINE int remove_trailing_zeros(uint32_t& n) FMT_NOEXCEPT { } // Removes trailing zeros and returns the number of zeros removed (double) -FMT_ALWAYS_INLINE int remove_trailing_zeros(uint64_t& n) FMT_NOEXCEPT { -#ifdef FMT_BUILTIN_CTZLL - int t = FMT_BUILTIN_CTZLL(n); +UMPIRE_FMT_ALWAYS_INLINE int remove_trailing_zeros(uint64_t& n) UMPIRE_FMT_NOEXCEPT { +#ifdef UMPIRE_FMT_BUILTIN_CTZLL + int t = UMPIRE_FMT_BUILTIN_CTZLL(n); #else int t = ctzll(n); #endif @@ -2117,8 +2117,8 @@ FMT_ALWAYS_INLINE int remove_trailing_zeros(uint64_t& n) FMT_NOEXCEPT { // The main algorithm for shorter interval case template -FMT_ALWAYS_INLINE decimal_fp shorter_interval_case(int exponent) - FMT_NOEXCEPT { +UMPIRE_FMT_ALWAYS_INLINE decimal_fp shorter_interval_case(int exponent) + UMPIRE_FMT_NOEXCEPT { decimal_fp ret_value; // Compute k and beta const int minus_k = floor_log10_pow2_minus_log10_4_over_3(exponent); @@ -2164,7 +2164,7 @@ FMT_ALWAYS_INLINE decimal_fp shorter_interval_case(int exponent) return ret_value; } -template decimal_fp to_decimal(T x) FMT_NOEXCEPT { +template decimal_fp to_decimal(T x) UMPIRE_FMT_NOEXCEPT { // Step 1: integer promotion & Schubfach multiplier calculation. using carrier_uint = typename float_info::carrier_uint; @@ -2421,7 +2421,7 @@ void fallback_format(Double d, int num_digits, bool binary32, buffer& buf, template int format_float(T value, int precision, float_specs specs, buffer& buf) { static_assert(!std::is_same::value, ""); - FMT_ASSERT(value >= 0, "value is negative"); + UMPIRE_FMT_ASSERT(value >= 0, "value is negative"); const bool fixed = specs.format == float_format::fixed; if (value <= 0) { // <= instead of == to silence a warning. @@ -2485,7 +2485,7 @@ template int snprintf_float(T value, int precision, float_specs specs, buffer& buf) { // Buffer capacity must be non-zero, otherwise MSVC's vsnprintf_s will fail. - FMT_ASSERT(buf.capacity() > buf.size(), "empty buffer"); + UMPIRE_FMT_ASSERT(buf.capacity() > buf.size(), "empty buffer"); static_assert(!std::is_same::value, ""); // Subtract 1 to account for the difference in precision since we use %e for @@ -2515,14 +2515,14 @@ int snprintf_float(T value, int precision, float_specs specs, for (;;) { auto begin = buf.data() + offset; auto capacity = buf.capacity() - offset; -#ifdef FMT_FUZZ +#ifdef UMPIRE_FMT_FUZZ if (precision > 100000) throw std::runtime_error( "fuzz mode - avoid large allocation inside snprintf"); #endif // Suppress the warning about a nonliteral format string. // Cannot use auto because of a bug in MinGW (#1532). - int (*snprintf_ptr)(char*, size_t, const char*, ...) = FMT_SNPRINTF; + int (*snprintf_ptr)(char*, size_t, const char*, ...) = UMPIRE_FMT_SNPRINTF; int result = precision >= 0 ? snprintf_ptr(begin, capacity, format, precision, value) : snprintf_ptr(begin, capacity, format, value); @@ -2563,11 +2563,11 @@ int snprintf_float(T value, int precision, float_specs specs, --exp_pos; } while (*exp_pos != 'e'); char sign = exp_pos[1]; - FMT_ASSERT(sign == '+' || sign == '-', ""); + UMPIRE_FMT_ASSERT(sign == '+' || sign == '-', ""); int exp = 0; auto p = exp_pos + 2; // Skip 'e' and sign. do { - FMT_ASSERT(is_digit(*p), ""); + UMPIRE_FMT_ASSERT(is_digit(*p), ""); exp = exp * 10 + (*p++ - '0'); } while (p != end); if (sign == '-') exp = -exp; @@ -2586,7 +2586,7 @@ int snprintf_float(T value, int precision, float_specs specs, } struct stringifier { - template FMT_INLINE std::string operator()(T value) const { + template UMPIRE_FMT_INLINE std::string operator()(T value) const { return to_string(value); } std::string operator()(basic_format_arg::handle h) const { @@ -2600,7 +2600,7 @@ struct stringifier { } // namespace detail template <> struct formatter { - FMT_CONSTEXPR format_parse_context::iterator parse( + UMPIRE_FMT_CONSTEXPR format_parse_context::iterator parse( format_parse_context& ctx) { return ctx.begin(); } @@ -2612,22 +2612,22 @@ template <> struct formatter { for (auto i = n.bigits_.size(); i > 0; --i) { auto value = n.bigits_[i - 1u]; if (first) { - out = format_to(out, FMT_STRING("{:x}"), value); + out = format_to(out, UMPIRE_FMT_STRING("{:x}"), value); first = false; continue; } - out = format_to(out, FMT_STRING("{:08x}"), value); + out = format_to(out, UMPIRE_FMT_STRING("{:08x}"), value); } if (n.exp_ > 0) - out = format_to(out, FMT_STRING("p{}"), + out = format_to(out, UMPIRE_FMT_STRING("p{}"), n.exp_ * detail::bigint::bigit_bits); return out; } }; -FMT_FUNC detail::utf8_to_utf16::utf8_to_utf16(string_view s) { +UMPIRE_FMT_FUNC detail::utf8_to_utf16::utf8_to_utf16(string_view s) { for_each_codepoint(s, [this](uint32_t cp, int error) { - if (error != 0) FMT_THROW(std::runtime_error("invalid utf8")); + if (error != 0) UMPIRE_FMT_THROW(std::runtime_error("invalid utf8")); if (cp <= 0xFFFF) { buffer_.push_back(static_cast(cp)); } else { @@ -2639,9 +2639,9 @@ FMT_FUNC detail::utf8_to_utf16::utf8_to_utf16(string_view s) { buffer_.push_back(0); } -FMT_FUNC void format_system_error(detail::buffer& out, int error_code, - string_view message) FMT_NOEXCEPT { - FMT_TRY { +UMPIRE_FMT_FUNC void format_system_error(detail::buffer& out, int error_code, + string_view message) UMPIRE_FMT_NOEXCEPT { + UMPIRE_FMT_TRY { memory_buffer buf; buf.resize(inline_buffer_size); for (;;) { @@ -2649,7 +2649,7 @@ FMT_FUNC void format_system_error(detail::buffer& out, int error_code, int result = detail::safe_strerror(error_code, system_message, buf.size()); if (result == 0) { - format_to(detail::buffer_appender(out), FMT_STRING("{}: {}"), + format_to(detail::buffer_appender(out), UMPIRE_FMT_STRING("{}: {}"), message, system_message); return; } @@ -2658,20 +2658,20 @@ FMT_FUNC void format_system_error(detail::buffer& out, int error_code, buf.resize(buf.size() * 2); } } - FMT_CATCH(...) {} + UMPIRE_FMT_CATCH(...) {} format_error_code(out, error_code, message); } -FMT_FUNC void detail::error_handler::on_error(const char* message) { - FMT_THROW(format_error(message)); +UMPIRE_FMT_FUNC void detail::error_handler::on_error(const char* message) { + UMPIRE_FMT_THROW(format_error(message)); } -FMT_FUNC void report_system_error(int error_code, - umpire::fmt::string_view message) FMT_NOEXCEPT { +UMPIRE_FMT_FUNC void report_system_error(int error_code, + umpire::fmt::string_view message) UMPIRE_FMT_NOEXCEPT { report_error(format_system_error, error_code, message); } -FMT_FUNC std::string detail::vformat(string_view format_str, format_args args) { +UMPIRE_FMT_FUNC std::string detail::vformat(string_view format_str, format_args args) { if (format_str.size() == 2 && equal2(format_str.data(), "{}")) { auto arg = args.get(0); if (!arg) error_handler().on_error("argument not found"); @@ -2690,7 +2690,7 @@ extern "C" __declspec(dllimport) int __stdcall WriteConsoleW( // } // namespace detail #endif -FMT_FUNC void vprint(std::FILE* f, string_view format_str, format_args args) { +UMPIRE_FMT_FUNC void vprint(std::FILE* f, string_view format_str, format_args args) { memory_buffer buffer; detail::vformat_to(buffer, format_str, basic_format_args>(args)); @@ -2713,7 +2713,7 @@ FMT_FUNC void vprint(std::FILE* f, string_view format_str, format_args args) { #ifdef _WIN32 // Print assuming legacy (non-Unicode) encoding. -FMT_FUNC void detail::vprint_mojibake(std::FILE* f, string_view format_str, +UMPIRE_FMT_FUNC void detail::vprint_mojibake(std::FILE* f, string_view format_str, format_args args) { memory_buffer buffer; detail::vformat_to(buffer, format_str, @@ -2722,10 +2722,10 @@ FMT_FUNC void detail::vprint_mojibake(std::FILE* f, string_view format_str, } #endif -FMT_FUNC void vprint(string_view format_str, format_args args) { +UMPIRE_FMT_FUNC void vprint(string_view format_str, format_args args) { vprint(stdout, format_str, args); } -FMT_END_NAMESPACE +UMPIRE_FMT_END_NAMESPACE -#endif // FMT_FORMAT_INL_H_ +#endif // UMPIRE_FMT_FORMAT_INL_H_ diff --git a/src/tpl/umpire/fmt/format.h b/src/tpl/umpire/fmt/format.h index 8cceae731..4717a682f 100644 --- a/src/tpl/umpire/fmt/format.h +++ b/src/tpl/umpire/fmt/format.h @@ -30,8 +30,8 @@ without including the above copyright and permission notices. */ -#ifndef FMT_FORMAT_H_ -#define FMT_FORMAT_H_ +#ifndef UMPIRE_FMT_FORMAT_H_ +#define UMPIRE_FMT_FORMAT_H_ #include #include @@ -46,67 +46,67 @@ #include "core.h" #ifdef __INTEL_COMPILER -# define FMT_ICC_VERSION __INTEL_COMPILER +# define UMPIRE_FMT_ICC_VERSION __INTEL_COMPILER #elif defined(__ICL) -# define FMT_ICC_VERSION __ICL +# define UMPIRE_FMT_ICC_VERSION __ICL #else -# define FMT_ICC_VERSION 0 +# define UMPIRE_FMT_ICC_VERSION 0 #endif #ifdef __NVCC__ -# define FMT_CUDA_VERSION (__CUDACC_VER_MAJOR__ * 100 + __CUDACC_VER_MINOR__) +# define UMPIRE_FMT_CUDA_VERSION (__CUDACC_VER_MAJOR__ * 100 + __CUDACC_VER_MINOR__) #else -# define FMT_CUDA_VERSION 0 +# define UMPIRE_FMT_CUDA_VERSION 0 #endif #ifdef __has_builtin -# define FMT_HAS_BUILTIN(x) __has_builtin(x) +# define UMPIRE_FMT_HAS_BUILTIN(x) __has_builtin(x) #else -# define FMT_HAS_BUILTIN(x) 0 +# define UMPIRE_FMT_HAS_BUILTIN(x) 0 #endif -#if FMT_GCC_VERSION || FMT_CLANG_VERSION -# define FMT_NOINLINE __attribute__((noinline)) +#if UMPIRE_FMT_GCC_VERSION || UMPIRE_FMT_CLANG_VERSION +# define UMPIRE_FMT_NOINLINE __attribute__((noinline)) #else -# define FMT_NOINLINE +# define UMPIRE_FMT_NOINLINE #endif -#if FMT_GCC_VERSION -# define FMT_GCC_VISIBILITY_HIDDEN __attribute__((visibility("hidden"))) +#if UMPIRE_FMT_GCC_VERSION +# define UMPIRE_FMT_GCC_VISIBILITY_HIDDEN __attribute__((visibility("hidden"))) #else -# define FMT_GCC_VISIBILITY_HIDDEN +# define UMPIRE_FMT_GCC_VISIBILITY_HIDDEN #endif #if __cplusplus == 201103L || __cplusplus == 201402L # if defined(__INTEL_COMPILER) || defined(__PGI) -# define FMT_FALLTHROUGH +# define UMPIRE_FMT_FALLTHROUGH # elif defined(__clang__) -# define FMT_FALLTHROUGH [[clang::fallthrough]] -# elif FMT_GCC_VERSION >= 700 && \ +# define UMPIRE_FMT_FALLTHROUGH [[clang::fallthrough]] +# elif UMPIRE_FMT_GCC_VERSION >= 700 && \ (!defined(__EDG_VERSION__) || __EDG_VERSION__ >= 520) -# define FMT_FALLTHROUGH [[gnu::fallthrough]] +# define UMPIRE_FMT_FALLTHROUGH [[gnu::fallthrough]] # else -# define FMT_FALLTHROUGH +# define UMPIRE_FMT_FALLTHROUGH # endif -#elif FMT_HAS_CPP17_ATTRIBUTE(fallthrough) || \ +#elif UMPIRE_FMT_HAS_CPP17_ATTRIBUTE(fallthrough) || \ (defined(_MSVC_LANG) && _MSVC_LANG >= 201703L) -# define FMT_FALLTHROUGH [[fallthrough]] +# define UMPIRE_FMT_FALLTHROUGH [[fallthrough]] #else -# define FMT_FALLTHROUGH +# define UMPIRE_FMT_FALLTHROUGH #endif -#ifndef FMT_MAYBE_UNUSED -# if FMT_HAS_CPP17_ATTRIBUTE(maybe_unused) -# define FMT_MAYBE_UNUSED [[maybe_unused]] +#ifndef UMPIRE_FMT_MAYBE_UNUSED +# if UMPIRE_FMT_HAS_CPP17_ATTRIBUTE(maybe_unused) +# define UMPIRE_FMT_MAYBE_UNUSED [[maybe_unused]] # else -# define FMT_MAYBE_UNUSED +# define UMPIRE_FMT_MAYBE_UNUSED # endif #endif -#ifndef FMT_THROW -# if FMT_EXCEPTIONS -# if FMT_MSC_VER || FMT_NVCC -FMT_BEGIN_NAMESPACE +#ifndef UMPIRE_FMT_THROW +# if UMPIRE_FMT_EXCEPTIONS +# if UMPIRE_FMT_MSC_VER || UMPIRE_FMT_NVCC +UMPIRE_FMT_BEGIN_NAMESPACE namespace detail { template inline void do_throw(const Exception& x) { // Silence unreachable code warnings in MSVC and NVCC because these @@ -115,82 +115,82 @@ template inline void do_throw(const Exception& x) { if (b) throw x; } } // namespace detail -FMT_END_NAMESPACE -# define FMT_THROW(x) detail::do_throw(x) +UMPIRE_FMT_END_NAMESPACE +# define UMPIRE_FMT_THROW(x) detail::do_throw(x) # else -# define FMT_THROW(x) throw x +# define UMPIRE_FMT_THROW(x) throw x # endif # else -# define FMT_THROW(x) \ +# define UMPIRE_FMT_THROW(x) \ do { \ - FMT_ASSERT(false, (x).what()); \ + UMPIRE_FMT_ASSERT(false, (x).what()); \ } while (false) # endif #endif -#if FMT_EXCEPTIONS -# define FMT_TRY try -# define FMT_CATCH(x) catch (x) +#if UMPIRE_FMT_EXCEPTIONS +# define UMPIRE_FMT_TRY try +# define UMPIRE_FMT_CATCH(x) catch (x) #else -# define FMT_TRY if (true) -# define FMT_CATCH(x) if (false) +# define UMPIRE_FMT_TRY if (true) +# define UMPIRE_FMT_CATCH(x) if (false) #endif -#ifndef FMT_USE_USER_DEFINED_LITERALS +#ifndef UMPIRE_FMT_USE_USER_DEFINED_LITERALS // EDG based compilers (Intel, NVIDIA, Elbrus, etc), GCC and MSVC support UDLs. -# if (FMT_HAS_FEATURE(cxx_user_literals) || FMT_GCC_VERSION >= 407 || \ - FMT_MSC_VER >= 1900) && \ +# if (UMPIRE_FMT_HAS_FEATURE(cxx_user_literals) || UMPIRE_FMT_GCC_VERSION >= 407 || \ + UMPIRE_FMT_MSC_VER >= 1900) && \ (!defined(__EDG_VERSION__) || __EDG_VERSION__ >= /* UDL feature */ 480) -# define FMT_USE_USER_DEFINED_LITERALS 1 +# define UMPIRE_FMT_USE_USER_DEFINED_LITERALS 1 # else -# define FMT_USE_USER_DEFINED_LITERALS 0 +# define UMPIRE_FMT_USE_USER_DEFINED_LITERALS 0 # endif #endif -#ifndef FMT_USE_FLOAT -# define FMT_USE_FLOAT 1 +#ifndef UMPIRE_FMT_USE_FLOAT +# define UMPIRE_FMT_USE_FLOAT 1 #endif -#ifndef FMT_USE_DOUBLE -# define FMT_USE_DOUBLE 1 +#ifndef UMPIRE_FMT_USE_DOUBLE +# define UMPIRE_FMT_USE_DOUBLE 1 #endif -#ifndef FMT_USE_LONG_DOUBLE -# define FMT_USE_LONG_DOUBLE 1 +#ifndef UMPIRE_FMT_USE_LONG_DOUBLE +# define UMPIRE_FMT_USE_LONG_DOUBLE 1 #endif -// Defining FMT_REDUCE_INT_INSTANTIATIONS to 1, will reduce the number of +// Defining UMPIRE_FMT_REDUCE_INT_INSTANTIATIONS to 1, will reduce the number of // integer formatter template instantiations to just one by only using the // largest integer type. This results in a reduction in binary size but will // cause a decrease in integer formatting performance. -#if !defined(FMT_REDUCE_INT_INSTANTIATIONS) -# define FMT_REDUCE_INT_INSTANTIATIONS 0 +#if !defined(UMPIRE_FMT_REDUCE_INT_INSTANTIATIONS) +# define UMPIRE_FMT_REDUCE_INT_INSTANTIATIONS 0 #endif // __builtin_clz is broken in clang with Microsoft CodeGen: // https://github.com/fmtlib/fmt/issues/519 -#if (FMT_GCC_VERSION || FMT_HAS_BUILTIN(__builtin_clz)) && !FMT_MSC_VER -# define FMT_BUILTIN_CLZ(n) __builtin_clz(n) +#if (UMPIRE_FMT_GCC_VERSION || UMPIRE_FMT_HAS_BUILTIN(__builtin_clz)) && !UMPIRE_FMT_MSC_VER +# define UMPIRE_FMT_BUILTIN_CLZ(n) __builtin_clz(n) #endif -#if (FMT_GCC_VERSION || FMT_HAS_BUILTIN(__builtin_clzll)) && !FMT_MSC_VER -# define FMT_BUILTIN_CLZLL(n) __builtin_clzll(n) +#if (UMPIRE_FMT_GCC_VERSION || UMPIRE_FMT_HAS_BUILTIN(__builtin_clzll)) && !UMPIRE_FMT_MSC_VER +# define UMPIRE_FMT_BUILTIN_CLZLL(n) __builtin_clzll(n) #endif -#if (FMT_GCC_VERSION || FMT_HAS_BUILTIN(__builtin_ctz)) -# define FMT_BUILTIN_CTZ(n) __builtin_ctz(n) +#if (UMPIRE_FMT_GCC_VERSION || UMPIRE_FMT_HAS_BUILTIN(__builtin_ctz)) +# define UMPIRE_FMT_BUILTIN_CTZ(n) __builtin_ctz(n) #endif -#if (FMT_GCC_VERSION || FMT_HAS_BUILTIN(__builtin_ctzll)) -# define FMT_BUILTIN_CTZLL(n) __builtin_ctzll(n) +#if (UMPIRE_FMT_GCC_VERSION || UMPIRE_FMT_HAS_BUILTIN(__builtin_ctzll)) +# define UMPIRE_FMT_BUILTIN_CTZLL(n) __builtin_ctzll(n) #endif -#if FMT_MSC_VER +#if UMPIRE_FMT_MSC_VER # include // _BitScanReverse[64], _BitScanForward[64], _umul128 #endif // Some compilers masquerade as both MSVC and GCC-likes or otherwise support -// __builtin_clz and __builtin_clzll, so only define FMT_BUILTIN_CLZ using the +// __builtin_clz and __builtin_clzll, so only define UMPIRE_FMT_BUILTIN_CLZ using the // MSVC intrinsics if the clz and clzll builtins are not available. -#if FMT_MSC_VER && !defined(FMT_BUILTIN_CLZLL) && !defined(FMT_BUILTIN_CTZLL) -FMT_BEGIN_NAMESPACE +#if UMPIRE_FMT_MSC_VER && !defined(UMPIRE_FMT_BUILTIN_CLZLL) && !defined(UMPIRE_FMT_BUILTIN_CTZLL) +UMPIRE_FMT_BEGIN_NAMESPACE namespace detail { // Avoid Clang with Microsoft CodeGen's -Wunknown-pragmas warning. # if !defined(__clang__) @@ -206,14 +206,14 @@ namespace detail { inline int clz(uint32_t x) { unsigned long r = 0; _BitScanReverse(&r, x); - FMT_ASSERT(x != 0, ""); + UMPIRE_FMT_ASSERT(x != 0, ""); // Static analysis complains about using uninitialized data // "r", but the only way that can happen is if "x" is 0, // which the callers guarantee to not happen. - FMT_MSC_WARNING(suppress : 6102) + UMPIRE_FMT_MSC_WARNING(suppress : 6102) return 31 ^ static_cast(r); } -# define FMT_BUILTIN_CLZ(n) detail::clz(n) +# define UMPIRE_FMT_BUILTIN_CLZ(n) detail::clz(n) inline int clzll(uint64_t x) { unsigned long r = 0; @@ -225,25 +225,25 @@ inline int clzll(uint64_t x) { // Scan the low 32 bits. _BitScanReverse(&r, static_cast(x)); # endif - FMT_ASSERT(x != 0, ""); - FMT_MSC_WARNING(suppress : 6102) // Suppress a bogus static analysis warning. + UMPIRE_FMT_ASSERT(x != 0, ""); + UMPIRE_FMT_MSC_WARNING(suppress : 6102) // Suppress a bogus static analysis warning. return 63 ^ static_cast(r); } -# define FMT_BUILTIN_CLZLL(n) detail::clzll(n) +# define UMPIRE_FMT_BUILTIN_CLZLL(n) detail::clzll(n) inline int ctz(uint32_t x) { unsigned long r = 0; _BitScanForward(&r, x); - FMT_ASSERT(x != 0, ""); - FMT_MSC_WARNING(suppress : 6102) // Suppress a bogus static analysis warning. + UMPIRE_FMT_ASSERT(x != 0, ""); + UMPIRE_FMT_MSC_WARNING(suppress : 6102) // Suppress a bogus static analysis warning. return static_cast(r); } -# define FMT_BUILTIN_CTZ(n) detail::ctz(n) +# define UMPIRE_FMT_BUILTIN_CTZ(n) detail::ctz(n) inline int ctzll(uint64_t x) { unsigned long r = 0; - FMT_ASSERT(x != 0, ""); - FMT_MSC_WARNING(suppress : 6102) // Suppress a bogus static analysis warning. + UMPIRE_FMT_ASSERT(x != 0, ""); + UMPIRE_FMT_MSC_WARNING(suppress : 6102) // Suppress a bogus static analysis warning. # ifdef _WIN64 _BitScanForward64(&r, x); # else @@ -255,27 +255,27 @@ inline int ctzll(uint64_t x) { # endif return static_cast(r); } -# define FMT_BUILTIN_CTZLL(n) detail::ctzll(n) +# define UMPIRE_FMT_BUILTIN_CTZLL(n) detail::ctzll(n) # if !defined(__clang__) # pragma managed(pop) # endif } // namespace detail -FMT_END_NAMESPACE +UMPIRE_FMT_END_NAMESPACE #endif // Enable the deprecated numeric alignment. -#ifndef FMT_DEPRECATED_NUMERIC_ALIGN -# define FMT_DEPRECATED_NUMERIC_ALIGN 0 +#ifndef UMPIRE_FMT_DEPRECATED_NUMERIC_ALIGN +# define UMPIRE_FMT_DEPRECATED_NUMERIC_ALIGN 0 #endif -FMT_BEGIN_NAMESPACE +UMPIRE_FMT_BEGIN_NAMESPACE namespace detail { #if __cplusplus >= 202002L || \ - (__cplusplus >= 201709L && FMT_GCC_VERSION >= 1002) -# define FMT_CONSTEXPR20 constexpr + (__cplusplus >= 201709L && UMPIRE_FMT_GCC_VERSION >= 1002) +# define UMPIRE_FMT_CONSTEXPR20 constexpr #else -# define FMT_CONSTEXPR20 +# define UMPIRE_FMT_CONSTEXPR20 #endif // An equivalent of `*reinterpret_cast(&source)` that doesn't have @@ -336,9 +336,9 @@ template <> constexpr int num_bits() { std::numeric_limits::digits); } -FMT_INLINE void assume(bool condition) { +UMPIRE_FMT_INLINE void assume(bool condition) { (void)condition; -#if FMT_HAS_BUILTIN(__builtin_assume) +#if UMPIRE_FMT_HAS_BUILTIN(__builtin_assume) __builtin_assume(condition); #endif } @@ -368,8 +368,8 @@ template using checked_ptr = T*; template inline T* make_checked(T* p, size_t) { return p; } #endif -template ::value)> -#if FMT_CLANG_VERSION >= 307 +template ::value)> +#if UMPIRE_FMT_CLANG_VERSION >= 307 __attribute__((no_sanitize("undefined"))) #endif inline checked_ptr @@ -407,7 +407,7 @@ template T* to_pointer(buffer_appender it, size_t n) { return buf.data() + size; } -template ::value)> +template ::value)> inline std::back_insert_iterator base_iterator( std::back_insert_iterator& it, checked_ptr) { @@ -461,12 +461,12 @@ class counting_iterator { // is spectacularly slow to compile in C++20 so use a simple fill_n // instead (#1998). template -FMT_CONSTEXPR OutputIt fill_n(OutputIt out, Size count, const T& value) { +UMPIRE_FMT_CONSTEXPR OutputIt fill_n(OutputIt out, Size count, const T& value) { for (Size i = 0; i < count; ++i) *out++ = value; return out; } template -FMT_CONSTEXPR20 T* fill_n(T* out, Size count, char value) { +UMPIRE_FMT_CONSTEXPR20 T* fill_n(T* out, Size count, char value) { if (is_constant_evaluated()) { return fill_n(out, count, value); } @@ -481,15 +481,15 @@ using needs_conversion = bool_constant< std::is_same::value>; template ::value)> -FMT_CONSTEXPR OutputIt copy_str(InputIt begin, InputIt end, OutputIt it) { + UMPIRE_FMT_ENABLE_IF(!needs_conversion::value)> +UMPIRE_FMT_CONSTEXPR OutputIt copy_str(InputIt begin, InputIt end, OutputIt it) { while (begin != end) *it++ = *begin++; return it; } template ::value)> -FMT_CONSTEXPR20 OutChar* copy_str(InputIt begin, InputIt end, OutChar* out) { + UMPIRE_FMT_ENABLE_IF(!needs_conversion::value)> +UMPIRE_FMT_CONSTEXPR20 OutChar* copy_str(InputIt begin, InputIt end, OutChar* out) { if (is_constant_evaluated()) { return copy_str(begin, end, out); } @@ -497,14 +497,14 @@ FMT_CONSTEXPR20 OutChar* copy_str(InputIt begin, InputIt end, OutChar* out) { } template ::value)> + UMPIRE_FMT_ENABLE_IF(needs_conversion::value)> OutputIt copy_str(InputIt begin, InputIt end, OutputIt it) { while (begin != end) *it++ = static_cast(*begin++); return it; } template ::value)> + UMPIRE_FMT_ENABLE_IF(!needs_conversion::value)> buffer_appender copy_str(InputIt begin, InputIt end, buffer_appender out) { get_container(out).append(begin, end); @@ -518,7 +518,7 @@ inline counting_iterator copy_str(InputIt begin, InputIt end, } template -FMT_CONSTEXPR int code_point_length(const Char* begin) { +UMPIRE_FMT_CONSTEXPR int code_point_length(const Char* begin) { if (const_check(sizeof(Char) != 1)) return 1; constexpr char lengths[] = {1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 0, 0, 0, 0, 0, 0, 0, 0, 2, 2, 2, 2, 3, 3, 4, 0}; @@ -547,7 +547,7 @@ FMT_CONSTEXPR int code_point_length(const Char* begin) { * occurs, this pointer will be a guess that depends on the particular * error, but it will always advance at least one byte. */ -FMT_CONSTEXPR inline const char* utf8_decode(const char* s, uint32_t* c, +UMPIRE_FMT_CONSTEXPR inline const char* utf8_decode(const char* s, uint32_t* c, int* e) { constexpr const int masks[] = {0x00, 0x7f, 0x1f, 0x0f, 0x07}; constexpr const uint32_t mins[] = {4194304, 0, 128, 2048, 65536}; @@ -580,7 +580,7 @@ FMT_CONSTEXPR inline const char* utf8_decode(const char* s, uint32_t* c, } template -FMT_CONSTEXPR void for_each_codepoint(string_view s, F f) { +UMPIRE_FMT_CONSTEXPR void for_each_codepoint(string_view s, F f) { auto decode = [f](const char* p) { auto cp = uint32_t(); auto error = 0; @@ -609,12 +609,12 @@ inline size_t compute_width(basic_string_view s) { } // Computes approximate display width of a UTF-8 string. -FMT_CONSTEXPR inline size_t compute_width(string_view s) { +UMPIRE_FMT_CONSTEXPR inline size_t compute_width(string_view s) { size_t num_code_points = 0; // It is not a lambda for compatibility with C++14. struct count_code_points { size_t* count; - FMT_CONSTEXPR void operator()(uint32_t cp, int error) const { + UMPIRE_FMT_CONSTEXPR void operator()(uint32_t cp, int error) const { *count += 1 + (error == 0 && cp >= 0x1100 && @@ -666,8 +666,8 @@ template using is_fast_float = bool_constant::is_iec559 && sizeof(T) <= sizeof(double)>; -#ifndef FMT_USE_FULL_CACHE_DRAGONBOX -# define FMT_USE_FULL_CACHE_DRAGONBOX 0 +#ifndef UMPIRE_FMT_USE_FULL_CACHE_DRAGONBOX +# define UMPIRE_FMT_USE_FULL_CACHE_DRAGONBOX 0 #endif template @@ -741,7 +741,7 @@ class basic_memory_buffer final : public detail::buffer { } protected: - void grow(size_t size) final FMT_OVERRIDE; + void grow(size_t size) final UMPIRE_FMT_OVERRIDE; public: using value_type = T; @@ -779,15 +779,15 @@ class basic_memory_buffer final : public detail::buffer { of the other object to it. \endrst */ - basic_memory_buffer(basic_memory_buffer&& other) FMT_NOEXCEPT { move(other); } + basic_memory_buffer(basic_memory_buffer&& other) UMPIRE_FMT_NOEXCEPT { move(other); } /** \rst Moves the content of the other ``basic_memory_buffer`` object to this one. \endrst */ - basic_memory_buffer& operator=(basic_memory_buffer&& other) FMT_NOEXCEPT { - FMT_ASSERT(this != &other, ""); + basic_memory_buffer& operator=(basic_memory_buffer&& other) UMPIRE_FMT_NOEXCEPT { + UMPIRE_FMT_ASSERT(this != &other, ""); deallocate(); move(other); return *this; @@ -815,7 +815,7 @@ class basic_memory_buffer final : public detail::buffer { template void basic_memory_buffer::grow(size_t size) { -#ifdef FMT_FUZZ +#ifdef UMPIRE_FMT_FUZZ if (size > 5000) throw std::runtime_error("fuzz mode - won't grow that much"); #endif const size_t max_size = std::allocator_traits::max_size(alloc_); @@ -846,8 +846,8 @@ struct is_contiguous> : std::true_type { }; /** A formatting error such as invalid format string. */ -FMT_CLASS_API -class FMT_API format_error : public std::runtime_error { +UMPIRE_FMT_CLASS_API +class UMPIRE_FMT_API format_error : public std::runtime_error { public: explicit format_error(const char* message) : std::runtime_error(message) {} explicit format_error(const std::string& message) @@ -856,7 +856,7 @@ class FMT_API format_error : public std::runtime_error { format_error& operator=(const format_error&) = default; format_error(format_error&&) = default; format_error& operator=(format_error&&) = default; - ~format_error() FMT_NOEXCEPT FMT_OVERRIDE; + ~format_error() UMPIRE_FMT_NOEXCEPT UMPIRE_FMT_OVERRIDE; }; namespace detail { @@ -868,49 +868,49 @@ using is_signed = // Returns true if value is negative, false otherwise. // Same as `value < 0` but doesn't produce warnings if T is an unsigned type. -template ::value)> -FMT_CONSTEXPR bool is_negative(T value) { +template ::value)> +UMPIRE_FMT_CONSTEXPR bool is_negative(T value) { return value < 0; } -template ::value)> -FMT_CONSTEXPR bool is_negative(T) { +template ::value)> +UMPIRE_FMT_CONSTEXPR bool is_negative(T) { return false; } -template ::value)> -FMT_CONSTEXPR bool is_supported_floating_point(T) { - return (std::is_same::value && FMT_USE_FLOAT) || - (std::is_same::value && FMT_USE_DOUBLE) || - (std::is_same::value && FMT_USE_LONG_DOUBLE); +template ::value)> +UMPIRE_FMT_CONSTEXPR bool is_supported_floating_point(T) { + return (std::is_same::value && UMPIRE_FMT_USE_FLOAT) || + (std::is_same::value && UMPIRE_FMT_USE_DOUBLE) || + (std::is_same::value && UMPIRE_FMT_USE_LONG_DOUBLE); } // Smallest of uint32_t, uint64_t, uint128_t that is large enough to // represent all values of an integral type T. template using uint32_or_64_or_128_t = - conditional_t() <= 32 && !FMT_REDUCE_INT_INSTANTIATIONS, + conditional_t() <= 32 && !UMPIRE_FMT_REDUCE_INT_INSTANTIATIONS, uint32_t, conditional_t() <= 64, uint64_t, uint128_t>>; template using uint64_or_128_t = conditional_t() <= 64, uint64_t, uint128_t>; // 128-bit integer type used internally -struct FMT_EXTERN_TEMPLATE_API uint128_wrapper { +struct UMPIRE_FMT_EXTERN_TEMPLATE_API uint128_wrapper { uint128_wrapper() = default; -#if FMT_USE_INT128 +#if UMPIRE_FMT_USE_INT128 uint128_t internal_; - uint128_wrapper(uint64_t high, uint64_t low) FMT_NOEXCEPT + uint128_wrapper(uint64_t high, uint64_t low) UMPIRE_FMT_NOEXCEPT : internal_{static_cast(low) | (static_cast(high) << 64)} {} uint128_wrapper(uint128_t u) : internal_{u} {} - uint64_t high() const FMT_NOEXCEPT { return uint64_t(internal_ >> 64); } - uint64_t low() const FMT_NOEXCEPT { return uint64_t(internal_); } + uint64_t high() const UMPIRE_FMT_NOEXCEPT { return uint64_t(internal_ >> 64); } + uint64_t low() const UMPIRE_FMT_NOEXCEPT { return uint64_t(internal_); } - uint128_wrapper& operator+=(uint64_t n) FMT_NOEXCEPT { + uint128_wrapper& operator+=(uint64_t n) UMPIRE_FMT_NOEXCEPT { internal_ += n; return *this; } @@ -918,13 +918,13 @@ struct FMT_EXTERN_TEMPLATE_API uint128_wrapper { uint64_t high_; uint64_t low_; - uint128_wrapper(uint64_t high, uint64_t low) FMT_NOEXCEPT : high_{high}, + uint128_wrapper(uint64_t high, uint64_t low) UMPIRE_FMT_NOEXCEPT : high_{high}, low_{low} {} - uint64_t high() const FMT_NOEXCEPT { return high_; } - uint64_t low() const FMT_NOEXCEPT { return low_; } + uint64_t high() const UMPIRE_FMT_NOEXCEPT { return high_; } + uint64_t low() const UMPIRE_FMT_NOEXCEPT { return low_; } - uint128_wrapper& operator+=(uint64_t n) FMT_NOEXCEPT { + uint128_wrapper& operator+=(uint64_t n) UMPIRE_FMT_NOEXCEPT { # if defined(_MSC_VER) && defined(_M_X64) unsigned char carry = _addcarry_u64(0, low_, n, &low_); _addcarry_u64(carry, high_, 0, &high_); @@ -940,13 +940,13 @@ struct FMT_EXTERN_TEMPLATE_API uint128_wrapper { }; // Table entry type for divisibility test used internally -template struct FMT_EXTERN_TEMPLATE_API divtest_table_entry { +template struct UMPIRE_FMT_EXTERN_TEMPLATE_API divtest_table_entry { T mod_inv; T max_quotient; }; // Static data is placed in this class template for the header-only config. -template struct FMT_EXTERN_TEMPLATE_API basic_data { +template struct UMPIRE_FMT_EXTERN_TEMPLATE_API basic_data { static const uint64_t powers_of_10_64[]; static const uint32_t zero_or_powers_of_10_32_new[]; static const uint64_t zero_or_powers_of_10_64_new[]; @@ -958,7 +958,7 @@ template struct FMT_EXTERN_TEMPLATE_API basic_data { static const uint128_wrapper dragonbox_pow10_significands_128[]; // log10(2) = 0x0.4d104d427de7fbcc... static const uint64_t log10_2_significand = 0x4d104d427de7fbcc; -#if !FMT_USE_FULL_CACHE_DRAGONBOX +#if !UMPIRE_FMT_USE_FULL_CACHE_DRAGONBOX static const uint64_t powers_of_5_64[]; static const uint32_t dragonbox_pow10_recovery_errors[]; #endif @@ -983,7 +983,7 @@ template struct FMT_EXTERN_TEMPLATE_API basic_data { // Maps bsr(n) to ceil(log10(pow(2, bsr(n) + 1) - 1)). // This is a function instead of an array to workaround a bug in GCC10 (#1810). -FMT_INLINE uint16_t bsr2log10(int bsr) { +UMPIRE_FMT_INLINE uint16_t bsr2log10(int bsr) { static constexpr uint16_t data[] = { 1, 1, 1, 2, 2, 2, 3, 3, 3, 4, 4, 4, 4, 5, 5, 5, 6, 6, 6, 7, 7, 7, 7, 8, 8, 8, 9, 9, 9, 10, 10, 10, @@ -992,14 +992,14 @@ FMT_INLINE uint16_t bsr2log10(int bsr) { return data[bsr]; } -#ifndef FMT_EXPORTED -FMT_EXTERN template struct basic_data; +#ifndef UMPIRE_FMT_EXPORTED +UMPIRE_FMT_EXTERN template struct basic_data; #endif // This is a struct rather than an alias to avoid shadowing warnings in gcc. struct data : basic_data<> {}; -template FMT_CONSTEXPR int count_digits_fallback(T n) { +template UMPIRE_FMT_CONSTEXPR int count_digits_fallback(T n) { int count = 1; for (;;) { // Integer division is slow so do it for a group of four digits instead @@ -1013,21 +1013,21 @@ template FMT_CONSTEXPR int count_digits_fallback(T n) { count += 4; } } -#if FMT_USE_INT128 -FMT_CONSTEXPR inline int count_digits(uint128_t n) { +#if UMPIRE_FMT_USE_INT128 +UMPIRE_FMT_CONSTEXPR inline int count_digits(uint128_t n) { return count_digits_fallback(n); } #endif // Returns the number of decimal digits in n. Leading zeros are not counted // except for n == 0 in which case count_digits returns 1. -FMT_CONSTEXPR20 inline int count_digits(uint64_t n) { +UMPIRE_FMT_CONSTEXPR20 inline int count_digits(uint64_t n) { if (is_constant_evaluated()) { return count_digits_fallback(n); } -#ifdef FMT_BUILTIN_CLZLL +#ifdef UMPIRE_FMT_BUILTIN_CLZLL // https://github.com/fmtlib/format-benchmark/blob/master/digits10 - auto t = bsr2log10(FMT_BUILTIN_CLZLL(n | 1) ^ 63); + auto t = bsr2log10(UMPIRE_FMT_BUILTIN_CLZLL(n | 1) ^ 63); return t - (n < data::zero_or_powers_of_10_64_new[t]); #else return count_digits_fallback(n); @@ -1035,10 +1035,10 @@ FMT_CONSTEXPR20 inline int count_digits(uint64_t n) { } // Counts the number of digits in n. BITS = log2(radix). -template FMT_CONSTEXPR int count_digits(UInt n) { -#ifdef FMT_BUILTIN_CLZ +template UMPIRE_FMT_CONSTEXPR int count_digits(UInt n) { +#ifdef UMPIRE_FMT_BUILTIN_CLZ if (num_bits() == 32) - return (FMT_BUILTIN_CLZ(static_cast(n) | 1) ^ 31) / BITS + 1; + return (UMPIRE_FMT_BUILTIN_CLZ(static_cast(n) | 1) ^ 31) / BITS + 1; #endif int num_digits = 0; do { @@ -1049,33 +1049,33 @@ template FMT_CONSTEXPR int count_digits(UInt n) { template <> int count_digits<4>(detail::fallback_uintptr n); -#if FMT_GCC_VERSION || FMT_CLANG_VERSION -# define FMT_ALWAYS_INLINE inline __attribute__((always_inline)) -#elif FMT_MSC_VER -# define FMT_ALWAYS_INLINE __forceinline +#if UMPIRE_FMT_GCC_VERSION || UMPIRE_FMT_CLANG_VERSION +# define UMPIRE_FMT_ALWAYS_INLINE inline __attribute__((always_inline)) +#elif UMPIRE_FMT_MSC_VER +# define UMPIRE_FMT_ALWAYS_INLINE __forceinline #else -# define FMT_ALWAYS_INLINE inline +# define UMPIRE_FMT_ALWAYS_INLINE inline #endif -#ifdef FMT_BUILTIN_CLZ +#ifdef UMPIRE_FMT_BUILTIN_CLZ // Optional version of count_digits for better performance on 32-bit platforms. -FMT_CONSTEXPR20 inline int count_digits(uint32_t n) { +UMPIRE_FMT_CONSTEXPR20 inline int count_digits(uint32_t n) { if (is_constant_evaluated()) { return count_digits_fallback(n); } - auto t = bsr2log10(FMT_BUILTIN_CLZ(n | 1) ^ 31); + auto t = bsr2log10(UMPIRE_FMT_BUILTIN_CLZ(n | 1) ^ 31); return t - (n < data::zero_or_powers_of_10_32_new[t]); } #endif -template constexpr int digits10() FMT_NOEXCEPT { +template constexpr int digits10() UMPIRE_FMT_NOEXCEPT { return std::numeric_limits::digits10; } -template <> constexpr int digits10() FMT_NOEXCEPT { return 38; } -template <> constexpr int digits10() FMT_NOEXCEPT { return 38; } +template <> constexpr int digits10() UMPIRE_FMT_NOEXCEPT { return 38; } +template <> constexpr int digits10() UMPIRE_FMT_NOEXCEPT { return 38; } // DEPRECATED! grouping will be merged into thousands_sep. -template FMT_API std::string grouping_impl(locale_ref loc); +template UMPIRE_FMT_API std::string grouping_impl(locale_ref loc); template inline std::string grouping(locale_ref loc) { return grouping_impl(loc); } @@ -1083,7 +1083,7 @@ template <> inline std::string grouping(locale_ref loc) { return grouping_impl(loc); } -template FMT_API Char thousands_sep_impl(locale_ref loc); +template UMPIRE_FMT_API Char thousands_sep_impl(locale_ref loc); template inline Char thousands_sep(locale_ref loc) { return Char(thousands_sep_impl(loc)); } @@ -1091,7 +1091,7 @@ template <> inline wchar_t thousands_sep(locale_ref loc) { return thousands_sep_impl(loc); } -template FMT_API Char decimal_point_impl(locale_ref loc); +template UMPIRE_FMT_API Char decimal_point_impl(locale_ref loc); template inline Char decimal_point(locale_ref loc) { return Char(decimal_point_impl(loc)); } @@ -1112,7 +1112,7 @@ template void copy2(Char* dst, const char* src) { *dst++ = static_cast(*src++); *dst = static_cast(*src); } -FMT_INLINE void copy2(char* dst, const char* src) { memcpy(dst, src, 2); } +UMPIRE_FMT_INLINE void copy2(char* dst, const char* src) { memcpy(dst, src, 2); } template struct format_decimal_result { Iterator begin; @@ -1123,10 +1123,10 @@ template struct format_decimal_result { // buffer of specified size. The caller must ensure that the buffer is large // enough. template -FMT_CONSTEXPR20 format_decimal_result format_decimal(Char* out, +UMPIRE_FMT_CONSTEXPR20 format_decimal_result format_decimal(Char* out, UInt value, int size) { - FMT_ASSERT(size >= count_digits(value), "invalid digit count"); + UMPIRE_FMT_ASSERT(size >= count_digits(value), "invalid digit count"); out += size; Char* end = out; if (is_constant_evaluated()) { @@ -1155,7 +1155,7 @@ FMT_CONSTEXPR20 format_decimal_result format_decimal(Char* out, } template >::value)> + UMPIRE_FMT_ENABLE_IF(!std::is_pointer>::value)> inline format_decimal_result format_decimal(Iterator out, UInt value, int size) { // Buffer is large enough to hold all digits (digits10 + 1). @@ -1165,7 +1165,7 @@ inline format_decimal_result format_decimal(Iterator out, UInt value, } template -FMT_CONSTEXPR Char* format_uint(Char* buffer, UInt value, int num_digits, +UMPIRE_FMT_CONSTEXPR Char* format_uint(Char* buffer, UInt value, int num_digits, bool upper = false) { buffer += num_digits; Char* end = buffer; @@ -1218,7 +1218,7 @@ class utf8_to_utf16 { wmemory_buffer buffer_; public: - FMT_API explicit utf8_to_utf16(string_view s); + UMPIRE_FMT_API explicit utf8_to_utf16(string_view s); operator wstring_view() const { return {&buffer_[0], size()}; } size_t size() const { return buffer_.size() - 1; } const wchar_t* c_str() const { return &buffer_[0]; } @@ -1235,10 +1235,10 @@ template struct fill_t { unsigned char size_ = 1; public: - FMT_CONSTEXPR void operator=(basic_string_view s) { + UMPIRE_FMT_CONSTEXPR void operator=(basic_string_view s) { auto size = s.size(); if (size > max_size) { - FMT_THROW(format_error("invalid fill")); + UMPIRE_FMT_THROW(format_error("invalid fill")); return; } for (size_t i = 0; i < size; ++i) data_[i] = s[i]; @@ -1248,8 +1248,8 @@ template struct fill_t { constexpr size_t size() const { return size_; } constexpr const Char* data() const { return data_; } - FMT_CONSTEXPR Char& operator[](size_t index) { return data_[index]; } - FMT_CONSTEXPR const Char& operator[](size_t index) const { + UMPIRE_FMT_CONSTEXPR Char& operator[](size_t index) { return data_[index]; } + UMPIRE_FMT_CONSTEXPR const Char& operator[](size_t index) const { return data_[index]; } }; @@ -1354,7 +1354,7 @@ template struct decimal_fp { int exponent; }; -template FMT_API decimal_fp to_decimal(T x) FMT_NOEXCEPT; +template UMPIRE_FMT_API decimal_fp to_decimal(T x) UMPIRE_FMT_NOEXCEPT; } // namespace dragonbox template @@ -1385,7 +1385,7 @@ struct float_specs { // Writes the exponent exp in the form "[+-]d{2,3}" to buffer. template It write_exponent(int exp, It it) { - FMT_ASSERT(-10000 < exp && exp < 10000, "exponent out of range"); + UMPIRE_FMT_ASSERT(-10000 < exp && exp < 10000, "exponent out of range"); if (exp < 0) { *it++ = static_cast('-'); exp = -exp; @@ -1416,7 +1416,7 @@ template T promote_float(T value) { return value; } inline double promote_float(float value) { return static_cast(value); } template -FMT_CONSTEXPR float_specs parse_float_type_spec( +UMPIRE_FMT_CONSTEXPR float_specs parse_float_type_spec( const basic_format_specs& specs, ErrorHandler&& eh = {}) { auto result = float_specs(); result.showpoint = specs.alt; @@ -1427,31 +1427,31 @@ FMT_CONSTEXPR float_specs parse_float_type_spec( break; case 'G': result.upper = true; - FMT_FALLTHROUGH; + UMPIRE_FMT_FALLTHROUGH; case 'g': result.format = float_format::general; break; case 'E': result.upper = true; - FMT_FALLTHROUGH; + UMPIRE_FMT_FALLTHROUGH; case 'e': result.format = float_format::exp; result.showpoint |= specs.precision != 0; break; case 'F': result.upper = true; - FMT_FALLTHROUGH; + UMPIRE_FMT_FALLTHROUGH; case 'f': result.format = float_format::fixed; result.showpoint |= specs.precision != 0; break; case 'A': result.upper = true; - FMT_FALLTHROUGH; + UMPIRE_FMT_FALLTHROUGH; case 'a': result.format = float_format::hex; break; -#ifdef FMT_DEPRECATED_N_SPECIFIER +#ifdef UMPIRE_FMT_DEPRECATED_N_SPECIFIER case 'n': result.locale = true; break; @@ -1464,7 +1464,7 @@ FMT_CONSTEXPR float_specs parse_float_type_spec( } template -FMT_CONSTEXPR void check_int_type_spec(char spec, ErrorHandler&& eh) { +UMPIRE_FMT_CONSTEXPR void check_int_type_spec(char spec, ErrorHandler&& eh) { switch (spec) { case 0: case 'd': @@ -1473,7 +1473,7 @@ FMT_CONSTEXPR void check_int_type_spec(char spec, ErrorHandler&& eh) { case 'b': case 'B': case 'o': -#ifdef FMT_DEPRECATED_N_SPECIFIER +#ifdef UMPIRE_FMT_DEPRECATED_N_SPECIFIER case 'n': #endif case 'c': @@ -1485,7 +1485,7 @@ FMT_CONSTEXPR void check_int_type_spec(char spec, ErrorHandler&& eh) { } template -FMT_CONSTEXPR void handle_char_specs(const basic_format_specs& specs, +UMPIRE_FMT_CONSTEXPR void handle_char_specs(const basic_format_specs& specs, Handler&& handler) { if (specs.type && specs.type != 'c') return handler.on_int(); if (specs.align == align::numeric || specs.sign != sign::none || specs.alt) @@ -1494,7 +1494,7 @@ FMT_CONSTEXPR void handle_char_specs(const basic_format_specs& specs, } template -FMT_CONSTEXPR void handle_cstring_type_spec(Char spec, Handler&& handler) { +UMPIRE_FMT_CONSTEXPR void handle_cstring_type_spec(Char spec, Handler&& handler) { if (spec == 0 || spec == 's') handler.on_string(); else if (spec == 'p') @@ -1504,12 +1504,12 @@ FMT_CONSTEXPR void handle_cstring_type_spec(Char spec, Handler&& handler) { } template -FMT_CONSTEXPR void check_string_type_spec(Char spec, ErrorHandler&& eh) { +UMPIRE_FMT_CONSTEXPR void check_string_type_spec(Char spec, ErrorHandler&& eh) { if (spec != 0 && spec != 's') eh.on_error("invalid type specifier"); } template -FMT_CONSTEXPR void check_pointer_type_spec(Char spec, ErrorHandler&& eh) { +UMPIRE_FMT_CONSTEXPR void check_pointer_type_spec(Char spec, ErrorHandler&& eh) { if (spec != 0 && spec != 'p') eh.on_error("invalid type specifier"); } @@ -1519,25 +1519,25 @@ class char_specs_checker : public ErrorHandler { char type_; public: - FMT_CONSTEXPR char_specs_checker(char type, ErrorHandler eh) + UMPIRE_FMT_CONSTEXPR char_specs_checker(char type, ErrorHandler eh) : ErrorHandler(eh), type_(type) {} - FMT_CONSTEXPR void on_int() { check_int_type_spec(type_, *this); } - FMT_CONSTEXPR void on_char() {} + UMPIRE_FMT_CONSTEXPR void on_int() { check_int_type_spec(type_, *this); } + UMPIRE_FMT_CONSTEXPR void on_char() {} }; template class cstring_type_checker : public ErrorHandler { public: - FMT_CONSTEXPR explicit cstring_type_checker(ErrorHandler eh) + UMPIRE_FMT_CONSTEXPR explicit cstring_type_checker(ErrorHandler eh) : ErrorHandler(eh) {} - FMT_CONSTEXPR void on_string() {} - FMT_CONSTEXPR void on_pointer() {} + UMPIRE_FMT_CONSTEXPR void on_string() {} + UMPIRE_FMT_CONSTEXPR void on_pointer() {} }; template -FMT_NOINLINE FMT_CONSTEXPR OutputIt fill(OutputIt it, size_t n, +UMPIRE_FMT_NOINLINE UMPIRE_FMT_CONSTEXPR OutputIt fill(OutputIt it, size_t n, const fill_t& fill) { auto fill_size = fill.size(); if (fill_size == 1) return detail::fill_n(it, n, fill[0]); @@ -1552,7 +1552,7 @@ FMT_NOINLINE FMT_CONSTEXPR OutputIt fill(OutputIt it, size_t n, // width: output display width in (terminal) column positions. template -FMT_CONSTEXPR OutputIt write_padded(OutputIt out, +UMPIRE_FMT_CONSTEXPR OutputIt write_padded(OutputIt out, const basic_format_specs& specs, size_t size, size_t width, F&& f) { static_assert(align == align::left || align == align::right, ""); @@ -1602,7 +1602,7 @@ template struct write_int_data { size_t size; size_t padding; - FMT_CONSTEXPR write_int_data(int num_digits, unsigned prefix, + UMPIRE_FMT_CONSTEXPR write_int_data(int num_digits, unsigned prefix, const basic_format_specs& specs) : size((prefix >> 24) + to_unsigned(num_digits)), padding(0) { if (specs.align == align::numeric) { @@ -1623,7 +1623,7 @@ template struct write_int_data { // where are written by write_digits(it). // prefix contains chars in three lower bytes and the size in the fourth byte. template -FMT_CONSTEXPR FMT_INLINE OutputIt +UMPIRE_FMT_CONSTEXPR UMPIRE_FMT_INLINE OutputIt write_int(OutputIt out, int num_digits, unsigned prefix, const basic_format_specs& specs, W write_digits) { // Slightly faster check for specs.width == 0 && specs.precision == -1. @@ -1699,13 +1699,13 @@ bool write_int_localized(OutputIt& out, UInt value, unsigned prefix, return true; } -FMT_CONSTEXPR inline void prefix_append(unsigned& prefix, unsigned value) { +UMPIRE_FMT_CONSTEXPR inline void prefix_append(unsigned& prefix, unsigned value) { prefix |= prefix != 0 ? value << 8 : value; prefix += (1u + (value > 0xff ? 1 : 0)) << 24; } template -FMT_CONSTEXPR OutputIt write_int(OutputIt out, T value, +UMPIRE_FMT_CONSTEXPR OutputIt write_int(OutputIt out, T value, const basic_format_specs& specs, locale_ref loc) { auto prefix = 0u; @@ -1762,20 +1762,20 @@ FMT_CONSTEXPR OutputIt write_int(OutputIt out, T value, return format_uint<3, Char>(it, abs_value, num_digits); }); } -#ifdef FMT_DEPRECATED_N_SPECIFIER +#ifdef UMPIRE_FMT_DEPRECATED_N_SPECIFIER case 'n': return write_int_localized(out, abs_value, prefix, specs, loc); #endif case 'c': return write_char(out, static_cast(abs_value), specs); default: - FMT_THROW(format_error("invalid type specifier")); + UMPIRE_FMT_THROW(format_error("invalid type specifier")); } return out; } template -FMT_CONSTEXPR OutputIt write(OutputIt out, basic_string_view s, +UMPIRE_FMT_CONSTEXPR OutputIt write(OutputIt out, basic_string_view s, const basic_format_specs& specs) { auto data = s.data(); auto size = s.size(); @@ -1832,7 +1832,7 @@ inline OutputIt write_significand(OutputIt out, UInt significand, } template ::value)> + UMPIRE_FMT_ENABLE_IF(std::is_integral::value)> inline Char* write_significand(Char* out, UInt significand, int significand_size, int integral_size, Char decimal_point) { @@ -1848,7 +1848,7 @@ inline Char* write_significand(Char* out, UInt significand, } template >::value)> + UMPIRE_FMT_ENABLE_IF(!std::is_pointer>::value)> inline OutputIt write_significand(OutputIt out, UInt significand, int significand_size, int integral_size, Char decimal_point) { @@ -1924,7 +1924,7 @@ OutputIt write_float(OutputIt out, const DecimalFP& fp, // 1234e5 -> 123400000[.0+] size += to_unsigned(fp.exponent); int num_zeros = fspecs.precision - exp; -#ifdef FMT_FUZZ +#ifdef UMPIRE_FMT_FUZZ if (num_zeros > 5000) throw std::runtime_error("fuzz mode - avoiding excessive cpu use"); #endif @@ -1970,7 +1970,7 @@ OutputIt write_float(OutputIt out, const DecimalFP& fp, } template ::value)> + UMPIRE_FMT_ENABLE_IF(std::is_floating_point::value)> OutputIt write(OutputIt out, T value, basic_format_specs specs, locale_ref loc = {}) { if (const_check(!is_supported_floating_point(value))) return out; @@ -2003,7 +2003,7 @@ OutputIt write(OutputIt out, T value, basic_format_specs specs, int precision = specs.precision >= 0 || !specs.type ? specs.precision : 6; if (fspecs.format == float_format::exp) { if (precision == max_value()) - FMT_THROW(format_error("number is too big")); + UMPIRE_FMT_THROW(format_error("number is too big")); else ++precision; } @@ -2018,7 +2018,7 @@ OutputIt write(OutputIt out, T value, basic_format_specs specs, } template ::value)> + UMPIRE_FMT_ENABLE_IF(is_fast_float::value)> OutputIt write(OutputIt out, T value) { if (const_check(!is_supported_floating_point(value))) return out; @@ -2043,7 +2043,7 @@ OutputIt write(OutputIt out, T value) { } template ::value && + UMPIRE_FMT_ENABLE_IF(std::is_floating_point::value && !is_fast_float::value)> inline OutputIt write(OutputIt out, T value) { return write(out, value, basic_format_specs()); @@ -2069,12 +2069,12 @@ template <> struct is_integral : std::true_type {}; template OutputIt write(OutputIt out, monostate) { - FMT_ASSERT(false, ""); + UMPIRE_FMT_ASSERT(false, ""); return out; } template ::value)> + UMPIRE_FMT_ENABLE_IF(!std::is_same::value)> OutputIt write(OutputIt out, string_view value) { auto it = reserve(out, value.size()); it = copy_str(value.begin(), value.end(), it); @@ -2082,23 +2082,23 @@ OutputIt write(OutputIt out, string_view value) { } template -FMT_CONSTEXPR OutputIt write(OutputIt out, basic_string_view value) { +UMPIRE_FMT_CONSTEXPR OutputIt write(OutputIt out, basic_string_view value) { auto it = reserve(out, value.size()); it = copy_str(value.begin(), value.end(), it); return base_iterator(out, it); } template ::value)> + UMPIRE_FMT_ENABLE_IF(is_string::value)> constexpr OutputIt write(OutputIt out, const T& value) { return write(out, to_string_view(value)); } template ::value && + UMPIRE_FMT_ENABLE_IF(is_integral::value && !std::is_same::value && !std::is_same::value)> -FMT_CONSTEXPR OutputIt write(OutputIt out, T value) { +UMPIRE_FMT_CONSTEXPR OutputIt write(OutputIt out, T value) { auto abs_value = static_cast>(value); bool negative = is_negative(value); // Don't do -abs_value since it trips unsigned-integer-overflow sanitizer. @@ -2116,15 +2116,15 @@ FMT_CONSTEXPR OutputIt write(OutputIt out, T value) { return base_iterator(out, it); } -// FMT_ENABLE_IF() condition separated to workaround MSVC bug +// UMPIRE_FMT_ENABLE_IF() condition separated to workaround MSVC bug template < typename Char, typename OutputIt, typename T, bool check = std::is_enum::value && !std::is_same::value && mapped_type_constant>::value != type::custom_type, - FMT_ENABLE_IF(check)> -FMT_CONSTEXPR OutputIt write(OutputIt out, T value) { + UMPIRE_FMT_ENABLE_IF(check)> +UMPIRE_FMT_CONSTEXPR OutputIt write(OutputIt out, T value) { return write( out, static_cast::type>(value)); } @@ -2135,16 +2135,16 @@ constexpr OutputIt write(OutputIt out, bool value) { } template -FMT_CONSTEXPR OutputIt write(OutputIt out, Char value) { +UMPIRE_FMT_CONSTEXPR OutputIt write(OutputIt out, Char value) { auto it = reserve(out, 1); *it++ = value; return base_iterator(out, it); } template -FMT_CONSTEXPR OutputIt write(OutputIt out, const Char* value) { +UMPIRE_FMT_CONSTEXPR OutputIt write(OutputIt out, const Char* value) { if (!value) { - FMT_THROW(format_error("string pointer is null")); + UMPIRE_FMT_THROW(format_error("string pointer is null")); } else { auto length = std::char_traits::length(value); out = write(out, basic_string_view(value, length)); @@ -2216,7 +2216,7 @@ class arg_formatter_base { *it++ = value; } - template ::value)> + template ::value)> void write(Ch value) { out_ = detail::write(out_, value); } @@ -2242,7 +2242,7 @@ class arg_formatter_base { } template - FMT_CONSTEXPR void write(basic_string_view s, + UMPIRE_FMT_CONSTEXPR void write(basic_string_view s, const format_specs& specs = {}) { out_ = detail::write(out_, s, specs); } @@ -2258,13 +2258,13 @@ class arg_formatter_base { constexpr char_spec_handler(arg_formatter_base& f, Char val) : formatter(f), value(val) {} - FMT_CONSTEXPR void on_int() { + UMPIRE_FMT_CONSTEXPR void on_int() { // char is only formatted as int if there are specs. formatter.out_ = detail::write_int(formatter.out_, static_cast(value), formatter.specs_, formatter.locale_); } - FMT_CONSTEXPR void on_char() { + UMPIRE_FMT_CONSTEXPR void on_char() { formatter.out_ = write_char(formatter.out_, value, formatter.specs_); } }; @@ -2284,7 +2284,7 @@ class arg_formatter_base { iterator out() { return out_; } const format_specs& specs() { return specs_; } - FMT_CONSTEXPR void write(bool value) { + UMPIRE_FMT_CONSTEXPR void write(bool value) { write(string_view(value ? "true" : "false"), specs_); } @@ -2292,7 +2292,7 @@ class arg_formatter_base { if (value) write(basic_string_view(value), specs_); else - FMT_THROW(format_error("string pointer is null")); + UMPIRE_FMT_THROW(format_error("string pointer is null")); } public: @@ -2300,33 +2300,33 @@ class arg_formatter_base { : out_(out), specs_(s), locale_(loc) {} iterator operator()(monostate) { - FMT_ASSERT(false, "invalid argument type"); + UMPIRE_FMT_ASSERT(false, "invalid argument type"); return out_; } - template ::value)> - FMT_CONSTEXPR FMT_INLINE iterator operator()(T value) { + template ::value)> + UMPIRE_FMT_CONSTEXPR UMPIRE_FMT_INLINE iterator operator()(T value) { return out_ = detail::write_int(out_, value, specs_, locale_); } - FMT_CONSTEXPR iterator operator()(Char value) { + UMPIRE_FMT_CONSTEXPR iterator operator()(Char value) { handle_char_specs(specs_, char_spec_handler(*this, static_cast(value))); return out_; } - FMT_CONSTEXPR iterator operator()(bool value) { + UMPIRE_FMT_CONSTEXPR iterator operator()(bool value) { if (specs_.type && specs_.type != 's') return (*this)(value ? 1 : 0); write(value != 0); return out_; } - template ::value)> + template ::value)> iterator operator()(T value) { if (const_check(is_supported_floating_point(value))) out_ = detail::write(out_, value, specs_, locale_); else - FMT_ASSERT(false, "unsupported float argument type"); + UMPIRE_FMT_ASSERT(false, "unsupported float argument type"); return out_; } @@ -2335,7 +2335,7 @@ class arg_formatter_base { return out_; } - FMT_CONSTEXPR iterator operator()(basic_string_view value) { + UMPIRE_FMT_CONSTEXPR iterator operator()(basic_string_view value) { check_string_type_spec(specs_.type, error_handler()); write(value, specs_); return out_; @@ -2381,16 +2381,16 @@ class arg_formatter : public arg_formatter_base { } }; -template FMT_CONSTEXPR bool is_name_start(Char c) { +template UMPIRE_FMT_CONSTEXPR bool is_name_start(Char c) { return ('a' <= c && c <= 'z') || ('A' <= c && c <= 'Z') || '_' == c; } // Parses the range [begin, end) as an unsigned integer. This function assumes // that the range is non-empty and the first character is a digit. template -FMT_CONSTEXPR int parse_nonnegative_int(const Char*& begin, const Char* end, +UMPIRE_FMT_CONSTEXPR int parse_nonnegative_int(const Char*& begin, const Char* end, ErrorHandler&& eh) { - FMT_ASSERT(begin != end && '0' <= *begin && *begin <= '9', ""); + UMPIRE_FMT_ASSERT(begin != end && '0' <= *begin && *begin <= '9', ""); unsigned value = 0; // Convert to unsigned to prevent a warning. constexpr unsigned max_int = max_value(); @@ -2435,16 +2435,16 @@ using is_integer = template class width_checker { public: - explicit FMT_CONSTEXPR width_checker(ErrorHandler& eh) : handler_(eh) {} + explicit UMPIRE_FMT_CONSTEXPR width_checker(ErrorHandler& eh) : handler_(eh) {} - template ::value)> - FMT_CONSTEXPR unsigned long long operator()(T value) { + template ::value)> + UMPIRE_FMT_CONSTEXPR unsigned long long operator()(T value) { if (is_negative(value)) handler_.on_error("negative width"); return static_cast(value); } - template ::value)> - FMT_CONSTEXPR unsigned long long operator()(T) { + template ::value)> + UMPIRE_FMT_CONSTEXPR unsigned long long operator()(T) { handler_.on_error("width is not integer"); return 0; } @@ -2455,16 +2455,16 @@ template class width_checker { template class precision_checker { public: - explicit FMT_CONSTEXPR precision_checker(ErrorHandler& eh) : handler_(eh) {} + explicit UMPIRE_FMT_CONSTEXPR precision_checker(ErrorHandler& eh) : handler_(eh) {} - template ::value)> - FMT_CONSTEXPR unsigned long long operator()(T value) { + template ::value)> + UMPIRE_FMT_CONSTEXPR unsigned long long operator()(T value) { if (is_negative(value)) handler_.on_error("negative precision"); return static_cast(value); } - template ::value)> - FMT_CONSTEXPR unsigned long long operator()(T) { + template ::value)> + UMPIRE_FMT_CONSTEXPR unsigned long long operator()(T) { handler_.on_error("precision is not integer"); return 0; } @@ -2476,34 +2476,34 @@ template class precision_checker { // A format specifier handler that sets fields in basic_format_specs. template class specs_setter { public: - explicit FMT_CONSTEXPR specs_setter(basic_format_specs& specs) + explicit UMPIRE_FMT_CONSTEXPR specs_setter(basic_format_specs& specs) : specs_(specs) {} - FMT_CONSTEXPR specs_setter(const specs_setter& other) + UMPIRE_FMT_CONSTEXPR specs_setter(const specs_setter& other) : specs_(other.specs_) {} - FMT_CONSTEXPR void on_align(align_t align) { specs_.align = align; } - FMT_CONSTEXPR void on_fill(basic_string_view fill) { + UMPIRE_FMT_CONSTEXPR void on_align(align_t align) { specs_.align = align; } + UMPIRE_FMT_CONSTEXPR void on_fill(basic_string_view fill) { specs_.fill = fill; } - FMT_CONSTEXPR void on_plus() { specs_.sign = sign::plus; } - FMT_CONSTEXPR void on_minus() { specs_.sign = sign::minus; } - FMT_CONSTEXPR void on_space() { specs_.sign = sign::space; } - FMT_CONSTEXPR void on_hash() { specs_.alt = true; } - FMT_CONSTEXPR void on_localized() { specs_.localized = true; } + UMPIRE_FMT_CONSTEXPR void on_plus() { specs_.sign = sign::plus; } + UMPIRE_FMT_CONSTEXPR void on_minus() { specs_.sign = sign::minus; } + UMPIRE_FMT_CONSTEXPR void on_space() { specs_.sign = sign::space; } + UMPIRE_FMT_CONSTEXPR void on_hash() { specs_.alt = true; } + UMPIRE_FMT_CONSTEXPR void on_localized() { specs_.localized = true; } - FMT_CONSTEXPR void on_zero() { + UMPIRE_FMT_CONSTEXPR void on_zero() { specs_.align = align::numeric; specs_.fill[0] = Char('0'); } - FMT_CONSTEXPR void on_width(int width) { specs_.width = width; } - FMT_CONSTEXPR void on_precision(int precision) { + UMPIRE_FMT_CONSTEXPR void on_width(int width) { specs_.width = width; } + UMPIRE_FMT_CONSTEXPR void on_precision(int precision) { specs_.precision = precision; } - FMT_CONSTEXPR void end_precision() {} + UMPIRE_FMT_CONSTEXPR void end_precision() {} - FMT_CONSTEXPR void on_type(Char type) { + UMPIRE_FMT_CONSTEXPR void on_type(Char type) { specs_.type = static_cast(type); } @@ -2513,15 +2513,15 @@ template class specs_setter { template class numeric_specs_checker { public: - FMT_CONSTEXPR numeric_specs_checker(ErrorHandler& eh, detail::type arg_type) + UMPIRE_FMT_CONSTEXPR numeric_specs_checker(ErrorHandler& eh, detail::type arg_type) : error_handler_(eh), arg_type_(arg_type) {} - FMT_CONSTEXPR void require_numeric_argument() { + UMPIRE_FMT_CONSTEXPR void require_numeric_argument() { if (!is_arithmetic_type(arg_type_)) error_handler_.on_error("format specifier requires numeric argument"); } - FMT_CONSTEXPR void check_sign() { + UMPIRE_FMT_CONSTEXPR void check_sign() { require_numeric_argument(); if (is_integral_type(arg_type_) && arg_type_ != type::int_type && arg_type_ != type::long_long_type && arg_type_ != type::char_type) { @@ -2529,7 +2529,7 @@ template class numeric_specs_checker { } } - FMT_CONSTEXPR void check_precision() { + UMPIRE_FMT_CONSTEXPR void check_precision() { if (is_integral_type(arg_type_) || arg_type_ == type::pointer_type) error_handler_.on_error("precision not allowed for this argument type"); } @@ -2546,56 +2546,56 @@ template class specs_checker : public Handler { numeric_specs_checker checker_; // Suppress an MSVC warning about using this in initializer list. - FMT_CONSTEXPR Handler& error_handler() { return *this; } + UMPIRE_FMT_CONSTEXPR Handler& error_handler() { return *this; } public: - FMT_CONSTEXPR specs_checker(const Handler& handler, detail::type arg_type) + UMPIRE_FMT_CONSTEXPR specs_checker(const Handler& handler, detail::type arg_type) : Handler(handler), checker_(error_handler(), arg_type) {} - FMT_CONSTEXPR specs_checker(const specs_checker& other) + UMPIRE_FMT_CONSTEXPR specs_checker(const specs_checker& other) : Handler(other), checker_(error_handler(), other.arg_type_) {} - FMT_CONSTEXPR void on_align(align_t align) { + UMPIRE_FMT_CONSTEXPR void on_align(align_t align) { if (align == align::numeric) checker_.require_numeric_argument(); Handler::on_align(align); } - FMT_CONSTEXPR void on_plus() { + UMPIRE_FMT_CONSTEXPR void on_plus() { checker_.check_sign(); Handler::on_plus(); } - FMT_CONSTEXPR void on_minus() { + UMPIRE_FMT_CONSTEXPR void on_minus() { checker_.check_sign(); Handler::on_minus(); } - FMT_CONSTEXPR void on_space() { + UMPIRE_FMT_CONSTEXPR void on_space() { checker_.check_sign(); Handler::on_space(); } - FMT_CONSTEXPR void on_hash() { + UMPIRE_FMT_CONSTEXPR void on_hash() { checker_.require_numeric_argument(); Handler::on_hash(); } - FMT_CONSTEXPR void on_localized() { + UMPIRE_FMT_CONSTEXPR void on_localized() { checker_.require_numeric_argument(); Handler::on_localized(); } - FMT_CONSTEXPR void on_zero() { + UMPIRE_FMT_CONSTEXPR void on_zero() { checker_.require_numeric_argument(); Handler::on_zero(); } - FMT_CONSTEXPR void end_precision() { checker_.check_precision(); } + UMPIRE_FMT_CONSTEXPR void end_precision() { checker_.check_precision(); } }; template