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

Enable accessing Kokkos::Array elements in constant expressions #4916

Merged
merged 10 commits into from
Mar 31, 2022

Conversation

dalg24
Copy link
Member

@dalg24 dalg24 commented Mar 30, 2022

Fix #4905
The tricky part was the custom error messages for out of bounds accesses.
The string manipulation facility is a bit heavy handed but we will need something like that anyway to produce better error messages with memory access violations in Kokkos::View.
I decided to call abort from the host-side as well instead of throwing a runtime error.

@dalg24 dalg24 requested a review from nliber March 30, 2022 16:39
core/src/impl/Kokkos_StringManipulation.hpp Show resolved Hide resolved
core/src/impl/Kokkos_StringManipulation.hpp Outdated Show resolved Hide resolved
core/src/impl/Kokkos_StringManipulation.hpp Show resolved Hide resolved
core/src/impl/Kokkos_StringManipulation.hpp Show resolved Hide resolved
core/src/impl/Kokkos_StringManipulation.hpp Show resolved Hide resolved
core/src/impl/Kokkos_StringManipulation.hpp Show resolved Hide resolved
core/unit_test/TestStringManipulation.cpp Show resolved Hide resolved
@dalg24 dalg24 force-pushed the array_constexpr_element_access branch from 9b9cac6 to e7b58e9 Compare March 30, 2022 19:39
@dalg24
Copy link
Member Author

dalg24 commented Mar 31, 2022

Retest this please

@masterleinad
Copy link
Contributor

Retest this please.

@crtrott crtrott merged commit 34aab59 into kokkos:develop Mar 31, 2022
@dalg24 dalg24 deleted the array_constexpr_element_access branch March 31, 2022 17:58
@PhilMiller
Copy link
Contributor

Looks like this makes lots of files warn under NVCC 11.6:
https://cloud.cees.ornl.gov/jenkins-ci/blue/organizations/jenkins/Kokkos/detail/Kokkos/8532/pipeline/56

