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

Solve compilation issue with NVCC on some PowerPC machines #2702

Merged
merged 12 commits into from
Oct 6, 2023
3 changes: 3 additions & 0 deletions host-configs/TOTAL/pangea3-gcc8.4.1-openmpi-4.1.2.cmake
Original file line number Diff line number Diff line change
Expand Up @@ -108,4 +108,7 @@ set(ENABLE_PETSC OFF CACHE BOOL "")
set(ENABLE_HYPRE ON CACHE BOOL "")
set(ENABLE_HYPRE_DEVICE "CUDA" CACHE BOOL "")

# activate workaround for fmt formatter
set(ENABLE_FMT_CONST_FORMATTER_WORKAROUND ON CACHE BOOL "")

include( ${CMAKE_CURRENT_LIST_DIR}/../tpls.cmake )
1 change: 1 addition & 0 deletions src/cmake/GeosxConfig.cmake
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,7 @@ set( PREPROCESSOR_DEFINES ARRAY_BOUNDS_CHECK
CUDA
CUDA_NVTOOLSEXT
HIP
FMT_CONST_FORMATTER_WORKAROUND
FORTRAN_MANGLE_NO_UNDERSCORE
FPE
HYPRE
Expand Down
3 changes: 3 additions & 0 deletions src/coreComponents/common/GeosxConfig.hpp.in
Original file line number Diff line number Diff line change
Expand Up @@ -41,6 +41,9 @@
/// Enables use of HIP (CMake option ENABLE_HIP)
#cmakedefine GEOS_USE_HIP

/// Workaround for FMT compilation issue on some NVCC/PowerPC machines (CMake option ENABLE_FMT_CONST_FORMATTER_WORKAROUND)
#cmakedefine GEOS_USE_FMT_CONST_FORMATTER_WORKAROUND

/// Enables use of PVTPackage (CMake option ENABLE_PVTPackage)
#cmakedefine GEOSX_USE_PVTPackage

Expand Down
22 changes: 22 additions & 0 deletions src/coreComponents/dataRepository/DataContext.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -223,4 +223,26 @@ struct GEOS_FMT_NS::formatter< geos::dataRepository::DataContext > : GEOS_FMT_NS
}
};

// The following workaround is needed to fix compilation with NVCC on some PowerPC machines.
// The issue causes the following assertion error message:
// "Cannot format an argument. To make type T formattable provide a formatter<T> specialization"
// The standard definition of the has_const_formatter check of fmt fails due to a compiler bug, see the issue below:
// https://github.com/fmtlib/fmt/issues/2746
// The workaround was originally implemented in fmt:
// https://github.com/fmtlib/fmt/commit/70de324aa801eaf52e94c402d526a3849797c620
// but later removed:
// https://github.com/fmtlib/fmt/commit/466e0650ec2d153d255a40ec230eb77d7f1c3334
// This workaround provides a specialization of the const formatter check for the DataContext object.
// The formatter is defined within this file, and therefore the check is not needed.
// The scope of the check override is as small as possible to solve the current issue.
#ifdef GEOS_USE_FMT_CONST_FORMATTER_WORKAROUND
template<>
constexpr auto GEOS_FMT_NS::detail::has_const_formatter< geos::dataRepository::DataContext, GEOS_FMT_NS::format_context >() -> bool
{
return true;
}
#endif
// End of the workaround for fmt compilation issues


#endif /* GEOS_DATAREPOSITORY_DATACONTEXT_HPP_ */