Thanks to visit codestin.com
Credit goes to github.com

Skip to content

[CUDA][HIP] add test for uses of std::array on device code #244

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

Draft
wants to merge 2 commits into
base: main
Choose a base branch
from

Conversation

jmmartinez
Copy link

First attempt at testing llvm/llvm-project#136133 .

Draft for the moment, I have to manually test this further.

__global__ void kernel() { do_test(); }

int main() {
kernel<<<32, 32>>>();
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

can std::array be parameter type of kernel or device functions?

can it be used as non-constexpr stack variable in kernel or device functions?

if so, can we have testcases for those?

Copy link
Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

can std::array be parameter type of kernel or device functions?

It can be used as a parameter for device and kernel functions (which would trigger the copy-constructor). According to the c++ reference std::array is an aggregate in the the same way as a struct with an array inside; so the same rules should apply. For example, all the constructors are implicitly declared.

I'm not sure that adding the copy-constructor case here will improve the coverage of the test (we're testing the interaction with the standard C++ library, and there is no code to test since these behaviors are implicitly defined by clang). Passing an aggregate as an argument should be covered by the tests on clang's side.

I can add the test for std::array constructors here too if you think we really need them.

can it be used as non-constexpr stack variable in kernel or device functions?

This is already covered in the test. We check std::array both in a constexpr and non-constexpr context.

@jmmartinez jmmartinez force-pushed the cuda_wrappers/array branch from 7984192 to e9f5343 Compare May 16, 2025 13:01
@jmmartinez jmmartinez force-pushed the cuda_wrappers/array branch from e9f5343 to 2731dd1 Compare May 16, 2025 14:15
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants