What happened
Environment:
- GCC 15.2.1
- CUDA release 13.1, V13.1.115
- CMAKE 4.2.3
Compiling muda with the tools above:
mkdir build
cd build
cmkae -S .. -B .
make
nvcc reports:
/home/ll06/src/muda/src/muda/buffer/details/graph_var_view.inl(10): error: declaration is incompatible with "muda::ComputeGraphVar<muda::ComputeGraphVar<muda::VarView<T>>::VarType> &muda::ComputeGraphVar<muda::VarView<T>>::operator=(const muda::ComputeGraphVar<muda::VarView<T>>::RWView &)" (declared at line 48 of /home/ll06/src/muda/src/muda/buffer/graph_var_view.h)
inline ComputeGraphVar<VarView<T>>& ComputeGraphVar<VarView<T>>::operator=(const RWView& view)
^
/home/ll06/src/muda/src/muda/buffer/details/graph_buffer_view.inl(10): error: declaration is incompatible with "muda::ComputeGraphVar<muda::ComputeGraphVar<muda::BufferView<T>>::VarType> &muda::ComputeGraphVar<muda::BufferView<T>>::operator=(const muda::ComputeGraphVar<muda::BufferView<T>>::RWView &)" (declared at line 51 of /home/ll06/src/muda/src/muda/buffer/graph_buffer_view.h)
inline ComputeGraphVar<BufferView<T>>& ComputeGraphVar<BufferView<T>>::operator=(const RWView& view)
^
/home/ll06/src/muda/src/muda/buffer/details/graph_buffer_2d_view.inl(10): error: declaration is incompatible with "muda::ComputeGraphVar<muda::ComputeGraphVar<muda::Buffer2DView<T>>::VarType> &muda::ComputeGraphVar<muda::Buffer2DView<T>>::operator=(const muda::ComputeGraphVar<muda::Buffer2DView<T>>::RWView &)" (declared at line 51 of /home/ll06/src/muda/src/muda/buffer/graph_buffer_2d_view.h)
inline ComputeGraphVar<Buffer2DView<T>>& ComputeGraphVar<Buffer2DView<T>>::operator=(const RWView& view)
^
/home/ll06/src/muda/src/muda/buffer/details/graph_buffer_3d_view.inl(10): error: declaration is incompatible with "muda::ComputeGraphVar<muda::ComputeGraphVar<muda::Buffer3DView<T>>::VarType> &muda::ComputeGraphVar<muda::Buffer3DView<T>>::operator=(const muda::ComputeGraphVar<muda::Buffer3DView<T>>::RWView &)" (declared at line 51 of /home/ll06/src/muda/src/muda/buffer/graph_buffer_3d_view.h)
inline ComputeGraphVar<Buffer3DView<T>>& ComputeGraphVar<Buffer3DView<T>>::operator=(const RWView& view)
According to the test, the following files have the same problem:
graph_buffer_2d_view.inl
graph_buffer_3d_view.inl
graph_buffer_view.inl
graph_var_view.inl
Possible reason
Here is a snippet that could make nvcc report the same error:
// Common pattern of these file.
namespace muda {
template <bool IsConst, typename T> struct VarView {};
template <typename T>
using var_view = VarView<false, T>;
template <typename T>
class ComputeGraphVar {
public:
using VarType = T;
using RWView = T;
ComputeGraphVar<VarType>& operator=(const RWView& view) {}
};
template <typename T>
class ComputeGraphVar<var_view<T>> {
using VarType = var_view<T>;
using RWView = var_view<T>;
ComputeGraphVar<VarType>& operator=(const RWView& view);
};
template <typename U>
inline ComputeGraphVar<var_view<U>>&
ComputeGraphVar<var_view<U>>::operator=(const var_view<U>& view) {
return *this;
}
}
int main() {
muda::ComputeGraphVar<muda::var_view<int>> v;
return 0;
}
Compile the snippet with command
$ nvcc -o exp exp.cu --verbose
#$ "/usr/bin"/g++ -D__CUDA_ARCH_LIST__=750 -E -x c++ -D__CUDACC__ -D__NVCC__ "-I/opt/cuda/bin/../targets/x86_64-linux/include" "-isystem" "/opt/cuda/bin/../targets/x86_64-linux/include/cccl" -D__CUDACC_VER_MAJOR__=13 -D__CUDACC_VER_MINOR__=1 -D__CUDACC_VER_BUILD__=115 -D__CUDA_API_VER_MAJOR__=13 -D__CUDA_API_VER_MINOR__=1 -D__NVCC_DIAG_PRAGMA_SUPPORT__=1 -D__CUDACC_DEVICE_ATOMIC_BUILTINS__=1 -include "cuda_runtime.h" -m64 "exp.cu" -o "/tmp/tmpxft_00002618_00000000-5_exp.cpp4.ii"
#$ cudafe++ --c++17 --static-host-stub --device-hidden-visibility --gnu_version=150201 --display_error_number --orig_src_file_name "exp.cu" --orig_src_path_name "/home/ll06/src/muda/build/tmp/exp.cu" --allow_managed --m64 --parse_templates --gen_c_file_name "/tmp/tmpxft_00002618_00000000-6_exp.cudafe1.cpp" --stub_file_name "tmpxft_00002618_00000000-6_exp.cudafe1.stub.c" --gen_module_id_file --module_id_file_name "/tmp/tmpxft_00002618_00000000-4_exp.module_id" "/tmp/tmpxft_00002618_00000000-5_exp.cpp4.ii"
exp.cu(30): error: declaration is incompatible with "muda::ComputeGraphVar<muda::ComputeGraphVar<muda::var_view<T>>::VarType> &muda::ComputeGraphVar<muda::var_view<T>>::operator=(const muda::ComputeGraphVar<muda::var_view<T>>::RWView &)" (declared at line 25)
ComputeGraphVar<var_view<U>>::operator=(const var_view<U>& view) {
^
1 error detected in the compilation of "exp.cu".
The error looks due to cudafe++ 's strict dependant name reolsve. The following function definition seems to be able to fix the problem. Passing it to cudafe++ directly will crash with SIGSEGV. But passing to nvcc is okay.
// Try fixing the bug by tailing return type.
template <typename U>
inline auto ComputeGraphVar<var_view<U>>::operator=(const RWView& view) -> ComputeGraphVar<VarType>& {
return *this;
}
What happened
Environment:
Compiling muda with the tools above:
nvcc reports:
According to the test, the following files have the same problem:
graph_buffer_2d_view.inlgraph_buffer_3d_view.inlgraph_buffer_view.inlgraph_var_view.inlPossible reason
Here is a snippet that could make nvcc report the same error:
Compile the snippet with command
The error looks due to
cudafe++'s strict dependant name reolsve. The following function definition seems to be able to fix the problem. Passing it tocudafe++directly will crash with SIGSEGV. But passing tonvccis okay.