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

[BUG]: Proclaiming copyable arguments for lambdas fails to compile #2834

Closed
1 task done
bernhardmgruber opened this issue Nov 15, 2024 · 3 comments · Fixed by #2833
Closed
1 task done

[BUG]: Proclaiming copyable arguments for lambdas fails to compile #2834

bernhardmgruber opened this issue Nov 15, 2024 · 3 comments · Fixed by #2833
Assignees
Labels
2.8.0 target for 2.8.0 release bug Something isn't working right.

Comments

@bernhardmgruber
Copy link
Contributor

Is this a duplicate?

Type of Bug

Compile-time Error

Component

libcu++

Describe the bug

The following code fails to compile:

#include <thrust/transform.h>
#include <thrust/device_vector.h>

using T = int;

int main() {
    const auto n = 16354564;
    thrust::device_vector<T> a(n, 424);
    thrust::device_vector<T> b(n, 74565);
    thrust::device_vector<T> c(n);

    thrust::transform(a.begin(), a.end(), b.begin(), c.begin(),
        cuda::proclaim_copyable_arguments(
            [] __host__ __device__ (const T& lhs, const T& rhs) {
                return lhs + rhs;
        }));
}

How to Reproduce

https://godbolt.org/z/KbPKaoxW8

Expected behavior

It should succeed to compile.

Reproduction link

No response

Operating System

No response

nvidia-smi output

No response

NVCC version

No response

@bernhardmgruber bernhardmgruber added the bug Something isn't working right. label Nov 15, 2024
@github-project-automation github-project-automation bot moved this to Todo in CCCL Nov 15, 2024
@bernhardmgruber bernhardmgruber self-assigned this Nov 15, 2024
@cccl-authenticator-app cccl-authenticator-app bot moved this from Todo to In Progress in CCCL Nov 15, 2024
@bernhardmgruber
Copy link
Contributor Author

Surprisingly, it also fails for ordinary function objects: https://godbolt.org/z/EqbjzeT9h

@bernhardmgruber bernhardmgruber added the 2.8.0 target for 2.8.0 release label Nov 19, 2024
@bernhardmgruber
Copy link
Contributor Author

Alright, this is a problem with the host compiler g++-10, which is used on compiler explorer. I can reproduce the problem locally. With g++-11:

bgruber@concorde:~/dev$ cat proclaim.cu 
#include <thrust/transform.h>
#include <thrust/device_vector.h>

using T = int;

int main() {
    const auto n = 16354564;
    thrust::device_vector<T> a(n, 424);
    thrust::device_vector<T> b(n, 74565);
    thrust::device_vector<T> c(n);

    thrust::transform(a.begin(), a.end(), b.begin(), c.begin(),
        cuda::proclaim_copyable_arguments(
            [] __host__ __device__ (const T& lhs, const T& rhs) {
                return lhs + rhs;
        }));
}
bgruber@concorde:~/dev$ /usr/local/cuda-12.6/bin/nvcc -ccbin g++-11 --extended-lambda -Icccl/cub -Icccl/thrust -Icccl/libcudacxx/include ./proclaim.cu 

it works, but changing to g++-10:

bgruber@concorde:~/dev$ /usr/local/cuda-12.6/bin/nvcc -ccbin g++-10 --extended-lambda -Icccl/cub -Icccl/thrust -Icccl/libcudacxx/include ./proclaim.cu 
cccl/libcudacxx/include/cuda/__functional/address_stability.h(66): error: no instance of constructor "cuda::__4::__callable_permitting_copied_arguments<F>::__callable_permitting_copied_arguments [with F=lambda [](const T &, const T &)->int]" matches the argument list
            argument types are: (lambda [](const T &, const T &)->int)
    return __callable_permitting_copied_arguments<F>{::cuda::std::__4::move(f)};
                                                    ^
cccl/libcudacxx/include/cuda/__functional/address_stability.h(49): note #3326-D: function "cuda::__4::__callable_permitting_copied_arguments<F>::__callable_permitting_copied_arguments(const cuda::__4::__callable_permitting_copied_arguments<lambda [](const T &, const T &)->int> &) [with F=lambda [](const T &, const T &)->int]" does not match because argument #1 does not match parameter
  struct __callable_permitting_copied_arguments : F
         ^
cccl/libcudacxx/include/cuda/__functional/address_stability.h(49): note #3326-D: function "cuda::__4::__callable_permitting_copied_arguments<F>::__callable_permitting_copied_arguments(cuda::__4::__callable_permitting_copied_arguments<lambda [](const T &, const T &)->int> &&) [with F=lambda [](const T &, const T &)->int]" does not match because argument #1 does not match parameter
  struct __callable_permitting_copied_arguments : F
         ^
cccl/libcudacxx/include/cuda/__functional/address_stability.h(49): note #3322-D: number of parameters of function "cuda::__4::__callable_permitting_copied_arguments<F>::__callable_permitting_copied_arguments() [with F=lambda [](const T &, const T &)->int]" does not match the call
  struct __callable_permitting_copied_arguments : F
         ^
          detected during instantiation of "auto cuda::__4::proclaim_copyable_arguments(F)->cuda::__4::__callable_permitting_copied_arguments<F> [with F=lambda [](const T &, const T &)->int]" at line 16 of ./proclaim.cu

1 error detected in the compilation of "./proclaim.cu".

@bernhardmgruber bernhardmgruber closed this as not planned Won't fix, can't repro, duplicate, stale Nov 19, 2024
@github-project-automation github-project-automation bot moved this from In Progress to Done in CCCL Nov 19, 2024
@bernhardmgruber
Copy link
Contributor Author

We need to implement a workaround for g++-10.

@github-project-automation github-project-automation bot moved this from Done to Needs Triage in CCCL Nov 20, 2024
@bernhardmgruber bernhardmgruber moved this from Needs Triage to Todo in CCCL Nov 20, 2024
@cccl-authenticator-app cccl-authenticator-app bot moved this from Todo to In Review in CCCL Nov 26, 2024
@github-project-automation github-project-automation bot moved this from In Review to Done in CCCL Nov 28, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
2.8.0 target for 2.8.0 release bug Something isn't working right.
Projects
Status: Done
Development

Successfully merging a pull request may close this issue.

1 participant