-
Notifications
You must be signed in to change notification settings - Fork 10.8k
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
[CUDA][HIP] file-scope device variable not allowed with trivial ctor #72261
Comments
|
Make trivial ctor/dtor implicitly host device functions so that they can be used to initialize file-scope device variables to match nvcc behavior. Fixes: llvm#72261 Fixes: SWDEV-432412
Make trivial ctor/dtor implicitly host device functions so that they can be used to initialize file-scope device variables to match nvcc behavior. Fixes: #72261 Fixes: SWDEV-432412
@llvm/issue-subscribers-clang-frontend Author: Yaxun (Sam) Liu (yxsamliu)
`struct A {
A() {}
~A() {}
int x;
};
device A x;` the above code is allowed with nvcc but not cuda-clang. https://godbolt.org/z/jjMG3zTd3 https://godbolt.org/z/74Ed1WvGn nvcc allows it not because it makes the ctor A::A() implicitly host device (this can be seen by defining A x in device function), but because it does not check host/device availability for file-scope device var. I think it makes sense to make trivial ctor/dtor implicitly host device. @Artem-B |
@yxsamliu The patch is causing compilation issues: #72394 (comment) |
Make trivial ctor/dtor implicitly host device functions so that they can be used to initialize file-scope device variables to match nvcc behavior. Fixes: llvm#72261 Fixes: SWDEV-432412
Make trivial ctor/dtor implicitly host device functions so that they can be used to initialize file-scope device variables to match nvcc behavior. Fixes: llvm#72261 Fixes: SWDEV-432412
Treat ctor/dtor in device var init as host device function so that they can be used to initialize file-scope device variables to match nvcc behavior. If they are non-trivial they will be diagnosed. We cannot add implicit host device attrs to non-trivial ctor/dtor since determining whether they are non-trivial needs to know whether they have a trivial body and all their member and base classes' ctor/dtor have trivial body, which is affected by where their bodies are defined or instantiated. Fixes: llvm#72261 Fixes: SWDEV-432412
Make trivial ctor/dtor implicitly host device functions so that they can be used to initialize file-scope device variables to match nvcc behavior. Fixes: llvm#72261 Fixes: SWDEV-432412 cherry-pick of: llvm#72394 Change-Id: Ieac37f8fa35e035a84bae9c5d29c6f5acab6a766
Treat ctor/dtor in device var init as host device function so that they can be used to initialize file-scope device variables to match nvcc behavior. If they are non-trivial they will be diagnosed. We cannot add implicit host device attrs to non-trivial ctor/dtor since determining whether they are non-trivial needs to know whether they have a trivial body and all their member and base classes' ctor/dtor have trivial body, which is affected by where their bodies are defined or instantiated. Fixes: #72261 Fixes: SWDEV-432412
Make trivial ctor/dtor implicitly host device functions so that they can be used to initialize file-scope device variables to match nvcc behavior. Fixes: llvm#72261 Fixes: SWDEV-432412 cherry-pick of: llvm#72394 [CUDA][HIP] ignore implicit host/device attr for override When deciding whether a previous function declaration is an overload or override, implicit host/device attrs should not be considered. This fixes the failure for the following code: `template <typename T> class C { explicit C() {}; }; template <> C<int>::C() {}; ` The issue was introduced by llvm#72394 sine the template specialization is treated as overload due to implicit host/device attrs are considered for overload/override differentiation. cherry-pick of llvm#72815 Change-Id: Ie896cc0e4d5d82d5af48e08a996a3b392285d9ee
Treat ctor/dtor in device var init as host device function so that they can be used to initialize file-scope device variables to match nvcc behavior. If they are non-trivial they will be diagnosed. We cannot add implicit host device attrs to non-trivial ctor/dtor since determining whether they are non-trivial needs to know whether they have a trivial body and all their member and base classes' ctor/dtor have trivial body, which is affected by where their bodies are defined or instantiated. Revert "[CUDA][HIP] make trivial ctor/dtor host device" This reverts commit 876f99a. Fixes: llvm#72261 Fixes: SWDEV-432412 Fixes: SWDEV-433956 Change-Id: I711db63a2166ce77dea06aad5d04cae10d96ce24
Treat ctor/dtor in device var init as host device function so that they can be used to initialize file-scope device variables to match nvcc behavior. If they are non-trivial they will be diagnosed. We cannot add implicit host device attrs to non-trivial ctor/dtor since determining whether they are non-trivial needs to know whether they have a trivial body and all their member and base classes' ctor/dtor have trivial body, which is affected by where their bodies are defined or instantiated. Fixes: llvm#72261 Fixes: SWDEV-432412 Change-Id: Iac807ee37d235c73d66fcf9c4416b928a1afe832
`struct A {
A() {}
~A() {}
int x;
};
device A x;`
the above code is allowed with nvcc but not cuda-clang.
https://godbolt.org/z/jjMG3zTd3
https://godbolt.org/z/74Ed1WvGn
nvcc allows it not because it makes the ctor A::A() implicitly host device (this can be seen by defining A x in device function), but because it does not check host/device availability for file-scope device var.
I think it makes sense to make trivial ctor/dtor implicitly host device.
@Artem-B
The text was updated successfully, but these errors were encountered: