From cae861615e34fb712e7a4e33a29e80453b626a3b Mon Sep 17 00:00:00 2001 From: Ryan Quinlan Date: Fri, 20 Jan 2023 17:18:42 -0800 Subject: [PATCH 1/7] Bugfix for BVH tree using gcc@8.1 without RAJA --- src/axom/spin/internal/linear_bvh/build_radix_tree.hpp | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/axom/spin/internal/linear_bvh/build_radix_tree.hpp b/src/axom/spin/internal/linear_bvh/build_radix_tree.hpp index 21336c6ec5..99fc62692d 100644 --- a/src/axom/spin/internal/linear_bvh/build_radix_tree.hpp +++ b/src/axom/spin/internal/linear_bvh/build_radix_tree.hpp @@ -264,7 +264,7 @@ void sort_mcodes(Array& mcodes, int32 size, const ArrayView iter) std::stable_sort(iter.begin(), iter.begin() + size, - [=](int32 i1, int32 i2) { return mcodes[i1] < mcodes[i2]; }); + [&](int32 i1, int32 i2) { return mcodes[i1] < mcodes[i2]; }); ); From b6c38307ea597e4bb009cd40bf3da15db0ac8182 Mon Sep 17 00:00:00 2001 From: Kenneth Weiss Date: Mon, 23 Jan 2023 17:45:15 -0800 Subject: [PATCH 2/7] Updates fmt sprintf patch for XL compiler based on accepted fmt PR See: https://github.com/fmtlib/fmt/pull/3256 --- src/thirdparty/axom/fmt/README | 2 +- src/thirdparty/axom/fmt/format.h | 8 ------ src/thirdparty/axom/fmt/printf.h | 16 ++++++++--- src/thirdparty/axom/fmt/xl_clang.patch | 35 ------------------------- src/thirdparty/axom/fmt/xl_printf.patch | 33 +++++++++++++++++++++++ 5 files changed, 47 insertions(+), 47 deletions(-) delete mode 100644 src/thirdparty/axom/fmt/xl_clang.patch create mode 100644 src/thirdparty/axom/fmt/xl_printf.patch diff --git a/src/thirdparty/axom/fmt/README b/src/thirdparty/axom/fmt/README index 83ed98bdc0..d718ccef24 100644 --- a/src/thirdparty/axom/fmt/README +++ b/src/thirdparty/axom/fmt/README @@ -11,5 +11,5 @@ We also put fmt in the axom namespace to isolate it from other libraries that mi > find . -type f -regex .*[.]h$ -exec sed -i "s/fmt::/axom::fmt::/g" {} \; * Add `namespace axom { \` to `AXOM_FMT_BEGIN_NAMESPACE` in `fmt/core.h` * Add `} \` to `AXOM_FMT_END_NAMESPACE` in `fmt/core.h` -* Apply `src/thirdparty/axom/fmt/xl_clang.patch` -- bugfix for XL compiler +* Apply `src/thirdparty/axom/fmt/xl_printf.patch` -- bugfix for XL compiler * Apply `src/thirdparty/axom/fmt/hipcc_long_double.patch` -- bugfix for dealing with `long double` type on EAS architecture with hip compiler diff --git a/src/thirdparty/axom/fmt/format.h b/src/thirdparty/axom/fmt/format.h index 480af73a92..8fdbee451f 100644 --- a/src/thirdparty/axom/fmt/format.h +++ b/src/thirdparty/axom/fmt/format.h @@ -3393,14 +3393,6 @@ template struct arg_formatter { const basic_format_specs& specs; locale_ref locale; - // BEGIN AXOM BUGFIX - arg_formatter(buffer_appender it, const basic_format_specs& s) - : out (it), specs (s) {} - - arg_formatter(buffer_appender it, const basic_format_specs& s, locale_ref l) - : out (it), specs (s), locale (l) {} - // END AXOM BUGFIX - template AXOM_FMT_CONSTEXPR AXOM_FMT_INLINE auto operator()(T value) -> iterator { return detail::write(out, value, specs, locale); diff --git a/src/thirdparty/axom/fmt/printf.h b/src/thirdparty/axom/fmt/printf.h index 0ee1f30f3e..903fbe480d 100644 --- a/src/thirdparty/axom/fmt/printf.h +++ b/src/thirdparty/axom/fmt/printf.h @@ -220,6 +220,16 @@ template class printf_width_handler { } }; +// BEGIN AXOM BUGFIX +// Workaround for a bug with the XL compiler when initializing +// printf_arg_formatter's base class. +template +auto make_arg_formatter(buffer_appender iter, basic_format_specs& s) + -> arg_formatter { + return {iter, s, locale_ref()}; +} +// END AXOM BUGFIX + // The ``printf`` argument formatter. template class printf_arg_formatter : public arg_formatter { @@ -237,10 +247,10 @@ class printf_arg_formatter : public arg_formatter { } public: - // BEGIN AXOM BUGFIX +// BEGIN AXOM BUGFIX printf_arg_formatter(OutputIt iter, format_specs& s, context_type& ctx) - : base{iter, s}, context_(ctx) {} - // END AXOM BUGFIX + : base(make_arg_formatter(iter, s)), context_(ctx) {} +// END AXOM BUGFIX OutputIt operator()(monostate value) { return base::operator()(value); } diff --git a/src/thirdparty/axom/fmt/xl_clang.patch b/src/thirdparty/axom/fmt/xl_clang.patch deleted file mode 100644 index 6038440aa5..0000000000 --- a/src/thirdparty/axom/fmt/xl_clang.patch +++ /dev/null @@ -1,35 +0,0 @@ -diff --git a/src/thirdparty/axom/fmt/format.h b/src/thirdparty/axom/fmt/format.h -index 309b7d098..047bf255e 100644 ---- a/src/thirdparty/axom/fmt/format.h -+++ b/src/thirdparty/axom/fmt/format.h -@@ -3389,6 +3389,14 @@ template struct arg_formatter { - const basic_format_specs& specs; - locale_ref locale; - -+ // BEGIN AXOM BUGFIX -+ arg_formatter(buffer_appender it, const basic_format_specs& s) -+ : out (it), specs (s) {} -+ -+ arg_formatter(buffer_appender it, const basic_format_specs& s, locale_ref l) -+ : out (it), specs (s), locale (l) {} -+ // END AXOM BUGFIX -+ - template - AXOM_FMT_CONSTEXPR AXOM_FMT_INLINE auto operator()(T value) -> iterator { - return detail::write(out, value, specs, locale); -diff --git a/src/thirdparty/axom/fmt/printf.h b/src/thirdparty/axom/fmt/printf.h -index 1c6f960a6..0ee1f30f3 100644 ---- a/src/thirdparty/axom/fmt/printf.h -+++ b/src/thirdparty/axom/fmt/printf.h -@@ -237,8 +237,10 @@ class printf_arg_formatter : public arg_formatter { - } - - public: -+ // BEGIN AXOM BUGFIX - printf_arg_formatter(OutputIt iter, format_specs& s, context_type& ctx) -- : base{iter, s, locale_ref()}, context_(ctx) {} -+ : base{iter, s}, context_(ctx) {} -+ // END AXOM BUGFIX - - OutputIt operator()(monostate value) { return base::operator()(value); } - diff --git a/src/thirdparty/axom/fmt/xl_printf.patch b/src/thirdparty/axom/fmt/xl_printf.patch new file mode 100644 index 0000000000..98d1bf541e --- /dev/null +++ b/src/thirdparty/axom/fmt/xl_printf.patch @@ -0,0 +1,33 @@ +diff --git a/src/thirdparty/axom/fmt/printf.h b/src/thirdparty/axom/fmt/printf.h +index 1c6f960a6..7f221d01b 100644 +--- a/src/thirdparty/axom/fmt/printf.h ++++ b/src/thirdparty/axom/fmt/printf.h +@@ -220,6 +220,16 @@ template class printf_width_handler { + } + }; + ++// BEGIN AXOM BUGFIX ++// Workaround for a bug with the XL compiler when initializing ++// printf_arg_formatter's base class. ++template ++auto make_arg_formatter(buffer_appender iter, basic_format_specs& s) ++ -> arg_formatter { ++ return {iter, s, locale_ref()}; ++} ++// END AXOM BUGFIX ++ + // The ``printf`` argument formatter. + template + class printf_arg_formatter : public arg_formatter { +@@ -237,8 +247,10 @@ class printf_arg_formatter : public arg_formatter { + } + + public: ++// BEGIN AXOM BUGFIX + printf_arg_formatter(OutputIt iter, format_specs& s, context_type& ctx) +- : base{iter, s, locale_ref()}, context_(ctx) {} ++ : base(make_arg_formatter(iter, s)), context_(ctx) {} ++// END AXOM BUGFIX + + OutputIt operator()(monostate value) { return base::operator()(value); } + From c4024d4a267e7b80613db8fa168b5629986d081f Mon Sep 17 00:00:00 2001 From: Kenneth Weiss Date: Mon, 23 Jan 2023 18:29:12 -0800 Subject: [PATCH 3/7] Adds `using namespace std` to fmt's smoke test This generates a compiler error w/ nvcc. It's preprocessor replaces `std:runtime_error` with `class std::runtime_error' and then complains that `return class std::runtime_error' is invalid. Credit: Ryan Quinlan provided this simple reproducer and the key to a simple fix Co-Authored-By: Ryan Quinlan --- src/thirdparty/tests/CMakeLists.txt | 5 ++++- src/thirdparty/tests/fmt_smoke.cpp | 4 ++++ 2 files changed, 8 insertions(+), 1 deletion(-) diff --git a/src/thirdparty/tests/CMakeLists.txt b/src/thirdparty/tests/CMakeLists.txt index 8567c8fa88..0add0fa0cf 100644 --- a/src/thirdparty/tests/CMakeLists.txt +++ b/src/thirdparty/tests/CMakeLists.txt @@ -130,11 +130,14 @@ endif() #------------------------------------------------------------------------------ # Smoke test for fmt third party library #------------------------------------------------------------------------------ +set(fmt_smoke_dependencies fmt gtest) +blt_list_append( TO fmt_smoke_dependencies ELEMENTS cuda IF ENABLE_CUDA) + blt_add_executable( NAME fmt_smoke_test SOURCES fmt_smoke.cpp OUTPUT_DIR ${TEST_OUTPUT_DIRECTORY} - DEPENDS_ON fmt gtest + DEPENDS_ON ${fmt_smoke_dependencies} FOLDER axom/thirdparty/tests ) axom_add_test(NAME fmt_smoke diff --git a/src/thirdparty/tests/fmt_smoke.cpp b/src/thirdparty/tests/fmt_smoke.cpp index 95fb7d6035..4604674f73 100644 --- a/src/thirdparty/tests/fmt_smoke.cpp +++ b/src/thirdparty/tests/fmt_smoke.cpp @@ -16,6 +16,10 @@ #include "gtest/gtest.h" +// Note: The following line generates an error with nvcc on fmt@9.1 +// Axom has a patch to workaround this error. +using namespace std; + //----------------------------------------------------------------------------- TEST(fmt_smoke, basic_use) { From 332f3d779dca088e500fabbe267f75cc9b0c8c88 Mon Sep 17 00:00:00 2001 From: Kenneth Weiss Date: Mon, 23 Jan 2023 20:19:44 -0800 Subject: [PATCH 4/7] Adds patch for nvcc error with `using namespace std` and fmt Bugfix adapted from Ryan Quinlan's solution Co-Authored-By: Ryan Quinlan --- src/thirdparty/axom/fmt/README | 1 + src/thirdparty/axom/fmt/format-inl.h | 14 +++++-- src/thirdparty/axom/fmt/runtime_error.patch | 44 +++++++++++++++++++++ 3 files changed, 56 insertions(+), 3 deletions(-) create mode 100644 src/thirdparty/axom/fmt/runtime_error.patch diff --git a/src/thirdparty/axom/fmt/README b/src/thirdparty/axom/fmt/README index d718ccef24..12a66b7f47 100644 --- a/src/thirdparty/axom/fmt/README +++ b/src/thirdparty/axom/fmt/README @@ -13,3 +13,4 @@ We also put fmt in the axom namespace to isolate it from other libraries that mi * Add `} \` to `AXOM_FMT_END_NAMESPACE` in `fmt/core.h` * Apply `src/thirdparty/axom/fmt/xl_printf.patch` -- bugfix for XL compiler * Apply `src/thirdparty/axom/fmt/hipcc_long_double.patch` -- bugfix for dealing with `long double` type on EAS architecture with hip compiler +* Apply `src/thirdparty/axom/fmt/runtime_error.patch` -- workaround for dealing with `std::runtime_error` bug in nvcc \ No newline at end of file diff --git a/src/thirdparty/axom/fmt/format-inl.h b/src/thirdparty/axom/fmt/format-inl.h index ff6e6323f8..efdbeb40ac 100644 --- a/src/thirdparty/axom/fmt/format-inl.h +++ b/src/thirdparty/axom/fmt/format-inl.h @@ -121,11 +121,17 @@ template AXOM_FMT_FUNC Char decimal_point_impl(locale_ref) { AXOM_FMT_API AXOM_FMT_FUNC format_error::~format_error() noexcept = default; #endif -AXOM_FMT_FUNC std::system_error vsystem_error(int error_code, string_view format_str, +// BEGIN AXOM BUGFIX +// NVCC's preprocessor converts 'std::error_code' to `class std::error_code' +// and then complains that `return class std::error_code' isn't valid! +using axom_fmt_system_error = std::system_error; + +AXOM_FMT_FUNC axom_fmt_system_error vsystem_error(int error_code, string_view format_str, format_args args) { auto ec = std::error_code(error_code, std::generic_category()); - return std::system_error(ec, vformat(format_str, args)); + return axom_fmt_system_error(ec, vformat(format_str, args)); } +// END AXOM BUGFIX namespace detail { @@ -1449,16 +1455,18 @@ AXOM_FMT_FUNC detail::utf8_to_utf16::utf8_to_utf16(string_view s) { buffer_.push_back(0); } +// BEGIN AXOM BUGFIX AXOM_FMT_FUNC void format_system_error(detail::buffer& out, int error_code, const char* message) noexcept { AXOM_FMT_TRY { auto ec = std::error_code(error_code, std::generic_category()); - write(std::back_inserter(out), std::system_error(ec, message).what()); + write(std::back_inserter(out), axom_fmt_system_error(ec, message).what()); return; } AXOM_FMT_CATCH(...) {} format_error_code(out, error_code, message); } +// END AXOM BUGFIX AXOM_FMT_FUNC void report_system_error(int error_code, const char* message) noexcept { diff --git a/src/thirdparty/axom/fmt/runtime_error.patch b/src/thirdparty/axom/fmt/runtime_error.patch new file mode 100644 index 0000000000..fa92887310 --- /dev/null +++ b/src/thirdparty/axom/fmt/runtime_error.patch @@ -0,0 +1,44 @@ +diff --git a/src/thirdparty/axom/fmt/format-inl.h b/src/thirdparty/axom/fmt/format-inl.h +index ff6e6323f..efdbeb40a 100644 +--- a/src/thirdparty/axom/fmt/format-inl.h ++++ b/src/thirdparty/axom/fmt/format-inl.h +@@ -121,11 +121,17 @@ template AXOM_FMT_FUNC Char decimal_point_impl(locale_ref) { + AXOM_FMT_API AXOM_FMT_FUNC format_error::~format_error() noexcept = default; + #endif + +-AXOM_FMT_FUNC std::system_error vsystem_error(int error_code, string_view format_str, ++// BEGIN AXOM BUGFIX ++// NVCC's preprocessor converts 'std::error_code' to `class std::error_code' ++// and then complains that `return class std::error_code' isn't valid! ++using axom_fmt_system_error = std::system_error; ++ ++AXOM_FMT_FUNC axom_fmt_system_error vsystem_error(int error_code, string_view format_str, + format_args args) { + auto ec = std::error_code(error_code, std::generic_category()); +- return std::system_error(ec, vformat(format_str, args)); ++ return axom_fmt_system_error(ec, vformat(format_str, args)); + } ++// END AXOM BUGFIX + + namespace detail { + +@@ -1449,16 +1455,18 @@ AXOM_FMT_FUNC detail::utf8_to_utf16::utf8_to_utf16(string_view s) { + buffer_.push_back(0); + } + ++// BEGIN AXOM BUGFIX + AXOM_FMT_FUNC void format_system_error(detail::buffer& out, int error_code, + const char* message) noexcept { + AXOM_FMT_TRY { + auto ec = std::error_code(error_code, std::generic_category()); +- write(std::back_inserter(out), std::system_error(ec, message).what()); ++ write(std::back_inserter(out), axom_fmt_system_error(ec, message).what()); + return; + } + AXOM_FMT_CATCH(...) {} + format_error_code(out, error_code, message); + } ++// END AXOM BUGFIX + + AXOM_FMT_FUNC void report_system_error(int error_code, + const char* message) noexcept { From 938bff7279474fa3a43bbc1bcac2f66978362261 Mon Sep 17 00:00:00 2001 From: Kenneth Weiss Date: Mon, 23 Jan 2023 20:59:43 -0800 Subject: [PATCH 5/7] Suppress warnings on XL compiler for cub and cuda related to Clang version --- .../thirdparty/SetupAxomThirdParty.cmake | 19 +++++++++++++++++++ 1 file changed, 19 insertions(+) diff --git a/src/cmake/thirdparty/SetupAxomThirdParty.cmake b/src/cmake/thirdparty/SetupAxomThirdParty.cmake index 669112725d..d7bb81058b 100644 --- a/src/cmake/thirdparty/SetupAxomThirdParty.cmake +++ b/src/cmake/thirdparty/SetupAxomThirdParty.cmake @@ -99,6 +99,25 @@ if (RAJA_DIR) message(STATUS "RAJA loaded: ${RAJA_DIR}") set(RAJA_FOUND TRUE CACHE BOOL "") endif() + + # Suppress warnings from cub and cuda related to the (low) version + # of clang that XL compiler pretends to be. + if(C_COMPILER_FAMILY_IS_XL) + if(TARGET RAJA::cub) + blt_add_target_definitions( + TO RAJA::cub + SCOPE INTERFACE + TARGET_DEFINITIONS CUB_IGNORE_DEPRECATED_CPP_DIALECT) + endif() + + if(TARGET cuda) + blt_add_target_definitions( + TO cuda + SCOPE INTERFACE + TARGET_DEFINITIONS THRUST_IGNORE_DEPRECATED_CPP_DIALECT) + endif() + endif() + else() message(STATUS "RAJA support is OFF" ) set(RAJA_FOUND FALSE CACHE BOOL "") From cbfad0b19cc9215872f1532a7d0de2b4687a2249 Mon Sep 17 00:00:00 2001 From: Kenneth Weiss Date: Mon, 23 Jan 2023 21:10:59 -0800 Subject: [PATCH 6/7] Only run `omp`, `cuda` and `hip` tests for DistributedClosestPoint in `RAJA` configurations These capabilities are provided by RAJA. --- src/axom/quest/examples/CMakeLists.txt | 8 +++++--- 1 file changed, 5 insertions(+), 3 deletions(-) diff --git a/src/axom/quest/examples/CMakeLists.txt b/src/axom/quest/examples/CMakeLists.txt index f641e3dea8..140233b3db 100644 --- a/src/axom/quest/examples/CMakeLists.txt +++ b/src/axom/quest/examples/CMakeLists.txt @@ -53,9 +53,11 @@ if(ENABLE_MPI AND AXOM_ENABLE_SIDRE) # Run the distributed closest point example on N ranks for each enabled policy set(_policies "seq") - blt_list_append(TO _policies ELEMENTS "omp" IF ENABLE_OPENMP) - blt_list_append(TO _policies ELEMENTS "cuda" IF ENABLE_CUDA) - blt_list_append(TO _policies ELEMENTS "hip" IF ENABLE_HIP) + if(RAJA_FOUND) + blt_list_append(TO _policies ELEMENTS "cuda" IF ENABLE_CUDA) + blt_list_append(TO _policies ELEMENTS "hip" IF ENABLE_HIP) + blt_list_append(TO _policies ELEMENTS "omp" IF ENABLE_OPENMP) + endif() # Non-zero empty-rank probability tests domain underloading case set(_meshes "mdmesh.2x1" "mdmesh.2x3") From 4dc8ca29f93d19e808cb02d06daeea9ad7bb23d4 Mon Sep 17 00:00:00 2001 From: Kenny Weiss Date: Tue, 24 Jan 2023 12:16:42 -0800 Subject: [PATCH 7/7] Adds newline to README Per PR suggestion. --- src/thirdparty/axom/fmt/README | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/thirdparty/axom/fmt/README b/src/thirdparty/axom/fmt/README index 12a66b7f47..e6c28d5809 100644 --- a/src/thirdparty/axom/fmt/README +++ b/src/thirdparty/axom/fmt/README @@ -13,4 +13,4 @@ We also put fmt in the axom namespace to isolate it from other libraries that mi * Add `} \` to `AXOM_FMT_END_NAMESPACE` in `fmt/core.h` * Apply `src/thirdparty/axom/fmt/xl_printf.patch` -- bugfix for XL compiler * Apply `src/thirdparty/axom/fmt/hipcc_long_double.patch` -- bugfix for dealing with `long double` type on EAS architecture with hip compiler -* Apply `src/thirdparty/axom/fmt/runtime_error.patch` -- workaround for dealing with `std::runtime_error` bug in nvcc \ No newline at end of file +* Apply `src/thirdparty/axom/fmt/runtime_error.patch` -- workaround for dealing with `std::runtime_error` bug in nvcc