Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Fixes several outstanding bugs #1009

Merged
merged 7 commits into from
Jan 24, 2023
Merged

Conversation

kennyweiss
Copy link
Member

Summary

  • This PR is a bugfix for several outstanding issues
  • It fixes a problem with our BVH tree in non-RAJA configurations where a lambda capture was capturing an array by value. This triggered an error with gcc@8.1 and was extremely inefficient with other compilers. The problem and fix were reported by Ryan Quinlan.
    • It also adds some compiler defines to CUB and CUDA when using the XL compiler to suppress warning about using a version of clang that is too low
    • It also disables omp tests (as well as raja and hip tests) for the distributed_closest_point example for axom configurations without RAJA since these capabilities are provided by RAJA.
  • It includes a workaround for a compiler bug with nvcc on code that uses fmt and has using namespace std. This bug was also reported by Ryan Quinlan, along with a simple reproducer and proposed solution.
    • For some reason, nvcc's preprocessor replaces std::runtime_error with class std::runtime_error and then complains that return class std::runtime_error is not valid. The solution was to use a using statement to create an alias for std::runtime_error
  • It also updates our patch for fmt's printf bug to the accepted solution in Bugfix for fmt::printf on Power9 architecture with the XL compiler fmtlib/fmt#3256

Credits: Thanks Ryan Quinlan for reporting several of these issues, along with reproducers and workarounds!

@kennyweiss kennyweiss added bug Something isn't working App Integration Issues related to integration with applications Spin Issues related to Axom's 'spin' component cuda Issues related to CUDA compiler Related to various compilers and their quirks labels Jan 24, 2023
@kennyweiss kennyweiss added this to the April 2023 Release milestone Jan 24, 2023
@kennyweiss kennyweiss self-assigned this Jan 24, 2023
Comment on lines 265 to 269
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]; });

);
Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

At the axom meeting on 1/28/2023, we discussed an alternate resolution of converting the mcodes parameter to sort_mcodes from an axom::Array to an axom::ArrayView which would avoid the copy.

Should I apply this suggestion instead of the by-reference capture?

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Let's put in the by-reference change at this point, and later change to use an ArrayView.

Comment on lines +103 to +119
# 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()
Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

These avoid some annoying repeated warnings from cub and thrust about the Clang version needing to be greater than 6. They're not particularly useful to us when using the XL compiler, since it's C++ implementation is sufficiently modern.

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));
Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

As far as I can tell, nvcc's preprocessor appears to be replacing std::runtime_error with class std::runtime_error when the code has using namespace std

The errors here and below were:

<axom>/src/thirdparty/axom/fmt/format-inl.h:127:8: error: expected expression
return class std::system_error(ec, vformat(format_str, args)); 
       ^
<axom>/src/thirdparty/axom/fmt/format-inl.h:1456:32: error: expected expression
write(std::back_inserter(out), class std::system_error(ec, message).what()); 
                               ^

Using a type alias circumvents this problem.

Copy link
Member Author

@kennyweiss kennyweiss Jan 24, 2023

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I'll try to create a simple reproducer (ideally outside of fmt and axom) and log an issue.

In the meantime, our fmt_smoke test should trigger this issue (and require the bugfix in this file).

Copy link
Member

@agcapps agcapps left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Thank you for wrapping these up, Kenny.

Copy link
Contributor

@gunney1 gunney1 left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Thanks @kennyweiss

Ryan Quinlan and others added 6 commits January 24, 2023 09:49
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 <quinlan4@llnl.gov>
Bugfix adapted from Ryan Quinlan's solution

Co-Authored-By: Ryan Quinlan <quinlan4@llnl.gov>
… `RAJA` configurations

These capabilities are provided by RAJA.
* 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
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Should the no newline at end of file note be addressed?

Copy link
Member

@rhornung67 rhornung67 left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Thanks @kennyweiss one minor comment.

Per PR suggestion.
@kennyweiss kennyweiss merged commit 5370e8b into develop Jan 24, 2023
@kennyweiss kennyweiss deleted the bugfix/kweiss/odds-and-ends branch January 24, 2023 20:56
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
App Integration Issues related to integration with applications bug Something isn't working compiler Related to various compilers and their quirks cuda Issues related to CUDA Spin Issues related to Axom's 'spin' component
Projects
None yet
Development

Successfully merging this pull request may close these issues.

5 participants