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

Avoid instantiating default constructor of value type when WithoutInitializing is given #5307

Merged

Conversation

masterleinad
Copy link
Contributor

Trying #2024 on top of #5277. Fixes #1873.

@masterleinad masterleinad force-pushed the avoid_default_ctor_withoutinitializing branch from 5700bca to 37af24c Compare August 3, 2022 17:42
@masterleinad masterleinad force-pushed the avoid_default_ctor_withoutinitializing branch from e79d08c to f44063b Compare August 4, 2022 15:10
@masterleinad masterleinad force-pushed the avoid_default_ctor_withoutinitializing branch from a48dcc8 to 7515804 Compare August 4, 2022 16:35
Comment on lines +3475 to +3479
if (false) {
// Make sure the destroy functor gets instantiated.
// This avoids "cudaErrorInvalidDeviceFunction"-type errors.
functor.destroy_shared_allocation();
}
Copy link
Contributor Author

Choose a reason for hiding this comment

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

This is the critical change that we missed in the previous attempts.

@masterleinad masterleinad marked this pull request as ready for review August 4, 2022 16:37
if (false) {
// Make sure the destroy functor gets instantiated.
// This avoids "cudaErrorInvalidDeviceFunction"-type errors.
functor.destroy_shared_allocation();
Copy link
Contributor

Choose a reason for hiding this comment

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

Is this not going to generate warnings about unreachable code from one compiler or another? How about (void)&functor_type::destroy_shared_allocation?

Copy link
Contributor Author

Choose a reason for hiding this comment

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

I would try to deal with it when we run into problems. At least our CI seems to be fine with it.

Copy link
Member

@dalg24 dalg24 left a comment

Choose a reason for hiding this comment

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

I am glad you figured that one out

core/unit_test/TestWithoutInitializing.hpp Outdated Show resolved Hide resolved
core/unit_test/TestWithoutInitializing.hpp Outdated Show resolved Hide resolved
core/src/impl/Kokkos_ViewMapping.hpp Show resolved Hide resolved
Co-authored-by: Damien L-G <dalg24+github@gmail.com>
@masterleinad masterleinad force-pushed the avoid_default_ctor_withoutinitializing branch from 5c2cf3f to 2a9ef31 Compare August 5, 2022 14:06
@masterleinad
Copy link
Contributor Author

Retest this please.

Copy link
Member

@crtrott crtrott left a comment

Choose a reason for hiding this comment

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

Just guard that thing in the ViewArray version too then I approve. The clang stuff we should look at independently.


KOKKOS_INLINE_FUNCTION void operator()(DestroyTag const&,
const size_t i) const {
// KOKKOS_IMPL_CUDA_CLANG_WORKAROUND this line causes ptax error
Copy link
Member

Choose a reason for hiding this comment

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

does this comment still has any meaning? Not holding this up because of it but would be good to figure out. I also see that one of hte tests is commented out for HIP too ?

Copy link
Contributor Author

Choose a reason for hiding this comment

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

As far as I can see, the test is also enabled for Cuda+Clang so I removed the comment.

@masterleinad
Copy link
Contributor Author

Just guard that thing in the ViewArray version too then I approve. The clang stuff we should look at independently.

See 3f3bbc2.

@masterleinad masterleinad force-pushed the avoid_default_ctor_withoutinitializing branch from b6da0a9 to 8268c40 Compare August 10, 2022 12:51
@masterleinad
Copy link
Contributor Author

Retest this please.

@masterleinad
Copy link
Contributor Author

Only KokkosCore_UnitTest_CudaTimingBased is failing in CUDA-11.6-NVHPC.

@masterleinad masterleinad deleted the avoid_default_ctor_withoutinitializing branch January 18, 2023 19:00
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
4 participants