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

nvcc compile error #2476

Closed
nielskm opened this issue Jul 4, 2022 · 7 comments · Fixed by #2477
Closed

nvcc compile error #2476

nielskm opened this issue Jul 4, 2022 · 7 comments · Fixed by #2477

Comments

@nielskm
Copy link
Contributor

nielskm commented Jul 4, 2022

Describe the bug
The const version of Catch::Benchmark::Detail::ObjectStorage::stored_object does not compile with nvcc (invalid type cast). The problem is solved by first casting to const void* and then to void* using const_cast.

I will make a PR ASAP.

@horenmar
Copy link
Member

horenmar commented Jul 4, 2022

Which nvcc version is that?

@nielskm
Copy link
Contributor Author

nielskm commented Jul 4, 2022

I tested it with CUDA 11.7 (compiler version 11.7.64).

@jbadwaik
Copy link
Contributor

jbadwaik commented Jul 4, 2022

Could you please post the complete error? I'm a little confused at the situation.

nvcc is a device compiler, it offloads the host side compilation to the underlying host compiler (which is most probably gcc). And since Catch does not have any __device__ annotations, the error should actually come from the underlying host GCC compiler. Hence, my curiousity.

@nielskm
Copy link
Contributor Author

nielskm commented Jul 5, 2022

I understand completely, and I agree that the error should come from the host compiler.

I get the following error:
/path/to/catch2/benchmark/catch_constructor.hpp(62): error: invalid type conversion
When compiling the attached example with version 11.7 of the CUDA toolkit.
catch2_nvcc_error.tar.gz

@nielskm
Copy link
Contributor Author

nielskm commented Jul 5, 2022

By the way, I am testing this on Ubuntu 22.04 where the default GCC version is 11.2. I suppose that is the one used by nvcc.

@jbadwaik
Copy link
Contributor

jbadwaik commented Jul 5, 2022

Thank you. Yes. You are correct. I can reproduce this.

T const& stored_object() const {
    return *static_cast<T const*>(static_cast<void const*>(data));
}

I suggest the above fix instead, which does not need any const cast.

@jbadwaik
Copy link
Contributor

jbadwaik commented Jul 5, 2022

As a workaround for now, I will suggest not using catch/catch_all.hpp if possible but instead using fine-grained headers catch_test_macros.hpp and catch_approx.hpp. That will remove the problem of using the benchmark headers.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging a pull request may close this issue.

3 participants