-
Notifications
You must be signed in to change notification settings - Fork 190
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
Ensure that we can use cuda::std::optional
with types that are not __host__ __device__
#1663
Conversation
22c1418
to
868f28d
Compare
I am currently only defining |
868f28d
to
8d5519b
Compare
} | ||
}; | ||
|
||
__global__ void ensure_exec_check_is_disabled() |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
question: Do we need to define a separate __global__
function? The fake_main()
thing already makes main()
a __global__
function, right?
Can't we do something like:
int main(){
NV_IF_TARGET(NV_IS_DEVICE, assert(optional<DeviceOnly>{} == DeviceOnly{}));
}
?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I do not really understand why, but that is what I initially did and it did not emit any errors.
Probably the same that using global objects like cuda::std::nullopt
only triggers errors in a kernel
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Could be because main()
actually expands to a __host__ __device__
function which is then invoked from a __global__
. That could interfere with if/when nvcc emits a diagnostic.
cccl/libcudacxx/test/libcudacxx/force_include.h
Lines 49 to 57 in e3d181f
__host__ __device__ int fake_main(int, char**); | |
int cuda_thread_count = 1; | |
int cuda_cluster_size = 1; | |
__global__ void fake_main_kernel(int* ret) | |
{ | |
*ret = fake_main(0, NULL); | |
} |
8d5519b
to
7e0adb0
Compare
🟨 CI Results [ Failed: 1 | Passed: 301 | Total: 302 ]
|
# | Runner |
---|---|
232 | linux-amd64-cpu16 |
28 | linux-amd64-gpu-v100-latest-1 |
24 | linux-arm64-cpu16 |
18 | windows-amd64-cpu16 |
👃 Inspect Changes
Modifications in project?
Project | |
---|---|
CCCL Infrastructure | |
+/- | libcu++ |
CUB | |
Thrust |
Modifications in project or dependencies?
Project | |
---|---|
CCCL Infrastructure | |
+/- | libcu++ |
+/- | CUB |
+/- | Thrust |
1 similar comment
🟨 CI Results [ Failed: 1 | Passed: 301 | Total: 302 ]
|
# | Runner |
---|---|
232 | linux-amd64-cpu16 |
28 | linux-amd64-gpu-v100-latest-1 |
24 | linux-arm64-cpu16 |
18 | windows-amd64-cpu16 |
👃 Inspect Changes
Modifications in project?
Project | |
---|---|
CCCL Infrastructure | |
+/- | libcu++ |
CUB | |
Thrust |
Modifications in project or dependencies?
Project | |
---|---|
CCCL Infrastructure | |
+/- | libcu++ |
+/- | CUB |
+/- | Thrust |
🟩 CI Results [ Failed: 0 | Passed: 302 | Total: 302 ]
|
# | Runner |
---|---|
232 | linux-amd64-cpu16 |
28 | linux-amd64-gpu-v100-latest-1 |
24 | linux-arm64-cpu16 |
18 | windows-amd64-cpu16 |
👃 Inspect Changes
Modifications in project?
Project | |
---|---|
CCCL Infrastructure | |
+/- | libcu++ |
CUB | |
Thrust |
Modifications in project or dependencies?
Project | |
---|---|
CCCL Infrastructure | |
+/- | libcu++ |
+/- | CUB |
+/- | Thrust |
_LIBCUDACXX_INLINE_VISIBILITY _CCCL_CONSTEXPR_CXX20 ~__expected_destruct() | ||
{ | ||
if (__has_val_) | ||
{ | ||
_CUDA_VSTD::__destroy_at(_CUDA_VSTD::addressof(__union_.__val_)); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Question: there is no advantage of destroy_at
over calling the dtor explicitely? Both work during constant evaluation, if the dtor is constexpr.
destroy_at` only has a convenience advantage because we do not need to spell the destroyed type's dtor, right?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Right, but it has the disadvantage of an additional function instantiation and that it will only work with std::destroy_at
during compile time as that is the standard blessed function
We do not want to force users to make everything
__host__ __device__
so allow types that are either host only or device only with the caveat that the users must ensure that they are used correctly