Skip to content

Commit

Permalink
Prefer View::rank() to View::rank
Browse files Browse the repository at this point in the history
  • Loading branch information
aprokop committed Oct 9, 2024
1 parent 62caef6 commit 1796247
Show file tree
Hide file tree
Showing 13 changed files with 35 additions and 34 deletions.
4 changes: 2 additions & 2 deletions examples/viz/tree_visualization.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -28,7 +28,7 @@ template <typename Points>
void loadPointCloud(std::string const &filename, Points &random_points)
{
static_assert(Kokkos::is_view_v<Points>);
static_assert(Points::rank == 1);
static_assert(Points::rank() == 1);
static_assert(
ArborX::GeometryTraits::dimension_v<typename Points::value_type> == 3);

Expand All @@ -55,7 +55,7 @@ template <typename Points>
void writePointCloud(Points random_points, std::string const &filename)
{
static_assert(Kokkos::is_view_v<Points>);
static_assert(Points::rank == 1);
static_assert(Points::rank() == 1);
static_assert(
ArborX::GeometryTraits::dimension_v<typename Points::value_type> == 3);

Expand Down
8 changes: 4 additions & 4 deletions src/distributed/detail/ArborX_Distributor.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -217,7 +217,7 @@ class Distributor
Kokkos::Profiling::ScopedRegion guard(
"ArborX::Distributor::createFromSends(batched)");

static_assert(View::rank == 1);
static_assert(View::rank() == 1);
static_assert(
std::is_same<typename View::non_const_value_type, int>::value);

Expand All @@ -238,7 +238,7 @@ class Distributor
Kokkos::Profiling::ScopedRegion guard(
"ArborX::Distributor::createFromSends");

static_assert(View::rank == 1);
static_assert(View::rank() == 1);
static_assert(
std::is_same<typename View::non_const_value_type, int>::value);

Expand Down Expand Up @@ -289,12 +289,12 @@ class Distributor
static_assert(
KokkosExt::is_accessible_from<typename decltype(_permute)::memory_space,
ExecutionSpace>::value);
static_assert(ExportView::rank == 1 &&
static_assert(ExportView::rank() == 1 &&
(std::is_same_v<typename ExportView::array_layout,
Kokkos::LayoutLeft> ||
std::is_same_v<typename ExportView::array_layout,
Kokkos::LayoutRight>));
static_assert(ImportView::rank == 1 &&
static_assert(ImportView::rank() == 1 &&
(std::is_same_v<typename ImportView::array_layout,
Kokkos::LayoutLeft> ||
std::is_same_v<typename ImportView::array_layout,
Expand Down
4 changes: 2 additions & 2 deletions src/interpolation/ArborX_InterpMovingLeastSquares.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -146,15 +146,15 @@ class MovingLeastSquares
"Memory space must be accessible from the execution space");

// SourceValues is a 1D view of all source values
static_assert(Kokkos::is_view_v<SourceValues> && SourceValues::rank == 1,
static_assert(Kokkos::is_view_v<SourceValues> && SourceValues::rank() == 1,
"Source values must be a 1D view of values");
static_assert(
KokkosExt::is_accessible_from<typename SourceValues::memory_space,
ExecutionSpace>::value,
"Source values must be accessible from the execution space");

// ApproxValues is a 1D view for approximated values
static_assert(Kokkos::is_view_v<ApproxValues> && ApproxValues::rank == 1,
static_assert(Kokkos::is_view_v<ApproxValues> && ApproxValues::rank() == 1,
"Approx values must be a 1D view");
static_assert(
KokkosExt::is_accessible_from<typename ApproxValues::memory_space,
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -241,7 +241,7 @@ auto movingLeastSquaresCoefficients(ExecutionSpace const &space,
"Memory space must be accessible from the execution space");

// SourcePoints is a 2D view of points
static_assert(Kokkos::is_view_v<SourcePoints> && SourcePoints::rank == 2,
static_assert(Kokkos::is_view_v<SourcePoints> && SourcePoints::rank() == 2,
"source points must be a 2D view of points");
static_assert(
KokkosExt::is_accessible_from<typename SourcePoints::memory_space,
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -26,7 +26,7 @@ KOKKOS_INLINE_FUNCTION void
ensureIsSquareMatrix([[maybe_unused]] Matrix const &mat)
{
static_assert(Kokkos::is_view_v<Matrix>, "Matrix must be a view");
static_assert(Matrix::rank == 2, "Matrix must be 2D");
static_assert(Matrix::rank() == 2, "Matrix must be 2D");
KOKKOS_ASSERT(mat.extent(0) == mat.extent(1));
}

Expand Down Expand Up @@ -95,7 +95,7 @@ KOKKOS_FUNCTION void symmetricPseudoInverseSVDKernel(Matrix &mat, Diag &diag,
"mat must be writable");

static_assert(Kokkos::is_view_v<Diag>, "diag must be a view");
static_assert(Diag::rank == 1, "diag must be 1D");
static_assert(Diag::rank() == 1, "diag must be 1D");
static_assert(!std::is_const_v<typename Diag::value_type>,
"diag must be writable");

Expand Down Expand Up @@ -237,7 +237,7 @@ void symmetricPseudoInverseSVD(ExecutionSpace const &space,
static_assert(Kokkos::is_view_v<InOutMatrices>, "matrices must be a view");
static_assert(!std::is_const_v<typename InOutMatrices::value_type>,
"matrices must be writable");
static_assert(InOutMatrices::rank == 3,
static_assert(InOutMatrices::rank() == 3,
"matrices must be a list of square matrices");
static_assert(
ArborX::Details::KokkosExt::is_accessible_from<
Expand Down
7 changes: 4 additions & 3 deletions src/kokkos_ext/ArborX_KokkosExtMinMaxReduce.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -30,7 +30,8 @@ minmax_reduce(ExecutionSpace const &space, ViewType const &v)
static_assert(is_accessible_from<typename ViewType::memory_space,
ExecutionSpace>::value,
"View must be accessible from the execution space");
static_assert(ViewType::rank == 1, "minmax_reduce requires a View of rank 1");
static_assert(ViewType::rank() == 1,
"minmax_reduce requires a View of rank 1");

auto const n = v.extent(0);
ARBORX_ASSERT(n > 0);
Expand Down Expand Up @@ -65,7 +66,7 @@ typename ViewType::non_const_value_type min_reduce(ExecutionSpace const &space,
static_assert(is_accessible_from<typename ViewType::memory_space,
ExecutionSpace>::value,
"View must be accessible from the execution space");
static_assert(ViewType::rank == 1, "min_reduce requires a View of rank 1");
static_assert(ViewType::rank() == 1, "min_reduce requires a View of rank 1");

auto const n = v.extent(0);
ARBORX_ASSERT(n > 0);
Expand All @@ -92,7 +93,7 @@ typename ViewType::non_const_value_type max_reduce(ExecutionSpace const &space,
static_assert(is_accessible_from<typename ViewType::memory_space,
ExecutionSpace>::value,
"View must be accessible from the execution space");
static_assert(ViewType::rank == 1, "max_reduce requires a View of rank 1");
static_assert(ViewType::rank() == 1, "max_reduce requires a View of rank 1");

auto const n = v.extent(0);
ARBORX_ASSERT(n > 0);
Expand Down
12 changes: 6 additions & 6 deletions src/kokkos_ext/ArborX_KokkosExtSort.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -83,8 +83,8 @@ void sortByKey(ExecutionSpace const &space, Keys &keys, Values &values)

static_assert(Kokkos::is_view<Keys>::value);
static_assert(Kokkos::is_view<Values>::value);
static_assert(Keys::rank == 1);
static_assert(Values::rank == 1);
static_assert(Keys::rank() == 1);
static_assert(Values::rank() == 1);
static_assert(KokkosExt::is_accessible_from<typename Keys::memory_space,
ExecutionSpace>::value);
static_assert(KokkosExt::is_accessible_from<typename Values::memory_space,
Expand Down Expand Up @@ -125,8 +125,8 @@ void sortByKey(
using ExecutionSpace = std::decay_t<decltype(space)>;
static_assert(Kokkos::is_view<Keys>::value);
static_assert(Kokkos::is_view<Values>::value);
static_assert(Keys::rank == 1);
static_assert(Values::rank == 1);
static_assert(Keys::rank() == 1);
static_assert(Values::rank() == 1);
static_assert(KokkosExt::is_accessible_from<typename Keys::memory_space,
ExecutionSpace>::value);
static_assert(KokkosExt::is_accessible_from<typename Values::memory_space,
Expand Down Expand Up @@ -158,8 +158,8 @@ void sortByKey(Kokkos::Experimental::SYCL const &space, Keys &keys,
using ExecutionSpace = std::decay_t<decltype(space)>;
static_assert(Kokkos::is_view<Keys>::value);
static_assert(Kokkos::is_view<Values>::value);
static_assert(Keys::rank == 1);
static_assert(Values::rank == 1);
static_assert(Keys::rank() == 1);
static_assert(Values::rank() == 1);
static_assert(KokkosExt::is_accessible_from<typename Keys::memory_space,
ExecutionSpace>::value);
static_assert(KokkosExt::is_accessible_from<typename Values::memory_space,
Expand Down
2 changes: 1 addition & 1 deletion src/kokkos_ext/ArborX_KokkosExtStdAlgorithms.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -33,7 +33,7 @@ void iota(ExecutionSpace const &space, ViewType const &v,
static_assert(is_accessible_from<typename ViewType::memory_space,
ExecutionSpace>::value,
"View must be accessible from the execution space");
static_assert(unsigned(ViewType::rank) == unsigned(1),
static_assert(unsigned(ViewType::rank()) == unsigned(1),
"iota requires a View of rank 1");

using ValueType = typename ViewType::value_type;
Expand Down
2 changes: 1 addition & 1 deletion src/kokkos_ext/ArborX_KokkosExtViewHelpers.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -31,7 +31,7 @@ template <class ExecutionSpace, class T, class... P>
typename Kokkos::ViewTraits<T, P...>::non_const_value_type
lastElement(ExecutionSpace const &space, Kokkos::View<T, P...> const &v)
{
static_assert(unsigned(Kokkos::ViewTraits<T, P...>::rank) == unsigned(1),
static_assert(unsigned(Kokkos::ViewTraits<T, P...>::rank()) == unsigned(1),
"lastElement requires Views of rank 1");
auto const n = v.extent(0);
ARBORX_ASSERT(n > 0);
Expand Down
8 changes: 4 additions & 4 deletions src/misc/ArborX_SortUtils.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -51,8 +51,8 @@ void applyInversePermutation(ExecutionSpace const &space,
{
static_assert(Kokkos::is_view_v<InputView>);
static_assert(Kokkos::is_view_v<OutputView>);
static_assert(InputView::rank == 1);
static_assert(OutputView::rank == 1);
static_assert(InputView::rank() == 1);
static_assert(OutputView::rank() == 1);
static_assert(std::is_integral_v<typename PermutationView::value_type>);

auto const n = input_view.extent(0);
Expand All @@ -73,8 +73,8 @@ void applyPermutation(ExecutionSpace const &space,
{
static_assert(Kokkos::is_view_v<InputView>);
static_assert(Kokkos::is_view_v<OutputView>);
static_assert(InputView::rank == 1);
static_assert(OutputView::rank == 1);
static_assert(InputView::rank() == 1);
static_assert(OutputView::rank() == 1);
static_assert(std::is_integral_v<typename PermutationView::value_type>);

auto const n = input_view.extent(0);
Expand Down
4 changes: 2 additions & 2 deletions src/spatial/detail/ArborX_AccessTraits.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -39,7 +39,7 @@ using AccessTraitsNotSpecializedArchetypeAlias =

template <typename View, typename Tag>
struct AccessTraits<
View, Tag, std::enable_if_t<Kokkos::is_view<View>{} && View::rank == 1>>
View, Tag, std::enable_if_t<Kokkos::is_view<View>{} && View::rank() == 1>>
{
// Returns a const reference
KOKKOS_FUNCTION static typename View::const_value_type &get(View const &v,
Expand All @@ -56,7 +56,7 @@ struct AccessTraits<

template <typename View, typename Tag>
struct AccessTraits<
View, Tag, std::enable_if_t<Kokkos::is_view<View>{} && View::rank == 2>>
View, Tag, std::enable_if_t<Kokkos::is_view<View>{} && View::rank() == 2>>
{
template <std::size_t... Is>
KOKKOS_FUNCTION static auto getPoint(std::index_sequence<Is...>,
Expand Down
2 changes: 1 addition & 1 deletion test/ArborX_BoostRangeAdapters.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -25,7 +25,7 @@ namespace boost
{
#define ARBORX_ASSERT_VIEW_COMPATIBLE(View) \
using Traits = typename View::traits; \
static_assert(Traits::rank == 1, \
static_assert(Traits::rank() == 1, \
"Adaptor to Boost.Range only available for Views of rank 1"); \
static_assert( \
ArborX::Details::KokkosExt::is_accessible_from_host<View>::value, \
Expand Down
8 changes: 4 additions & 4 deletions test/ArborX_EnableViewComparison.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -29,7 +29,7 @@ template <typename U, typename V>
void arborxViewCheck(U const &u, V const &v, std::string const &u_name,
std::string const &v_name, CommonValueType<U, V> tol = 0)
{
static constexpr int rank = U::rank;
static constexpr int rank = U::rank();

bool same_dim_size = true;
for (int i = 0; i < rank; i++)
Expand Down Expand Up @@ -88,8 +88,8 @@ void arborxViewCheck(U const &u, V const &v, std::string const &u_name,
auto view_a = Kokkos::create_mirror_view_and_copy(Kokkos::HostSpace{}, u); \
auto view_b = Kokkos::create_mirror_view_and_copy(Kokkos::HostSpace{}, v); \
\
static_assert(unsigned(std::decay_t<decltype(u)>::rank) == \
unsigned(std::decay_t<decltype(v)>::rank), \
static_assert(unsigned(std::decay_t<decltype(u)>::rank()) == \
unsigned(std::decay_t<decltype(v)>::rank()), \
"'" #VIEWA "' and '" #VIEWB "' must have the same rank"); \
\
std::string view_a_name(#VIEWA); \
Expand All @@ -115,7 +115,7 @@ struct is_forward_iterable<Kokkos::View<T, P...>> : public boost::mpl::true_
// NOTE Prefer static assertion to SFINAE because error message about no
// operator== for the operands is not as clear.
static_assert(
Kokkos::View<T, P...>::rank == 1 &&
Kokkos::View<T, P...>::rank() == 1 &&
!std::is_same_v<typename Kokkos::View<T, P...>::array_layout,
Kokkos::LayoutStride> &&
ArborX::Details::KokkosExt::is_accessible_from_host<
Expand Down

0 comments on commit 1796247

Please sign in to comment.