v4.1.0 fails with NVCC 12.6 in IndexRanges::size()
Disclaimer: this issue was filed with the help of Codex, but it is a real issue that I hit while trying to compile with v4.1.0. The issue occurred within the stablebear (https://github.com/kthtda/stablebear) devcontainer if this helps with reproducing the issue.
I do not have the issue on commit 718b336.
Summary
Taskflow v4.1.0 fails to compile with NVCC 12.6.85 and GCC 13.4.0 on Ubuntu 22.04.5. Including taskflow/utility/iterator.hpp alone triggers the error; no tasks, kernels, or template instantiations are needed. The same file compiles with GCC directly.
The 4.1.0 release notes list CUDA 12.0 or newer as supported.
Taskflow reproducer
git clone --depth 1 --branch v4.1.0 https://github.com/taskflow/taskflow.gitSave as repro.cu:
#include <taskflow/utility/iterator.hpp>nvcc -std=c++20 -Itaskflow -c repro.cu -o repro.oFails with:
taskflow/utility/iterator.hpp:706:29: error: default argument for template parameter for class enclosing ‘size_t tf::IndexRanges<T, N>::size() const’
706 | size_t IndexRanges<T, N>::size() const {
| ^~~~~The GCC control succeeds:
g++ -std=c++20 -x c++ -Itaskflow -c repro.cu -o repro-gcc.oReduced compiler reproducer (no Taskflow dependency)
Save as reduced.cu:
template <typename T, int N = 1>
struct Range {
int size() const;
};
template <typename T, int N>
int Range<T, N>::size() const {
auto value = []<int D>() { return D; };
return value.template operator()<N>();
}g++ -std=c++20 -x c++ -c reduced.cu -o reduced-gcc.o # succeeds
nvcc -std=c++20 -c reduced.cu -o reduced-nvcc.o # failsThis appears to be an NVCC host-code generation bug. With --keep, the generated reduced.cudafe1.cpp incorrectly repeats N = 1 on the out-of-class member definition, although the source definition has no default:
template<class T, int N = 1>
int Range<T, N>::size() const { /* ... */ }Workaround checked
Replacing the recursive templated lambda inside IndexRanges::size() with an equivalent loop allows compilation with NVCC 12.6.
Source: taskflow/taskflow