[](https://cloud.cees.ornl.gov/jenkins-ci/blue/organizations/jenkins/Kokkos/detail/Kokkos/8532/pipeline/56#step-359-log-1092)[](https://cloud.cees.ornl.gov/jenkins-ci/blue/organizations/jenkins/Kokkos/detail/Kokkos/8532/pipeline/56#step-359-log-1093)[](https://cloud.cees.ornl.gov/jenkins-ci/blue/organizations/jenkins/Kokkos/detail/Kokkos/8532/pipeline/56#step-359-log-1094)[](https://cloud.cees.ornl.gov/jenkins-ci/blue/organizations/jenkins/Kokkos/detail/Kokkos/8532/pipeline/56#step-359-log-1095)[](https://cloud.cees.ornl.gov/jenkins-ci/blue/organizations/jenkins/Kokkos/detail/Kokkos/8532/pipeline/56#step-359-log-1096)[](https://cloud.cees.ornl.gov/jenkins-ci/blue/organizations/jenkins/Kokkos/detail/Kokkos/8532/pipeline/56#step-359-log-1097)[](https://cloud.cees.ornl.gov/jenkins-ci/blue/organizations/jenkins/Kokkos/detail/Kokkos/8532/pipeline/56#step-359-log-1098)[](https://cloud.cees.ornl.gov/jenkins-ci/blue/organizations/jenkins/Kokkos/detail/Kokkos/8532/pipeline/56#step-359-log-1099)[](https://cloud.cees.ornl.gov/jenkins-ci/blue/organizations/jenkins/Kokkos/detail/Kokkos/8532/pipeline/56#step-359-log-1100)[](https://cloud.cees.ornl.gov/jenkins-ci/blue/organizations/jenkins/Kokkos/detail/Kokkos/8532/pipeline/56#step-359-log-1101)[](https://cloud.cees.ornl.gov/jenkins-ci/blue/organizations/jenkins/Kokkos/detail/Kokkos/8532/pipeline/56#step-359-log-1102)[](https://cloud.cees.ornl.gov/jenkins-ci/blue/organizations/jenkins/Kokkos/detail/Kokkos/8532/pipeline/56#step-359-log-1103)[](https://cloud.cees.ornl.gov/jenkins-ci/blue/organizations/jenkins/Kokkos/detail/Kokkos/8532/pipeline/56#step-359-log-1104)[](https://cloud.cees.ornl.gov/jenkins-ci/blue/organizations/jenkins/Kokkos/detail/Kokkos/8532/pipeline/56#step-359-log-1105)[](https://cloud.cees.ornl.gov/jenkins-ci/blue/organizations/jenkins/Kokkos/detail/Kokkos/8532/pipeline/56#step-359-log-1106)[](https://cloud.cees.ornl.gov/jenkins-ci/blue/organizations/jenkins/Kokkos/detail/Kokkos/8532/pipeline/56#step-359-log-1107)[](https://cloud.cees.ornl.gov/jenkins-ci/blue/organizations/jenkins/Kokkos/detail/Kokkos/8532/pipeline/56#step-359-log-1108)[](https://cloud.cees.ornl.gov/jenkins-ci/blue/organizations/jenkins/Kokkos/detail/Kokkos/8532/pipeline/56#step-359-log-1109)[](https://cloud.cees.ornl.gov/jenkins-ci/blue/organizations/jenkins/Kokkos/detail/Kokkos/8532/pipeline/56#step-359-log-1110)/var/jenkins/workspace/Kokkos/core/src/impl/Kokkos_StringManipulation.hpp(203): warning #186-D: pointless comparison of unsigned integer with zero

          detected during:

            instantiation of "Kokkos::Impl::to_chars_result Kokkos::Impl::to_chars_i(char *, char *, Integral) [with Integral=size_t]" 

/var/jenkins/workspace/Kokkos/core/src/Kokkos_Array.hpp(86): here

            instantiation of "Kokkos::Impl::ArrayBoundsCheck<Integral, false>::ArrayBoundsCheck(Integral, size_t) [with Integral=const int &]" 

/var/jenkins/workspace/Kokkos/core/src/Kokkos_Array.hpp(134): here

            instantiation of "Kokkos::Array<T, N, Proxy>::reference Kokkos::Array<T, N, Proxy>::operator[](const iType &) [with T=int64_t, N=2UL, Proxy=void, iType=int]" 

/var/jenkins/workspace/Kokkos/core/src/KokkosExp_MDRangePolicy.hpp(351): here

            instantiation of "void Kokkos::MDRangePolicy<Properties...>::init_helper(Kokkos::Impl::TileSizeProperties) [with Properties=<Kokkos::DefaultHostExecutionSpace, Kokkos::Rank<2U, Kokkos::Iterate::Right, Kokkos::Iterate::Right>, Kokkos::IndexType<int64_t>>]" 

/var/jenkins/workspace/Kokkos/core/src/KokkosExp_MDRangePolicy.hpp(296): here

            instantiation of "Kokkos::MDRangePolicy<Properties...>::MDRangePolicy(const Kokkos::Impl::PolicyTraits<Properties...>::execution_space &, const Kokkos::MDRangePolicy<Properties...>::point_type &, const Kokkos::MDRangePolicy<Properties...>::point_type &, const Kokkos::MDRangePolicy<Properties...>::tile_type &) [with Properties=<Kokkos::DefaultHostExecutionSpace, Kokkos::Rank<2U, Kokkos::Iterate::Right, Kokkos::Iterate::Right>, Kokkos::IndexType<int64_t>>]" 

/var/jenkins/workspace/Kokkos/core/src/KokkosExp_MDRangePolicy.hpp(279): here

            instantiation of "Kokkos::MDRangePolicy<Properties...>::MDRangePolicy(const Kokkos::Impl::PolicyTraits<Properties...>::execution_space &, const LT (&)[LN], const UT (&)[UN], const TT (&)[TN]) [with Properties=<Kokkos::DefaultHostExecutionSpace, Kokkos::Rank<2U, Kokkos::Iterate::Right, Kokkos::Iterate::Right>, Kokkos::IndexType<int64_t>>, LT=int, LN=2UL, UT=unsigned long, UN=2UL, TT=int64_t, TN=2UL, <unnamed>=void]" 

/var/jenkins/workspace/Kokkos/core/src/Kokkos_CopyViews.hpp(118): here

            instantiation of "Kokkos::Impl::ViewFill<ViewType, Layout, ExecSpace, 2, iType>::ViewFill(const ViewType &, ViewType::const_value_type &, const ExecSpace &) [with ViewType=Kokkos::View<double **, Kokkos::LayoutStride, Kokkos::Device<Kokkos::HostSpace::execution_space, Kokkos::AnonymousSpace>, Kokkos::MemoryTraits<0U>>, Layout=Kokkos::LayoutRight, ExecSpace=Kokkos::DefaultHostExecutionSpace, iType=int64_t]" 

/var/jenkins/workspace/Kokkos/core/src/Kokkos_CopyViews.hpp(1434): here

            instantiation of "void Kokkos::deep_copy(const Kokkos::View<DT, DP...> &, Kokkos::ViewTraits<DT, DP...>::const_value_type &, std::enable_if<std::is_same<Kokkos::ViewTraits<DT, DP...>::specialize, void>::value, void>::type *) [with DT=double **, DP=<Kokkos::LayoutStride, Kokkos::Device<Kokkos::HostSpace::execution_space, Kokkos::HostSpace::memory_space>, Kokkos::MemoryManaged>]" 

/var/jenkins/workspace/Kokkos/core/unit_test/TestLocalDeepCopy.hpp(68): here

            instantiation of "void Test::impl_test_local_deepcopy_teampolicy_rank_1<ExecSpace,ViewType>(int) [with ExecSpace=Kokkos::Serial, ViewType=Kokkos::View<double ********, Kokkos::LayoutLeft, Kokkos::Serial>]" 

/var/jenkins/workspace/Kokkos/core/unit_test/TestLocalDeepCopy.hpp(941): here

@dalg24
Copy link
Member Author

dalg24 commented Mar 31, 2022

core/src/impl/Kokkos_StringManipulation.hpp(203): warning #186-D: pointless comparison of unsigned integer with zero

@dalg24
Copy link
Member Author

dalg24 commented Mar 31, 2022

There are also a lot of core/src/impl/Kokkos_Error.hpp(117): warning #1305-D: function declared with "noreturn" does return

@PhilMiller
Copy link
Contributor

There are also a lot of core/src/impl/Kokkos_Error.hpp(117): warning #1305-D: function declared with "noreturn" does return

I looked into that a little bit, and I think nvcc is being screwy. The preprocessed source doesn't declare device_abort as noreturn


//<editor-fold desc="String examination">
// returns the length of a given string
KOKKOS_FUNCTION constexpr std::size_t strlen(const char *str) {
Copy link
Member Author

Choose a reason for hiding this comment

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

These need to be declared inline. Will fix.

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.

None yet

5 participants