abseil-cpp: [Bug]: Parameter pack workaround fails with nvcc
Describe the issue
Was looking into failures with abseil 20240116.1 and tensorflow today, which fail with
# Execution platform: @local_execution_config_platform//:platform
$PREFIX/include/absl/strings/str_cat.h: In function 'std::enable_if_t<(sizeof... (T) > 1), typename std::common_type<typename std::conditional<true, void, absl::lts_20240116::strings_internal::EnableIfFastCase<T, typename std::enable_if<((std::is_arithmetic<T>::value && (! std::is_same<T, char>::value)) && (! std::is_same<T, bool>::value)), void>::type> >::type ...>::type> absl::lts_20240116::StrAppend(absl::Nonnull<T*>, T ...)':
$PREFIX/include/absl/strings/str_cat.h:606:316: error: expected ';' before '...' token
606 | for (const SomeTrivialEmptyType& dummy2 :
| ^
$PREFIX/include/absl/strings/str_cat.h:606:43: error: parameter packs not expanded with '...':
606 | for (const SomeTrivialEmptyType& dummy2 :
| ^
The relevant chunk of code https://github.com/abseil/abseil-cpp/blob/2f9e432cce407ce0ae50676696666f33a77d42ac/absl/strings/str_cat.h#L606-L614 got introduced recently (d5a2cec006d14c6801ddeb768bf2574a1cf4fa7f), and as it turns out, there already was a comment on that commit noting exactly this problem:
@georgthegreat: @derekmauro, this pattern breaks nvcc (tested with
nvcc11.4 + c++14
,nvcc11.4 + c++17
,nvcc12.1 + c++17
modes) with the following error:absl/strings/str_cat.h:609:316: error: expected ';' after expression for (const SomeTrivialEmptyType &dummy2 : ({((((((void)(n = (lengths[i]))), ((void)((n < (0)) ? ((void)((*(pos++)) = '-')), (n = (~n)) : (0)))), ((void)numbers_internal::FastIntToBufferBackward(numbers_internal::UnsignedAbsoluteValue(std::move(args)), pos += n, static_cast< uint32_t>(n)))), ((void)(++i))), dummy1)...}))
Can we do anything about this? I do not quite understand the meaning of this code, so I can not truly refactor it to make it compilable.
I do understand that nvcc is quite weird when it comes to such complex c++ code, so I need a workaround of some kind.
@derekmauro: @higher-performance - Can you take a look at this?
I think it effectively boils down to a compiler shortcoming of nvcc, but it would be good to be able to use abseil with CUDA.
Steps to reproduce the problem
Build CUDA-enabled tensorflow with newest abseil.
What version of Abseil are you using?
20240116.1
What operating system and version are you using?
Linux
What compiler and version are you using?
GCC + nvcc
What build system are you using?
bazel
Additional context
No response
About this issue
- Original URL
- State: closed
- Created 4 months ago
- Comments: 17 (9 by maintainers)
Commits related to this issue
- Optimize integer-to-string conversions The updated code is designed to: - Be branch-predictor-friendly - Be cache-friendly - Minimize the lengths of critical paths - Minimize slow operations (particu... — committed to abseil/abseil-cpp by invalid-email-address 6 months ago
- Workaround for NVIDIA C++ compiler being unable to parse variadic expansions in range of range-based for loop Fixes: #1629 PiperOrigin-RevId: 611131201 Change-Id: I787731e00207b544ee16055e6e0d323a509... — committed to Brugarolas/abseil-cpp by invalid-email-address 4 months ago
- mgard: conflict between cuda and abseil@20240116.1 compiling mgard+cuda with gcc@12.3.0 and nvcc from cuda@12.3.0 against protobuf pulling in abseil-cpp@20240116.1 results in the errors reported here... — committed to aumuell/spack by aumuell 3 months ago
- mgard: don't restrict protobuf version more than necessary (#43172) * mgard: don't restrict protobuf version more than necessary successfully built: mgard@2022-11-18 ^protobuf@3.{4,21,25} mgard@... — committed to spack/spack by aumuell 3 months ago
- mgard: don't restrict protobuf version more than necessary (#43172) * mgard: don't restrict protobuf version more than necessary successfully built: mgard@2022-11-18 ^protobuf@3.{4,21,25} mgard@... — committed to mathomp4/spack by aumuell 3 months ago
- Workaround for NVIDIA C++ compiler being unable to parse variadic expansions in range of range-based for loop Fixes: #1629 PiperOrigin-RevId: 611131201 Change-Id: I787731e00207b544ee16055e6e0d323a509... — committed to netkex/abseil-cpp by invalid-email-address 4 months ago
- Abseil LTS Branch, Jan 2024, Patch 2 * Prevent overflow in absl::CEscape() Strings larger than 1 GiB on a platform with a 32-bit size_t could potentially overflow size_t in `CEscapedLength()`, result... — committed to derekmauro/abseil-cpp by derekmauro 3 months ago
- Abseil LTS Branch, Jan 2024, Patch 2 (#1650) * Prevent overflow in absl::CEscape() Strings larger than 1 GiB on a platform with a 32-bit size_t could potentially overflow size_t in `CEscapedLength(... — committed to abseil/abseil-cpp by derekmauro 3 months ago
Hi @higher-performance
A repro with godbolt here
Ah, here’s a workaround. Apparently this works, I’ll take care of it.