From f31850b124288f00b83799d30be7ea8533a4f0f2 Mon Sep 17 00:00:00 2001 From: john bowen Date: Tue, 23 Jun 2026 17:23:58 -0700 Subject: [PATCH 1/8] split tests into two categories: strongindex support and non stron index support. Add support for arithmetic --- include/RAJA/index/IndexValue.hpp | 120 ++++++++++++++++-- include/RAJA/index/RangeSegment.hpp | 19 ++- include/RAJA/util/Span.hpp | 13 +- .../test-forall-CombiningAdapter.cpp.in | 2 +- .../test-forall-indexset-view.cpp.in | 2 +- .../indexset/test-forall-indexset.cpp.in | 2 +- .../forall/region/test-forall-region.cpp.in | 3 +- .../test-forall-resource-indexset.cpp.in | 2 +- .../test-forall-segment-view.cpp.in | 2 +- .../test-kernel-hyperplane-2D.cpp.in | 2 +- .../test-kernel-hyperplane-3D.cpp.in | 2 +- .../test-kernel-nested-loop-segments.cpp.in | 6 +- .../test-kernel-nested-loop-view.cpp.in | 2 +- .../reduce-loc/test-kernel-reduceloc.cpp.in | 2 +- ...t-kernel-reduce-params-multi-lambda.cpp.in | 2 +- .../test-kernel-basic-param.cpp.in | 2 +- .../region/test-kernel-region-sync.cpp.in | 2 +- .../kernel/region/test-kernel-region.cpp.in | 2 +- ...-kernel-tile-count-direct-unchecked.cpp.in | 2 +- ...kernel-tile-ForICount-direct-unchecked.hpp | 10 +- .../test-kernel-tile-count-direct.cpp.in | 2 +- .../test-kernel-tile-ForICount-direct.hpp | 14 +- .../test-kernel-tile-count-loop.cpp.in | 2 +- .../tile-variants/test-kernel-tiledyn.cpp.in | 2 +- .../test-kernel-tilefixed.cpp.in | 2 +- .../test-kernel-tilelocal.cpp.in | 2 +- .../nested_direct/test-launch-nested.cpp.in | 2 +- .../test-launch-nested.cpp.in | 2 +- .../nested_loop/test-launch-nested.cpp.in | 2 +- .../test-launch-nested-tile-direct.cpp.in | 2 +- ...launch-nested-tile-direct-unchecked.cpp.in | 2 +- .../test-launch-nested-tile-loop.cpp.in | 2 +- ...ch-nested-tile-icount-tcount-direct.cpp.in | 2 +- ...tile-icount-tcount-direct-unchecked.cpp.in | 2 +- ...unch-nested-tile-icount-tcount-loop.cpp.in | 2 +- test/include/RAJA_test-index-types.hpp | 46 +++---- 36 files changed, 192 insertions(+), 95 deletions(-) diff --git a/include/RAJA/index/IndexValue.hpp b/include/RAJA/index/IndexValue.hpp index 6f1fc7336f..3ab317d69c 100644 --- a/include/RAJA/index/IndexValue.hpp +++ b/include/RAJA/index/IndexValue.hpp @@ -24,6 +24,7 @@ #include +#include "RAJA/util/concepts.hpp" #include "RAJA/util/macros.hpp" #include "RAJA/util/types.hpp" @@ -58,13 +59,17 @@ struct IndexValue : public IndexValueBase RAJA_INLINE IndexValue& operator=(IndexValue const&) = default; RAJA_INLINE IndexValue& operator=(IndexValue&&) = default; + RAJA_INLINE IndexValue& operator=(const value_type& v) + { + value = v; + return *this; + } + /*! - * \brief Explicit constructor. + * \brief Constructor. * \param v Initial value */ - RAJA_HOST_DEVICE RAJA_INLINE constexpr explicit IndexValue(value_type v) - : value(v) - {} + RAJA_HOST_DEVICE RAJA_INLINE constexpr IndexValue(value_type v) : value(v) {} //! Dereference provides cast-to-integer. RAJA_HOST_DEVICE RAJA_INLINE value_type& operator*() { return value; } @@ -302,19 +307,100 @@ convertIndex_helper(typename FROM::IndexValueType const val) namespace type_traits { -template -struct is_instance_of_index_value : std::is_base_of, T> +template +struct is_instance_of_index_value : std::is_base_of, T> {}; -template +template constexpr bool is_instance_of_index_value_v = - is_instance_of_index_value::value; + is_instance_of_index_value::value; } // namespace type_traits namespace concepts { template -concept IndexValued = type_traits::is_instance_of_index_value_v; +concept IndexValued = + type_traits::is_instance_of_index_value_v; + +template +concept Index = concepts::Integral || concepts::IndexValued; +} // namespace concepts + +template +RAJA_HOST_DEVICE RAJA_INLINE TYPE operator+(typename TYPE::value_type lhs, + TYPE rhs) +{ + return TYPE(lhs + *rhs); +} + +template +RAJA_HOST_DEVICE RAJA_INLINE TYPE operator-(typename TYPE::value_type lhs, + TYPE rhs) +{ + return TYPE(lhs - *rhs); +} + +template +RAJA_HOST_DEVICE RAJA_INLINE TYPE operator*(typename TYPE::value_type lhs, + TYPE rhs) +{ + return TYPE(lhs * *rhs); +} + +template +RAJA_HOST_DEVICE RAJA_INLINE TYPE operator/(typename TYPE::value_type lhs, + TYPE rhs) +{ + return TYPE(lhs / *rhs); +} + +template +RAJA_HOST_DEVICE RAJA_INLINE TYPE operator%(typename TYPE::value_type lhs, + TYPE rhs) +{ + return TYPE(lhs % *rhs); +} + +template +RAJA_HOST_DEVICE RAJA_INLINE bool operator<(typename TYPE::value_type lhs, + TYPE rhs) +{ + return lhs < *rhs; +} + +template +RAJA_HOST_DEVICE RAJA_INLINE bool operator<=(typename TYPE::value_type lhs, + TYPE rhs) +{ + return lhs <= *rhs; +} + +template +RAJA_HOST_DEVICE RAJA_INLINE bool operator>(typename TYPE::value_type lhs, + TYPE rhs) +{ + return lhs > *rhs; +} + +template +RAJA_HOST_DEVICE RAJA_INLINE bool operator>=(typename TYPE::value_type lhs, + TYPE rhs) +{ + return lhs >= *rhs; +} + +template +RAJA_HOST_DEVICE RAJA_INLINE bool operator==(typename TYPE::value_type lhs, + TYPE rhs) +{ + return lhs == *rhs; +} + +template +RAJA_HOST_DEVICE RAJA_INLINE bool operator!=(typename TYPE::value_type lhs, + TYPE rhs) +{ + return lhs != *rhs; } /*! @@ -402,12 +488,15 @@ using make_signed_t = #define RAJA_INDEX_VALUE(TYPE, NAME) \ class TYPE : public ::RAJA::IndexValue \ { \ - using parent = ::RAJA::IndexValue; \ - \ public: \ + using parent = ::RAJA::IndexValue; \ + using parent::operator=; \ + using parent::operator*; \ + using parent::operator++; \ + using parent::operator--; \ using IndexValueType = TYPE; \ RAJA_HOST_DEVICE RAJA_INLINE TYPE() : parent::IndexValue() {} \ - RAJA_HOST_DEVICE RAJA_INLINE explicit TYPE(::RAJA::Index_type v) \ + RAJA_HOST_DEVICE RAJA_INLINE TYPE(::RAJA::Index_type v) \ : parent::IndexValue(v) \ {} \ static inline std::string getName() { return NAME; } \ @@ -423,10 +512,15 @@ using make_signed_t = class TYPE : public ::RAJA::IndexValue \ { \ public: \ + using parent = RAJA::IndexValue; \ + using parent::operator=; \ + using parent::operator*; \ + using parent::operator++; \ + using parent::operator--; \ RAJA_HOST_DEVICE RAJA_INLINE TYPE() \ : RAJA::IndexValue::IndexValue() \ {} \ - RAJA_HOST_DEVICE RAJA_INLINE explicit TYPE(IDXT v) \ + RAJA_HOST_DEVICE RAJA_INLINE TYPE(IDXT v) \ : RAJA::IndexValue::IndexValue(v) \ {} \ static inline std::string getName() { return NAME; } \ diff --git a/include/RAJA/index/RangeSegment.hpp b/include/RAJA/index/RangeSegment.hpp index bb91cfcc00..73946f02cf 100644 --- a/include/RAJA/index/RangeSegment.hpp +++ b/include/RAJA/index/RangeSegment.hpp @@ -94,7 +94,7 @@ namespace RAJA * ****************************************************************************** */ -template>> struct TypedRangeSegment { @@ -105,8 +105,6 @@ struct TypedRangeSegment // static_assert(std::is_signed::value, "TypedRangeSegment DiffT requires signed type."); - static_assert(!std::is_floating_point::value, - "TypedRangeSegment Type must be non floating point."); //@{ //! @name Types used in implementation based on template parameters. @@ -139,6 +137,21 @@ struct TypedRangeSegment m_end(begin > end ? m_begin : iterator(end)) {} + //! This constructor exists whenever an IndexValued index is passed to a + //! RangeSegment So that the class may be constructed directly with values of + //! the underlying storage type + template + requires((concepts::IndexValued || concepts::IndexValued) && + std::is_convertible_v, StripStorageT> && + std::is_convertible_v, StripStorageT>) + RAJA_HOST_DEVICE constexpr TypedRangeSegment(BeginT begin, EndT end) + : m_begin(iterator(StripStorageT(stripIndexType(begin)))), + m_end(StripStorageT(stripIndexType(begin)) > + StripStorageT(stripIndexType(end)) + ? m_begin + : iterator(StripStorageT(stripIndexType(end)))) + {} + //! Disable compiler generated constructor RAJA_HOST_DEVICE TypedRangeSegment() = delete; diff --git a/include/RAJA/util/Span.hpp b/include/RAJA/util/Span.hpp index 3119431100..6f86cc0279 100644 --- a/include/RAJA/util/Span.hpp +++ b/include/RAJA/util/Span.hpp @@ -20,11 +20,7 @@ #ifndef RAJA_SPAN_HPP #define RAJA_SPAN_HPP -#include -#include - #include "RAJA/index/IndexValue.hpp" -#include "RAJA/util/concepts.hpp" #include "RAJA/util/macros.hpp" #include "RAJA/util/types.hpp" #include "camp/concepts.hpp" @@ -61,14 +57,7 @@ namespace RAJA * compile time extents * */ - -namespace concepts -{ -template -concept SpanIndex = concepts::Integral || concepts::IndexValued; -}; - -template +template struct Span { using element_type = typename std::iterator_traits::value_type; diff --git a/test/functional/forall/CombiningAdapter/test-forall-CombiningAdapter.cpp.in b/test/functional/forall/CombiningAdapter/test-forall-CombiningAdapter.cpp.in index 70fcefd657..4b9986a91e 100644 --- a/test/functional/forall/CombiningAdapter/test-forall-CombiningAdapter.cpp.in +++ b/test/functional/forall/CombiningAdapter/test-forall-CombiningAdapter.cpp.in @@ -30,7 +30,7 @@ // Cartesian product of types used in parameterized tests // using @BACKEND@ForallCombiningAdapter@DIMENSION@Types = - Test< camp::cartesian_product>::Types; diff --git a/test/functional/forall/indexset-view/test-forall-indexset-view.cpp.in b/test/functional/forall/indexset-view/test-forall-indexset-view.cpp.in index 15f464b88e..1adf50d694 100644 --- a/test/functional/forall/indexset-view/test-forall-indexset-view.cpp.in +++ b/test/functional/forall/indexset-view/test-forall-indexset-view.cpp.in @@ -32,7 +32,7 @@ // Cartesian product of types used in parameterized tests // using @BACKEND@ForallIndexSetViewTypes = - Test< camp::cartesian_product>::Types; diff --git a/test/functional/forall/indexset/test-forall-indexset.cpp.in b/test/functional/forall/indexset/test-forall-indexset.cpp.in index 24748ee380..7589001204 100644 --- a/test/functional/forall/indexset/test-forall-indexset.cpp.in +++ b/test/functional/forall/indexset/test-forall-indexset.cpp.in @@ -32,7 +32,7 @@ // Cartesian product of types used in parameterized tests // using @BACKEND@ForallIndexSetTypes = - Test< camp::cartesian_product>::Types; diff --git a/test/functional/forall/region/test-forall-region.cpp.in b/test/functional/forall/region/test-forall-region.cpp.in index 0a255b9851..b5d37562bb 100644 --- a/test/functional/forall/region/test-forall-region.cpp.in +++ b/test/functional/forall/region/test-forall-region.cpp.in @@ -47,7 +47,7 @@ using OpenMPForallRegionExecPols = // Cartesian product of types used in parameterized tests // using @REGION_BACKEND@ForallRegionTypes = - Test< camp::cartesian_product>::Types; @@ -60,4 +60,3 @@ INSTANTIATE_TYPED_TEST_SUITE_P(@REGION_BACKEND@, @REGION_BACKEND@ForallRegionTypes); - diff --git a/test/functional/forall/resource-indexset/test-forall-resource-indexset.cpp.in b/test/functional/forall/resource-indexset/test-forall-resource-indexset.cpp.in index 0803f9e663..7445ebff39 100644 --- a/test/functional/forall/resource-indexset/test-forall-resource-indexset.cpp.in +++ b/test/functional/forall/resource-indexset/test-forall-resource-indexset.cpp.in @@ -32,7 +32,7 @@ // Cartesian product of types used in parameterized tests // using @BACKEND@ForallResourceIndexSetTypes = - Test< camp::cartesian_product>::Types; diff --git a/test/functional/forall/segment-view/test-forall-segment-view.cpp.in b/test/functional/forall/segment-view/test-forall-segment-view.cpp.in index 7447087c71..49f34113b5 100644 --- a/test/functional/forall/segment-view/test-forall-segment-view.cpp.in +++ b/test/functional/forall/segment-view/test-forall-segment-view.cpp.in @@ -30,7 +30,7 @@ // Cartesian product of types used in parameterized tests // using @BACKEND@ForallSegmentViewTypes = - Test< camp::cartesian_product>::Types; diff --git a/test/functional/kernel/hyperplane/test-kernel-hyperplane-2D.cpp.in b/test/functional/kernel/hyperplane/test-kernel-hyperplane-2D.cpp.in index 3bafd5f7fd..16fb402f75 100644 --- a/test/functional/kernel/hyperplane/test-kernel-hyperplane-2D.cpp.in +++ b/test/functional/kernel/hyperplane/test-kernel-hyperplane-2D.cpp.in @@ -179,7 +179,7 @@ using HipKernelHyperplaneExecPols = // Cartesian product of types used in parameterized tests // using @BACKEND@KernelHyperplane = - Test< camp::cartesian_product>::Types; diff --git a/test/functional/kernel/nested-loop-view-types/test-kernel-nested-loop-view.cpp.in b/test/functional/kernel/nested-loop-view-types/test-kernel-nested-loop-view.cpp.in index c7d9b318b8..598ad026f3 100644 --- a/test/functional/kernel/nested-loop-view-types/test-kernel-nested-loop-view.cpp.in +++ b/test/functional/kernel/nested-loop-view-types/test-kernel-nested-loop-view.cpp.in @@ -309,7 +309,7 @@ camp::list< // Cartesian product of types used in parameterized tests // using @BACKEND@KernelNestesLoop@TESTTYPE@@DIM@Types = - Test< camp::cartesian_product>::Types; diff --git a/test/functional/kernel/reduce-loc/test-kernel-reduceloc.cpp.in b/test/functional/kernel/reduce-loc/test-kernel-reduceloc.cpp.in index cc3b2ee7e1..1d54534726 100644 --- a/test/functional/kernel/reduce-loc/test-kernel-reduceloc.cpp.in +++ b/test/functional/kernel/reduce-loc/test-kernel-reduceloc.cpp.in @@ -245,7 +245,7 @@ using HipKernelLocForallPols = // Cartesian product of types used in parameterized tests // using @LOC_BACKEND@KernelLocTypes = - Test< camp::cartesian_product>::Types; diff --git a/test/functional/kernel/region/test-kernel-region.cpp.in b/test/functional/kernel/region/test-kernel-region.cpp.in index 5d9e6b6731..719e06f768 100644 --- a/test/functional/kernel/region/test-kernel-region.cpp.in +++ b/test/functional/kernel/region/test-kernel-region.cpp.in @@ -72,7 +72,7 @@ using OpenMPKernelRegionExecPols = // Cartesian product of types used in parameterized tests // using @REGION_BACKEND@KernelRegionTypes = - Test< camp::cartesian_product>::Types; diff --git a/test/functional/kernel/tile-icount-tcount-direct-unchecked/test-kernel-tile-count-direct-unchecked.cpp.in b/test/functional/kernel/tile-icount-tcount-direct-unchecked/test-kernel-tile-count-direct-unchecked.cpp.in index b3bd80e8ca..8e92b0ed89 100644 --- a/test/functional/kernel/tile-icount-tcount-direct-unchecked/test-kernel-tile-count-direct-unchecked.cpp.in +++ b/test/functional/kernel/tile-icount-tcount-direct-unchecked/test-kernel-tile-count-direct-unchecked.cpp.in @@ -109,7 +109,7 @@ using HipKernelTileTCountExecPols = camp::list< // Cartesian product of types used in parameterized tests // using @BACKEND@KernelTile@TESTTYPE@Types = - Test< camp::cartesian_product& _trip_count, RAJA::expt::ValOp& _tile_count) { - _trip_count += 1; + _trip_count += IDX_TYPE(1); if ( i % tsize == t && ii == t ) { - _tile_count += 1; + _tile_count += IDX_TYPE(1); } } ); @@ -62,9 +62,9 @@ CallKernel(IDX_TYPE& _trip_count, RAJA::make_tuple( static_cast(0) ), [=] RAJA_HOST_DEVICE(IDX_TYPE i, IDX_TYPE ii) { - trip_count += 1; + trip_count += IDX_TYPE(1); if ( i % tsize == t && ii == t ) { - tile_count += 1; + tile_count += IDX_TYPE(1); } } ); @@ -83,7 +83,7 @@ void KernelTileForICountDirectUncheckedTestImpl(IDX_TYPE N, IDX_TYPE tsize) IDX_TYPE tile_expect = N / tsize; if ( t < N % tsize ) { - tile_expect += 1; + tile_expect += IDX_TYPE(1); } ASSERT_EQ(trip_count, (t+1) * N); ASSERT_EQ(tile_count, tile_expect); diff --git a/test/functional/kernel/tile-icount-tcount-direct/test-kernel-tile-count-direct.cpp.in b/test/functional/kernel/tile-icount-tcount-direct/test-kernel-tile-count-direct.cpp.in index b39f1573a5..fa2de78ca2 100644 --- a/test/functional/kernel/tile-icount-tcount-direct/test-kernel-tile-count-direct.cpp.in +++ b/test/functional/kernel/tile-icount-tcount-direct/test-kernel-tile-count-direct.cpp.in @@ -236,7 +236,7 @@ using SyclKernelTileTCountExecPols = camp::list< // Cartesian product of types used in parameterized tests // using @BACKEND@KernelTile@TESTTYPE@Types = - Test< camp::cartesian_product& _trip_count, RAJA::expt::ValOp& _tile_count) { - _trip_count += 1; + _trip_count += IDX_TYPE(1); if ( i % tsize == t && ii == t ) { - _tile_count += 1; + _tile_count += IDX_TYPE(1); } } ); @@ -60,9 +60,9 @@ CallKernel(IDX_TYPE& _trip_count, RAJA::make_tuple( static_cast(0) ), [=] RAJA_HOST_DEVICE(IDX_TYPE i, IDX_TYPE ii) { - trip_count += 1; + trip_count += IDX_TYPE(1); if ( i % tsize == t && ii == t ) { - tile_count += 1; + tile_count += IDX_TYPE(1); } } ); @@ -75,8 +75,8 @@ void KernelTileForICountDirectTestImpl(IDX_TYPE N, IDX_TYPE tsize) { IDX_TYPE trip_count(0); - for (IDX_TYPE t = 0; t < tsize; ++t) { - IDX_TYPE tile_count = 0; + for (IDX_TYPE t(0); t < tsize; ++t) { + IDX_TYPE tile_count(0); CallKernel(trip_count, tile_count, t, N, tsize); IDX_TYPE tile_expect = N / tsize; @@ -105,7 +105,7 @@ TYPED_TEST_P(KernelTileForICountDirectTest, ForICountTileKernel) using REDUCE_POLICY = typename camp::at>::type; using USE_REDUCER_PARAM = typename camp::at>::type; - IDX_TYPE tsize = camp::at_v::value; + IDX_TYPE tsize(camp::at_v::value); KernelTileForICountDirectTestImpl( IDX_TYPE(57), tsize); diff --git a/test/functional/kernel/tile-icount-tcount-loop/test-kernel-tile-count-loop.cpp.in b/test/functional/kernel/tile-icount-tcount-loop/test-kernel-tile-count-loop.cpp.in index 7f9701d4f8..d99117fb8b 100644 --- a/test/functional/kernel/tile-icount-tcount-loop/test-kernel-tile-count-loop.cpp.in +++ b/test/functional/kernel/tile-icount-tcount-loop/test-kernel-tile-count-loop.cpp.in @@ -236,7 +236,7 @@ using SyclKernelTileTCountExecPols = camp::list< // Cartesian product of types used in parameterized tests // using @BACKEND@KernelTile@TESTTYPE@Types = - Test< camp::cartesian_product>::Types; diff --git a/test/functional/kernel/tile-variants/test-kernel-tilefixed.cpp.in b/test/functional/kernel/tile-variants/test-kernel-tilefixed.cpp.in index c397aa039b..e535c1e0fd 100644 --- a/test/functional/kernel/tile-variants/test-kernel-tilefixed.cpp.in +++ b/test/functional/kernel/tile-variants/test-kernel-tilefixed.cpp.in @@ -270,7 +270,7 @@ using SyclKernelTileExecPols = // Cartesian product of types used in parameterized tests // using @TILE_BACKEND@KernelTileTypes = - Test< camp::cartesian_product>::Types; diff --git a/test/functional/launch/nested_direct/test-launch-nested.cpp.in b/test/functional/launch/nested_direct/test-launch-nested.cpp.in index ea92db5cdf..1a78907650 100644 --- a/test/functional/launch/nested_direct/test-launch-nested.cpp.in +++ b/test/functional/launch/nested_direct/test-launch-nested.cpp.in @@ -29,7 +29,7 @@ // Cartesian product of types used in parameterized tests // using @BACKEND@LaunchNestedTypes = - Test< camp::cartesian_product>::Types; diff --git a/test/functional/launch/nested_direct_unchecked/test-launch-nested.cpp.in b/test/functional/launch/nested_direct_unchecked/test-launch-nested.cpp.in index 628c7efb08..262924a2d8 100644 --- a/test/functional/launch/nested_direct_unchecked/test-launch-nested.cpp.in +++ b/test/functional/launch/nested_direct_unchecked/test-launch-nested.cpp.in @@ -29,7 +29,7 @@ // Cartesian product of types used in parameterized tests // using @BACKEND@LaunchNestedTypes = - Test< camp::cartesian_product>::Types; diff --git a/test/functional/launch/nested_loop/test-launch-nested.cpp.in b/test/functional/launch/nested_loop/test-launch-nested.cpp.in index cd2af8ee26..80d8d7b016 100644 --- a/test/functional/launch/nested_loop/test-launch-nested.cpp.in +++ b/test/functional/launch/nested_loop/test-launch-nested.cpp.in @@ -29,7 +29,7 @@ // Cartesian product of types used in parameterized tests // using @BACKEND@LaunchNestedTypes = - Test< camp::cartesian_product>::Types; diff --git a/test/functional/launch/nested_tile_direct/test-launch-nested-tile-direct.cpp.in b/test/functional/launch/nested_tile_direct/test-launch-nested-tile-direct.cpp.in index 59a1ea91a5..425d385bd1 100644 --- a/test/functional/launch/nested_tile_direct/test-launch-nested-tile-direct.cpp.in +++ b/test/functional/launch/nested_tile_direct/test-launch-nested-tile-direct.cpp.in @@ -29,7 +29,7 @@ // Cartesian product of types used in parameterized tests // using @BACKEND@LaunchNestedTypes = - Test< camp::cartesian_product>::Types; diff --git a/test/functional/launch/nested_tile_direct_unchecked/test-launch-nested-tile-direct-unchecked.cpp.in b/test/functional/launch/nested_tile_direct_unchecked/test-launch-nested-tile-direct-unchecked.cpp.in index 0238fc01a7..41d263a910 100644 --- a/test/functional/launch/nested_tile_direct_unchecked/test-launch-nested-tile-direct-unchecked.cpp.in +++ b/test/functional/launch/nested_tile_direct_unchecked/test-launch-nested-tile-direct-unchecked.cpp.in @@ -29,7 +29,7 @@ // Cartesian product of types used in parameterized tests // using @BACKEND@LaunchNestedTypes = - Test< camp::cartesian_product>::Types; diff --git a/test/functional/launch/nested_tile_loop/test-launch-nested-tile-loop.cpp.in b/test/functional/launch/nested_tile_loop/test-launch-nested-tile-loop.cpp.in index 5d063da3b7..1163dae07d 100644 --- a/test/functional/launch/nested_tile_loop/test-launch-nested-tile-loop.cpp.in +++ b/test/functional/launch/nested_tile_loop/test-launch-nested-tile-loop.cpp.in @@ -29,7 +29,7 @@ // Cartesian product of types used in parameterized tests // using @BACKEND@LaunchNestedTypes = - Test< camp::cartesian_product>::Types; diff --git a/test/functional/launch/tile_icount_tcount_direct/test-launch-nested-tile-icount-tcount-direct.cpp.in b/test/functional/launch/tile_icount_tcount_direct/test-launch-nested-tile-icount-tcount-direct.cpp.in index f42482f7b6..199e0f5971 100644 --- a/test/functional/launch/tile_icount_tcount_direct/test-launch-nested-tile-icount-tcount-direct.cpp.in +++ b/test/functional/launch/tile_icount_tcount_direct/test-launch-nested-tile-icount-tcount-direct.cpp.in @@ -29,7 +29,7 @@ // Cartesian product of types used in parameterized tests // using @BACKEND@LaunchNestedTypes = - Test< camp::cartesian_product>::Types; diff --git a/test/functional/launch/tile_icount_tcount_direct_unchecked/test-launch-nested-tile-icount-tcount-direct-unchecked.cpp.in b/test/functional/launch/tile_icount_tcount_direct_unchecked/test-launch-nested-tile-icount-tcount-direct-unchecked.cpp.in index 0ca15ad6b0..651ae43baf 100644 --- a/test/functional/launch/tile_icount_tcount_direct_unchecked/test-launch-nested-tile-icount-tcount-direct-unchecked.cpp.in +++ b/test/functional/launch/tile_icount_tcount_direct_unchecked/test-launch-nested-tile-icount-tcount-direct-unchecked.cpp.in @@ -29,7 +29,7 @@ // Cartesian product of types used in parameterized tests // using @BACKEND@LaunchNestedTypes = - Test< camp::cartesian_product>::Types; diff --git a/test/functional/launch/tile_icount_tcount_loop/test-launch-nested-tile-icount-tcount-loop.cpp.in b/test/functional/launch/tile_icount_tcount_loop/test-launch-nested-tile-icount-tcount-loop.cpp.in index bee00c999b..38456dfb09 100644 --- a/test/functional/launch/tile_icount_tcount_loop/test-launch-nested-tile-icount-tcount-loop.cpp.in +++ b/test/functional/launch/tile_icount_tcount_loop/test-launch-nested-tile-icount-tcount-loop.cpp.in @@ -29,7 +29,7 @@ // Cartesian product of types used in parameterized tests // using @BACKEND@LaunchNestedTypes = - Test< camp::cartesian_product>::Types; diff --git a/test/include/RAJA_test-index-types.hpp b/test/include/RAJA_test-index-types.hpp index bb8c6acbe9..c861051b66 100644 --- a/test/include/RAJA_test-index-types.hpp +++ b/test/include/RAJA_test-index-types.hpp @@ -27,44 +27,47 @@ // RAJA_INDEX_VALUE(StrongIndexType, "StrongIndexType"); RAJA_INDEX_VALUE_T(StrongInt, int, "StrongIntType"); -RAJA_INDEX_VALUE_T(StrongULL, unsigned long long , "StrongULLType"); +RAJA_INDEX_VALUE_T(StrongUL, unsigned long , "StrongULType"); // -// Standard index types list +// Raw index types list // -// TODO(bowen): do we want to support StrongULL here? -using IdxTypeList = camp::list; + unsigned long long>; // -// Signed index types list +// Raw signed index types list // -// TODO(bowen): do we want to support StrongInt here? -using SignedIdxTypeList = camp::list; +// Use this list for tests that require signed builtin integer semantics. +using RawSignedIdxTypeList = camp::list; // -// Index types w/ Strong types list +// Strong-compatible index types list // +// Use this list for tests that are expected to work with strongly typed +// indices and avoid raw integer interoperability assumptions. using StrongIdxTypeList = camp::list; #endif // __RAJA_test_index_types_HPP__ From f175e67ee366d6294e67e97083583f03b210c165 Mon Sep 17 00:00:00 2001 From: john bowen Date: Tue, 30 Jun 2026 17:34:36 -0700 Subject: [PATCH 2/8] Refactor kernel unit tests to support IndexValue types --- include/RAJA/index/IndexValue.hpp | 6 +- include/RAJA/pattern/params/params_base.hpp | 93 +++++++++++- include/RAJA/pattern/params/reducer.hpp | 32 ++++- include/RAJA/util/Span.hpp | 12 +- .../test-kernel-hyperplane-2D.cpp.in | 2 +- .../test-kernel-hyperplane-3D.cpp.in | 2 +- .../tests/test-kernel-hyperplane-2D.hpp | 72 ++++++---- .../tests/test-kernel-hyperplane-3D.hpp | 117 +++++++++------ .../test-kernel-nested-loop-segments.cpp.in | 2 +- ...test-kernel-nested-loops-segment-types.hpp | 47 ++++-- .../test-kernel-nested-loop-view.cpp.in | 2 +- .../test-kernel-nested-loop-OffsetView2D.hpp | 34 ++++- .../test-kernel-nested-loop-OffsetView3D.hpp | 43 ++++-- ...ernel-nested-loop-PermutedOffsetView2D.hpp | 48 +++++-- ...ernel-nested-loop-PermutedOffsetView3D.hpp | 52 +++++-- ...test-kernel-nested-loop-PermutedView2D.hpp | 33 ++++- ...test-kernel-nested-loop-PermutedView3D.hpp | 35 ++++- .../reduce-loc/test-kernel-reduceloc.cpp.in | 2 +- .../tests/test-kernel-reduceloc-Max2D.hpp | 84 +++++------ .../tests/test-kernel-reduceloc-Max2DView.hpp | 86 +++++------ .../test-kernel-reduceloc-Max2DViewTuple.hpp | 82 +++++------ .../tests/test-kernel-reduceloc-Min2D.hpp | 84 +++++------ .../tests/test-kernel-reduceloc-Min2DView.hpp | 86 +++++------ .../test-kernel-reduceloc-Min2DViewTuple.hpp | 82 +++++------ ...t-kernel-reduce-params-multi-lambda.cpp.in | 2 +- ...test-kernel-reduce-params-multi-lambda.hpp | 118 +++++++-------- .../test-kernel-basic-param.cpp.in | 2 +- .../tests/test-kernel-basic-param.hpp | 136 +++++++++--------- .../test-kernel-tile-count-loop.cpp.in | 2 +- .../tile-variants/test-kernel-tiledyn.cpp.in | 2 +- .../test-kernel-tilefixed.cpp.in | 2 +- .../test-kernel-tilelocal.cpp.in | 6 +- .../tests/test-kernel-tile-Dynamic2D.hpp | 87 +++++++---- .../tests/test-kernel-tile-Fixed2D.hpp | 74 +++++++--- .../tests/test-kernel-tile-Fixed2DMinMax.hpp | 52 +++++-- .../tests/test-kernel-tile-Fixed2DSum.hpp | 53 +++++-- .../tests/test-kernel-tile-LocalArray2D.hpp | 80 +++++++---- test/include/RAJA_test-forall-data.hpp | 7 +- test/include/RAJA_test-reduceloc-types.hpp | 8 +- 39 files changed, 1118 insertions(+), 651 deletions(-) diff --git a/include/RAJA/index/IndexValue.hpp b/include/RAJA/index/IndexValue.hpp index 3ab317d69c..6edfea9fc8 100644 --- a/include/RAJA/index/IndexValue.hpp +++ b/include/RAJA/index/IndexValue.hpp @@ -66,10 +66,12 @@ struct IndexValue : public IndexValueBase } /*! - * \brief Constructor. + * \brief Explicit constructor. * \param v Initial value */ - RAJA_HOST_DEVICE RAJA_INLINE constexpr IndexValue(value_type v) : value(v) {} + RAJA_HOST_DEVICE RAJA_INLINE constexpr explicit IndexValue(value_type v) + : value(v) + {} //! Dereference provides cast-to-integer. RAJA_HOST_DEVICE RAJA_INLINE value_type& operator*() { return value; } diff --git a/include/RAJA/pattern/params/params_base.hpp b/include/RAJA/pattern/params/params_base.hpp index 20daf5c820..7cd87047eb 100644 --- a/include/RAJA/pattern/params/params_base.hpp +++ b/include/RAJA/pattern/params/params_base.hpp @@ -10,22 +10,90 @@ #ifndef RAJA_PARAMS_BASE #define RAJA_PARAMS_BASE +#include + +#include "RAJA/index/IndexValue.hpp" + namespace RAJA { namespace expt { +namespace detail +{ + +template +using valloc_index_storage_t = + std::conditional_t::value, + RAJA::strip_index_type_t, + IndexType>; + +template +RAJA_HOST_DEVICE constexpr valloc_index_storage_t +strip_valloc_index(IndexType const& index) +{ + if constexpr (std::is_base_of::value) + { + return RAJA::stripIndexType(index); + } + else + { + return index; + } +} + +template +RAJA_HOST_DEVICE constexpr IndexType +restore_valloc_index(valloc_index_storage_t const& index) +{ + if constexpr (std::is_base_of::value) + { + return IndexType(index); + } + else + { + return index; + } +} + +template +RAJA_HOST_DEVICE constexpr valloc_index_storage_t +default_valloc_index() +{ + using stored_index_type = valloc_index_storage_t; + + if constexpr (std::is_constructible::value) + { + return stored_index_type(-1); + } + else + { + return stored_index_type {}; + } +} + +} // namespace detail template struct ValLoc { - using index_type = IndexType; - using value_type = T; + using index_type = IndexType; + using stored_index_type = detail::valloc_index_storage_t; + using value_type = T; ValLoc() = default; RAJA_HOST_DEVICE constexpr explicit ValLoc(value_type v) : val(v) {} - RAJA_HOST_DEVICE constexpr ValLoc(value_type v, index_type l) : val(v), loc(l) + RAJA_HOST_DEVICE constexpr ValLoc(value_type v, index_type l) + : val(v), + loc(detail::strip_valloc_index(l)) + {} + + template::value>* = nullptr> + RAJA_HOST_DEVICE constexpr ValLoc(value_type v, stored_index_type l) + : val(v), + loc(l) {} ValLoc(ValLoc const&) = default; @@ -45,20 +113,31 @@ struct ValLoc RAJA_HOST_DEVICE constexpr const value_type& getVal() const { return val; } - RAJA_HOST_DEVICE constexpr const index_type& getLoc() const { return loc; } + RAJA_HOST_DEVICE constexpr index_type getLoc() const + { + return detail::restore_valloc_index(loc); + } + + RAJA_HOST_DEVICE constexpr const stored_index_type& getStoredLoc() const + { + return loc; + } RAJA_HOST_DEVICE void set(T inval, IndexType inindex) { val = inval; - loc = inindex; + loc = detail::strip_valloc_index(inindex); } RAJA_HOST_DEVICE void setVal(T inval) { val = inval; } - RAJA_HOST_DEVICE void setLoc(IndexType inindex) { loc = inindex; } + RAJA_HOST_DEVICE void setLoc(IndexType inindex) + { + loc = detail::strip_valloc_index(inindex); + } value_type val; - index_type loc = -1; + stored_index_type loc = detail::default_valloc_index(); }; template class Op> diff --git a/include/RAJA/pattern/params/reducer.hpp b/include/RAJA/pattern/params/reducer.hpp index 4279a6a70c..bc7e03022e 100644 --- a/include/RAJA/pattern/params/reducer.hpp +++ b/include/RAJA/pattern/params/reducer.hpp @@ -146,8 +146,9 @@ struct Reducer, ValLoc, ValLoc>, ValOp, Op>> : public ForallParamBase { using target_value_type = T; - using target_index_type = I; using value_type = ValLoc; + using target_index_type = typename value_type::index_type; + using stored_index_type = typename value_type::stored_index_type; using op = Op; using VOp = ValOp, Op>; @@ -168,7 +169,7 @@ struct Reducer, ValLoc, ValLoc>, target_index_type* index_in) : m_valop(VOp {}), target_value(data_in), - target_index(index_in) + external_target_index(index_in) {} Reducer(Reducer const&) = default; @@ -183,18 +184,26 @@ struct Reducer, ValLoc, ValLoc>, // Points to either dual value and index defined by the user, or value and // index within a ValLoc defined by the user - target_value_type* target_value = nullptr; - target_index_type* target_index = nullptr; + target_value_type* target_value = nullptr; + stored_index_type* target_index = nullptr; + target_index_type* external_target_index = nullptr; // combineTarget() performs the final op on the target data and location in // param_resolve() RAJA_HOST_DEVICE void combineTarget(value_type in) { // Create a different temp ValLoc solely for combining - value_type temp(*target_value, *target_index); + value_type temp(*target_value, getTargetIndex()); temp = op {}(temp, in); *target_value = temp.val; - *target_index = temp.loc; + if (target_index != nullptr) + { + *target_index = temp.getStoredLoc(); + } + if (external_target_index != nullptr) + { + *external_target_index = temp.getLoc(); + } } RAJA_HOST_DEVICE @@ -222,6 +231,17 @@ struct Reducer, ValLoc, ValLoc>, using ARG_LIST_T = typename ARG_TUP_T::TList; static constexpr size_t num_lambda_args = camp::tuple_size::value; + +private: + RAJA_HOST_DEVICE target_index_type getTargetIndex() const + { + if (target_index != nullptr) + { + return RAJA::expt::detail::restore_valloc_index( + *target_index); + } + return *external_target_index; + } }; } // namespace detail diff --git a/include/RAJA/util/Span.hpp b/include/RAJA/util/Span.hpp index 6f86cc0279..aef426a15d 100644 --- a/include/RAJA/util/Span.hpp +++ b/include/RAJA/util/Span.hpp @@ -63,6 +63,7 @@ struct Span using element_type = typename std::iterator_traits::value_type; using value_type = camp::decay; using size_type = IndexType; + using offset_type = RAJA::strip_index_type_t; using difference_type = std::ptrdiff_t; using reference = element_type&; using const_reference = const element_type&; @@ -76,7 +77,7 @@ struct Span constexpr RAJA_HOST_DEVICE Span(iterator begin, size_type size) : m_begin {begin}, - m_end {begin + size} + m_end {begin + RAJA::stripIndexType(size)} {} constexpr RAJA_HOST_DEVICE RAJA_INLINE iterator begin() { return m_begin; } @@ -149,7 +150,7 @@ struct Span constexpr RAJA_HOST_DEVICE RAJA_INLINE reference operator[](size_type i) const { - return data()[i]; + return data()[RAJA::stripIndexType(i)]; } constexpr RAJA_HOST_DEVICE RAJA_INLINE iterator data() const @@ -186,8 +187,11 @@ struct Span constexpr RAJA_HOST_DEVICE RAJA_INLINE Span slice(size_type begin, size_type length) const { - auto start = m_begin + begin; - auto end = start + length > m_end ? m_end : start + length; + offset_type stripped_begin = RAJA::stripIndexType(begin); + offset_type stripped_length = RAJA::stripIndexType(length); + auto start = m_begin + stripped_begin; + auto end = start + stripped_length > m_end ? m_end + : start + stripped_length; return Span(start, end); } diff --git a/test/functional/kernel/hyperplane/test-kernel-hyperplane-2D.cpp.in b/test/functional/kernel/hyperplane/test-kernel-hyperplane-2D.cpp.in index 16fb402f75..9fcafe29fb 100644 --- a/test/functional/kernel/hyperplane/test-kernel-hyperplane-2D.cpp.in +++ b/test/functional/kernel/hyperplane/test-kernel-hyperplane-2D.cpp.in @@ -179,7 +179,7 @@ using HipKernelHyperplaneExecPols = // Cartesian product of types used in parameterized tests // using @BACKEND@KernelHyperplane = - Test< camp::cartesian_product #include +namespace { +template +struct val_t_impl { + using type = T; +}; + +template +struct val_t_impl { + using type = typename T::value_type; +}; + +template +using VAL_T = typename val_t_impl::type; + +template +RAJA_HOST_DEVICE typename T::value_type get_val(T index_val) { return *index_val; } + +template +requires (!RAJA::concepts::IndexValued) +RAJA_HOST_DEVICE auto get_val(T index_val) { return index_val; } +} + template std::enable_if_t CallKernel(DATA_TYPE& trip_count, DATA_TYPE& oob_count, - RAJA::View>& WorkView, - const int idim, - const int jdim, - const int groups) + RAJA::View>>& WorkView, + const INDEX_TYPE idim, + const INDEX_TYPE jdim, + const INDEX_TYPE groups) { RAJA::TypedRangeSegment Grange( 0, groups ); RAJA::TypedRangeSegment Irange( 0, idim ); @@ -34,7 +56,7 @@ CallKernel(DATA_TYPE& trip_count, [=] RAJA_HOST_DEVICE (INDEX_TYPE g, INDEX_TYPE ii, INDEX_TYPE jj, RAJA::expt::ValOp& _trip_count, RAJA::expt::ValOp& _oob_count ) { - if ((int)g < 0 || (int)g >= groups || (int)ii < 0 || (int)ii >= idim || (int)jj < 0 || (int)jj >= jdim) { + if (get_val(g) >= get_val(groups) || get_val(ii) >= get_val(idim) || get_val(jj) >= get_val(jdim)) { _oob_count += 1; } @@ -59,10 +81,10 @@ template CallKernel(DATA_TYPE& _trip_count, DATA_TYPE& _oob_count, - RAJA::View>& WorkView, - const int idim, - const int jdim, - const int groups) + RAJA::View>>& WorkView, + const INDEX_TYPE idim, + const INDEX_TYPE jdim, + const INDEX_TYPE groups) { RAJA::TypedRangeSegment Grange( 0, groups ); RAJA::TypedRangeSegment Irange( 0, idim ); @@ -73,7 +95,7 @@ CallKernel(DATA_TYPE& _trip_count, RAJA::kernel ( RAJA::make_tuple( Grange, Irange, Jrange ), [=] RAJA_HOST_DEVICE ( INDEX_TYPE g, INDEX_TYPE ii, INDEX_TYPE jj ) { - if ((int)g < 0 || (int)g >= groups || (int)ii < 0 || (int)ii >= idim || (int)jj < 0 || (int)jj >= jdim) { + if (get_val(g) >= get_val(groups) || get_val(ii) >= get_val(idim) || get_val(jj) >= get_val(jdim)) { oob_count += 1; } @@ -97,7 +119,7 @@ CallKernel(DATA_TYPE& _trip_count, template -void KernelHyperplane2DTestImpl(const int groups, const int idim, const int jdim) +void KernelHyperplane2DTestImpl(const INDEX_TYPE groups, const INDEX_TYPE idim, const INDEX_TYPE jdim) { // This test traverses "groups" 2D arrays, and modifies values in a 1D hyperplane manner. @@ -116,14 +138,16 @@ void KernelHyperplane2DTestImpl(const int groups, const int idim, const int jdim &test_array ); - RAJA::View> HostView( test_array, groups, idim, jdim ); - RAJA::View> WorkView( work_array, groups, idim, jdim ); - RAJA::View> CheckView( check_array, groups, idim, jdim ); + using LayoutType = RAJA::TypedLayout>; + using ViewType = RAJA::View; + ViewType HostView( test_array, groups, idim, jdim ); + ViewType WorkView( work_array, groups, idim, jdim ); + ViewType CheckView( check_array, groups, idim, jdim ); // initialize array - std::iota( test_array, test_array + array_length, 1 ); + std::iota( test_array, test_array + get_val(array_length), 1 ); - work_res.memcpy( work_array, test_array, sizeof(DATA_TYPE) * array_length ); + work_res.memcpy( work_array, test_array, sizeof(DATA_TYPE) * get_val(array_length) ); DATA_TYPE trip_count(0); DATA_TYPE oob_count(0); @@ -131,15 +155,15 @@ void KernelHyperplane2DTestImpl(const int groups, const int idim, const int jdim // perform array arithmetic with a 1D hyperplane, in either the I or J direction CallKernel(trip_count, oob_count, WorkView, idim, jdim, groups); - ASSERT_EQ((INDEX_TYPE)trip_count, (INDEX_TYPE)groups * idim * jdim); + ASSERT_EQ((INDEX_TYPE)trip_count, groups * idim * jdim); ASSERT_EQ((INDEX_TYPE)oob_count, (INDEX_TYPE)0); - work_res.memcpy( check_array, work_array, sizeof(DATA_TYPE) * array_length ); + work_res.memcpy( check_array, work_array, sizeof(DATA_TYPE) * get_val(array_length) ); // perform array arithmetic on the CPU - for (int g = 0; g < groups; ++g) { - for (int i = 0; i < idim; ++i) { - for (int j = 0; j < jdim; ++j) { + for (INDEX_TYPE g(0); g < groups; ++g) { + for (INDEX_TYPE i(0); i < idim; ++i) { + for (INDEX_TYPE j(0); j < jdim; ++j) { DATA_TYPE left = 1; if (i > 0) { left = HostView(g, i - 1, j); @@ -155,9 +179,9 @@ void KernelHyperplane2DTestImpl(const int groups, const int idim, const int jdim } } - for (int g = 0; g < groups; ++g) { - for (int i = 0; i < idim; ++i) { - for (int j = 0; j < jdim; ++j) { + for (INDEX_TYPE g(0); g < groups; ++g) { + for (INDEX_TYPE i(0); i < idim; ++i) { + for (INDEX_TYPE j(0); j < jdim; ++j) { ASSERT_FLOAT_EQ(CheckView(g, i, j), HostView(g, i, j)); } } diff --git a/test/functional/kernel/hyperplane/tests/test-kernel-hyperplane-3D.hpp b/test/functional/kernel/hyperplane/tests/test-kernel-hyperplane-3D.hpp index 01ed31ebef..e6597e7a5a 100644 --- a/test/functional/kernel/hyperplane/tests/test-kernel-hyperplane-3D.hpp +++ b/test/functional/kernel/hyperplane/tests/test-kernel-hyperplane-3D.hpp @@ -13,22 +13,44 @@ #include #include +namespace { +template +struct val_t_impl { + using type = T; +}; + +template +struct val_t_impl { + using type = typename T::value_type; +}; + +template +using VAL_T = typename val_t_impl::type; + +template +RAJA_HOST_DEVICE typename T::value_type get_val(T index_val) { return *index_val; } + +template +requires (!RAJA::concepts::IndexValued) +RAJA_HOST_DEVICE auto get_val(T index_val) { return index_val; } +} + template std::enable_if_t CallKernel(DATA_TYPE& trip_count, DATA_TYPE& oob_count, - RAJA::View>& WorkView, - const int idim, - const int jdim, - const int kdim, - const int groups) + RAJA::View>>& WorkView, + const INDEX_TYPE idim, + const INDEX_TYPE jdim, + const INDEX_TYPE kdim, + const INDEX_TYPE groups) { // perform array arithmetic with a 2D J-K hyperplane - RAJA::TypedRangeSegment Grange( 0, groups ); - RAJA::TypedRangeStrideSegment Irange( 0, idim, 1 ); - RAJA::TypedRangeStrideSegment Jrange( jdim-1, -1, -1 ); - RAJA::TypedRangeStrideSegment Krange( 0, kdim, 1 ); + RAJA::TypedRangeSegment Grange( 0, get_val(groups) ); + RAJA::TypedRangeStrideSegment Irange( 0, get_val(idim), 1 ); + RAJA::TypedRangeStrideSegment Jrange( get_val(jdim) - 1, -1, -1 ); + RAJA::TypedRangeStrideSegment Krange( 0, get_val(kdim), 1 ); RAJA::kernel_param ( RAJA::make_tuple( Grange, Irange, Jrange, Krange ), @@ -39,7 +61,8 @@ CallKernel(DATA_TYPE& trip_count, [=] RAJA_HOST_DEVICE ( INDEX_TYPE g, INDEX_TYPE ii, INDEX_TYPE jj, INDEX_TYPE kk, RAJA::expt::ValOp& _trip_count, RAJA::expt::ValOp& _oob_count ) { - if (g < 0 || g >= groups || ii < 0 || ii >= idim || jj < 0 || jj >= jdim || kk < 0 || kk >= kdim) { + if (get_val(g) >= get_val(groups) || get_val(ii) >= get_val(idim) || + get_val(jj) >= get_val(jdim) || get_val(kk) >= get_val(kdim)) { _oob_count += 1; } @@ -68,23 +91,24 @@ template CallKernel(DATA_TYPE& _trip_count, DATA_TYPE& _oob_count, - RAJA::View>& WorkView, - const int idim, - const int jdim, - const int kdim, - const int groups) + RAJA::View>>& WorkView, + const INDEX_TYPE idim, + const INDEX_TYPE jdim, + const INDEX_TYPE kdim, + const INDEX_TYPE groups) { RAJA::ReduceSum trip_count (_trip_count); RAJA::ReduceSum oob_count (_oob_count); // perform array arithmetic with a 2D J-K hyperplane - RAJA::TypedRangeSegment Grange( 0, groups ); - RAJA::TypedRangeStrideSegment Irange( 0, idim, 1 ); - RAJA::TypedRangeStrideSegment Jrange( jdim-1, -1, -1 ); - RAJA::TypedRangeStrideSegment Krange( 0, kdim, 1 ); + RAJA::TypedRangeSegment Grange( 0, get_val(groups) ); + RAJA::TypedRangeStrideSegment Irange( 0, get_val(idim), 1 ); + RAJA::TypedRangeStrideSegment Jrange( get_val(jdim - 1), -1, -1 ); + RAJA::TypedRangeStrideSegment Krange( 0, get_val(kdim), 1 ); RAJA::kernel ( RAJA::make_tuple( Grange, Irange, Jrange, Krange ), [=] RAJA_HOST_DEVICE ( INDEX_TYPE g, INDEX_TYPE ii, INDEX_TYPE jj, INDEX_TYPE kk ) { - if (g < 0 || g >= groups || ii < 0 || ii >= idim || jj < 0 || jj >= jdim || kk < 0 || kk >= kdim) { + if (get_val(g) >= get_val(groups) || get_val(ii) >= get_val(idim) || + get_val(jj) >= get_val(jdim) || get_val(kk) >= get_val(kdim)) { oob_count += 1; } @@ -113,18 +137,19 @@ CallKernel(DATA_TYPE& _trip_count, template std::enable_if_t>::value> -KernelHyperplane3DTestImpl(const int RAJA_UNUSED_ARG(groups), const int RAJA_UNUSED_ARG(idim), const int RAJA_UNUSED_ARG(jdim), const int RAJA_UNUSED_ARG(kdim)) +KernelHyperplane3DTestImpl(const INDEX_TYPE RAJA_UNUSED_ARG(groups), const INDEX_TYPE RAJA_UNUSED_ARG(idim), const INDEX_TYPE RAJA_UNUSED_ARG(jdim), const INDEX_TYPE RAJA_UNUSED_ARG(kdim)) { // do nothing for unsigned index types } template std::enable_if_t>::value> -KernelHyperplane3DTestImpl(const int groups, const int idimin, const int jdimin, const int kdimin) +KernelHyperplane3DTestImpl(const INDEX_TYPE groups, const INDEX_TYPE idimin, const INDEX_TYPE jdimin, const INDEX_TYPE kdimin) { // This test traverses "groups" number of 3D arrays, and modifies values in a 2D hyperplane manner. - int idim, jdim, kdim; + using raw_index_type = VAL_T; + raw_index_type idim, jdim, kdim; if ( std::is_same::value ) { // Restrict to a small data size for better float precision. @@ -134,18 +159,22 @@ KernelHyperplane3DTestImpl(const int groups, const int idimin, const int jdimin, } else { - idim = idimin; - jdim = jdimin; - kdim = kdimin; + idim = get_val(idimin); + jdim = get_val(jdimin); + kdim = get_val(kdimin); } + INDEX_TYPE idim_t(idim); + INDEX_TYPE jdim_t(jdim); + INDEX_TYPE kdim_t(kdim); + camp::resources::Resource work_res{WORKING_RES::get_default()}; DATA_TYPE * work_array; DATA_TYPE * check_array; DATA_TYPE * test_array; - INDEX_TYPE array_length = groups * idim * jdim * kdim; + INDEX_TYPE array_length = groups * idim_t * jdim_t * kdim_t; allocateForallTestData ( array_length, work_res, @@ -154,30 +183,32 @@ KernelHyperplane3DTestImpl(const int groups, const int idimin, const int jdimin, &test_array ); - RAJA::View> HostView( test_array, groups, idim, jdim, kdim ); - RAJA::View> WorkView( work_array, groups, idim, jdim, kdim ); - RAJA::View> CheckView( check_array, groups, idim, jdim, kdim ); + using LayoutType = RAJA::TypedLayout>; + using ViewType = RAJA::View; + ViewType HostView( test_array, groups, idim_t, jdim_t, kdim_t ); + ViewType WorkView( work_array, groups, idim_t, jdim_t, kdim_t ); + ViewType CheckView( check_array, groups, idim_t, jdim_t, kdim_t ); // initialize array - std::iota( test_array, test_array + array_length, 1 ); + std::iota( test_array, test_array + get_val(array_length), 1 ); - work_res.memcpy( work_array, test_array, sizeof(DATA_TYPE) * array_length ); + work_res.memcpy( work_array, test_array, sizeof(DATA_TYPE) * get_val(array_length) ); DATA_TYPE trip_count(0); DATA_TYPE oob_count(0); - CallKernel(trip_count, oob_count, WorkView, idim, jdim, kdim, groups); + CallKernel(trip_count, oob_count, WorkView, idim_t, jdim_t, kdim_t, groups); - ASSERT_EQ((INDEX_TYPE)trip_count, (INDEX_TYPE)groups * idim * jdim * kdim); + ASSERT_EQ((INDEX_TYPE)trip_count, groups * idim_t * jdim_t * kdim_t); ASSERT_EQ((INDEX_TYPE)oob_count, (INDEX_TYPE)0); - work_res.memcpy( check_array, work_array, sizeof(DATA_TYPE) * array_length ); + work_res.memcpy( check_array, work_array, sizeof(DATA_TYPE) * get_val(array_length) ); // perform array arithmetic on the CPU - for (int g = 0; g < groups; ++g) { - for (int i = 0; i < idim; ++i) { - for (int j = jdim - 1; j >= 0; --j) { - for (int k = 0; k < kdim; ++k) { + for (INDEX_TYPE g(0); g < groups; ++g) { + for (INDEX_TYPE i(0); i < idim_t; ++i) { + for (INDEX_TYPE j(jdim_t - 1); j >= INDEX_TYPE(0); --j) { + for (INDEX_TYPE k(0); k < kdim_t; ++k) { DATA_TYPE left = 1; if (i > 0) { left = HostView(g, i - 1, j, k); @@ -199,10 +230,10 @@ KernelHyperplane3DTestImpl(const int groups, const int idimin, const int jdimin, } } - for (int g = 0; g < groups; ++g) { - for (int i = 0; i < idim; ++i) { - for (int j = 0; j < jdim; ++j) { - for (int k = 0; k < kdim; ++k) { + for (INDEX_TYPE g(0); g < groups; ++g) { + for (INDEX_TYPE i(0); i < idim_t; ++i) { + for (INDEX_TYPE j(0); j < jdim_t; ++j) { + for (INDEX_TYPE k(0); k < kdim_t; ++k) { ASSERT_FLOAT_EQ(CheckView(g, i, j, k), HostView(g, i, j, k)); } } diff --git a/test/functional/kernel/nested-loop-segment-types/test-kernel-nested-loop-segments.cpp.in b/test/functional/kernel/nested-loop-segment-types/test-kernel-nested-loop-segments.cpp.in index a0127a870a..73d504cc58 100644 --- a/test/functional/kernel/nested-loop-segment-types/test-kernel-nested-loop-segments.cpp.in +++ b/test/functional/kernel/nested-loop-segment-types/test-kernel-nested-loop-segments.cpp.in @@ -174,7 +174,7 @@ using SyclKernelExecPols = camp::list< // Cartesian product of types used in parameterized tests // using @BACKEND@KernelNestedLoopsSegmentTypes = - Test< camp::cartesian_product>::Types; diff --git a/test/functional/kernel/nested-loop-segment-types/tests/test-kernel-nested-loops-segment-types.hpp b/test/functional/kernel/nested-loop-segment-types/tests/test-kernel-nested-loops-segment-types.hpp index bb9e9065a8..a0259e91cf 100644 --- a/test/functional/kernel/nested-loop-segment-types/tests/test-kernel-nested-loops-segment-types.hpp +++ b/test/functional/kernel/nested-loop-segment-types/tests/test-kernel-nested-loops-segment-types.hpp @@ -18,6 +18,27 @@ #include #include +namespace { +template +struct val_t_impl { + using type = T; +}; + +template +struct val_t_impl { + using type = typename T::value_type; +}; + +template +using VAL_T = typename val_t_impl::type; + +template +RAJA_HOST_DEVICE typename T::value_type get_val(T index_val) { return *index_val; } + +template +requires (!RAJA::concepts::IndexValued) +RAJA_HOST_DEVICE auto get_val(T index_val) { return index_val; } +} template void KernelNestedLoopsSegmentTypesTestImpl( @@ -61,24 +82,25 @@ void KernelNestedLoopsSegmentTypesTestImpl( &check_array, &test_array); - RAJA::View< DATA_TYPE, RAJA::Layout<3> > work_view(work_array, - dim1, dim2, dim3); - RAJA::View< DATA_TYPE, RAJA::Layout<3> > test_view(test_array, - dim1, dim2, dim3); + using LayoutType = RAJA::TypedLayout>; + using ViewType = RAJA::View; + + ViewType work_view(work_array, dim1, dim2, dim3); + ViewType test_view(test_array, dim1, dim2, dim3); memset( static_cast(test_array), 0, - sizeof(DATA_TYPE) * RAJA::stripIndexType(data_len) ); + sizeof(DATA_TYPE) * get_val(data_len) ); working_res.memcpy(work_array, test_array, - sizeof(DATA_TYPE) * RAJA::stripIndexType(data_len)); + sizeof(DATA_TYPE) * get_val(data_len)); if ( !zero_legth_segment ) { for (IDX_TYPE i1 = 0; i1 < idx1_len; ++i1) { for (IDX_TYPE i2 = 0; i2 < idx2_len; ++i2) { for (IDX_TYPE i3 = 0; i3 < idx3_len; ++i3) { - auto ii1 = RAJA::stripIndexType(i1); - auto ii2 = RAJA::stripIndexType(i2); - auto ii3 = RAJA::stripIndexType(i3); + auto ii1 = get_val(i1); + auto ii2 = get_val(i2); + auto ii3 = get_val(i3); test_view( s1_idx[ii1], s2_idx[ii2], s3_idx[ii3] ) = static_cast( RAJA::stripIndexType( s1_idx[ii1] + s2_idx[ii2] + s3_idx[ii3]) ); @@ -115,7 +137,7 @@ void KernelNestedLoopsSegmentTypesTestImpl( } working_res.memcpy(check_array, work_array, - sizeof(DATA_TYPE) * RAJA::stripIndexType(data_len)); + sizeof(DATA_TYPE) * get_val(data_len)); for (IDX_TYPE i = 0; i < data_len; ++i) { auto ii = RAJA::stripIndexType(i); @@ -140,6 +162,7 @@ TYPED_TEST_P(KernelNestedLoopsSegmentTypesTest, NestedLoopsSegmentTypesKernel) using IDX_TYPE = typename camp::at>::type; using WORKING_RES = typename camp::at>::type; using EXEC_POLICY = typename camp::at>::type; + using raw_idx_type = VAL_T; camp::resources::Resource working_res{WORKING_RES::get_default()}; @@ -153,7 +176,7 @@ TYPED_TEST_P(KernelNestedLoopsSegmentTypesTest, NestedLoopsSegmentTypesKernel) RAJA::TypedRangeSegment s1( 0, 69 ); RAJA::getIndices(s1_idx, s1); - RAJA::TypedRangeStrideSegment s2( 3, 188, 2 ); + RAJA::TypedRangeStrideSegment s2( raw_idx_type(3), raw_idx_type(188), raw_idx_type(2) ); RAJA::getIndices(s2_idx, s2); IDX_TYPE last = IDX_TYPE(427); @@ -223,7 +246,7 @@ TYPED_TEST_P(KernelNestedLoopsSegmentTypesTest, NestedLoopsSegmentTypesKernel) perm); // Zero-length range stride segment - RAJA::TypedRangeStrideSegment s5( 3, 3, 2 ); + RAJA::TypedRangeStrideSegment s5( raw_idx_type(3), raw_idx_type(3), raw_idx_type(2) ); std::vector s5_idx; RAJA::getIndices(s5_idx, s5); diff --git a/test/functional/kernel/nested-loop-view-types/test-kernel-nested-loop-view.cpp.in b/test/functional/kernel/nested-loop-view-types/test-kernel-nested-loop-view.cpp.in index 598ad026f3..94acc89ca6 100644 --- a/test/functional/kernel/nested-loop-view-types/test-kernel-nested-loop-view.cpp.in +++ b/test/functional/kernel/nested-loop-view-types/test-kernel-nested-loop-view.cpp.in @@ -309,7 +309,7 @@ camp::list< // Cartesian product of types used in parameterized tests // using @BACKEND@KernelNestesLoop@TESTTYPE@@DIM@Types = - Test< camp::cartesian_product>::Types; diff --git a/test/functional/kernel/nested-loop-view-types/tests/test-kernel-nested-loop-OffsetView2D.hpp b/test/functional/kernel/nested-loop-view-types/tests/test-kernel-nested-loop-OffsetView2D.hpp index 331a1cff1a..0ebe38a689 100644 --- a/test/functional/kernel/nested-loop-view-types/tests/test-kernel-nested-loop-OffsetView2D.hpp +++ b/test/functional/kernel/nested-loop-view-types/tests/test-kernel-nested-loop-OffsetView2D.hpp @@ -10,6 +10,20 @@ #ifndef __TEST_KERNEL_NESTEDLOOP_OFFSETVIEW2D_HPP__ #define __TEST_KERNEL_NESTEDLOOP_OFFSETVIEW2D_HPP__ +namespace { +template +struct val_t_impl { + using type = T; +}; + +template +struct val_t_impl { + using type = typename T::value_type; +}; + +template +using VAL_T = typename val_t_impl::type; +} template void KernelOffsetView2DTestImpl(std::array dim, @@ -45,14 +59,20 @@ void KernelOffsetView2DTestImpl(std::array dim, } - RAJA::OffsetLayout<2> layout = - RAJA::make_offset_layout<2>( {{offset_lo.at(0), offset_lo.at(1)}}, - {{offset_lo.at(0) + dim.at(0), - offset_lo.at(1) + dim.at(1)}} ); - RAJA::View< IDX_TYPE, RAJA::OffsetLayout<2> > view(working_array, layout); + using raw_idx_type = VAL_T; + using LayoutType = + RAJA::TypedOffsetLayout>; + + LayoutType layout({{raw_idx_type(offset_lo.at(0)), + raw_idx_type(offset_lo.at(1))}}, + {{raw_idx_type(offset_lo.at(0) + dim.at(0)), + raw_idx_type(offset_lo.at(1) + dim.at(1))}}); + RAJA::View view(working_array, layout); - RAJA::TypedRangeSegment iseg( offset_lo.at(0), offset_hi.at(0)); - RAJA::TypedRangeSegment jseg( offset_lo.at(1), offset_hi.at(1)); + RAJA::TypedRangeSegment iseg( IDX_TYPE(offset_lo.at(0)), + IDX_TYPE(offset_hi.at(0))); + RAJA::TypedRangeSegment jseg( IDX_TYPE(offset_lo.at(1)), + IDX_TYPE(offset_hi.at(1))); RAJA::kernel( RAJA::make_tuple( iseg, jseg ), diff --git a/test/functional/kernel/nested-loop-view-types/tests/test-kernel-nested-loop-OffsetView3D.hpp b/test/functional/kernel/nested-loop-view-types/tests/test-kernel-nested-loop-OffsetView3D.hpp index 4161cf81a5..601eed6b99 100644 --- a/test/functional/kernel/nested-loop-view-types/tests/test-kernel-nested-loop-OffsetView3D.hpp +++ b/test/functional/kernel/nested-loop-view-types/tests/test-kernel-nested-loop-OffsetView3D.hpp @@ -10,6 +10,20 @@ #ifndef __TEST_KERNEL_NESTEDLOOP_OFFSETVIEW3D_HPP__ #define __TEST_KERNEL_NESTEDLOOP_OFFSETVIEW3D_HPP__ +namespace { +template +struct val_t_impl { + using type = T; +}; + +template +struct val_t_impl { + using type = typename T::value_type; +}; + +template +using VAL_T = typename val_t_impl::type; +} template void KernelOffsetView3DTestImpl(std::array dim, @@ -50,19 +64,26 @@ void KernelOffsetView3DTestImpl(std::array dim, } - RAJA::OffsetLayout<3> layout = - RAJA::make_offset_layout<3>( {{offset_lo.at(0), - offset_lo.at(1), - offset_lo.at(2)}}, - {{offset_lo.at(0) + dim.at(0), - offset_lo.at(1) + dim.at(1), - offset_lo.at(2) + dim.at(2)}} ); + using raw_idx_type = VAL_T; + using LayoutType = + RAJA::TypedOffsetLayout>; + + LayoutType layout({{raw_idx_type(offset_lo.at(0)), + raw_idx_type(offset_lo.at(1)), + raw_idx_type(offset_lo.at(2))}}, + {{raw_idx_type(offset_lo.at(0) + dim.at(0)), + raw_idx_type(offset_lo.at(1) + dim.at(1)), + raw_idx_type(offset_lo.at(2) + dim.at(2))}}); - RAJA::View< IDX_TYPE, RAJA::OffsetLayout<3> > view(working_array, layout); + RAJA::View view(working_array, layout); - RAJA::TypedRangeSegment iseg( offset_lo.at(0), offset_hi.at(0)); - RAJA::TypedRangeSegment jseg( offset_lo.at(1), offset_hi.at(1)); - RAJA::TypedRangeSegment kseg( offset_lo.at(2), offset_hi.at(2)); + RAJA::TypedRangeSegment iseg( IDX_TYPE(offset_lo.at(0)), + IDX_TYPE(offset_hi.at(0))); + RAJA::TypedRangeSegment jseg( IDX_TYPE(offset_lo.at(1)), + IDX_TYPE(offset_hi.at(1))); + RAJA::TypedRangeSegment kseg( IDX_TYPE(offset_lo.at(2)), + IDX_TYPE(offset_hi.at(2))); RAJA::kernel( RAJA::make_tuple( iseg, jseg, kseg ), diff --git a/test/functional/kernel/nested-loop-view-types/tests/test-kernel-nested-loop-PermutedOffsetView2D.hpp b/test/functional/kernel/nested-loop-view-types/tests/test-kernel-nested-loop-PermutedOffsetView2D.hpp index 8b5de9aaf1..966af4aee6 100644 --- a/test/functional/kernel/nested-loop-view-types/tests/test-kernel-nested-loop-PermutedOffsetView2D.hpp +++ b/test/functional/kernel/nested-loop-view-types/tests/test-kernel-nested-loop-PermutedOffsetView2D.hpp @@ -10,10 +10,33 @@ #ifndef __TEST_KERNEL_NESTEDLOOP_PERMUTEDOFFSETVIEW2D_HPP__ #define __TEST_KERNEL_NESTEDLOOP_PERMUTEDOFFSETVIEW2D_HPP__ +namespace { +template +struct val_t_impl { + using type = T; +}; + +template +struct val_t_impl { + using type = typename T::value_type; +}; + +template +using VAL_T = typename val_t_impl::type; + +template +RAJA_HOST_DEVICE typename T::value_type get_val(T index_val) { return *index_val; } + +template +requires (!RAJA::concepts::IndexValued) +RAJA_HOST_DEVICE auto get_val(T index_val) { return index_val; } +} + template void KernelPermutedOffsetView2DTestImpl(std::array dim, std::array perm) { + using raw_idx_type = VAL_T; camp::resources::Resource working_res{WORKING_RES::get_default()}; IDX_TYPE* A_work_array; IDX_TYPE* A_check_array; @@ -78,8 +101,8 @@ void KernelPermutedOffsetView2DTestImpl(std::array dim, for (RAJA::idx_t i = 0; i < Nint_outer; ++i) { for (RAJA::idx_t j = 0; j < Nint_inner; ++j) { - int A_idx = j + Nint_inner * i; - int B_idx = (j + 1) + Ntot_inner * (i + 1); + RAJA::idx_t A_idx = j + Nint_inner * i; + RAJA::idx_t B_idx = (j + 1) + Ntot_inner * (i + 1); A_test_array[A_idx] = B_test_array[B_idx] + // C B_test_array[B_idx - Ntot_inner] + // S @@ -98,20 +121,21 @@ void KernelPermutedOffsetView2DTestImpl(std::array dim, RAJA::Layout<2> A_layout = RAJA::make_permuted_layout( {{Nint_len.at(0), Nint_len.at(1)}}, perm ); - RAJA::View< IDX_TYPE, RAJA::OffsetLayout<2> > B_view(B_work_array, B_layout); - RAJA::View< IDX_TYPE, RAJA::Layout<2> > A_view(A_work_array, A_layout); - - RAJA::TypedRangeSegment iseg( 0, Nint_len.at(0) ); - RAJA::TypedRangeSegment jseg( 0, Nint_len.at(1) ); + RAJA::TypedRangeSegment iseg( 0, IDX_TYPE(Nint_len.at(0)) ); + RAJA::TypedRangeSegment jseg( 0, IDX_TYPE(Nint_len.at(1)) ); RAJA::kernel( RAJA::make_tuple( iseg, jseg ), [=] RAJA_HOST_DEVICE(IDX_TYPE i, IDX_TYPE j) { - - A_view(i, j) = B_view(i, j) + - B_view(i - 1, j) + B_view(i + 1, j) + - B_view(i, j - 1) + B_view(i, j + 1); - + auto ii = raw_idx_type(get_val(i)); + auto jj = raw_idx_type(get_val(j)); + auto a_idx = RAJA::stripIndexType(A_layout(ii, jj)); + A_work_array[a_idx] = + B_work_array[RAJA::stripIndexType(B_layout(ii, jj))] + + B_work_array[RAJA::stripIndexType(B_layout(ii - raw_idx_type(1), jj))] + + B_work_array[RAJA::stripIndexType(B_layout(ii + raw_idx_type(1), jj))] + + B_work_array[RAJA::stripIndexType(B_layout(ii, jj - raw_idx_type(1)))] + + B_work_array[RAJA::stripIndexType(B_layout(ii, jj + raw_idx_type(1)))]; } ); diff --git a/test/functional/kernel/nested-loop-view-types/tests/test-kernel-nested-loop-PermutedOffsetView3D.hpp b/test/functional/kernel/nested-loop-view-types/tests/test-kernel-nested-loop-PermutedOffsetView3D.hpp index e8db6957e3..f086e5900a 100644 --- a/test/functional/kernel/nested-loop-view-types/tests/test-kernel-nested-loop-PermutedOffsetView3D.hpp +++ b/test/functional/kernel/nested-loop-view-types/tests/test-kernel-nested-loop-PermutedOffsetView3D.hpp @@ -10,10 +10,33 @@ #ifndef __TEST_KERNEL_NESTEDLOOP_PERMUTEDOFFSETVIEW3D_HPP__ #define __TEST_KERNEL_NESTEDLOOP_PERMUTEDOFFSETVIEW3D_HPP__ +namespace { +template +struct val_t_impl { + using type = T; +}; + +template +struct val_t_impl { + using type = typename T::value_type; +}; + +template +using VAL_T = typename val_t_impl::type; + +template +RAJA_HOST_DEVICE typename T::value_type get_val(T index_val) { return *index_val; } + +template +requires (!RAJA::concepts::IndexValued) +RAJA_HOST_DEVICE auto get_val(T index_val) { return index_val; } +} + template void KernelPermutedOffsetView3DTestImpl(std::array dim, std::array perm) { + using raw_idx_type = VAL_T; camp::resources::Resource working_res{WORKING_RES::get_default()}; IDX_TYPE* A_work_array; IDX_TYPE* A_check_array; @@ -86,8 +109,8 @@ void KernelPermutedOffsetView3DTestImpl(std::array dim, for (RAJA::idx_t j = 0; j < Nint_middle; ++j) { for (RAJA::idx_t k = 0; k < Nint_inner; ++k) { - int A_idx = k + j * Nint_inner + i * Nint_inner * Nint_middle; - int B_idx = + RAJA::idx_t A_idx = k + j * Nint_inner + i * Nint_inner * Nint_middle; + RAJA::idx_t B_idx = (k + 1) + (j + 1) * Ntot_inner + (i + 1) * Ntot_inner * Ntot_middle; A_test_array[A_idx] = @@ -115,20 +138,25 @@ void KernelPermutedOffsetView3DTestImpl(std::array dim, Nint_len.at(1), Nint_len.at(2)}}, perm ); - RAJA::View< IDX_TYPE, RAJA::OffsetLayout<3> > B_view(B_work_array, B_layout); - RAJA::View< IDX_TYPE, RAJA::Layout<3> > A_view(A_work_array, A_layout); - - RAJA::TypedRangeSegment iseg( 0, Nint_len.at(0) ); - RAJA::TypedRangeSegment jseg( 0, Nint_len.at(1) ); - RAJA::TypedRangeSegment kseg( 0, Nint_len.at(2) ); + RAJA::TypedRangeSegment iseg( 0, IDX_TYPE(Nint_len.at(0)) ); + RAJA::TypedRangeSegment jseg( 0, IDX_TYPE(Nint_len.at(1)) ); + RAJA::TypedRangeSegment kseg( 0, IDX_TYPE(Nint_len.at(2)) ); RAJA::kernel( RAJA::make_tuple( iseg, jseg, kseg ), [=] RAJA_HOST_DEVICE(IDX_TYPE i, IDX_TYPE j, IDX_TYPE k) { - A_view(i, j, k) = B_view(i, j, k) + - B_view(i - 1, j, k) + B_view(i + 1, j, k) + - B_view(i, j - 1, k) + B_view(i, j + 1, k) + - B_view(i, j, k - 1) + B_view(i, j, k + 1); + auto ii = raw_idx_type(get_val(i)); + auto jj = raw_idx_type(get_val(j)); + auto kk = raw_idx_type(get_val(k)); + auto a_idx = RAJA::stripIndexType(A_layout(ii, jj, kk)); + A_work_array[a_idx] = + B_work_array[RAJA::stripIndexType(B_layout(ii, jj, kk))] + + B_work_array[RAJA::stripIndexType(B_layout(ii - raw_idx_type(1), jj, kk))] + + B_work_array[RAJA::stripIndexType(B_layout(ii + raw_idx_type(1), jj, kk))] + + B_work_array[RAJA::stripIndexType(B_layout(ii, jj - raw_idx_type(1), kk))] + + B_work_array[RAJA::stripIndexType(B_layout(ii, jj + raw_idx_type(1), kk))] + + B_work_array[RAJA::stripIndexType(B_layout(ii, jj, kk - raw_idx_type(1)))] + + B_work_array[RAJA::stripIndexType(B_layout(ii, jj, kk + raw_idx_type(1)))]; } ); diff --git a/test/functional/kernel/nested-loop-view-types/tests/test-kernel-nested-loop-PermutedView2D.hpp b/test/functional/kernel/nested-loop-view-types/tests/test-kernel-nested-loop-PermutedView2D.hpp index c97663c2db..82bc205cb0 100644 --- a/test/functional/kernel/nested-loop-view-types/tests/test-kernel-nested-loop-PermutedView2D.hpp +++ b/test/functional/kernel/nested-loop-view-types/tests/test-kernel-nested-loop-PermutedView2D.hpp @@ -10,6 +10,27 @@ #ifndef __TEST_KERNEL_NESTEDLOOP_PERMUTEDVIEW2D_HPP__ #define __TEST_KERNEL_NESTEDLOOP_PERMUTEDVIEW2D_HPP__ +namespace { +template +struct val_t_impl { + using type = T; +}; + +template +struct val_t_impl { + using type = typename T::value_type; +}; + +template +using VAL_T = typename val_t_impl::type; + +template +RAJA_HOST_DEVICE typename T::value_type get_val(T index_val) { return *index_val; } + +template +requires (!RAJA::concepts::IndexValued) +RAJA_HOST_DEVICE auto get_val(T index_val) { return index_val; } +} template void KernelPermutedView2DTestImpl(std::array dim, @@ -35,20 +56,20 @@ void KernelPermutedView2DTestImpl(std::array dim, working_res.memcpy(working_array, test_array, sizeof(IDX_TYPE) * N); - int mod_val = dim.at( perm.at(1) ); + using raw_idx_type = VAL_T; + raw_idx_type mod_val = get_val(dim.at( perm.at(1) )); for (RAJA::idx_t ii = 0; ii < N; ++ii) { test_array[ii] = static_cast(ii % mod_val); } RAJA::Layout<2> layout = RAJA::make_permuted_layout(dim_strip, perm); - RAJA::View< IDX_TYPE, RAJA::Layout<2, int> > view(working_array, layout); RAJA::kernel( - RAJA::make_tuple( RAJA::TypedRangeSegment(0, dim_strip.at(0)), - RAJA::TypedRangeSegment(0, dim_strip.at(1)) ), + RAJA::make_tuple( RAJA::TypedRangeSegment(0, IDX_TYPE(dim_strip.at(0))), + RAJA::TypedRangeSegment(0, IDX_TYPE(dim_strip.at(1))) ), [=] RAJA_HOST_DEVICE(IDX_TYPE i, IDX_TYPE j) { - int val = RAJA::stripIndexType(layout(i, j)) % mod_val; - view(i, j) = static_cast(val); + auto linear = RAJA::stripIndexType(layout(get_val(i), get_val(j))); + working_array[linear] = static_cast(linear % mod_val); } ); diff --git a/test/functional/kernel/nested-loop-view-types/tests/test-kernel-nested-loop-PermutedView3D.hpp b/test/functional/kernel/nested-loop-view-types/tests/test-kernel-nested-loop-PermutedView3D.hpp index 0a6a99a7cc..043cfb39b3 100644 --- a/test/functional/kernel/nested-loop-view-types/tests/test-kernel-nested-loop-PermutedView3D.hpp +++ b/test/functional/kernel/nested-loop-view-types/tests/test-kernel-nested-loop-PermutedView3D.hpp @@ -10,6 +10,27 @@ #ifndef __TEST_KERNEL_NESTEDLOOP_PERMUTEDVIEW3D_HPP_ #define __TEST_KERNEL_NESTEDLOOP_PERMUTEDVIEW3D_HPP_ +namespace { +template +struct val_t_impl { + using type = T; +}; + +template +struct val_t_impl { + using type = typename T::value_type; +}; + +template +using VAL_T = typename val_t_impl::type; + +template +RAJA_HOST_DEVICE typename T::value_type get_val(T index_val) { return *index_val; } + +template +requires (!RAJA::concepts::IndexValued) +RAJA_HOST_DEVICE auto get_val(T index_val) { return index_val; } +} template void KernelPermutedView3DTestImpl(std::array dim, @@ -36,21 +57,21 @@ void KernelPermutedView3DTestImpl(std::array dim, working_res.memcpy(working_array, test_array, sizeof(IDX_TYPE) * N); - int mod_val = dim.at( perm.at(1) ) * dim.at( perm.at(2) ); + using raw_idx_type = VAL_T; + raw_idx_type mod_val = get_val(dim.at(perm.at(1))) * get_val(dim.at(perm.at(2))); for (RAJA::idx_t ii = 0; ii < N; ++ii) { test_array[ii] = static_cast(ii % mod_val); } RAJA::Layout<3> layout = RAJA::make_permuted_layout(dim_strip, perm); - RAJA::View< IDX_TYPE, RAJA::Layout<3, int> > view(working_array, layout); RAJA::kernel( - RAJA::make_tuple( RAJA::TypedRangeSegment(0, dim_strip.at(0)), - RAJA::TypedRangeSegment(0, dim_strip.at(1)), - RAJA::TypedRangeSegment(0, dim_strip.at(2)) ), + RAJA::make_tuple( RAJA::TypedRangeSegment(0, IDX_TYPE(dim_strip.at(0))), + RAJA::TypedRangeSegment(0, IDX_TYPE(dim_strip.at(1))), + RAJA::TypedRangeSegment(0, IDX_TYPE(dim_strip.at(2))) ), [=] RAJA_HOST_DEVICE(IDX_TYPE i, IDX_TYPE j, IDX_TYPE k) { - int val = RAJA::stripIndexType(layout(i, j, k)) % mod_val; - view(i, j, k) = static_cast(val); + auto linear = RAJA::stripIndexType(layout(get_val(i), get_val(j), get_val(k))); + working_array[linear] = static_cast(linear % mod_val); } ); diff --git a/test/functional/kernel/reduce-loc/test-kernel-reduceloc.cpp.in b/test/functional/kernel/reduce-loc/test-kernel-reduceloc.cpp.in index 1d54534726..6917615f57 100644 --- a/test/functional/kernel/reduce-loc/test-kernel-reduceloc.cpp.in +++ b/test/functional/kernel/reduce-loc/test-kernel-reduceloc.cpp.in @@ -245,7 +245,7 @@ using HipKernelLocForallPols = // Cartesian product of types used in parameterized tests // using @LOC_BACKEND@KernelLocTypes = - Test< camp::cartesian_product +struct val_t_impl { + using type = T; +}; + +template +struct val_t_impl { + using type = typename T::value_type; +}; + +template +using VAL_T = typename val_t_impl::type; + +template +RAJA_HOST_DEVICE typename T::value_type get_val(T index_val) { return *index_val; } + +template +requires (!RAJA::concepts::IndexValued) +RAJA_HOST_DEVICE auto get_val(T index_val) { return index_val; } + +} + template -void KernelLocMax2DTestImpl(const int xdim, const int ydim) +void KernelLocMax2DTestImpl(const INDEX_TYPE xdim, const INDEX_TYPE ydim) { camp::resources::Resource work_res{WORKING_RES::get_default()}; - DATA_TYPE ** workarr2D; - DATA_TYPE ** checkarr2D; - DATA_TYPE ** testarr2D; - DATA_TYPE * work_array; - DATA_TYPE * check_array; - DATA_TYPE * test_array; + DATA_TYPE* work_array; + DATA_TYPE* check_array; + DATA_TYPE* test_array; // square 2D array, xdim x ydim INDEX_TYPE array_length = xdim * ydim; @@ -32,60 +52,48 @@ void KernelLocMax2DTestImpl(const int xdim, const int ydim) &test_array ); - allocateForallTestData ( ydim, - work_res, - &workarr2D, - &checkarr2D, - &testarr2D - ); - // set rows to point to check and work _arrays RAJA::TypedRangeSegment seg(0,ydim); - RAJA::forall(seg, [=] RAJA_HOST_DEVICE(INDEX_TYPE zz) - { - workarr2D[zz] = work_array + zz * ydim; - }); - - RAJA::forall(seg, [=] (INDEX_TYPE zz) - { - checkarr2D[zz] = check_array + zz * ydim; - }); + using LayoutType = RAJA::TypedLayout>; + using ViewType = RAJA::View; + ViewType WorkView(work_array, xdim, ydim); + ViewType CheckView(check_array, xdim, ydim); // initializing values RAJA::forall(seg, [=] (INDEX_TYPE zz) { - for ( int xx = 0; xx < xdim; ++xx ) + for ( INDEX_TYPE xx(0); xx < xdim; ++xx ) { - checkarr2D[zz][xx] = zz*xdim + xx; + CheckView(zz, xx) = get_val(zz * xdim + xx); } - checkarr2D[ydim-1][xdim-1] = 0; + CheckView(ydim - 1, xdim - 1) = 0; }); - work_res.memcpy(work_array, check_array, sizeof(DATA_TYPE) * array_length); + work_res.memcpy(work_array, check_array, sizeof(DATA_TYPE) * get_val(array_length)); RAJA::TypedRangeSegment colrange(0, xdim); RAJA::TypedRangeSegment rowrange(0, ydim); - RAJA::ReduceMaxLoc maxloc_reducer((DATA_TYPE)0, Index2D(0, 0)); + RAJA::ReduceMaxLoc> maxloc_reducer((DATA_TYPE)0, Index2D(0, 0)); RAJA::kernel(RAJA::make_tuple(colrange, rowrange), - [=] RAJA_HOST_DEVICE (int c, int r) { - maxloc_reducer.maxloc(workarr2D[r][c], Index2D(c, r)); + [=] RAJA_HOST_DEVICE (INDEX_TYPE c, INDEX_TYPE r) { + maxloc_reducer.maxloc(WorkView(r, c), Index2D(c, r)); }); // CPU answer - RAJA::ReduceMaxLoc checkmaxloc_reducer((DATA_TYPE)0, Index2D(0, 0)); + RAJA::ReduceMaxLoc> checkmaxloc_reducer((DATA_TYPE)0, Index2D(0, 0)); RAJA::forall(colrange, [=] (INDEX_TYPE c) { - for( int r = 0; r < ydim; ++r) + for (INDEX_TYPE r(0); r < ydim; ++r) { - checkmaxloc_reducer.maxloc(checkarr2D[r][c], Index2D(c, r)); + checkmaxloc_reducer.maxloc(CheckView(r, c), Index2D(c, r)); } }); - Index2D raja_loc = maxloc_reducer.getLoc(); + Index2D raja_loc = maxloc_reducer.getLoc(); DATA_TYPE raja_max = (DATA_TYPE)maxloc_reducer.get(); - Index2D checkraja_loc = checkmaxloc_reducer.getLoc(); + Index2D checkraja_loc = checkmaxloc_reducer.getLoc(); DATA_TYPE checkraja_max = (DATA_TYPE)checkmaxloc_reducer.get(); ASSERT_DOUBLE_EQ((DATA_TYPE)checkraja_max, (DATA_TYPE)raja_max); @@ -97,12 +105,6 @@ void KernelLocMax2DTestImpl(const int xdim, const int ydim) check_array, test_array ); - - deallocateForallTestData ( work_res, - workarr2D, - checkarr2D, - testarr2D - ); } diff --git a/test/functional/kernel/reduce-loc/tests/test-kernel-reduceloc-Max2DView.hpp b/test/functional/kernel/reduce-loc/tests/test-kernel-reduceloc-Max2DView.hpp index 6395a3b712..657d592507 100644 --- a/test/functional/kernel/reduce-loc/tests/test-kernel-reduceloc-Max2DView.hpp +++ b/test/functional/kernel/reduce-loc/tests/test-kernel-reduceloc-Max2DView.hpp @@ -10,17 +10,37 @@ #ifndef __TEST_KERNEL_REDUCELOC_MAX2DVIEW_HPP__ #define __TEST_KERNEL_REDUCELOC_MAX2DVIEW_HPP__ +namespace { +template +struct val_t_impl { + using type = T; +}; + +template +struct val_t_impl { + using type = typename T::value_type; +}; + +template +using VAL_T = typename val_t_impl::type; + +template +RAJA_HOST_DEVICE typename T::value_type get_val(T index_val) { return *index_val; } + +template +requires (!RAJA::concepts::IndexValued) +RAJA_HOST_DEVICE auto get_val(T index_val) { return index_val; } + +} + template -void KernelLocMax2DViewTestImpl(const int xdim, const int ydim) +void KernelLocMax2DViewTestImpl(const INDEX_TYPE xdim, const INDEX_TYPE ydim) { camp::resources::Resource work_res{WORKING_RES::get_default()}; - DATA_TYPE ** workarr2D; - DATA_TYPE ** checkarr2D; - DATA_TYPE ** testarr2D; - DATA_TYPE * work_array; - DATA_TYPE * check_array; - DATA_TYPE * test_array; + DATA_TYPE* work_array; + DATA_TYPE* check_array; + DATA_TYPE* test_array; // square 2D array, xdim x ydim INDEX_TYPE array_length = xdim * ydim; @@ -32,62 +52,48 @@ void KernelLocMax2DViewTestImpl(const int xdim, const int ydim) &test_array ); - allocateForallTestData ( ydim, - work_res, - &workarr2D, - &checkarr2D, - &testarr2D - ); - // set rows to point to check and work _arrays RAJA::TypedRangeSegment seg(0,ydim); - RAJA::forall(seg, [=] RAJA_HOST_DEVICE(INDEX_TYPE zz) - { - workarr2D[zz] = work_array + zz * ydim; - }); - - RAJA::forall(seg, [=] (INDEX_TYPE zz) - { - checkarr2D[zz] = check_array + zz * ydim; - }); + using LayoutType = RAJA::TypedLayout>; + using ViewType = RAJA::View; + ViewType ArrView(work_array, xdim, ydim); + ViewType CheckView(check_array, xdim, ydim); // initializing values RAJA::forall(seg, [=] (INDEX_TYPE zz) { - for ( int xx = 0; xx < xdim; ++xx ) + for ( INDEX_TYPE xx(0); xx < xdim; ++xx ) { - checkarr2D[zz][xx] = zz*xdim + xx; + CheckView(zz, xx) = get_val(zz * xdim + xx); } - checkarr2D[ydim-1][xdim-1] = 0; + CheckView(ydim - 1, xdim - 1) = 0; }); - work_res.memcpy(work_array, check_array, sizeof(DATA_TYPE) * array_length); + work_res.memcpy(work_array, check_array, sizeof(DATA_TYPE) * get_val(array_length)); RAJA::TypedRangeSegment colrange(0, xdim); RAJA::TypedRangeSegment rowrange(0, ydim); - RAJA::View> ArrView(work_array, xdim, ydim); - - RAJA::ReduceMaxLoc maxloc_reducer((DATA_TYPE)0, Index2D(0, 0)); + RAJA::ReduceMaxLoc> maxloc_reducer((DATA_TYPE)0, Index2D(0, 0)); RAJA::kernel(RAJA::make_tuple(colrange, rowrange), - [=] RAJA_HOST_DEVICE (int c, int r) { - maxloc_reducer.maxloc(ArrView(r, c), Index2D(c, r)); + [=] RAJA_HOST_DEVICE (INDEX_TYPE c, INDEX_TYPE r) { + maxloc_reducer.maxloc(ArrView(r, c), Index2D(c, r)); }); // CPU answer - RAJA::ReduceMaxLoc checkmaxloc_reducer((DATA_TYPE)0, Index2D(0, 0)); + RAJA::ReduceMaxLoc> checkmaxloc_reducer((DATA_TYPE)0, Index2D(0, 0)); RAJA::forall(colrange, [=] (INDEX_TYPE c) { - for( int r = 0; r < ydim; ++r) + for (INDEX_TYPE r(0); r < ydim; ++r) { - checkmaxloc_reducer.maxloc(checkarr2D[r][c], Index2D(c, r)); + checkmaxloc_reducer.maxloc(CheckView(r, c), Index2D(c, r)); } }); - Index2D raja_loc = maxloc_reducer.getLoc(); + Index2D raja_loc = maxloc_reducer.getLoc(); DATA_TYPE raja_max = (DATA_TYPE)maxloc_reducer.get(); - Index2D checkraja_loc = checkmaxloc_reducer.getLoc(); + Index2D checkraja_loc = checkmaxloc_reducer.getLoc(); DATA_TYPE checkraja_max = (DATA_TYPE)checkmaxloc_reducer.get(); ASSERT_DOUBLE_EQ((DATA_TYPE)checkraja_max, (DATA_TYPE)raja_max); @@ -99,12 +105,6 @@ void KernelLocMax2DViewTestImpl(const int xdim, const int ydim) check_array, test_array ); - - deallocateForallTestData ( work_res, - workarr2D, - checkarr2D, - testarr2D - ); } diff --git a/test/functional/kernel/reduce-loc/tests/test-kernel-reduceloc-Max2DViewTuple.hpp b/test/functional/kernel/reduce-loc/tests/test-kernel-reduceloc-Max2DViewTuple.hpp index dbe5c475e8..9a26682a8e 100644 --- a/test/functional/kernel/reduce-loc/tests/test-kernel-reduceloc-Max2DViewTuple.hpp +++ b/test/functional/kernel/reduce-loc/tests/test-kernel-reduceloc-Max2DViewTuple.hpp @@ -10,17 +10,37 @@ #ifndef __TEST_KERNEL_REDUCELOC_MAX2DVIEWTUPLE_HPP__ #define __TEST_KERNEL_REDUCELOC_MAX2DVIEWTUPLE_HPP__ +namespace { +template +struct val_t_impl { + using type = T; +}; + +template +struct val_t_impl { + using type = typename T::value_type; +}; + +template +using VAL_T = typename val_t_impl::type; + +template +RAJA_HOST_DEVICE typename T::value_type get_val(T index_val) { return *index_val; } + +template +requires (!RAJA::concepts::IndexValued) +RAJA_HOST_DEVICE auto get_val(T index_val) { return index_val; } + +} + template -void KernelLocMax2DViewTupleTestImpl(const int xdim, const int ydim) +void KernelLocMax2DViewTupleTestImpl(const INDEX_TYPE xdim, const INDEX_TYPE ydim) { camp::resources::Resource work_res{WORKING_RES::get_default()}; - DATA_TYPE ** workarr2D; - DATA_TYPE ** checkarr2D; - DATA_TYPE ** testarr2D; - DATA_TYPE * work_array; - DATA_TYPE * check_array; - DATA_TYPE * test_array; + DATA_TYPE* work_array; + DATA_TYPE* check_array; + DATA_TYPE* test_array; // square 2D array, xdim x ydim INDEX_TYPE array_length = xdim * ydim; @@ -32,36 +52,24 @@ void KernelLocMax2DViewTupleTestImpl(const int xdim, const int ydim) &test_array ); - allocateForallTestData ( ydim, - work_res, - &workarr2D, - &checkarr2D, - &testarr2D - ); - // set rows to point to check and work _arrays RAJA::TypedRangeSegment seg(0,ydim); - RAJA::forall(seg, [=] RAJA_HOST_DEVICE(INDEX_TYPE zz) - { - workarr2D[zz] = work_array + zz * ydim; - }); - - RAJA::forall(seg, [=] (INDEX_TYPE zz) - { - checkarr2D[zz] = check_array + zz * ydim; - }); + using LayoutType = RAJA::TypedLayout>; + using ViewType = RAJA::View; + ViewType ArrView(work_array, xdim, ydim); + ViewType CheckView(check_array, xdim, ydim); // initializing values RAJA::forall(seg, [=] (INDEX_TYPE zz) { - for ( int xx = 0; xx < xdim; ++xx ) + for ( INDEX_TYPE xx(0); xx < xdim; ++xx ) { - checkarr2D[zz][xx] = zz*xdim + xx; + CheckView(zz, xx) = get_val(zz * xdim + xx); } - checkarr2D[ydim-1][xdim-1] = 0; + CheckView(ydim - 1, xdim - 1) = 0; }); - work_res.memcpy(work_array, check_array, sizeof(DATA_TYPE) * array_length); + work_res.memcpy(work_array, check_array, sizeof(DATA_TYPE) * get_val(array_length)); #if defined(RAJA_ENABLE_TARGET_OPENMP) //#pragma omp target data map(to:work_array[0:array_length]) @@ -70,30 +78,28 @@ void KernelLocMax2DViewTupleTestImpl(const int xdim, const int ydim) RAJA::TypedRangeSegment colrange(0, xdim); RAJA::TypedRangeSegment rowrange(0, ydim); - RAJA::View> ArrView(work_array, xdim, ydim); - RAJA::tuple LocTup(0, 0); RAJA::ReduceMaxLoc> maxloc_reducer((DATA_TYPE)0, LocTup); RAJA::kernel(RAJA::make_tuple(colrange, rowrange), - [=] RAJA_HOST_DEVICE (int c, int r) { - maxloc_reducer.maxloc(ArrView(r, c), RAJA::make_tuple((DATA_TYPE)c, (DATA_TYPE)r)); + [=] RAJA_HOST_DEVICE (INDEX_TYPE c, INDEX_TYPE r) { + maxloc_reducer.maxloc(ArrView(r, c), RAJA::make_tuple((DATA_TYPE)get_val(c), (DATA_TYPE)get_val(r))); }); // CPU answer - RAJA::ReduceMaxLoc checkmaxloc_reducer((DATA_TYPE)0, Index2D(0, 0)); + RAJA::ReduceMaxLoc> checkmaxloc_reducer((DATA_TYPE)0, Index2D(0, 0)); RAJA::forall(colrange, [=] (INDEX_TYPE c) { - for( int r = 0; r < ydim; ++r) + for (INDEX_TYPE r(0); r < ydim; ++r) { - checkmaxloc_reducer.maxloc(checkarr2D[r][c], Index2D(c, r)); + checkmaxloc_reducer.maxloc(CheckView(r, c), Index2D(c, r)); } }); RAJA::tuple raja_loc = maxloc_reducer.getLoc(); DATA_TYPE raja_max = (DATA_TYPE)maxloc_reducer.get(); - Index2D checkraja_loc = checkmaxloc_reducer.getLoc(); + Index2D checkraja_loc = checkmaxloc_reducer.getLoc(); DATA_TYPE checkraja_max = (DATA_TYPE)checkmaxloc_reducer.get(); ASSERT_DOUBLE_EQ((DATA_TYPE)checkraja_max, (DATA_TYPE)raja_max); @@ -105,12 +111,6 @@ void KernelLocMax2DViewTupleTestImpl(const int xdim, const int ydim) check_array, test_array ); - - deallocateForallTestData ( work_res, - workarr2D, - checkarr2D, - testarr2D - ); } diff --git a/test/functional/kernel/reduce-loc/tests/test-kernel-reduceloc-Min2D.hpp b/test/functional/kernel/reduce-loc/tests/test-kernel-reduceloc-Min2D.hpp index 30dc977023..8667b7cf34 100644 --- a/test/functional/kernel/reduce-loc/tests/test-kernel-reduceloc-Min2D.hpp +++ b/test/functional/kernel/reduce-loc/tests/test-kernel-reduceloc-Min2D.hpp @@ -10,17 +10,37 @@ #ifndef __TEST_KERNEL_REDUCELOC_MIN2D_HPP__ #define __TEST_KERNEL_REDUCELOC_MIN2D_HPP__ +namespace { +template +struct val_t_impl { + using type = T; +}; + +template +struct val_t_impl { + using type = typename T::value_type; +}; + +template +using VAL_T = typename val_t_impl::type; + +template +RAJA_HOST_DEVICE typename T::value_type get_val(T index_val) { return *index_val; } + +template +requires (!RAJA::concepts::IndexValued) +RAJA_HOST_DEVICE auto get_val(T index_val) { return index_val; } + +} + template -void KernelLocMin2DTestImpl(const int xdim, const int ydim) +void KernelLocMin2DTestImpl(const INDEX_TYPE xdim, const INDEX_TYPE ydim) { camp::resources::Resource work_res{WORKING_RES::get_default()}; - DATA_TYPE ** workarr2D; - DATA_TYPE ** checkarr2D; - DATA_TYPE ** testarr2D; - DATA_TYPE * work_array; - DATA_TYPE * check_array; - DATA_TYPE * test_array; + DATA_TYPE* work_array; + DATA_TYPE* check_array; + DATA_TYPE* test_array; // square 2D array, xdim x ydim INDEX_TYPE array_length = xdim * ydim; @@ -32,60 +52,48 @@ void KernelLocMin2DTestImpl(const int xdim, const int ydim) &test_array ); - allocateForallTestData ( ydim, - work_res, - &workarr2D, - &checkarr2D, - &testarr2D - ); - // set rows to point to check and work _arrays RAJA::TypedRangeSegment seg(0,ydim); - RAJA::forall(seg, [=] RAJA_HOST_DEVICE(INDEX_TYPE zz) - { - workarr2D[zz] = work_array + zz * ydim; - }); - - RAJA::forall(seg, [=] (INDEX_TYPE zz) - { - checkarr2D[zz] = check_array + zz * ydim; - }); + using LayoutType = RAJA::TypedLayout>; + using ViewType = RAJA::View; + ViewType WorkView(work_array, xdim, ydim); + ViewType CheckView(check_array, xdim, ydim); // initializing values RAJA::forall(seg, [=] (INDEX_TYPE zz) { - for ( int xx = 0; xx < xdim; ++xx ) + for ( INDEX_TYPE xx(0); xx < xdim; ++xx ) { - checkarr2D[zz][xx] = zz*xdim + xx + 1; + CheckView(zz, xx) = get_val(zz * xdim + xx) + 1; } - checkarr2D[ydim-1][xdim-1] = 0; + CheckView(ydim - 1, xdim - 1) = 0; }); - work_res.memcpy(work_array, check_array, sizeof(DATA_TYPE) * array_length); + work_res.memcpy(work_array, check_array, sizeof(DATA_TYPE) * get_val(array_length)); RAJA::TypedRangeSegment colrange(0, xdim); RAJA::TypedRangeSegment rowrange(0, ydim); - RAJA::ReduceMinLoc minloc_reducer((DATA_TYPE)1024, Index2D(0, 0)); + RAJA::ReduceMinLoc> minloc_reducer((DATA_TYPE)1024, Index2D(0, 0)); RAJA::kernel(RAJA::make_tuple(colrange, rowrange), - [=] RAJA_HOST_DEVICE (int c, int r) { - minloc_reducer.minloc(workarr2D[r][c], Index2D(c, r)); + [=] RAJA_HOST_DEVICE (INDEX_TYPE c, INDEX_TYPE r) { + minloc_reducer.minloc(WorkView(r, c), Index2D(c, r)); }); // CPU answer - RAJA::ReduceMinLoc checkminloc_reducer((DATA_TYPE)1024, Index2D(0, 0)); + RAJA::ReduceMinLoc> checkminloc_reducer((DATA_TYPE)1024, Index2D(0, 0)); RAJA::forall(colrange, [=] (INDEX_TYPE c) { - for( int r = 0; r < ydim; ++r) + for (INDEX_TYPE r(0); r < ydim; ++r) { - checkminloc_reducer.minloc(checkarr2D[r][c], Index2D(c, r)); + checkminloc_reducer.minloc(CheckView(r, c), Index2D(c, r)); } }); - Index2D raja_loc = minloc_reducer.getLoc(); + Index2D raja_loc = minloc_reducer.getLoc(); DATA_TYPE raja_min = (DATA_TYPE)minloc_reducer.get(); - Index2D checkraja_loc = checkminloc_reducer.getLoc(); + Index2D checkraja_loc = checkminloc_reducer.getLoc(); DATA_TYPE checkraja_min = (DATA_TYPE)checkminloc_reducer.get(); ASSERT_DOUBLE_EQ((DATA_TYPE)checkraja_min, (DATA_TYPE)raja_min); @@ -97,12 +105,6 @@ void KernelLocMin2DTestImpl(const int xdim, const int ydim) check_array, test_array ); - - deallocateForallTestData ( work_res, - workarr2D, - checkarr2D, - testarr2D - ); } diff --git a/test/functional/kernel/reduce-loc/tests/test-kernel-reduceloc-Min2DView.hpp b/test/functional/kernel/reduce-loc/tests/test-kernel-reduceloc-Min2DView.hpp index 87386976ae..c8e6d246c7 100644 --- a/test/functional/kernel/reduce-loc/tests/test-kernel-reduceloc-Min2DView.hpp +++ b/test/functional/kernel/reduce-loc/tests/test-kernel-reduceloc-Min2DView.hpp @@ -10,17 +10,37 @@ #ifndef __TEST_KERNEL_REDUCELOC_MIN2DVIEW_HPP__ #define __TEST_KERNEL_REDUCELOC_MIN2DVIEW_HPP__ +namespace { +template +struct val_t_impl { + using type = T; +}; + +template +struct val_t_impl { + using type = typename T::value_type; +}; + +template +using VAL_T = typename val_t_impl::type; + +template +RAJA_HOST_DEVICE typename T::value_type get_val(T index_val) { return *index_val; } + +template +requires (!RAJA::concepts::IndexValued) +RAJA_HOST_DEVICE auto get_val(T index_val) { return index_val; } + +} + template -void KernelLocMin2DViewTestImpl(const int xdim, const int ydim) +void KernelLocMin2DViewTestImpl(const INDEX_TYPE xdim, const INDEX_TYPE ydim) { camp::resources::Resource work_res{WORKING_RES::get_default()}; - DATA_TYPE ** workarr2D; - DATA_TYPE ** checkarr2D; - DATA_TYPE ** testarr2D; - DATA_TYPE * work_array; - DATA_TYPE * check_array; - DATA_TYPE * test_array; + DATA_TYPE* work_array; + DATA_TYPE* check_array; + DATA_TYPE* test_array; // square 2D array, xdim x ydim INDEX_TYPE array_length = xdim * ydim; @@ -32,62 +52,48 @@ void KernelLocMin2DViewTestImpl(const int xdim, const int ydim) &test_array ); - allocateForallTestData ( ydim, - work_res, - &workarr2D, - &checkarr2D, - &testarr2D - ); - // set rows to point to check and work _arrays RAJA::TypedRangeSegment seg(0,ydim); - RAJA::forall(seg, [=] RAJA_HOST_DEVICE(INDEX_TYPE zz) - { - workarr2D[zz] = work_array + zz * ydim; - }); - - RAJA::forall(seg, [=] (INDEX_TYPE zz) - { - checkarr2D[zz] = check_array + zz * ydim; - }); + using LayoutType = RAJA::TypedLayout>; + using ViewType = RAJA::View; + ViewType ArrView(work_array, xdim, ydim); + ViewType CheckView(check_array, xdim, ydim); // initializing values RAJA::forall(seg, [=] (INDEX_TYPE zz) { - for ( int xx = 0; xx < xdim; ++xx ) + for ( INDEX_TYPE xx(0); xx < xdim; ++xx ) { - checkarr2D[zz][xx] = zz*xdim + xx + 1; + CheckView(zz, xx) = get_val(zz * xdim + xx) + 1; } - checkarr2D[ydim-1][xdim-1] = 0; + CheckView(ydim - 1, xdim - 1) = 0; }); - work_res.memcpy(work_array, check_array, sizeof(DATA_TYPE) * array_length); + work_res.memcpy(work_array, check_array, sizeof(DATA_TYPE) * get_val(array_length)); RAJA::TypedRangeSegment colrange(0, xdim); RAJA::TypedRangeSegment rowrange(0, ydim); - RAJA::View> ArrView(work_array, xdim, ydim); - - RAJA::ReduceMinLoc minloc_reducer((DATA_TYPE)1024, Index2D(0, 0)); + RAJA::ReduceMinLoc> minloc_reducer((DATA_TYPE)1024, Index2D(0, 0)); RAJA::kernel(RAJA::make_tuple(colrange, rowrange), - [=] RAJA_HOST_DEVICE (int c, int r) { - minloc_reducer.minloc(ArrView(r, c), Index2D(c, r)); + [=] RAJA_HOST_DEVICE (INDEX_TYPE c, INDEX_TYPE r) { + minloc_reducer.minloc(ArrView(r, c), Index2D(c, r)); }); // CPU answer - RAJA::ReduceMinLoc checkminloc_reducer((DATA_TYPE)1024, Index2D(0, 0)); + RAJA::ReduceMinLoc> checkminloc_reducer((DATA_TYPE)1024, Index2D(0, 0)); RAJA::forall(colrange, [=] (INDEX_TYPE c) { - for( int r = 0; r < ydim; ++r) + for (INDEX_TYPE r(0); r < ydim; ++r) { - checkminloc_reducer.minloc(checkarr2D[r][c], Index2D(c, r)); + checkminloc_reducer.minloc(CheckView(r, c), Index2D(c, r)); } }); - Index2D raja_loc = minloc_reducer.getLoc(); + Index2D raja_loc = minloc_reducer.getLoc(); DATA_TYPE raja_min = (DATA_TYPE)minloc_reducer.get(); - Index2D checkraja_loc = checkminloc_reducer.getLoc(); + Index2D checkraja_loc = checkminloc_reducer.getLoc(); DATA_TYPE checkraja_min = (DATA_TYPE)checkminloc_reducer.get(); ASSERT_DOUBLE_EQ((DATA_TYPE)checkraja_min, (DATA_TYPE)raja_min); @@ -99,12 +105,6 @@ void KernelLocMin2DViewTestImpl(const int xdim, const int ydim) check_array, test_array ); - - deallocateForallTestData ( work_res, - workarr2D, - checkarr2D, - testarr2D - ); } diff --git a/test/functional/kernel/reduce-loc/tests/test-kernel-reduceloc-Min2DViewTuple.hpp b/test/functional/kernel/reduce-loc/tests/test-kernel-reduceloc-Min2DViewTuple.hpp index f80b4fea1b..90dafc9d73 100644 --- a/test/functional/kernel/reduce-loc/tests/test-kernel-reduceloc-Min2DViewTuple.hpp +++ b/test/functional/kernel/reduce-loc/tests/test-kernel-reduceloc-Min2DViewTuple.hpp @@ -10,17 +10,37 @@ #ifndef __TEST_KERNEL_REDUCELOC_MIN2DVIEWTUPLE_HPP__ #define __TEST_KERNEL_REDUCELOC_MIN2DVIEWTUPLE_HPP__ +namespace { +template +struct val_t_impl { + using type = T; +}; + +template +struct val_t_impl { + using type = typename T::value_type; +}; + +template +using VAL_T = typename val_t_impl::type; + +template +RAJA_HOST_DEVICE typename T::value_type get_val(T index_val) { return *index_val; } + +template +requires (!RAJA::concepts::IndexValued) +RAJA_HOST_DEVICE auto get_val(T index_val) { return index_val; } + +} + template -void KernelLocMin2DViewTupleTestImpl(const int xdim, const int ydim) +void KernelLocMin2DViewTupleTestImpl(const INDEX_TYPE xdim, const INDEX_TYPE ydim) { camp::resources::Resource work_res{WORKING_RES::get_default()}; - DATA_TYPE ** workarr2D; - DATA_TYPE ** checkarr2D; - DATA_TYPE ** testarr2D; - DATA_TYPE * work_array; - DATA_TYPE * check_array; - DATA_TYPE * test_array; + DATA_TYPE* work_array; + DATA_TYPE* check_array; + DATA_TYPE* test_array; // square 2D array, xdim x ydim INDEX_TYPE array_length = xdim * ydim; @@ -32,64 +52,50 @@ void KernelLocMin2DViewTupleTestImpl(const int xdim, const int ydim) &test_array ); - allocateForallTestData ( ydim, - work_res, - &workarr2D, - &checkarr2D, - &testarr2D - ); - // set rows to point to check and work _arrays RAJA::TypedRangeSegment seg(0,ydim); - RAJA::forall(seg, [=] RAJA_HOST_DEVICE(INDEX_TYPE zz) - { - workarr2D[zz] = work_array + zz * ydim; - }); - - RAJA::forall(seg, [=] (INDEX_TYPE zz) - { - checkarr2D[zz] = check_array + zz * ydim; - }); + using LayoutType = RAJA::TypedLayout>; + using ViewType = RAJA::View; + ViewType ArrView(work_array, xdim, ydim); + ViewType CheckView(check_array, xdim, ydim); // initializing values RAJA::forall(seg, [=] (INDEX_TYPE zz) { - for ( int xx = 0; xx < xdim; ++xx ) + for ( INDEX_TYPE xx(0); xx < xdim; ++xx ) { - checkarr2D[zz][xx] = zz*xdim + xx + 1; + CheckView(zz, xx) = get_val(zz * xdim + xx) + 1; } - checkarr2D[ydim-1][xdim-1] = 0; + CheckView(ydim - 1, xdim - 1) = 0; }); - work_res.memcpy(work_array, check_array, sizeof(DATA_TYPE) * array_length); + work_res.memcpy(work_array, check_array, sizeof(DATA_TYPE) * get_val(array_length)); RAJA::TypedRangeSegment colrange(0, xdim); RAJA::TypedRangeSegment rowrange(0, ydim); - RAJA::View> ArrView(work_array, xdim, ydim); - RAJA::tuple LocTup(0, 0); RAJA::ReduceMinLoc> minloc_reducer((DATA_TYPE)1024, LocTup); RAJA::kernel(RAJA::make_tuple(colrange, rowrange), - [=] RAJA_HOST_DEVICE (int c, int r) { - minloc_reducer.minloc(ArrView(r, c), RAJA::make_tuple((DATA_TYPE)c, (DATA_TYPE)r)); + [=] RAJA_HOST_DEVICE (INDEX_TYPE c, INDEX_TYPE r) { + minloc_reducer.minloc(ArrView(r, c), RAJA::make_tuple((DATA_TYPE)get_val(c), (DATA_TYPE)get_val(r))); }); // CPU answer - RAJA::ReduceMinLoc checkminloc_reducer((DATA_TYPE)1024, Index2D(0, 0)); + RAJA::ReduceMinLoc> checkminloc_reducer((DATA_TYPE)1024, Index2D(0, 0)); RAJA::forall(colrange, [=] (INDEX_TYPE c) { - for( int r = 0; r < ydim; ++r) + for (INDEX_TYPE r(0); r < ydim; ++r) { - checkminloc_reducer.minloc(checkarr2D[r][c], Index2D(c, r)); + checkminloc_reducer.minloc(CheckView(r, c), Index2D(c, r)); } }); RAJA::tuple raja_loc = minloc_reducer.getLoc(); DATA_TYPE raja_min = (DATA_TYPE)minloc_reducer.get(); - Index2D checkraja_loc = checkminloc_reducer.getLoc(); + Index2D checkraja_loc = checkminloc_reducer.getLoc(); DATA_TYPE checkraja_min = (DATA_TYPE)checkminloc_reducer.get(); ASSERT_DOUBLE_EQ((DATA_TYPE)checkraja_min, (DATA_TYPE)raja_min); @@ -101,12 +107,6 @@ void KernelLocMin2DViewTupleTestImpl(const int xdim, const int ydim) check_array, test_array ); - - deallocateForallTestData ( work_res, - workarr2D, - checkarr2D, - testarr2D - ); } diff --git a/test/functional/kernel/reduce-params-multi-lambda/test-kernel-reduce-params-multi-lambda.cpp.in b/test/functional/kernel/reduce-params-multi-lambda/test-kernel-reduce-params-multi-lambda.cpp.in index e85715b5d4..5a060a2e5b 100644 --- a/test/functional/kernel/reduce-params-multi-lambda/test-kernel-reduce-params-multi-lambda.cpp.in +++ b/test/functional/kernel/reduce-params-multi-lambda/test-kernel-reduce-params-multi-lambda.cpp.in @@ -253,7 +253,7 @@ using HipKernelLocForallPols = // Cartesian product of types used in parameterized tests // using @BACKEND@KernelLocTypes = - Test< camp::cartesian_product +struct val_t_impl { + using type = T; +}; + +template +struct val_t_impl { + using type = typename T::value_type; +}; + +template +using VAL_T = typename val_t_impl::type; + +template +RAJA_HOST_DEVICE typename T::value_type get_val(T index_val) { return *index_val; } + +template +requires (!RAJA::concepts::IndexValued) +RAJA_HOST_DEVICE auto get_val(T index_val) { return index_val; } +} + template -void KernelParamReduceMultiLambda(const int xdim, const int ydim) +void KernelParamReduceMultiLambda(const INDEX_TYPE xdim_t, const INDEX_TYPE ydim_t) { + using raw_index_type = VAL_T; + camp::resources::Resource work_res{WORKING_RES::get_default()}; - DATA_TYPE ** workarr2D; - DATA_TYPE ** checkarr2D; - DATA_TYPE ** testarr2D; DATA_TYPE * work_array; DATA_TYPE * check_array; DATA_TYPE * test_array; // square 2D array, xdim x ydim - INDEX_TYPE array_length = xdim * ydim; + INDEX_TYPE array_length = xdim_t * ydim_t; allocateForallTestData ( array_length, work_res, @@ -32,42 +53,30 @@ void KernelParamReduceMultiLambda(const int xdim, const int ydim) &test_array ); - allocateForallTestData ( ydim, - work_res, - &workarr2D, - &checkarr2D, - &testarr2D - ); - - // set rows to point to check and work _arrays - RAJA::TypedRangeSegment seg(0,ydim); - RAJA::forall(seg, [=] RAJA_HOST_DEVICE (INDEX_TYPE zz) - { - workarr2D[zz] = work_array + zz * ydim; - }); - - RAJA::forall(seg, [=] RAJA_HOST_DEVICE (INDEX_TYPE zz) - { - checkarr2D[zz] = check_array + zz * ydim; - }); + using LayoutType = + RAJA::TypedLayout>; + using ViewType = RAJA::View; + ViewType WorkView(work_array, ydim_t, xdim_t); + ViewType CheckView(check_array, ydim_t, xdim_t); // initializing values - RAJA::forall(seg, [=] RAJA_HOST_DEVICE (INDEX_TYPE zz) + for (INDEX_TYPE row(0); row < ydim_t; ++row) { - for ( int xx = 0; xx < xdim; ++xx ) + for ( raw_index_type col = 0; col < get_val(xdim_t); ++col ) { - checkarr2D[zz][xx] = (zz*xdim + xx ) % 100 + 1; + CheckView(row, INDEX_TYPE(col)) = + (get_val(row) * get_val(xdim_t) + col) % 100 + 1; } // Make a unique min - checkarr2D[ydim-1][xdim-1] = 0; + CheckView(ydim_t - INDEX_TYPE(1), xdim_t - INDEX_TYPE(1)) = 0; // Make a unique max - checkarr2D[ydim/2][xdim/2] = 101; - }); + CheckView(ydim_t / INDEX_TYPE(2), xdim_t / INDEX_TYPE(2)) = 101; + } - work_res.memcpy(work_array, check_array, sizeof(DATA_TYPE) * array_length); + work_res.memcpy(work_array, check_array, sizeof(DATA_TYPE) * get_val(array_length)); - RAJA::TypedRangeSegment colrange(0, xdim); - RAJA::TypedRangeSegment rowrange(0, ydim); + RAJA::TypedRangeSegment colrange(0, xdim_t); + RAJA::TypedRangeSegment rowrange(0, ydim_t); using VALOP_DATA_TYPE_SUM = RAJA::expt::ValOp; using VALOP_DATA_TYPE_MIN = RAJA::expt::ValOp; @@ -104,28 +113,28 @@ void KernelParamReduceMultiLambda(const int xdim, const int ydim) // not init or resolving reducers in between lambda calls. RAJA::expt::Reduce(&mutual_sum) ), - [=] RAJA_HOST_DEVICE (int c, - int r, + [=] RAJA_HOST_DEVICE (INDEX_TYPE c, + INDEX_TYPE r, VALOP_DATA_TYPE_SUM &_sum, VALOP_DATA_TYPE_MIN &_min, VALOP_DATA_TYPE_MAX &_max, VALOP_DATA_TYPE_SUM &_mutual_sum) { - _sum += workarr2D[r][c]; - _mutual_sum += workarr2D[r][c]; - _min.min(workarr2D[r][c]); - _max.max(workarr2D[r][c]); + _sum += WorkView(r, c); + _mutual_sum += WorkView(r, c); + _min.min(WorkView(r, c)); + _max.max(WorkView(r, c)); }, - [=] RAJA_HOST_DEVICE (int c, - int r, + [=] RAJA_HOST_DEVICE (INDEX_TYPE c, + INDEX_TYPE r, VALOP_DATA_TYPE_SUM &_sum, VALOP_DATA_TYPE_MIN &_min, VALOP_DATA_TYPE_MAX &_max, double, VALOP_DATA_TYPE_SUM &_mutual_sum) { - _sum += workarr2D[r][c]; - _mutual_sum += workarr2D[r][c]; - _min.min(workarr2D[r][c]); - _max.max(workarr2D[r][c]); + _sum += WorkView(r, c); + _mutual_sum += WorkView(r, c); + _min.min(WorkView(r, c)); + _max.max(WorkView(r, c)); } ); @@ -141,11 +150,12 @@ void KernelParamReduceMultiLambda(const int xdim, const int ydim) VALOP_DATA_TYPE_MIN &_min, VALOP_DATA_TYPE_MAX &_max ) { - for (int c = 0; c < xdim; ++c) + for (raw_index_type c = 0; c < get_val(xdim_t); ++c) { - _sum += checkarr2D[r][c]; - _min.min(checkarr2D[r][c]); - _max.max(checkarr2D[r][c]); + auto c_idx = INDEX_TYPE(c); + _sum += CheckView(r, c_idx); + _min.min(CheckView(r, c_idx)); + _max.max(CheckView(r, c_idx)); } }); @@ -169,12 +179,6 @@ void KernelParamReduceMultiLambda(const int xdim, const int ydim) check_array, test_array ); - - deallocateForallTestData ( work_res, - workarr2D, - checkarr2D, - testarr2D - ); } @@ -192,9 +196,9 @@ TYPED_TEST_P(KernelParamReduceMultiLambdaTest, ParamReduceKernel) using FORALL_POLICY = typename camp::at>::type; using EXEC_POLICY = typename camp::at>::type; - KernelParamReduceMultiLambda(10, 10); - KernelParamReduceMultiLambda(151, 151); - KernelParamReduceMultiLambda(362, 362); + KernelParamReduceMultiLambda(INDEX_TYPE(10), INDEX_TYPE(10)); + KernelParamReduceMultiLambda(INDEX_TYPE(151), INDEX_TYPE(151)); + KernelParamReduceMultiLambda(INDEX_TYPE(362), INDEX_TYPE(362)); } REGISTER_TYPED_TEST_SUITE_P(KernelParamReduceMultiLambdaTest, diff --git a/test/functional/kernel/reduce-params/test-kernel-basic-param.cpp.in b/test/functional/kernel/reduce-params/test-kernel-basic-param.cpp.in index e5fc28d2cc..b0140e4692 100644 --- a/test/functional/kernel/reduce-params/test-kernel-basic-param.cpp.in +++ b/test/functional/kernel/reduce-params/test-kernel-basic-param.cpp.in @@ -245,7 +245,7 @@ using HipKernelLocForallPols = // Cartesian product of types used in parameterized tests // using @LOC_BACKEND@KernelLocTypes = - Test< camp::cartesian_product +struct val_t_impl { + using type = T; +}; + +template +struct val_t_impl { + using type = typename T::value_type; +}; + +template +using VAL_T = typename val_t_impl::type; + +template +typename T::value_type get_val(T index_val) { return *index_val; } + +template +requires (!RAJA::concepts::IndexValued) +auto get_val(T index_val) { return index_val; } + +} + template -void KernelParamReduceTestImpl(const int xdim, const int ydim) +void KernelParamReduceTestImpl(const INDEX_TYPE xdim, const INDEX_TYPE ydim) { camp::resources::Resource work_res{WORKING_RES::get_default()}; - DATA_TYPE ** workarr2D; - DATA_TYPE ** checkarr2D; - DATA_TYPE ** testarr2D; - DATA_TYPE * work_array; - DATA_TYPE * check_array; - DATA_TYPE * test_array; + DATA_TYPE* work_array; + DATA_TYPE* check_array; + DATA_TYPE* test_array; // square 2D array, xdim x ydim INDEX_TYPE array_length = xdim * ydim; @@ -32,64 +52,53 @@ void KernelParamReduceTestImpl(const int xdim, const int ydim) &test_array ); - allocateForallTestData ( ydim, - work_res, - &workarr2D, - &checkarr2D, - &testarr2D - ); - + // using index_setup_type = VAL_T; // set rows to point to check and work _arrays - RAJA::TypedRangeSegment seg(0,ydim); - RAJA::forall(seg, [=] RAJA_HOST_DEVICE(INDEX_TYPE zz) - { - workarr2D[zz] = work_array + zz * ydim; - }); - - RAJA::forall(seg, [=] RAJA_HOST_DEVICE (INDEX_TYPE zz) - { - checkarr2D[zz] = check_array + zz * ydim; - }); - + RAJA::TypedRangeSegment seg(0, ydim); + using LayoutType = RAJA::TypedLayout>; + using ViewType = RAJA::View; + ViewType TestView (test_array, xdim, ydim ); + ViewType WorkView (work_array, xdim, ydim ); + ViewType CheckView (check_array, xdim, ydim ); // initializing values RAJA::forall(seg, [=] RAJA_HOST_DEVICE (INDEX_TYPE zz) { - for ( int xx = 0; xx < xdim; ++xx ) + for ( INDEX_TYPE xx (0); xx < xdim; ++xx ) { - checkarr2D[zz][xx] = (zz*xdim + xx ) % 100 + 1; + CheckView(zz, xx) = get_val(zz * xdim + xx ) % 100 + 1; } // Make a unique min - checkarr2D[ydim-1][xdim-1] = 0; + CheckView(ydim - 1, xdim - 1) = 0; // Make a unique max - checkarr2D[ydim/2][xdim/2] = 101; + CheckView(ydim / 2, xdim / 2) = 101; }); - work_res.memcpy(work_array, check_array, sizeof(DATA_TYPE) * array_length); + work_res.memcpy(work_array, check_array, sizeof(DATA_TYPE) * get_val(array_length)); RAJA::TypedRangeSegment colrange(0, xdim); RAJA::TypedRangeSegment rowrange(0, ydim); - using VALLOC_DATA_TYPE = RAJA::expt::ValLoc; + using VALLOC_DATA_TYPE = RAJA::expt::ValLoc>; using VALOP_DATA_TYPE_SUM = RAJA::expt::ValOp; using VALOP_DATA_TYPE_MIN = RAJA::expt::ValOp; using VALOP_DATA_TYPE_MAX = RAJA::expt::ValOp; - using VALOPLOC_DATA_TYPE_MIN = RAJA::expt::ValLocOp; - using VALOPLOC_DATA_TYPE_MAX = RAJA::expt::ValLocOp; + using VALOPLOC_DATA_TYPE_MIN = RAJA::expt::ValLocOp, RAJA::operators::minimum>; + using VALOPLOC_DATA_TYPE_MAX = RAJA::expt::ValLocOp, RAJA::operators::maximum>; - VALLOC_DATA_TYPE seq_minloc(std::numeric_limits::max(), Index2D(-1,-1)); - VALLOC_DATA_TYPE seq_maxloc(std::numeric_limits::min(), Index2D(-1,-1)); - Index2D seq_minloc2(-1, -1); - Index2D seq_maxloc2(-1, -1); + VALLOC_DATA_TYPE seq_minloc(std::numeric_limits::max(), Index2D(-1,-1)); + VALLOC_DATA_TYPE seq_maxloc(std::numeric_limits::min(), Index2D(-1,-1)); + Index2D seq_minloc2(-1, -1); + Index2D seq_maxloc2(-1, -1); DATA_TYPE seq_sum = 0; DATA_TYPE seq_min = std::numeric_limits::max(); DATA_TYPE seq_max = std::numeric_limits::min(); DATA_TYPE seq_min2 = std::numeric_limits::max(); DATA_TYPE seq_max2 = std::numeric_limits::min(); - VALLOC_DATA_TYPE minloc(std::numeric_limits::max(), Index2D(-1,-1)); - VALLOC_DATA_TYPE maxloc(std::numeric_limits::min(), Index2D(-1,-1)); - Index2D minloc2(-1, -1); - Index2D maxloc2(-1, -1); + VALLOC_DATA_TYPE minloc(std::numeric_limits::max(), Index2D(-1,-1)); + VALLOC_DATA_TYPE maxloc(std::numeric_limits::min(), Index2D(-1,-1)); + Index2D minloc2(-1, -1); + Index2D maxloc2(-1, -1); DATA_TYPE sum = 0; DATA_TYPE min2 = std::numeric_limits::max(); DATA_TYPE max2 = std::numeric_limits::min(); @@ -109,8 +118,8 @@ void KernelParamReduceTestImpl(const int xdim, const int ydim) RAJA::expt::ReduceLoc(&min2, &minloc2), RAJA::expt::ReduceLoc(&max2, &maxloc2) ), - [=] RAJA_HOST_DEVICE (int c, - int r, + [=] RAJA_HOST_DEVICE (INDEX_TYPE c, + INDEX_TYPE r, VALOP_DATA_TYPE_SUM &_sum, VALOP_DATA_TYPE_MIN &_min, VALOP_DATA_TYPE_MAX &_max, @@ -118,15 +127,15 @@ void KernelParamReduceTestImpl(const int xdim, const int ydim) VALOPLOC_DATA_TYPE_MAX &_maxloc, VALOPLOC_DATA_TYPE_MIN &_minloc2, VALOPLOC_DATA_TYPE_MAX &_maxloc2) { - _sum += workarr2D[r][c]; - _min.min(workarr2D[r][c]); - _max.max(workarr2D[r][c]); + _sum += WorkView(r,c); + _min.min(WorkView(r,c)); + _max.max(WorkView(r,c)); // loc - _minloc.minloc(workarr2D[r][c], Index2D(c, r)); - _maxloc.maxloc(workarr2D[r][c], Index2D(c, r)); - _minloc2.minloc(workarr2D[r][c], Index2D(c, r)); - _maxloc2.maxloc(workarr2D[r][c], Index2D(c, r)); + _minloc.minloc(WorkView(r,c), Index2D(c, r)); + _maxloc.maxloc(WorkView(r,c), Index2D(c, r)); + _minloc2.minloc(WorkView(r,c), Index2D(c, r)); + _maxloc2.maxloc(WorkView(r,c), Index2D(c, r)); }); // CPU answer @@ -148,24 +157,24 @@ void KernelParamReduceTestImpl(const int xdim, const int ydim) VALOPLOC_DATA_TYPE_MIN &_minloc2, VALOPLOC_DATA_TYPE_MAX &_maxloc2 ) { - for (int c = 0; c < xdim; ++c) + for (INDEX_TYPE c(0); c < xdim; ++c) { - _sum += checkarr2D[r][c]; - _min = _min.min(checkarr2D[r][c]); - _max = _max.max(checkarr2D[r][c]); + _sum += CheckView(r,c); + _min = _min.min(CheckView(r,c)); + _max = _max.max(CheckView(r,c)); // loc - _minloc.minloc(checkarr2D[r][c], Index2D(c, r)); - _maxloc.maxloc(checkarr2D[r][c], Index2D(c, r)); - _minloc2.minloc(checkarr2D[r][c], Index2D(c, r)); - _maxloc2.maxloc(checkarr2D[r][c], Index2D(c, r)); + _minloc.minloc(CheckView(r,c), Index2D(c, r)); + _maxloc.maxloc(CheckView(r,c), Index2D(c, r)); + _minloc2.minloc(CheckView(r,c), Index2D(c, r)); + _maxloc2.maxloc(CheckView(r,c), Index2D(c, r)); } }); DATA_TYPE DEBUG_SUM = 0; - for (int r = 0 ; r < ydim; ++r) { - for (int c = 0; c < xdim; ++c) { - DEBUG_SUM += checkarr2D[r][c]; + for (INDEX_TYPE r (0) ; r < ydim; ++r) { + for (INDEX_TYPE c (0); c < xdim; ++c) { + DEBUG_SUM += CheckView(r,c); } } @@ -195,11 +204,6 @@ void KernelParamReduceTestImpl(const int xdim, const int ydim) test_array ); - deallocateForallTestData ( work_res, - workarr2D, - checkarr2D, - testarr2D - ); } diff --git a/test/functional/kernel/tile-icount-tcount-loop/test-kernel-tile-count-loop.cpp.in b/test/functional/kernel/tile-icount-tcount-loop/test-kernel-tile-count-loop.cpp.in index d99117fb8b..89679d9bdc 100644 --- a/test/functional/kernel/tile-icount-tcount-loop/test-kernel-tile-count-loop.cpp.in +++ b/test/functional/kernel/tile-icount-tcount-loop/test-kernel-tile-count-loop.cpp.in @@ -236,7 +236,7 @@ using SyclKernelTileTCountExecPols = camp::list< // Cartesian product of types used in parameterized tests // using @BACKEND@KernelTile@TESTTYPE@Types = - Test< camp::cartesian_product>::Types; diff --git a/test/functional/kernel/tile-variants/test-kernel-tilefixed.cpp.in b/test/functional/kernel/tile-variants/test-kernel-tilefixed.cpp.in index e535c1e0fd..f12996f0cb 100644 --- a/test/functional/kernel/tile-variants/test-kernel-tilefixed.cpp.in +++ b/test/functional/kernel/tile-variants/test-kernel-tilefixed.cpp.in @@ -270,7 +270,7 @@ using SyclKernelTileExecPols = // Cartesian product of types used in parameterized tests // using @TILE_BACKEND@KernelTileTypes = - Test< camp::cartesian_product, RAJA::statement::CudaSyncThreads, - + RAJA::statement::ForICount<0, RAJA::statement::Param<1>, RAJA::cuda_thread_x_loop, RAJA::statement::ForICount<1, RAJA::statement::Param<0>, RAJA::cuda_thread_y_direct, RAJA::statement::Lambda<1> @@ -146,7 +146,7 @@ using HipKernelTileExecPols = >, RAJA::statement::HipSyncThreads, - + RAJA::statement::ForICount<0, RAJA::statement::Param<1>, RAJA::hip_thread_x_loop, RAJA::statement::ForICount<1, RAJA::statement::Param<0>, RAJA::hip_thread_y_direct, RAJA::statement::Lambda<1> @@ -205,7 +205,7 @@ using HipKernelTileExecPols = // Cartesian product of types used in parameterized tests // using @TILE_BACKEND@KernelTileTypes = - Test< camp::cartesian_product>::Types; diff --git a/test/functional/kernel/tile-variants/tests/test-kernel-tile-Dynamic2D.hpp b/test/functional/kernel/tile-variants/tests/test-kernel-tile-Dynamic2D.hpp index d13c1a6146..d513fe0a2a 100644 --- a/test/functional/kernel/tile-variants/tests/test-kernel-tile-Dynamic2D.hpp +++ b/test/functional/kernel/tile-variants/tests/test-kernel-tile-Dynamic2D.hpp @@ -12,10 +12,33 @@ #include +namespace { +template +struct val_t_impl { + using type = T; +}; + +template +struct val_t_impl { + using type = typename T::value_type; +}; + +template +using VAL_T = typename val_t_impl::type; + +template +RAJA_HOST_DEVICE typename T::value_type get_val(T index_val) { return *index_val; } + +template +requires (!RAJA::concepts::IndexValued) +RAJA_HOST_DEVICE auto get_val(T index_val) { return index_val; } +} + template -void KernelTileDynamic2DTestImpl(const int rows, const int cols) +void KernelTileDynamic2DTestImpl(const INDEX_TYPE rows_t, const INDEX_TYPE cols_t) { // This test emulates matrix transposition with tiling. + using raw_index_type = VAL_T; camp::resources::Resource work_res{WORKING_RES::get_default()}; @@ -28,7 +51,7 @@ void KernelTileDynamic2DTestImpl(const int rows, const int cols) DATA_TYPE * check_array_t; DATA_TYPE * test_array_t; - INDEX_TYPE array_length = rows * cols; + INDEX_TYPE array_length = rows_t * cols_t; allocateForallTestData ( array_length, work_res, @@ -44,31 +67,35 @@ void KernelTileDynamic2DTestImpl(const int rows, const int cols) &test_array_t ); - RAJA::View> HostView( test_array, rows, cols ); - RAJA::View> HostTView( test_array_t, cols, rows ); - RAJA::View> WorkView( work_array, rows, cols ); - RAJA::View> WorkTView( work_array_t, cols, rows ); - RAJA::View> CheckTView( check_array_t, cols, rows ); + using LayoutType = + RAJA::TypedLayout>; + using ViewType = RAJA::View; + + ViewType HostView( test_array, rows_t, cols_t ); + ViewType HostTView( test_array_t, cols_t, rows_t ); + ViewType WorkView( work_array, rows_t, cols_t ); + ViewType WorkTView( work_array_t, cols_t, rows_t ); + ViewType CheckTView( check_array_t, cols_t, rows_t ); // initialize arrays - std::iota( test_array, test_array + array_length, 1 ); - std::iota( test_array_t, test_array_t + array_length, 1 ); + std::iota( test_array, test_array + get_val(array_length), 1 ); + std::iota( test_array_t, test_array_t + get_val(array_length), 1 ); - work_res.memcpy( work_array, test_array, sizeof(DATA_TYPE) * array_length ); - work_res.memcpy( work_array_t, test_array_t, sizeof(DATA_TYPE) * array_length ); + work_res.memcpy( work_array, test_array, sizeof(DATA_TYPE) * get_val(array_length) ); + work_res.memcpy( work_array_t, test_array_t, sizeof(DATA_TYPE) * get_val(array_length) ); // transpose test_array on CPU - for ( int rr = 0; rr < rows; ++rr ) + for ( raw_index_type rr = 0; rr < get_val(rows_t); ++rr ) { - for ( int cc = 0; cc < cols; ++cc ) + for ( raw_index_type cc = 0; cc < get_val(cols_t); ++cc ) { - HostTView( cc, rr ) = HostView( rr, cc ); + HostTView( INDEX_TYPE(cc), INDEX_TYPE(rr) ) = HostView( INDEX_TYPE(rr), INDEX_TYPE(cc) ); } } // transpose work_array - RAJA::TypedRangeSegment rowrange( 0, rows ); - RAJA::TypedRangeSegment colrange( 0, cols ); + RAJA::TypedRangeSegment rowrange( 0, rows_t ); + RAJA::TypedRangeSegment colrange( 0, cols_t ); RAJA::kernel_param ( RAJA::make_tuple( colrange, rowrange ), @@ -77,19 +104,20 @@ void KernelTileDynamic2DTestImpl(const int rows, const int cols) WorkTView( cc, rr ) = WorkView( rr, cc ); }); - work_res.memcpy( check_array_t, work_array_t, sizeof(DATA_TYPE) * array_length ); + work_res.memcpy( check_array_t, work_array_t, sizeof(DATA_TYPE) * get_val(array_length) ); - for ( int rr = 0; rr < rows; ++rr ) + for ( raw_index_type rr = 0; rr < get_val(rows_t); ++rr ) { - for ( int cc = 0; cc < cols; ++cc ) + for ( raw_index_type cc = 0; cc < get_val(cols_t); ++cc ) { - ASSERT_EQ(CheckTView(cc, rr), HostTView(cc, rr)); + ASSERT_EQ(CheckTView(INDEX_TYPE(cc), INDEX_TYPE(rr)), + HostTView(INDEX_TYPE(cc), INDEX_TYPE(rr))); } } // reset check and work transpose arrays - work_res.memcpy( check_array_t, test_array, sizeof(DATA_TYPE) * array_length ); - work_res.memcpy( work_array_t, test_array, sizeof(DATA_TYPE) * array_length ); + work_res.memcpy( check_array_t, test_array, sizeof(DATA_TYPE) * get_val(array_length) ); + work_res.memcpy( work_array_t, test_array, sizeof(DATA_TYPE) * get_val(array_length) ); // transpose work_array again with different tile sizes RAJA::kernel_param ( @@ -99,13 +127,14 @@ void KernelTileDynamic2DTestImpl(const int rows, const int cols) WorkTView( cc, rr ) = WorkView( rr, cc ); }); - work_res.memcpy( check_array_t, work_array_t, sizeof(DATA_TYPE) * array_length ); + work_res.memcpy( check_array_t, work_array_t, sizeof(DATA_TYPE) * get_val(array_length) ); - for ( int rr = 0; rr < rows; ++rr ) + for ( raw_index_type rr = 0; rr < get_val(rows_t); ++rr ) { - for ( int cc = 0; cc < cols; ++cc ) + for ( raw_index_type cc = 0; cc < get_val(cols_t); ++cc ) { - ASSERT_EQ(CheckTView(cc, rr), HostTView(cc, rr)); + ASSERT_EQ(CheckTView(INDEX_TYPE(cc), INDEX_TYPE(rr)), + HostTView(INDEX_TYPE(cc), INDEX_TYPE(rr))); } } @@ -136,9 +165,9 @@ TYPED_TEST_P(KernelTileDynamic2DTest, TileDynamic2DKernel) using WORKING_RES = typename camp::at>::type; using EXEC_POLICY = typename camp::at>::type; - KernelTileDynamic2DTestImpl(10, 10); - KernelTileDynamic2DTestImpl(151, 111); - KernelTileDynamic2DTestImpl(362, 362); + KernelTileDynamic2DTestImpl(INDEX_TYPE(10), INDEX_TYPE(10)); + KernelTileDynamic2DTestImpl(INDEX_TYPE(151), INDEX_TYPE(111)); + KernelTileDynamic2DTestImpl(INDEX_TYPE(362), INDEX_TYPE(362)); } REGISTER_TYPED_TEST_SUITE_P(KernelTileDynamic2DTest, diff --git a/test/functional/kernel/tile-variants/tests/test-kernel-tile-Fixed2D.hpp b/test/functional/kernel/tile-variants/tests/test-kernel-tile-Fixed2D.hpp index 07e5fe361d..b2f105fee2 100644 --- a/test/functional/kernel/tile-variants/tests/test-kernel-tile-Fixed2D.hpp +++ b/test/functional/kernel/tile-variants/tests/test-kernel-tile-Fixed2D.hpp @@ -12,10 +12,33 @@ #include +namespace { +template +struct val_t_impl { + using type = T; +}; + +template +struct val_t_impl { + using type = typename T::value_type; +}; + +template +using VAL_T = typename val_t_impl::type; + +template +RAJA_HOST_DEVICE typename T::value_type get_val(T index_val) { return *index_val; } + +template +requires (!RAJA::concepts::IndexValued) +RAJA_HOST_DEVICE auto get_val(T index_val) { return index_val; } +} + template -void KernelTileFixed2DTestImpl(const int rows, const int cols) +void KernelTileFixed2DTestImpl(const INDEX_TYPE rows_t, const INDEX_TYPE cols_t) { // This test emulates matrix transposition with tiling. + using raw_index_type = VAL_T; camp::resources::Resource work_res{WORKING_RES::get_default()}; @@ -28,7 +51,7 @@ void KernelTileFixed2DTestImpl(const int rows, const int cols) DATA_TYPE * check_array_t; DATA_TYPE * test_array_t; - INDEX_TYPE array_length = rows * cols; + INDEX_TYPE array_length = rows_t * cols_t; allocateForallTestData ( array_length, work_res, @@ -44,44 +67,49 @@ void KernelTileFixed2DTestImpl(const int rows, const int cols) &test_array_t ); - RAJA::View> HostView( test_array, rows, cols ); - RAJA::View> HostTView( test_array_t, cols, rows ); - RAJA::View> WorkView( work_array, rows, cols ); - RAJA::View> WorkTView( work_array_t, cols, rows ); - RAJA::View> CheckTView( check_array_t, cols, rows ); + using LayoutType = + RAJA::TypedLayout>; + using ViewType = RAJA::View; + + ViewType HostView( test_array, rows_t, cols_t ); + ViewType HostTView( test_array_t, cols_t, rows_t ); + ViewType WorkView( work_array, rows_t, cols_t ); + ViewType WorkTView( work_array_t, cols_t, rows_t ); + ViewType CheckTView( check_array_t, cols_t, rows_t ); // initialize arrays - std::iota( test_array, test_array + array_length, 1 ); - std::iota( test_array_t, test_array_t + array_length, 1 ); + std::iota( test_array, test_array + get_val(array_length), 1 ); + std::iota( test_array_t, test_array_t + get_val(array_length), 1 ); - work_res.memcpy( work_array, test_array, sizeof(DATA_TYPE) * array_length ); - work_res.memcpy( work_array_t, test_array_t, sizeof(DATA_TYPE) * array_length ); + work_res.memcpy( work_array, test_array, sizeof(DATA_TYPE) * get_val(array_length) ); + work_res.memcpy( work_array_t, test_array_t, sizeof(DATA_TYPE) * get_val(array_length) ); // transpose test_array on CPU - for ( int rr = 0; rr < rows; ++rr ) + for ( raw_index_type rr = 0; rr < get_val(rows_t); ++rr ) { - for ( int cc = 0; cc < cols; ++cc ) + for ( raw_index_type cc = 0; cc < get_val(cols_t); ++cc ) { - HostTView( cc, rr ) = HostView( rr, cc ); + HostTView( INDEX_TYPE(cc), INDEX_TYPE(rr) ) = HostView( INDEX_TYPE(rr), INDEX_TYPE(cc) ); } } // transpose work_array - RAJA::TypedRangeSegment rowrange( 0, rows ); - RAJA::TypedRangeSegment colrange( 0, cols ); + RAJA::TypedRangeSegment rowrange( 0, rows_t ); + RAJA::TypedRangeSegment colrange( 0, cols_t ); RAJA::kernel ( RAJA::make_tuple( colrange, rowrange ), [=] RAJA_HOST_DEVICE ( INDEX_TYPE cc, INDEX_TYPE rr ) { WorkTView( cc, rr ) = WorkView( rr, cc ); }); - work_res.memcpy( check_array_t, work_array_t, sizeof(DATA_TYPE) * array_length ); + work_res.memcpy( check_array_t, work_array_t, sizeof(DATA_TYPE) * get_val(array_length) ); - for ( int rr = 0; rr < rows; ++rr ) + for ( raw_index_type rr = 0; rr < get_val(rows_t); ++rr ) { - for ( int cc = 0; cc < cols; ++cc ) + for ( raw_index_type cc = 0; cc < get_val(cols_t); ++cc ) { - ASSERT_EQ(CheckTView(cc, rr), HostTView(cc, rr)); + ASSERT_EQ(CheckTView(INDEX_TYPE(cc), INDEX_TYPE(rr)), + HostTView(INDEX_TYPE(cc), INDEX_TYPE(rr))); } } @@ -112,9 +140,9 @@ TYPED_TEST_P(KernelTileFixed2DTest, TileFixed2DKernel) using WORKING_RES = typename camp::at>::type; using EXEC_POLICY = typename camp::at>::type; - KernelTileFixed2DTestImpl(10, 10); - KernelTileFixed2DTestImpl(151, 111); - KernelTileFixed2DTestImpl(362, 362); + KernelTileFixed2DTestImpl(INDEX_TYPE(10), INDEX_TYPE(10)); + KernelTileFixed2DTestImpl(INDEX_TYPE(151), INDEX_TYPE(111)); + KernelTileFixed2DTestImpl(INDEX_TYPE(362), INDEX_TYPE(362)); } REGISTER_TYPED_TEST_SUITE_P(KernelTileFixed2DTest, diff --git a/test/functional/kernel/tile-variants/tests/test-kernel-tile-Fixed2DMinMax.hpp b/test/functional/kernel/tile-variants/tests/test-kernel-tile-Fixed2DMinMax.hpp index 02ab058ff8..b935057565 100644 --- a/test/functional/kernel/tile-variants/tests/test-kernel-tile-Fixed2DMinMax.hpp +++ b/test/functional/kernel/tile-variants/tests/test-kernel-tile-Fixed2DMinMax.hpp @@ -13,10 +13,33 @@ #include #include +namespace { +template +struct val_t_impl { + using type = T; +}; + +template +struct val_t_impl { + using type = typename T::value_type; +}; + +template +using VAL_T = typename val_t_impl::type; + +template +RAJA_HOST_DEVICE typename T::value_type get_val(T index_val) { return *index_val; } + +template +requires (!RAJA::concepts::IndexValued) +RAJA_HOST_DEVICE auto get_val(T index_val) { return index_val; } +} + template -void KernelTileFixed2DMinMaxTestImpl(const int rows, const int cols) +void KernelTileFixed2DMinMaxTestImpl(const INDEX_TYPE rows_t, const INDEX_TYPE cols_t) { // This test reduces min and max with tiling. + using raw_index_type = VAL_T; camp::resources::Resource work_res{WORKING_RES::get_default()}; @@ -24,7 +47,7 @@ void KernelTileFixed2DMinMaxTestImpl(const int rows, const int cols) DATA_TYPE * check_array; DATA_TYPE * test_array; - INDEX_TYPE array_length = rows * cols; + INDEX_TYPE array_length = rows_t * cols_t; allocateForallTestData ( array_length, work_res, @@ -34,26 +57,29 @@ void KernelTileFixed2DMinMaxTestImpl(const int rows, const int cols) ); // initialize arrays - std::iota( test_array, test_array + array_length, 1 ); + std::iota( test_array, test_array + get_val(array_length), 1 ); // set min and max of the array test_array[4] = -1; - test_array[8] = array_length+2; + test_array[8] = static_cast(get_val(array_length) + 2); - RAJA::View> WorkView( work_array, rows, cols ); + using LayoutType = + RAJA::TypedLayout>; + using ViewType = RAJA::View; + ViewType WorkView( work_array, rows_t, cols_t ); - work_res.memcpy( work_array, test_array, sizeof(DATA_TYPE) * array_length ); + work_res.memcpy( work_array, test_array, sizeof(DATA_TYPE) * get_val(array_length) ); RAJA::ReduceMin workmin( DATA_TYPE(99999) ); RAJA::ReduceMax workmax( DATA_TYPE(-1) ); // mixed range types - RAJA::TypedRangeSegment rowrange( 0, rows ); + RAJA::TypedRangeSegment rowrange( 0, rows_t ); std::vector colidx; - for (INDEX_TYPE ii = INDEX_TYPE(0); ii < static_cast(cols); ++ii) + for (raw_index_type ii = 0; ii < get_val(cols_t); ++ii) { - colidx.push_back(ii); + colidx.push_back(INDEX_TYPE(ii)); } RAJA::TypedListSegment colrange( &colidx[0], colidx.size(), work_res ); @@ -66,7 +92,7 @@ void KernelTileFixed2DMinMaxTestImpl(const int rows, const int cols) }); ASSERT_EQ(static_cast(-1), static_cast(workmin.get())); - ASSERT_EQ(static_cast(array_length+2), static_cast(workmax.get())); + ASSERT_EQ(static_cast(get_val(array_length) + 2), static_cast(workmax.get())); deallocateForallTestData ( work_res, work_array, @@ -90,9 +116,9 @@ TYPED_TEST_P(KernelTileFixed2DMinMaxTest, TileFixed2DMinMaxKernel) using EXEC_POLICY = typename camp::at>::type; using REDUCE_POLICY = typename camp::at>::type; - KernelTileFixed2DMinMaxTestImpl(10, 10); - KernelTileFixed2DMinMaxTestImpl(151, 111); - KernelTileFixed2DMinMaxTestImpl(362, 362); + KernelTileFixed2DMinMaxTestImpl(INDEX_TYPE(10), INDEX_TYPE(10)); + KernelTileFixed2DMinMaxTestImpl(INDEX_TYPE(151), INDEX_TYPE(111)); + KernelTileFixed2DMinMaxTestImpl(INDEX_TYPE(362), INDEX_TYPE(362)); } REGISTER_TYPED_TEST_SUITE_P(KernelTileFixed2DMinMaxTest, diff --git a/test/functional/kernel/tile-variants/tests/test-kernel-tile-Fixed2DSum.hpp b/test/functional/kernel/tile-variants/tests/test-kernel-tile-Fixed2DSum.hpp index e9b88cda6f..ec8d93ade5 100644 --- a/test/functional/kernel/tile-variants/tests/test-kernel-tile-Fixed2DSum.hpp +++ b/test/functional/kernel/tile-variants/tests/test-kernel-tile-Fixed2DSum.hpp @@ -14,12 +14,35 @@ #include #include +namespace { +template +struct val_t_impl { + using type = T; +}; + +template +struct val_t_impl { + using type = typename T::value_type; +}; + +template +using VAL_T = typename val_t_impl::type; + +template +RAJA_HOST_DEVICE typename T::value_type get_val(T index_val) { return *index_val; } + +template +requires (!RAJA::concepts::IndexValued) +RAJA_HOST_DEVICE auto get_val(T index_val) { return index_val; } +} + template -void KernelTileFixed2DSumTestImpl(const int rowsin, const int colsin) +void KernelTileFixed2DSumTestImpl(const INDEX_TYPE rowsin, const INDEX_TYPE colsin) { // This test reduces sums with tiling. + using raw_index_type = VAL_T; - int rows, cols; + raw_index_type rows, cols; if ( std::is_same::value ) { // Restrict to a small data size for better float precision. @@ -28,8 +51,8 @@ void KernelTileFixed2DSumTestImpl(const int rowsin, const int colsin) } else { - rows = rowsin; - cols = colsin; + rows = get_val(rowsin); + cols = get_val(colsin); } camp::resources::Resource work_res{WORKING_RES::get_default()}; @@ -39,13 +62,13 @@ void KernelTileFixed2DSumTestImpl(const int rowsin, const int colsin) RAJA::ReduceSum worksum( DATA_TYPE(0) ); // sum on CPU in a tiled manner - for ( int rr = 0; rr < rows; rr += tile_dim_x ) + for ( raw_index_type rr = 0; rr < rows; rr += tile_dim_x ) { - for ( int cc = 0; cc < cols; cc += tile_dim_y ) + for ( raw_index_type cc = 0; cc < cols; cc += tile_dim_y ) { - for ( int r = rr; r < std::min(rr+tile_dim_x, rows); ++r ) + for ( raw_index_type r = rr; r < std::min(rr + tile_dim_x, rows); ++r ) { - for ( int c = cc; c < std::min(cc+tile_dim_y, cols); ++c ) + for ( raw_index_type c = cc; c < std::min(cc + tile_dim_y, cols); ++c ) { hostsum += (DATA_TYPE)(r * 1.1 + c); } @@ -54,12 +77,12 @@ void KernelTileFixed2DSumTestImpl(const int rowsin, const int colsin) } // mixed range types - RAJA::TypedRangeSegment rowrange( 0, rows ); + RAJA::TypedRangeSegment rowrange( 0, INDEX_TYPE(rows) ); std::vector colidx; - for (INDEX_TYPE ii = INDEX_TYPE(0); ii < static_cast(cols); ++ii) + for (raw_index_type ii = 0; ii < cols; ++ii) { - colidx.push_back(ii); + colidx.push_back(INDEX_TYPE(ii)); } RAJA::TypedListSegment colrange( &colidx[0], colidx.size(), work_res ); @@ -67,7 +90,7 @@ void KernelTileFixed2DSumTestImpl(const int rowsin, const int colsin) // sum on target platform RAJA::kernel ( RAJA::make_tuple( colrange, rowrange ), [=] RAJA_HOST_DEVICE ( INDEX_TYPE cc, INDEX_TYPE rr ) { - worksum += (DATA_TYPE)(rr * 1.1 + cc); + worksum += (DATA_TYPE)(get_val(rr) * 1.1 + get_val(cc)); }); ASSERT_FLOAT_EQ(hostsum, (DATA_TYPE)worksum.get()); @@ -88,9 +111,9 @@ TYPED_TEST_P(KernelTileFixed2DSumTest, TileFixed2DSumKernel) using EXEC_POLICY = typename camp::at>::type; using REDUCE_POLICY = typename camp::at>::type; - KernelTileFixed2DSumTestImpl(10, 10); - KernelTileFixed2DSumTestImpl(151, 111); - KernelTileFixed2DSumTestImpl(362, 362); + KernelTileFixed2DSumTestImpl(INDEX_TYPE(10), INDEX_TYPE(10)); + KernelTileFixed2DSumTestImpl(INDEX_TYPE(151), INDEX_TYPE(111)); + KernelTileFixed2DSumTestImpl(INDEX_TYPE(362), INDEX_TYPE(362)); } REGISTER_TYPED_TEST_SUITE_P(KernelTileFixed2DSumTest, diff --git a/test/functional/kernel/tile-variants/tests/test-kernel-tile-LocalArray2D.hpp b/test/functional/kernel/tile-variants/tests/test-kernel-tile-LocalArray2D.hpp index bd82821349..4d013d93dd 100644 --- a/test/functional/kernel/tile-variants/tests/test-kernel-tile-LocalArray2D.hpp +++ b/test/functional/kernel/tile-variants/tests/test-kernel-tile-LocalArray2D.hpp @@ -12,10 +12,33 @@ #include +namespace { +template +struct val_t_impl { + using type = T; +}; + +template +struct val_t_impl { + using type = typename T::value_type; +}; + +template +using VAL_T = typename val_t_impl::type; + +template +RAJA_HOST_DEVICE typename T::value_type get_val(T index_val) { return *index_val; } + +template +requires (!RAJA::concepts::IndexValued) +RAJA_HOST_DEVICE auto get_val(T index_val) { return index_val; } +} + template -void KernelTileLocalArray2DTestImpl(const int rows, const int cols) +void KernelTileLocalArray2DTestImpl(const INDEX_TYPE rows_t, const INDEX_TYPE cols_t) { // This test emulates matrix transposition with tiling. + using raw_index_type = VAL_T; camp::resources::Resource work_res{WORKING_RES::get_default()}; @@ -28,7 +51,7 @@ void KernelTileLocalArray2DTestImpl(const int rows, const int cols) DATA_TYPE * check_array_t; DATA_TYPE * test_array_t; - INDEX_TYPE array_length = rows * cols; + INDEX_TYPE array_length = rows_t * cols_t; allocateForallTestData ( array_length, work_res, @@ -44,53 +67,58 @@ void KernelTileLocalArray2DTestImpl(const int rows, const int cols) &test_array_t ); - RAJA::View> HostView( test_array, rows, cols ); - RAJA::View> HostTView( test_array_t, cols, rows ); - RAJA::View> WorkView( work_array, rows, cols ); - RAJA::View> WorkTView( work_array_t, cols, rows ); - RAJA::View> CheckTView( check_array_t, cols, rows ); + using LayoutType = + RAJA::TypedLayout>; + using ViewType = RAJA::View; + + ViewType HostView( test_array, rows_t, cols_t ); + ViewType HostTView( test_array_t, cols_t, rows_t ); + ViewType WorkView( work_array, rows_t, cols_t ); + ViewType WorkTView( work_array_t, cols_t, rows_t ); + ViewType CheckTView( check_array_t, cols_t, rows_t ); // initialize local array (shared mem) using TILE_MEM = RAJA::LocalArray, RAJA::SizeList>; TILE_MEM Tile_Array; // initialize arrays - std::iota( test_array, test_array + array_length, 1 ); - std::iota( test_array_t, test_array_t + array_length, 1 ); + std::iota( test_array, test_array + get_val(array_length), 1 ); + std::iota( test_array_t, test_array_t + get_val(array_length), 1 ); - work_res.memcpy( work_array, test_array, sizeof(DATA_TYPE) * array_length ); - work_res.memcpy( work_array_t, test_array_t, sizeof(DATA_TYPE) * array_length ); + work_res.memcpy( work_array, test_array, sizeof(DATA_TYPE) * get_val(array_length) ); + work_res.memcpy( work_array_t, test_array_t, sizeof(DATA_TYPE) * get_val(array_length) ); // transpose test_array on CPU - for ( int rr = 0; rr < rows; ++rr ) + for ( raw_index_type rr = 0; rr < get_val(rows_t); ++rr ) { - for ( int cc = 0; cc < cols; ++cc ) + for ( raw_index_type cc = 0; cc < get_val(cols_t); ++cc ) { - HostTView( cc, rr ) = HostView( rr, cc ); + HostTView( INDEX_TYPE(cc), INDEX_TYPE(rr) ) = HostView( INDEX_TYPE(rr), INDEX_TYPE(cc) ); } } // transpose work_array - RAJA::TypedRangeSegment rowrange( 0, rows ); - RAJA::TypedRangeSegment colrange( 0, cols ); + RAJA::TypedRangeSegment rowrange( 0, rows_t ); + RAJA::TypedRangeSegment colrange( 0, cols_t ); - RAJA::kernel_param ( RAJA::make_tuple( colrange, rowrange ), RAJA::make_tuple( (INDEX_TYPE)0, (INDEX_TYPE)0, Tile_Array ), + RAJA::kernel_param ( RAJA::make_tuple( colrange, rowrange ), RAJA::make_tuple( INDEX_TYPE(0), INDEX_TYPE(0), Tile_Array ), [=] RAJA_HOST_DEVICE ( INDEX_TYPE cc, INDEX_TYPE rr, INDEX_TYPE tx, INDEX_TYPE ty, TILE_MEM &_Tile_Array ) { - _Tile_Array( ty, tx ) = WorkView( rr, cc ); + _Tile_Array( get_val(ty), get_val(tx) ) = WorkView( rr, cc ); }, [=] RAJA_HOST_DEVICE ( INDEX_TYPE cc, INDEX_TYPE rr, INDEX_TYPE tx, INDEX_TYPE ty, TILE_MEM &_Tile_Array ) { - WorkTView( cc, rr ) = _Tile_Array( ty, tx ); + WorkTView( cc, rr ) = _Tile_Array( get_val(ty), get_val(tx) ); } ); - work_res.memcpy( check_array_t, work_array_t, sizeof(DATA_TYPE) * array_length ); + work_res.memcpy( check_array_t, work_array_t, sizeof(DATA_TYPE) * get_val(array_length) ); - for ( int rr = 0; rr < rows; ++rr ) + for ( raw_index_type rr = 0; rr < get_val(rows_t); ++rr ) { - for ( int cc = 0; cc < cols; ++cc ) + for ( raw_index_type cc = 0; cc < get_val(cols_t); ++cc ) { - ASSERT_EQ(CheckTView(cc, rr), HostTView(cc, rr)); + ASSERT_EQ(CheckTView(INDEX_TYPE(cc), INDEX_TYPE(rr)), + HostTView(INDEX_TYPE(cc), INDEX_TYPE(rr))); } } @@ -121,9 +149,9 @@ TYPED_TEST_P(KernelTileLocalArray2DTest, TileLocalArray2DKernel) using WORKING_RES = typename camp::at>::type; using EXEC_POLICY = typename camp::at>::type; - KernelTileLocalArray2DTestImpl(10, 10); - KernelTileLocalArray2DTestImpl(151, 111); - KernelTileLocalArray2DTestImpl(362, 362); + KernelTileLocalArray2DTestImpl(INDEX_TYPE(10), INDEX_TYPE(10)); + KernelTileLocalArray2DTestImpl(INDEX_TYPE(151), INDEX_TYPE(111)); + KernelTileLocalArray2DTestImpl(INDEX_TYPE(362), INDEX_TYPE(362)); } REGISTER_TYPED_TEST_SUITE_P(KernelTileLocalArray2DTest, diff --git a/test/include/RAJA_test-forall-data.hpp b/test/include/RAJA_test-forall-data.hpp index 6c45b8f8ab..97c54b8cb1 100644 --- a/test/include/RAJA_test-forall-data.hpp +++ b/test/include/RAJA_test-forall-data.hpp @@ -8,12 +8,13 @@ //~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~// // -// Utility routines for allocating/deallocating arrays in for forall tests. +// Utility routines for allocating/deallocating arrays in for forall tests. // #ifndef __RAJA_test_forall_data_HPP__ #define __RAJA_test_forall_data_HPP__ +#include "RAJA/index/IndexValue.hpp" #include "camp/resource.hpp" template @@ -33,8 +34,8 @@ void allocateForallTestData(size_t N, // for RAJA strongly typed indices template>::value>::type* = nullptr> -void allocateForallTestData(T N, + RAJA::concepts::IndexValued IdxType> +void allocateForallTestData(IdxType N, camp::resources::Resource work_res, T** work_array, T** check_array, diff --git a/test/include/RAJA_test-reduceloc-types.hpp b/test/include/RAJA_test-reduceloc-types.hpp index 1109e545f4..c56e9d11e6 100644 --- a/test/include/RAJA_test-reduceloc-types.hpp +++ b/test/include/RAJA_test-reduceloc-types.hpp @@ -15,14 +15,16 @@ #define __RAJA_test_reduceloc_types_HPP__ #include "RAJA/RAJA.hpp" +#include "RAJA/index/IndexValue.hpp" #include "RAJA/util/types.hpp" #include "camp/list.hpp" +template struct Index2D { - RAJA::Index_type idx, idy; + IDX idx, idy; constexpr Index2D() : idx(-1), idy(-1) {} - constexpr Index2D(RAJA::Index_type init) : idx(init), idy(init) {} - constexpr Index2D(RAJA::Index_type ix, RAJA::Index_type iy) : idx(ix), idy(iy) {} + constexpr Index2D(IDX ix) : idx(ix), idy(ix) {} + constexpr Index2D(IDX ix, IDX iy) : idx(ix), idy(iy) {} template RAJA_HOST_DEVICE void operator=(T rhs) { idx = rhs; idx = rhs; } }; From 1fd80e6cab6411e3eff381046055ec108727fbe8 Mon Sep 17 00:00:00 2001 From: john bowen Date: Tue, 11 Aug 2026 17:07:45 -0700 Subject: [PATCH 3/8] Fix merge build errors and test failure --- include/RAJA/index/IndexValue.hpp | 33 ++++++++++--------- include/RAJA/pattern/concepts.hpp | 3 ++ include/RAJA/pattern/params/params_base.hpp | 8 ++--- include/RAJA/pattern/params/reducer.hpp | 4 +-- include/RAJA/policy/sequential/reduce.hpp | 5 +-- include/RAJA/util/concepts.hpp | 1 + .../test-kernel-nested-loop-view.cpp.in | 2 +- test/include/RAJA_test-index-types.hpp | 8 ++--- 8 files changed, 36 insertions(+), 28 deletions(-) diff --git a/include/RAJA/index/IndexValue.hpp b/include/RAJA/index/IndexValue.hpp index 73e38d7062..5946b6c1cc 100644 --- a/include/RAJA/index/IndexValue.hpp +++ b/include/RAJA/index/IndexValue.hpp @@ -24,7 +24,7 @@ #include -#include "RAJA/util/concepts.hpp" +// #include "RAJA/util/concepts.hpp" #include "RAJA/util/macros.hpp" #include "RAJA/util/types.hpp" @@ -307,28 +307,31 @@ convertIndex_helper(typename FROM::IndexValueType const val) } // namespace internal -namespace type_traits +namespace concepts { +// Should we try to move this to either util/concepts.hpp +// or pattern/concepts.hpp? template -struct is_instance_of_index_value - : std::is_base_of>, - std::remove_cvref_t> -{}; +concept IndexValued = std::is_base_of_v< + RAJA::IndexValue, + typename std::remove_cvref_t::value_type>, + std::remove_cvref_t>; -template -constexpr bool is_instance_of_index_value_v = - is_instance_of_index_value::value; -} // namespace type_traits -namespace concepts +} // namespace concepts + +namespace type_traits { template -concept IndexValued = - type_traits::is_instance_of_index_value_v; +struct is_instance_of_index_value + : std::bool_constant> +{}; template -concept Index = concepts::Integral || concepts::IndexValued; -} // namespace concepts +inline constexpr bool is_instance_of_index_value_v = + is_instance_of_index_value::value; + +} // namespace type_traits template RAJA_HOST_DEVICE RAJA_INLINE TYPE operator+(typename TYPE::value_type lhs, diff --git a/include/RAJA/pattern/concepts.hpp b/include/RAJA/pattern/concepts.hpp index 47c19f1fb0..454e5dd455 100644 --- a/include/RAJA/pattern/concepts.hpp +++ b/include/RAJA/pattern/concepts.hpp @@ -53,6 +53,9 @@ concept ExecutionPolicy = /// specializations of camp::num. Because of this, their /// value type is actually const long, not bool. Therefore, static_cast to /// bool is used below to define these. +template +concept Index = concepts::Integral || concepts::IndexValued; + template concept IndexSetType = static_cast(type_traits::is_index_set>::value); diff --git a/include/RAJA/pattern/params/params_base.hpp b/include/RAJA/pattern/params/params_base.hpp index 7cd87047eb..adbf889b4c 100644 --- a/include/RAJA/pattern/params/params_base.hpp +++ b/include/RAJA/pattern/params/params_base.hpp @@ -28,8 +28,8 @@ using valloc_index_storage_t = IndexType>; template -RAJA_HOST_DEVICE constexpr valloc_index_storage_t -strip_valloc_index(IndexType const& index) +RAJA_HOST_DEVICE constexpr valloc_index_storage_t strip_valloc_index( + IndexType const& index) { if constexpr (std::is_base_of::value) { @@ -42,8 +42,8 @@ strip_valloc_index(IndexType const& index) } template -RAJA_HOST_DEVICE constexpr IndexType -restore_valloc_index(valloc_index_storage_t const& index) +RAJA_HOST_DEVICE constexpr IndexType restore_valloc_index( + valloc_index_storage_t const& index) { if constexpr (std::is_base_of::value) { diff --git a/include/RAJA/pattern/params/reducer.hpp b/include/RAJA/pattern/params/reducer.hpp index bc7e03022e..93111d6ed8 100644 --- a/include/RAJA/pattern/params/reducer.hpp +++ b/include/RAJA/pattern/params/reducer.hpp @@ -184,8 +184,8 @@ struct Reducer, ValLoc, ValLoc>, // Points to either dual value and index defined by the user, or value and // index within a ValLoc defined by the user - target_value_type* target_value = nullptr; - stored_index_type* target_index = nullptr; + target_value_type* target_value = nullptr; + stored_index_type* target_index = nullptr; target_index_type* external_target_index = nullptr; // combineTarget() performs the final op on the target data and location in diff --git a/include/RAJA/policy/sequential/reduce.hpp b/include/RAJA/policy/sequential/reduce.hpp index 642aeaa463..6c46f9be25 100644 --- a/include/RAJA/policy/sequential/reduce.hpp +++ b/include/RAJA/policy/sequential/reduce.hpp @@ -53,7 +53,8 @@ class ReduceSeq // This is a Combinable and is the first layer of that RAJA_SUPPRESS_HD_WARN RAJA_HOST_DEVICE - ReduceSeq(Policy p, T init_val, T identity_) : Base(init_val, identity_) + ReduceSeq(Policy p [[maybe_unused]], T init_val, T identity_) + : Base(init_val, identity_) { #if !defined(RAJA_GPU_DEVICE_COMPILE_PASS_ACTIVE) policy_matches_or_throw( @@ -64,7 +65,7 @@ class ReduceSeq // This is a Combinable and is the first layer of that RAJA_SUPPRESS_HD_WARN RAJA_HOST_DEVICE - void reset(Policy p, T init_val, T identity_) + void reset(Policy p [[maybe_unused]], T init_val, T identity_) { #if !defined(RAJA_GPU_DEVICE_COMPILE_PASS_ACTIVE) policy_matches_or_throw( diff --git a/include/RAJA/util/concepts.hpp b/include/RAJA/util/concepts.hpp index 2217314a69..4917df3066 100644 --- a/include/RAJA/util/concepts.hpp +++ b/include/RAJA/util/concepts.hpp @@ -97,6 +97,7 @@ template inline constexpr bool is_unary_function_v = is_unary_function::value; + using namespace camp::type_traits; } // namespace type_traits diff --git a/test/functional/kernel/nested-loop-view-types/test-kernel-nested-loop-view.cpp.in b/test/functional/kernel/nested-loop-view-types/test-kernel-nested-loop-view.cpp.in index 94acc89ca6..c7d9b318b8 100644 --- a/test/functional/kernel/nested-loop-view-types/test-kernel-nested-loop-view.cpp.in +++ b/test/functional/kernel/nested-loop-view-types/test-kernel-nested-loop-view.cpp.in @@ -309,7 +309,7 @@ camp::list< // Cartesian product of types used in parameterized tests // using @BACKEND@KernelNestesLoop@TESTTYPE@@DIM@Types = - Test< camp::cartesian_product>::Types; diff --git a/test/include/RAJA_test-index-types.hpp b/test/include/RAJA_test-index-types.hpp index c861051b66..f92c204479 100644 --- a/test/include/RAJA_test-index-types.hpp +++ b/test/include/RAJA_test-index-types.hpp @@ -53,9 +53,10 @@ using RawIdxTypeList = camp::list; +using SignedIdxTypeList = camp::list; // // Strong-compatible index types list @@ -66,7 +67,6 @@ using StrongIdxTypeList = camp::list Date: Wed, 12 Aug 2026 09:36:20 -0700 Subject: [PATCH 4/8] fix build error --- include/RAJA/util/Span.hpp | 7 +++---- 1 file changed, 3 insertions(+), 4 deletions(-) diff --git a/include/RAJA/util/Span.hpp b/include/RAJA/util/Span.hpp index aef426a15d..39495f00cb 100644 --- a/include/RAJA/util/Span.hpp +++ b/include/RAJA/util/Span.hpp @@ -20,10 +20,9 @@ #ifndef RAJA_SPAN_HPP #define RAJA_SPAN_HPP -#include "RAJA/index/IndexValue.hpp" #include "RAJA/util/macros.hpp" #include "RAJA/util/types.hpp" -#include "camp/concepts.hpp" +#include "RAJA/pattern/concepts.hpp" namespace RAJA { @@ -190,8 +189,8 @@ struct Span offset_type stripped_begin = RAJA::stripIndexType(begin); offset_type stripped_length = RAJA::stripIndexType(length); auto start = m_begin + stripped_begin; - auto end = start + stripped_length > m_end ? m_end - : start + stripped_length; + auto end = + start + stripped_length > m_end ? m_end : start + stripped_length; return Span(start, end); } From d768d5f6d40ee2fb2ba63ab3c20d775b28a77969 Mon Sep 17 00:00:00 2001 From: john bowen Date: Wed, 12 Aug 2026 16:04:23 -0700 Subject: [PATCH 5/8] reformat forall and launch tests to support IndexValue types in test suite --- include/RAJA/util/CombiningAdapter.hpp | 10 ++- .../test-forall-CombiningAdapter.cpp.in | 2 +- .../tests/test-forall-CombiningAdapter-1D.hpp | 18 ++-- .../tests/test-forall-CombiningAdapter-2D.hpp | 21 +++-- .../tests/test-forall-CombiningAdapter-3D.hpp | 31 ++++--- .../test-forall-indexset-view.cpp.in | 2 +- .../tests/test-forall-IcountIndexSetView.hpp | 24 ++++-- .../tests/test-forall-IndexSetView.hpp | 27 +++--- .../indexset/test-forall-indexset.cpp.in | 2 +- .../tests/test-forall-IcountIndexSet.hpp | 22 +++-- .../indexset/tests/test-forall-IndexSet.hpp | 22 +++-- .../forall/region/test-forall-region.cpp.in | 3 +- .../region/tests/test-forall-region.hpp | 34 +++++--- .../test-forall-resource-indexset.cpp.in | 2 +- .../test-forall-ResourceIcountIndexSet.hpp | 22 +++-- .../tests/test-forall-ResourceIndexSet.hpp | 22 +++-- .../test-forall-segment-view.cpp.in | 2 +- .../tests/test-forall-ListSegmentView.hpp | 64 +++++++++------ .../tests/test-forall-RangeSegment2DView.hpp | 63 ++++++++------ .../tests/test-forall-RangeSegmentView.hpp | 45 ++++++---- .../test-forall-RangeStrideSegmentView.hpp | 82 ++++++++++++------- .../nested_direct/test-launch-nested.cpp.in | 2 +- .../tests/test-launch-nested-Direct.hpp | 23 ++++-- .../test-launch-nested.cpp.in | 2 +- .../test-launch-nested-DirectUnchecked.hpp | 29 ++++--- .../nested_loop/test-launch-nested.cpp.in | 2 +- .../tests/test-launch-nested-Loop.hpp | 23 ++++-- .../test-launch-nested-tile-direct.cpp.in | 2 +- .../tests/test-launch-nested-Tile-Direct.hpp | 22 +++-- ...launch-nested-tile-direct-unchecked.cpp.in | 2 +- ...est-launch-nested-Tile-DirectUnchecked.hpp | 18 ++-- .../test-launch-nested-tile-loop.cpp.in | 2 +- .../tests/test-launch-nested-Tile-Loop.hpp | 22 +++-- ...ch-nested-tile-icount-tcount-direct.cpp.in | 2 +- ...aunch-nested-Tile-iCount-tCount-Direct.hpp | 39 ++++++--- ...tile-icount-tcount-direct-unchecked.cpp.in | 2 +- ...ted-Tile-iCount-tCount-DirectUnchecked.hpp | 29 +++++-- ...unch-nested-tile-icount-tcount-loop.cpp.in | 2 +- ...-launch-nested-Tile-iCount-tCount-Loop.hpp | 43 ++++++---- test/include/RAJA_test-indexset-build.hpp | 40 +++++---- 40 files changed, 537 insertions(+), 289 deletions(-) diff --git a/include/RAJA/util/CombiningAdapter.hpp b/include/RAJA/util/CombiningAdapter.hpp index 948c3988c5..0fa770e214 100644 --- a/include/RAJA/util/CombiningAdapter.hpp +++ b/include/RAJA/util/CombiningAdapter.hpp @@ -239,8 +239,9 @@ RAJA_INLINE auto make_CombiningAdapter( Layout layout(static_cast(distance(begin(segs), end(segs)))...); OffsetLayout offset_layout = OffsetLayout::from_layout_and_offsets( - {{(distance(begin(segs), end(segs)) ? static_cast(*begin(segs)) - : static_cast(0))...}}, + {{(distance(begin(segs), end(segs)) + ? static_cast(stripIndexType(*begin(segs))) + : static_cast(0))...}}, std::move(layout)); return make_CombiningAdapter_from_layout(std::forward(lambda), std::move(offset_layout)); @@ -266,8 +267,9 @@ RAJA_INLINE auto make_PermutedCombiningAdapter( {{static_cast(distance(begin(segs), end(segs)))...}}, RAJA::as_array::get()); OffsetLayout offset_layout = OffsetLayout::from_layout_and_offsets( - {{(distance(begin(segs), end(segs)) ? static_cast(*begin(segs)) - : static_cast(0))...}}, + {{(distance(begin(segs), end(segs)) + ? static_cast(stripIndexType(*begin(segs))) + : static_cast(0))...}}, std::move(layout)); return make_CombiningAdapter_from_layout(std::forward(lambda), diff --git a/test/functional/forall/CombiningAdapter/test-forall-CombiningAdapter.cpp.in b/test/functional/forall/CombiningAdapter/test-forall-CombiningAdapter.cpp.in index 4b9986a91e..742dbdbf5c 100644 --- a/test/functional/forall/CombiningAdapter/test-forall-CombiningAdapter.cpp.in +++ b/test/functional/forall/CombiningAdapter/test-forall-CombiningAdapter.cpp.in @@ -30,7 +30,7 @@ // Cartesian product of types used in parameterized tests // using @BACKEND@ForallCombiningAdapter@DIMENSION@Types = - Test< camp::cartesian_product>::Types; diff --git a/test/functional/forall/CombiningAdapter/tests/test-forall-CombiningAdapter-1D.hpp b/test/functional/forall/CombiningAdapter/tests/test-forall-CombiningAdapter-1D.hpp index 283fafe102..8fda3116f7 100644 --- a/test/functional/forall/CombiningAdapter/tests/test-forall-CombiningAdapter-1D.hpp +++ b/test/functional/forall/CombiningAdapter/tests/test-forall-CombiningAdapter-1D.hpp @@ -35,23 +35,31 @@ void ForallCombiningAdapter1DTestImpl(INDEX_TYPE first, INDEX_TYPE last) &check_array, &test_array); + using layout_type = + RAJA::TypedLayout>; + using view_type = RAJA::View< INDEX_TYPE, layout_type >; + + view_type test_view(test_array, N + INDEX_TYPE(1)); + view_type work_view(working_array, N + INDEX_TYPE(1)); + view_type check_view(check_array, N + INDEX_TYPE(1)); + { std::iota(test_array, test_array + RAJA::stripIndexType(N), first - first); for (INDEX_TYPE i0 = INDEX_TYPE(0); i0 < N0; i0++) { - test_array[i0] = i0; + test_view(i0) = i0; } - test_array[RAJA::stripIndexType(N)] = INDEX_TYPE(0); + test_view(N) = INDEX_TYPE(0); working_res.memset(working_array, 0, sizeof(INDEX_TYPE) * data_len); auto adapter = RAJA::make_CombiningAdapter([=] RAJA_HOST_DEVICE(INDEX_TYPE idx) { if (idx >= first && idx < last) { // in bounds - working_array[RAJA::stripIndexType(idx - first)] += (idx - first); + work_view(idx - first) += (idx - first); } else { // out of bounds - working_array[RAJA::stripIndexType(N)]++; + work_view(N)++; } }, r0); @@ -62,7 +70,7 @@ void ForallCombiningAdapter1DTestImpl(INDEX_TYPE first, INDEX_TYPE last) working_res.memcpy(check_array, working_array, sizeof(INDEX_TYPE) * data_len); for (INDEX_TYPE i = INDEX_TYPE(0); i <= N; i++) { - ASSERT_EQ(test_array[RAJA::stripIndexType(i)], check_array[RAJA::stripIndexType(i)]); + ASSERT_EQ(test_view(i), check_view(i)); } deallocateForallTestData(working_res, diff --git a/test/functional/forall/CombiningAdapter/tests/test-forall-CombiningAdapter-2D.hpp b/test/functional/forall/CombiningAdapter/tests/test-forall-CombiningAdapter-2D.hpp index 955b2b0cf7..e205676a49 100644 --- a/test/functional/forall/CombiningAdapter/tests/test-forall-CombiningAdapter-2D.hpp +++ b/test/functional/forall/CombiningAdapter/tests/test-forall-CombiningAdapter-2D.hpp @@ -38,14 +38,22 @@ void ForallCombiningAdapter2DTestImpl(INDEX_TYPE first0, INDEX_TYPE last0, &check_array, &test_array); + using layout_type = + RAJA::TypedLayout>; + using view_type = RAJA::View< INDEX_TYPE, layout_type >; + + view_type test_view(test_array, N + INDEX_TYPE(1)); + view_type work_view(working_array, N + INDEX_TYPE(1)); + view_type check_view(check_array, N + INDEX_TYPE(1)); + { for (INDEX_TYPE i0 = INDEX_TYPE(0); i0 < N0; i0++) { for (INDEX_TYPE i1 = INDEX_TYPE(0); i1 < N1; i1++) { - test_array[i0 * N1 + i1] = i0 * N1 + i1; + test_view(i0 * N1 + i1) = i0 * N1 + i1; } } - test_array[RAJA::stripIndexType(N)] = INDEX_TYPE(0); + test_view(N) = INDEX_TYPE(0); working_res.memset(working_array, 0, sizeof(INDEX_TYPE) * data_len); @@ -53,12 +61,11 @@ void ForallCombiningAdapter2DTestImpl(INDEX_TYPE first0, INDEX_TYPE last0, if (idx0 >= first0 && idx0 < last0 && idx1 >= first1 && idx1 < last1) { // in bounds - working_array[RAJA::stripIndexType((idx0 - first0) * N1 + - (idx1 - first1))] += (idx0 - first0) * N1 + - (idx1 - first1); + work_view((idx0 - first0) * N1 + (idx1 - first1)) += + (idx0 - first0) * N1 + (idx1 - first1); } else { // out of bounds - working_array[RAJA::stripIndexType(N)]++; + work_view(N)++; } }, r0, r1); @@ -69,7 +76,7 @@ void ForallCombiningAdapter2DTestImpl(INDEX_TYPE first0, INDEX_TYPE last0, working_res.memcpy(check_array, working_array, sizeof(INDEX_TYPE) * data_len); for (INDEX_TYPE i = INDEX_TYPE(0); i <= N; i++) { - ASSERT_EQ(test_array[RAJA::stripIndexType(i)], check_array[RAJA::stripIndexType(i)]); + ASSERT_EQ(test_view(i), check_view(i)); } deallocateForallTestData(working_res, diff --git a/test/functional/forall/CombiningAdapter/tests/test-forall-CombiningAdapter-3D.hpp b/test/functional/forall/CombiningAdapter/tests/test-forall-CombiningAdapter-3D.hpp index 9ded903935..5976054cdb 100644 --- a/test/functional/forall/CombiningAdapter/tests/test-forall-CombiningAdapter-3D.hpp +++ b/test/functional/forall/CombiningAdapter/tests/test-forall-CombiningAdapter-3D.hpp @@ -41,20 +41,25 @@ void ForallCombiningAdapter3DTestImpl(INDEX_TYPE first0, INDEX_TYPE last0, &check_array, &test_array); + using layout_type = + RAJA::TypedLayout>; + using view_type = RAJA::View< INDEX_TYPE, layout_type >; + + view_type test_view(test_array, N + INDEX_TYPE(1)); + view_type work_view(working_array, N + INDEX_TYPE(1)); + view_type check_view(check_array, N + INDEX_TYPE(1)); + { for (INDEX_TYPE i0 = INDEX_TYPE(0); i0 < N0; i0++) { for (INDEX_TYPE i1 = INDEX_TYPE(0); i1 < N1; i1++) { for (INDEX_TYPE i2 = INDEX_TYPE(0); i2 < N2; i2++) { - test_array[i0 * N1*N2 + - i1 * N2 + - i2] = i0 * N1 * N2 + - i1 * N2 + - i2; + test_view(i0 * N1 * N2 + i1 * N2 + i2) = + i0 * N1 * N2 + i1 * N2 + i2; } } } - test_array[RAJA::stripIndexType(N)] = INDEX_TYPE(0); + test_view(N) = INDEX_TYPE(0); working_res.memset(working_array, 0, sizeof(INDEX_TYPE) * data_len); @@ -63,14 +68,14 @@ void ForallCombiningAdapter3DTestImpl(INDEX_TYPE first0, INDEX_TYPE last0, idx1 >= first1 && idx1 < last1 && idx2 >= first2 && idx2 < last2) { // in bounds - working_array[RAJA::stripIndexType((idx0 - first0) * N1 * N2 + - (idx1 - first1) * N2 + - (idx2 - first2))] += (idx0 - first0) * N1 * N2 + - (idx1 - first1) * N2 + - (idx2 - first2); + work_view((idx0 - first0) * N1 * N2 + + (idx1 - first1) * N2 + + (idx2 - first2)) += (idx0 - first0) * N1 * N2 + + (idx1 - first1) * N2 + + (idx2 - first2); } else { // out of bounds - working_array[RAJA::stripIndexType(N)]++; + work_view(N)++; } }, r0, r1, r2); @@ -81,7 +86,7 @@ void ForallCombiningAdapter3DTestImpl(INDEX_TYPE first0, INDEX_TYPE last0, working_res.memcpy(check_array, working_array, sizeof(INDEX_TYPE) * data_len); for (INDEX_TYPE i = INDEX_TYPE(0); i <= N; i++) { - ASSERT_EQ(test_array[RAJA::stripIndexType(i)], check_array[RAJA::stripIndexType(i)]); + ASSERT_EQ(test_view(i), check_view(i)); } deallocateForallTestData(working_res, diff --git a/test/functional/forall/indexset-view/test-forall-indexset-view.cpp.in b/test/functional/forall/indexset-view/test-forall-indexset-view.cpp.in index 1adf50d694..5e971fcb48 100644 --- a/test/functional/forall/indexset-view/test-forall-indexset-view.cpp.in +++ b/test/functional/forall/indexset-view/test-forall-indexset-view.cpp.in @@ -32,7 +32,7 @@ // Cartesian product of types used in parameterized tests // using @BACKEND@ForallIndexSetViewTypes = - Test< camp::cartesian_product>::Types; diff --git a/test/functional/forall/indexset-view/tests/test-forall-IcountIndexSetView.hpp b/test/functional/forall/indexset-view/tests/test-forall-IcountIndexSetView.hpp index 6362b2b58f..833d5b013b 100644 --- a/test/functional/forall/indexset-view/tests/test-forall-IcountIndexSetView.hpp +++ b/test/functional/forall/indexset-view/tests/test-forall-IcountIndexSetView.hpp @@ -53,29 +53,35 @@ void ForallIcountIndexSetViewTestImpl() &check_array, &test_array); - memset( test_array, 0, sizeof(INDEX_TYPE) * N ); + memset( test_array, 0, sizeof(INDEX_TYPE) * RAJA::stripIndexType(N) ); - working_res.memcpy(working_array, test_array, sizeof(INDEX_TYPE) * N); + working_res.memcpy(working_array, test_array, + sizeof(INDEX_TYPE) * RAJA::stripIndexType(N)); + + using layout_type = + RAJA::TypedLayout>; + using view_type = RAJA::View< INDEX_TYPE, layout_type >; + + view_type test_view(test_array, N); + view_type work_view(working_array, N); + view_type check_view(check_array, N); INDEX_TYPE ticount = 0; for (size_t i = 0; i < is_indices.size(); ++i) { - test_array[ ticount++ ] = is_indices[i]; + test_view(ticount++) = is_indices[i]; } - RAJA::Layout<1> layout(N); - RAJA::View< INDEX_TYPE, RAJA::Layout<1, INDEX_TYPE, 0> > - work_view(working_array, layout); - RAJA::forall_Icount(iset, [=] RAJA_HOST_DEVICE(INDEX_TYPE icount, INDEX_TYPE idx) { work_view( icount ) = idx; }); - working_res.memcpy(check_array, working_array, sizeof(INDEX_TYPE) * N); + working_res.memcpy(check_array, working_array, + sizeof(INDEX_TYPE) * RAJA::stripIndexType(N)); // for (INDEX_TYPE i = 0; i < N; i++) { - ASSERT_EQ(test_array[i], check_array[i]); + ASSERT_EQ(test_view(i), check_view(i)); } deallocateForallTestData(working_res, diff --git a/test/functional/forall/indexset-view/tests/test-forall-IndexSetView.hpp b/test/functional/forall/indexset-view/tests/test-forall-IndexSetView.hpp index fd282e2525..8191e80df0 100644 --- a/test/functional/forall/indexset-view/tests/test-forall-IndexSetView.hpp +++ b/test/functional/forall/indexset-view/tests/test-forall-IndexSetView.hpp @@ -52,28 +52,33 @@ void ForallIndexSetViewTestImpl() &check_array, &test_array); - memset( test_array, 0, sizeof(INDEX_TYPE) * N ); + memset( test_array, 0, sizeof(INDEX_TYPE) * RAJA::stripIndexType(N) ); - working_res.memcpy(working_array, test_array, sizeof(INDEX_TYPE) * N); + working_res.memcpy(working_array, test_array, + sizeof(INDEX_TYPE) * RAJA::stripIndexType(N)); - for (size_t i = 0; i < is_indices.size(); ++i) { - test_array[ is_indices[i] ] = is_indices[i]; - } + using layout_type = + RAJA::TypedLayout>; + using view_type = RAJA::View< INDEX_TYPE, layout_type >; - using view_type = RAJA::View< INDEX_TYPE, RAJA::Layout<1, INDEX_TYPE, 0> >; + view_type test_view(test_array, N); + view_type work_view(working_array, N); + view_type check_view(check_array, N); - RAJA::Layout<1> layout(N); - view_type work_view(working_array, layout); + for (size_t i = 0; i < is_indices.size(); ++i) { + test_view(is_indices[i]) = is_indices[i]; + } RAJA::forall(iset, [=] RAJA_HOST_DEVICE(INDEX_TYPE idx) { - working_array[idx] = idx; + work_view(idx) = idx; }); - working_res.memcpy(check_array, working_array, sizeof(INDEX_TYPE) * N); + working_res.memcpy(check_array, working_array, + sizeof(INDEX_TYPE) * RAJA::stripIndexType(N)); // for (INDEX_TYPE i = 0; i < N; i++) { - ASSERT_EQ(test_array[i], check_array[i]); + ASSERT_EQ(test_view(i), check_view(i)); } deallocateForallTestData(working_res, diff --git a/test/functional/forall/indexset/test-forall-indexset.cpp.in b/test/functional/forall/indexset/test-forall-indexset.cpp.in index 7589001204..166386baf5 100644 --- a/test/functional/forall/indexset/test-forall-indexset.cpp.in +++ b/test/functional/forall/indexset/test-forall-indexset.cpp.in @@ -32,7 +32,7 @@ // Cartesian product of types used in parameterized tests // using @BACKEND@ForallIndexSetTypes = - Test< camp::cartesian_product>::Types; diff --git a/test/functional/forall/indexset/tests/test-forall-IcountIndexSet.hpp b/test/functional/forall/indexset/tests/test-forall-IcountIndexSet.hpp index cb1995b729..6c75e71597 100644 --- a/test/functional/forall/indexset/tests/test-forall-IcountIndexSet.hpp +++ b/test/functional/forall/indexset/tests/test-forall-IcountIndexSet.hpp @@ -51,24 +51,34 @@ void ForallIcountIndexSetTestImpl() &check_array, &test_array); - memset( test_array, 0, sizeof(INDEX_TYPE) * N ); + memset( test_array, 0, sizeof(INDEX_TYPE) * RAJA::stripIndexType(N) ); - working_res.memcpy(working_array, test_array, sizeof(INDEX_TYPE) * N); + working_res.memcpy(working_array, test_array, + sizeof(INDEX_TYPE) * RAJA::stripIndexType(N)); + + using layout_type = + RAJA::TypedLayout>; + using view_type = RAJA::View< INDEX_TYPE, layout_type >; + + view_type test_view(test_array, N); + view_type work_view(working_array, N); + view_type check_view(check_array, N); INDEX_TYPE ticount = 0; for (size_t i = 0; i < is_indices.size(); ++i) { - test_array[ ticount++ ] = is_indices[i]; + test_view(ticount++) = is_indices[i]; } RAJA::forall_Icount(EXEC_POLICY(), iset, [=] RAJA_HOST_DEVICE(INDEX_TYPE icount, INDEX_TYPE idx) { - working_array[icount] = idx; + work_view(icount) = idx; }); - working_res.memcpy(check_array, working_array, sizeof(INDEX_TYPE) * N); + working_res.memcpy(check_array, working_array, + sizeof(INDEX_TYPE) * RAJA::stripIndexType(N)); for (INDEX_TYPE i = 0; i < N; i++) { - ASSERT_EQ(test_array[i], check_array[i]); + ASSERT_EQ(test_view(i), check_view(i)); } deallocateForallTestData(working_res, diff --git a/test/functional/forall/indexset/tests/test-forall-IndexSet.hpp b/test/functional/forall/indexset/tests/test-forall-IndexSet.hpp index bb4e0051b5..3bd9c3fb6d 100644 --- a/test/functional/forall/indexset/tests/test-forall-IndexSet.hpp +++ b/test/functional/forall/indexset/tests/test-forall-IndexSet.hpp @@ -50,23 +50,33 @@ void ForallIndexSetTestImpl() &check_array, &test_array); - memset( test_array, 0, sizeof(INDEX_TYPE) * N ); + memset( test_array, 0, sizeof(INDEX_TYPE) * RAJA::stripIndexType(N) ); - working_res.memcpy(working_array, test_array, sizeof(INDEX_TYPE) * N); + working_res.memcpy(working_array, test_array, + sizeof(INDEX_TYPE) * RAJA::stripIndexType(N)); + + using layout_type = + RAJA::TypedLayout>; + using view_type = RAJA::View< INDEX_TYPE, layout_type >; + + view_type test_view(test_array, N); + view_type work_view(working_array, N); + view_type check_view(check_array, N); for (size_t i = 0; i < is_indices.size(); ++i) { - test_array[ is_indices[i] ] = is_indices[i]; + test_view(is_indices[i]) = is_indices[i]; } RAJA::forall(EXEC_POLICY(), iset, [=] RAJA_HOST_DEVICE(INDEX_TYPE idx) { - working_array[idx] = idx; + work_view(idx) = idx; }); - working_res.memcpy(check_array, working_array, sizeof(INDEX_TYPE) * N); + working_res.memcpy(check_array, working_array, + sizeof(INDEX_TYPE) * RAJA::stripIndexType(N)); // for (INDEX_TYPE i = 0; i < N; i++) { - ASSERT_EQ(test_array[i], check_array[i]); + ASSERT_EQ(test_view(i), check_view(i)); } deallocateForallTestData(working_res, diff --git a/test/functional/forall/region/test-forall-region.cpp.in b/test/functional/forall/region/test-forall-region.cpp.in index b5d37562bb..ea1490128e 100644 --- a/test/functional/forall/region/test-forall-region.cpp.in +++ b/test/functional/forall/region/test-forall-region.cpp.in @@ -47,7 +47,7 @@ using OpenMPForallRegionExecPols = // Cartesian product of types used in parameterized tests // using @REGION_BACKEND@ForallRegionTypes = - Test< camp::cartesian_product>::Types; @@ -59,4 +59,3 @@ INSTANTIATE_TYPED_TEST_SUITE_P(@REGION_BACKEND@, ForallRegionTest, @REGION_BACKEND@ForallRegionTypes); - diff --git a/test/functional/forall/region/tests/test-forall-region.hpp b/test/functional/forall/region/tests/test-forall-region.hpp index 2da77ed082..493aca0607 100644 --- a/test/functional/forall/region/tests/test-forall-region.hpp +++ b/test/functional/forall/region/tests/test-forall-region.hpp @@ -26,10 +26,10 @@ void ForallRegionTestImpl(INDEX_TYPE first, INDEX_TYPE last) RAJA::TypedRangeSegment rseg(first, last); - std::vector idx_array(N); - std::iota(&idx_array[0], &idx_array[0] + N, first); + std::vector idx_array(RAJA::stripIndexType(N)); + std::iota(&idx_array[0], &idx_array[0] + RAJA::stripIndexType(N), first); - RAJA::TypedListSegment lseg(&idx_array[0], N, + RAJA::TypedListSegment lseg(&idx_array[0], RAJA::stripIndexType(N), working_res); INDEX_TYPE* working_array; @@ -42,25 +42,34 @@ void ForallRegionTestImpl(INDEX_TYPE first, INDEX_TYPE last) &check_array, &test_array); - working_res.memset( working_array, 0, sizeof(INDEX_TYPE) * N ); + working_res.memset(working_array, 0, + sizeof(INDEX_TYPE) * RAJA::stripIndexType(N)); + + using layout_type = + RAJA::TypedLayout>; + using view_type = RAJA::View< INDEX_TYPE, layout_type >; + + view_type work_view(working_array, N); + view_type check_view(check_array, N); RAJA::region([=]() { RAJA::forall(rseg, [=] RAJA_HOST_DEVICE(INDEX_TYPE idx) { - working_array[idx - first] += 1; + work_view(idx - first) += 1; }); RAJA::forall(lseg, [=] RAJA_HOST_DEVICE(INDEX_TYPE idx) { - working_array[idx - first] += 2; + work_view(idx - first) += 2; }); }); - working_res.memcpy(check_array, working_array, sizeof(INDEX_TYPE) * N); + working_res.memcpy(check_array, working_array, + sizeof(INDEX_TYPE) * RAJA::stripIndexType(N)); for (INDEX_TYPE i = 0; i < N; i++) { - ASSERT_EQ(check_array[i], 3); + ASSERT_EQ(check_view(i), 3); } deallocateForallTestData(working_res, @@ -83,9 +92,12 @@ TYPED_TEST_P(ForallRegionTest, RegionForall) using REG_POLICY = typename camp::at>::type; using EXEC_POLICY = typename camp::at>::type; - ForallRegionTestImpl(0, 25); - ForallRegionTestImpl(1, 153); - ForallRegionTestImpl(3, 2556); + ForallRegionTestImpl( + INDEX_TYPE(0), INDEX_TYPE(25)); + ForallRegionTestImpl( + INDEX_TYPE(1), INDEX_TYPE(153)); + ForallRegionTestImpl( + INDEX_TYPE(3), INDEX_TYPE(2556)); } REGISTER_TYPED_TEST_SUITE_P(ForallRegionTest, diff --git a/test/functional/forall/resource-indexset/test-forall-resource-indexset.cpp.in b/test/functional/forall/resource-indexset/test-forall-resource-indexset.cpp.in index 7445ebff39..a059bcec65 100644 --- a/test/functional/forall/resource-indexset/test-forall-resource-indexset.cpp.in +++ b/test/functional/forall/resource-indexset/test-forall-resource-indexset.cpp.in @@ -32,7 +32,7 @@ // Cartesian product of types used in parameterized tests // using @BACKEND@ForallResourceIndexSetTypes = - Test< camp::cartesian_product>::Types; diff --git a/test/functional/forall/resource-indexset/tests/test-forall-ResourceIcountIndexSet.hpp b/test/functional/forall/resource-indexset/tests/test-forall-ResourceIcountIndexSet.hpp index ea3cd6bed8..9ab2901c94 100644 --- a/test/functional/forall/resource-indexset/tests/test-forall-ResourceIcountIndexSet.hpp +++ b/test/functional/forall/resource-indexset/tests/test-forall-ResourceIcountIndexSet.hpp @@ -52,24 +52,34 @@ void ForallResourceIcountIndexSetTestImpl() &check_array, &test_array); - memset( test_array, 0, sizeof(INDEX_TYPE) * N ); + memset( test_array, 0, sizeof(INDEX_TYPE) * RAJA::stripIndexType(N) ); - working_res.memcpy(working_array, test_array, sizeof(INDEX_TYPE) * N); + working_res.memcpy(working_array, test_array, + sizeof(INDEX_TYPE) * RAJA::stripIndexType(N)); + + using layout_type = + RAJA::TypedLayout>; + using view_type = RAJA::View< INDEX_TYPE, layout_type >; + + view_type test_view(test_array, N); + view_type work_view(working_array, N); + view_type check_view(check_array, N); INDEX_TYPE ticount = 0; for (size_t i = 0; i < is_indices.size(); ++i) { - test_array[ ticount++ ] = is_indices[i]; + test_view(ticount++) = is_indices[i]; } RAJA::forall_Icount(working_res, iset, [=] RAJA_HOST_DEVICE(INDEX_TYPE icount, INDEX_TYPE idx) { - working_array[icount] = idx; + work_view(icount) = idx; }); - working_res.memcpy(check_array, working_array, sizeof(INDEX_TYPE) * N); + working_res.memcpy(check_array, working_array, + sizeof(INDEX_TYPE) * RAJA::stripIndexType(N)); for (INDEX_TYPE i = 0; i < N; i++) { - ASSERT_EQ(test_array[i], check_array[i]); + ASSERT_EQ(test_view(i), check_view(i)); } deallocateForallTestData(erased_working_res, diff --git a/test/functional/forall/resource-indexset/tests/test-forall-ResourceIndexSet.hpp b/test/functional/forall/resource-indexset/tests/test-forall-ResourceIndexSet.hpp index 04ddee1dd3..19d46991b8 100644 --- a/test/functional/forall/resource-indexset/tests/test-forall-ResourceIndexSet.hpp +++ b/test/functional/forall/resource-indexset/tests/test-forall-ResourceIndexSet.hpp @@ -51,23 +51,33 @@ void ForallResourceIndexSetTestImpl() &check_array, &test_array); - memset( test_array, 0, sizeof(INDEX_TYPE) * N ); + memset( test_array, 0, sizeof(INDEX_TYPE) * RAJA::stripIndexType(N) ); - working_res.memcpy(working_array, test_array, sizeof(INDEX_TYPE) * N); + working_res.memcpy(working_array, test_array, + sizeof(INDEX_TYPE) * RAJA::stripIndexType(N)); + + using layout_type = + RAJA::TypedLayout>; + using view_type = RAJA::View< INDEX_TYPE, layout_type >; + + view_type test_view(test_array, N); + view_type work_view(working_array, N); + view_type check_view(check_array, N); for (size_t i = 0; i < is_indices.size(); ++i) { - test_array[ is_indices[i] ] = is_indices[i]; + test_view(is_indices[i]) = is_indices[i]; } RAJA::forall(working_res, iset, [=] RAJA_HOST_DEVICE(INDEX_TYPE idx) { - working_array[idx] = idx; + work_view(idx) = idx; }); - working_res.memcpy(check_array, working_array, sizeof(INDEX_TYPE) * N); + working_res.memcpy(check_array, working_array, + sizeof(INDEX_TYPE) * RAJA::stripIndexType(N)); // for (INDEX_TYPE i = 0; i < N; i++) { - ASSERT_EQ(test_array[i], check_array[i]); + ASSERT_EQ(test_view(i), check_view(i)); } deallocateForallTestData(erased_working_res, diff --git a/test/functional/forall/segment-view/test-forall-segment-view.cpp.in b/test/functional/forall/segment-view/test-forall-segment-view.cpp.in index 49f34113b5..07577b7361 100644 --- a/test/functional/forall/segment-view/test-forall-segment-view.cpp.in +++ b/test/functional/forall/segment-view/test-forall-segment-view.cpp.in @@ -30,7 +30,7 @@ // Cartesian product of types used in parameterized tests // using @BACKEND@ForallSegmentViewTypes = - Test< camp::cartesian_product>::Types; diff --git a/test/functional/forall/segment-view/tests/test-forall-ListSegmentView.hpp b/test/functional/forall/segment-view/tests/test-forall-ListSegmentView.hpp index 8eb64dc67c..90c4d43474 100644 --- a/test/functional/forall/segment-view/tests/test-forall-ListSegmentView.hpp +++ b/test/functional/forall/segment-view/tests/test-forall-ListSegmentView.hpp @@ -28,7 +28,7 @@ void ForallListSegmentViewTestImpl(INDEX_TYPE N) srand ( time(NULL) ); for (INDEX_TYPE i = 0; i < N; ++i) { - INDEX_TYPE randval = rand() % N; + INDEX_TYPE randval = INDEX_TYPE(rand() % RAJA::stripIndexType(N)); if ( i < randval ) { idx_array.push_back(i); } @@ -51,15 +51,13 @@ void ForallListSegmentViewTestImpl(INDEX_TYPE N) &check_array, &test_array); - memset( test_array, 0, sizeof(INDEX_TYPE) * N ); + memset( test_array, 0, sizeof(INDEX_TYPE) * RAJA::stripIndexType(N) ); - working_res.memcpy(working_array, test_array, sizeof(INDEX_TYPE) * N); + working_res.memcpy(working_array, test_array, + sizeof(INDEX_TYPE) * RAJA::stripIndexType(N)); - for (size_t i = 0; i < idxlen; ++i) { - test_array[ idx_array[i] ] = idx_array[i]; - } - - using layout_type = RAJA::Layout<1, INDEX_TYPE, 0>; + using layout_type = + RAJA::TypedLayout>; using view_type = RAJA::View< INDEX_TYPE, layout_type >; #if (!(defined(_GLIBCXX_RELEASE) || defined(RAJA_COMPILER_INTEL) || defined(RAJA_COMPILER_MSVC)))\ || _GLIBCXX_RELEASE >= 20150716 @@ -80,17 +78,23 @@ void ForallListSegmentViewTestImpl(INDEX_TYPE N) #endif - RAJA::Layout<1> layout(N); - view_type work_view(working_array, layout); + view_type test_view(test_array, N); + view_type work_view(working_array, N); + view_type check_view(check_array, N); + + for (size_t i = 0; i < idxlen; ++i) { + test_view(idx_array[i]) = idx_array[i]; + } RAJA::forall(lseg, [=] RAJA_HOST_DEVICE(INDEX_TYPE idx) { work_view( idx ) = idx; }); - working_res.memcpy(check_array, working_array, sizeof(INDEX_TYPE) * N); + working_res.memcpy(check_array, working_array, + sizeof(INDEX_TYPE) * RAJA::stripIndexType(N)); for (INDEX_TYPE i = 0; i < N; i++) { - ASSERT_EQ(test_array[i], check_array[i]); + ASSERT_EQ(test_view(i), check_view(i)); } deallocateForallTestData(working_res, @@ -109,7 +113,7 @@ void ForallListSegmentOffsetViewTestImpl(INDEX_TYPE N, INDEX_TYPE offset) srand ( time(NULL) ); for (INDEX_TYPE i = 0; i < N; ++i) { - INDEX_TYPE randval = rand() % N; + INDEX_TYPE randval = INDEX_TYPE(rand() % RAJA::stripIndexType(N)); if ( i < randval ) { idx_array.push_back(i+offset); } @@ -132,30 +136,36 @@ void ForallListSegmentOffsetViewTestImpl(INDEX_TYPE N, INDEX_TYPE offset) &check_array, &test_array); - memset( test_array, 0, sizeof(INDEX_TYPE) * N ); + memset( test_array, 0, sizeof(INDEX_TYPE) * RAJA::stripIndexType(N) ); - working_res.memcpy(working_array, test_array, sizeof(INDEX_TYPE) * N); + working_res.memcpy(working_array, test_array, + sizeof(INDEX_TYPE) * RAJA::stripIndexType(N)); - for (size_t i = 0; i < idxlen; ++i) { - test_array[ idx_array[i]-offset ] = idx_array[i]; - } - - using layout_type = RAJA::OffsetLayout<1, INDEX_TYPE>; + using layout_type = + RAJA::TypedOffsetLayout>; using view_type = RAJA::View< INDEX_TYPE, layout_type >; - INDEX_TYPE N_offset = N + offset; - view_type work_view(working_array, - RAJA::make_offset_layout<1, INDEX_TYPE>( {{offset}}, - {{N_offset}} )); + using raw_index_type = RAJA::strip_index_type_t; + raw_index_type offset_raw = RAJA::stripIndexType(offset); + raw_index_type N_offset = RAJA::stripIndexType(N + offset); + layout_type layout({{offset_raw}}, {{N_offset}}); + view_type test_view(test_array, layout); + view_type work_view(working_array, layout); + view_type check_view(check_array, layout); + + for (size_t i = 0; i < idxlen; ++i) { + test_view(idx_array[i]) = idx_array[i]; + } RAJA::forall(lseg, [=] RAJA_HOST_DEVICE(INDEX_TYPE idx) { work_view( idx ) = idx; }); - working_res.memcpy(check_array, working_array, sizeof(INDEX_TYPE) * N); + working_res.memcpy(check_array, working_array, + sizeof(INDEX_TYPE) * RAJA::stripIndexType(N)); - for (INDEX_TYPE i = 0; i < N; i++) { - ASSERT_EQ(test_array[i], check_array[i]); + for (INDEX_TYPE i = offset; i < N + offset; i++) { + ASSERT_EQ(test_view(i), check_view(i)); } deallocateForallTestData(working_res, diff --git a/test/functional/forall/segment-view/tests/test-forall-RangeSegment2DView.hpp b/test/functional/forall/segment-view/tests/test-forall-RangeSegment2DView.hpp index d7a1a412d0..be7f04e986 100644 --- a/test/functional/forall/segment-view/tests/test-forall-RangeSegment2DView.hpp +++ b/test/functional/forall/segment-view/tests/test-forall-RangeSegment2DView.hpp @@ -17,7 +17,6 @@ template void ForallRangeSegment2DViewTestImpl(INDEX_TYPE N) { INDEX_TYPE lentot = N * N; - const int NDIMS = 2; RAJA::TypedRangeSegment r1(0, lentot); @@ -32,12 +31,15 @@ void ForallRangeSegment2DViewTestImpl(INDEX_TYPE N) &check_array, &test_array); - std::iota(test_array, test_array + lentot, 0); + std::iota(test_array, test_array + RAJA::stripIndexType(lentot), 0); - using view_type = RAJA::View< INDEX_TYPE, RAJA::Layout >; - RAJA::Layout layout(N, N); + using layout_type = + RAJA::TypedLayout>; + using view_type = RAJA::View< INDEX_TYPE, layout_type >; - view_type work_view(working_array, layout); + view_type test_view(test_array, N, N); + view_type work_view(working_array, N, N); + view_type check_view(check_array, N, N); RAJA::forall(r1, [=] RAJA_HOST_DEVICE(INDEX_TYPE idx) { const INDEX_TYPE row = idx / N; @@ -45,10 +47,13 @@ void ForallRangeSegment2DViewTestImpl(INDEX_TYPE N) work_view(row, col) = row * N + col; }); - working_res.memcpy(check_array, working_array, sizeof(INDEX_TYPE) * lentot); + working_res.memcpy(check_array, working_array, + sizeof(INDEX_TYPE) * RAJA::stripIndexType(lentot)); for (INDEX_TYPE i = 0; i < lentot; i++) { - ASSERT_EQ(test_array[i], check_array[i]); + const INDEX_TYPE row = i / N; + const INDEX_TYPE col = i % N; + ASSERT_EQ(test_view(row, col), check_view(row, col)); } deallocateForallTestData(working_res, @@ -62,7 +67,6 @@ void ForallRangeSegment2DOffsetViewTestImpl(INDEX_TYPE N) { const INDEX_TYPE leninterior = N * N; const INDEX_TYPE lentot = (N + 2) * (N + 2); - const int NDIMS = 2; RAJA::TypedRangeSegment r1(0, leninterior); @@ -77,22 +81,28 @@ void ForallRangeSegment2DOffsetViewTestImpl(INDEX_TYPE N) &check_array, &test_array); - memset( test_array, 0, sizeof(INDEX_TYPE) * lentot ); + memset( test_array, 0, sizeof(INDEX_TYPE) * RAJA::stripIndexType(lentot) ); - working_res.memcpy(working_array, test_array, sizeof(INDEX_TYPE) * lentot); + working_res.memcpy(working_array, test_array, + sizeof(INDEX_TYPE) * RAJA::stripIndexType(lentot)); - for (int row = 1; row < N + 1; ++row) { - for (int col = 1; col < N + 1; ++col) { - int idx = row * (N+2) + col; - test_array[ idx ] = (row - 1) * N + (col - 1); - } - } - - using view_type = RAJA::View< INDEX_TYPE, RAJA::OffsetLayout >; - RAJA::OffsetLayout layout = - RAJA::make_offset_layout( {{-1, -1}} , {{N+1, N+1}} ); + using layout_type = + RAJA::TypedOffsetLayout>; + using view_type = RAJA::View< INDEX_TYPE, layout_type >; + using raw_index_type = RAJA::strip_index_type_t; + raw_index_type first = -1; + raw_index_type last = RAJA::stripIndexType(N + 1); + layout_type layout({{first, first}}, {{last, last}}); + view_type test_view(test_array, layout); view_type work_view(working_array, layout); + view_type check_view(check_array, layout); + + for (INDEX_TYPE row = 0; row < N; ++row) { + for (INDEX_TYPE col = 0; col < N; ++col) { + test_view(row, col) = row * N + col; + } + } RAJA::forall(r1, [=] RAJA_HOST_DEVICE(INDEX_TYPE idx) { const INDEX_TYPE row = idx / N; @@ -100,10 +110,13 @@ void ForallRangeSegment2DOffsetViewTestImpl(INDEX_TYPE N) work_view(row, col) = idx; }); - working_res.memcpy(check_array, working_array, sizeof(INDEX_TYPE) * lentot); + working_res.memcpy(check_array, working_array, + sizeof(INDEX_TYPE) * RAJA::stripIndexType(lentot)); - for (INDEX_TYPE i = 0; i < lentot; i++) { - ASSERT_EQ(test_array[i], check_array[i]); + for (INDEX_TYPE row = INDEX_TYPE(-1); row < N + 1; ++row) { + for (INDEX_TYPE col = INDEX_TYPE(-1); col < N + 1; ++col) { + ASSERT_EQ(test_view(row, col), check_view(row, col)); + } } deallocateForallTestData(working_res, @@ -119,13 +132,13 @@ class ForallRangeSegment2DViewTest : public ::testing::Test }; template ::value>::type* = nullptr> + typename std::enable_if>::value>::type* = nullptr> void runOffsetViewTests() { } template ::value>::type* = nullptr> + typename std::enable_if>::value>::type* = nullptr> void runOffsetViewTests() { ForallRangeSegment2DOffsetViewTestImpl(4); diff --git a/test/functional/forall/segment-view/tests/test-forall-RangeSegmentView.hpp b/test/functional/forall/segment-view/tests/test-forall-RangeSegmentView.hpp index 6757af3d1d..c08083e478 100644 --- a/test/functional/forall/segment-view/tests/test-forall-RangeSegmentView.hpp +++ b/test/functional/forall/segment-view/tests/test-forall-RangeSegmentView.hpp @@ -31,21 +31,25 @@ void ForallRangeSegmentViewTestImpl(INDEX_TYPE first, INDEX_TYPE last) const INDEX_TYPE rbegin = *r1.begin(); - std::iota(test_array, test_array + N, rbegin); + std::iota(test_array, test_array + RAJA::stripIndexType(N), rbegin); - using view_type = RAJA::View< INDEX_TYPE, RAJA::Layout<1, INDEX_TYPE, 0> >; + using layout_type = + RAJA::TypedLayout>; + using view_type = RAJA::View< INDEX_TYPE, layout_type >; - RAJA::Layout<1> layout(N); - view_type work_view(working_array, layout); + view_type test_view(test_array, N); + view_type work_view(working_array, N); + view_type check_view(check_array, N); RAJA::forall(r1, [=] RAJA_HOST_DEVICE(INDEX_TYPE idx) { work_view( idx - rbegin ) = idx; }); - working_res.memcpy(check_array, working_array, sizeof(INDEX_TYPE) * N); + working_res.memcpy(check_array, working_array, + sizeof(INDEX_TYPE) * RAJA::stripIndexType(N)); for (INDEX_TYPE i = 0; i < N; i++) { - ASSERT_EQ(test_array[i], check_array[i]); + ASSERT_EQ(test_view(i), check_view(i)); } deallocateForallTestData(working_res, @@ -74,24 +78,29 @@ void ForallRangeSegmentOffsetViewTestImpl(INDEX_TYPE first, INDEX_TYPE last, const INDEX_TYPE rbegin = *r1.begin(); - std::iota(test_array, test_array + N, rbegin); + std::iota(test_array, test_array + RAJA::stripIndexType(N), rbegin); - using view_type = RAJA::View< INDEX_TYPE, RAJA::OffsetLayout<1, INDEX_TYPE> >; + using layout_type = + RAJA::TypedOffsetLayout>; + using view_type = RAJA::View< INDEX_TYPE, layout_type >; - INDEX_TYPE f_offset = first + offset; - INDEX_TYPE l_offset = last + offset; - view_type work_view(working_array, - RAJA::make_offset_layout<1, INDEX_TYPE>({{f_offset}}, - {{l_offset}})); + using raw_index_type = RAJA::strip_index_type_t; + raw_index_type f_offset = RAJA::stripIndexType(first + offset); + raw_index_type l_offset = RAJA::stripIndexType(last + offset); + layout_type layout({{f_offset}}, {{l_offset}}); + view_type test_view(test_array, layout); + view_type work_view(working_array, layout); + view_type check_view(check_array, layout); RAJA::forall(r1, [=] RAJA_HOST_DEVICE(INDEX_TYPE idx) { work_view( idx ) = idx; }); - working_res.memcpy(check_array, working_array, sizeof(INDEX_TYPE) * N); + working_res.memcpy(check_array, working_array, + sizeof(INDEX_TYPE) * RAJA::stripIndexType(N)); - for (INDEX_TYPE i = 0; i < N; i++) { - ASSERT_EQ(test_array[i], check_array[i]); + for (INDEX_TYPE i = first + offset; i < last + offset; i++) { + ASSERT_EQ(test_view(i), check_view(i)); } deallocateForallTestData(working_res, @@ -101,13 +110,13 @@ void ForallRangeSegmentOffsetViewTestImpl(INDEX_TYPE first, INDEX_TYPE last, } template ::value>::type* = nullptr> + typename std::enable_if>::value>::type* = nullptr> void runNegativeViewTests() { } template ::value>::type* = nullptr> + typename std::enable_if>::value>::type* = nullptr> void runNegativeViewTests() { ForallRangeSegmentViewTestImpl(-5, 0); diff --git a/test/functional/forall/segment-view/tests/test-forall-RangeStrideSegmentView.hpp b/test/functional/forall/segment-view/tests/test-forall-RangeStrideSegmentView.hpp index 22a957bb5d..7b7a15afaa 100644 --- a/test/functional/forall/segment-view/tests/test-forall-RangeStrideSegmentView.hpp +++ b/test/functional/forall/segment-view/tests/test-forall-RangeStrideSegmentView.hpp @@ -15,7 +15,9 @@ template r1(first, last, stride); + RAJA::TypedRangeStrideSegment r1(RAJA::stripIndexType(first), + RAJA::stripIndexType(last), + stride); INDEX_TYPE N = r1.size(); camp::resources::Resource working_res{WORKING_RES::get_default()}; @@ -29,29 +31,34 @@ void ForallRangeStrideSegmentViewTestImpl(INDEX_TYPE first, INDEX_TYPE last, &check_array, &test_array); - memset( test_array, 0, sizeof(INDEX_TYPE) * N ); + memset( test_array, 0, sizeof(INDEX_TYPE) * RAJA::stripIndexType(N) ); - working_res.memcpy(working_array, test_array, sizeof(INDEX_TYPE) * N); + working_res.memcpy(working_array, test_array, + sizeof(INDEX_TYPE) * RAJA::stripIndexType(N)); INDEX_TYPE index = first; + using layout_type = + RAJA::TypedLayout>; + using view_type = RAJA::View< INDEX_TYPE, layout_type >; + + view_type test_view(test_array, N); + view_type work_view(working_array, N); + view_type check_view(check_array, N); + for (INDEX_TYPE i = 0; i < N; ++i) { - test_array[ (index-first)/stride ] = index; + test_view( (index-first)/stride ) = index; index += stride; } - using view_type = RAJA::View< INDEX_TYPE, RAJA::Layout<1, INDEX_TYPE, 0> >; - - RAJA::Layout<1> layout(N); - view_type work_view(working_array, layout); - RAJA::forall(r1, [=] RAJA_HOST_DEVICE(INDEX_TYPE idx) { work_view( (idx-first)/stride ) = idx; }); - working_res.memcpy(check_array, working_array, sizeof(INDEX_TYPE) * N); + working_res.memcpy(check_array, working_array, + sizeof(INDEX_TYPE) * RAJA::stripIndexType(N)); for (INDEX_TYPE i = 0; i < N; i++) { - ASSERT_EQ(test_array[i], check_array[i]); + ASSERT_EQ(test_view(i), check_view(i)); } deallocateForallTestData(working_res, @@ -61,21 +68,26 @@ void ForallRangeStrideSegmentViewTestImpl(INDEX_TYPE first, INDEX_TYPE last, } template ::value>::type* = nullptr> + typename std::enable_if>::value>::type* = nullptr> void runNegativeIndexViewTests() { } template ::value>::type* = nullptr> + typename std::enable_if>::value>::type* = nullptr> void runNegativeIndexViewTests() { - ForallRangeStrideSegmentViewTestImpl(-10, -1, 2); - ForallRangeStrideSegmentViewTestImpl(-5, 0, 2); - ForallRangeStrideSegmentViewTestImpl(-5, 5, 3); - - ForallRangeStrideSegmentViewTestImpl(10, -1, -1); - ForallRangeStrideSegmentViewTestImpl(10, 0, -2); + ForallRangeStrideSegmentViewTestImpl( + INDEX_TYPE(-10), INDEX_TYPE(-1), DIFF_TYPE(2)); + ForallRangeStrideSegmentViewTestImpl( + INDEX_TYPE(-5), INDEX_TYPE(0), DIFF_TYPE(2)); + ForallRangeStrideSegmentViewTestImpl( + INDEX_TYPE(-5), INDEX_TYPE(5), DIFF_TYPE(3)); + + ForallRangeStrideSegmentViewTestImpl( + INDEX_TYPE(10), INDEX_TYPE(-1), DIFF_TYPE(-1)); + ForallRangeStrideSegmentViewTestImpl( + INDEX_TYPE(10), INDEX_TYPE(0), DIFF_TYPE(-2)); } @@ -90,19 +102,29 @@ TYPED_TEST_P(ForallRangeStrideSegmentViewTest, RangeStrideSegmentForallView) using INDEX_TYPE = typename camp::at>::type; using WORKING_RES = typename camp::at>::type; using EXEC_POLICY = typename camp::at>::type; - using DIFF_TYPE = typename std::make_signed::type; - - ForallRangeStrideSegmentViewTestImpl(0, 20, 1); - ForallRangeStrideSegmentViewTestImpl(1, 20, 1); - ForallRangeStrideSegmentViewTestImpl(0, 20, 2); - ForallRangeStrideSegmentViewTestImpl(1, 20, 2); - ForallRangeStrideSegmentViewTestImpl(0, 21, 2); - ForallRangeStrideSegmentViewTestImpl(1, 21, 2); - ForallRangeStrideSegmentViewTestImpl(1, 255, 2); + using DIFF_TYPE = + typename std::make_signed>::type; + + ForallRangeStrideSegmentViewTestImpl( + INDEX_TYPE(0), INDEX_TYPE(20), DIFF_TYPE(1)); + ForallRangeStrideSegmentViewTestImpl( + INDEX_TYPE(1), INDEX_TYPE(20), DIFF_TYPE(1)); + ForallRangeStrideSegmentViewTestImpl( + INDEX_TYPE(0), INDEX_TYPE(20), DIFF_TYPE(2)); + ForallRangeStrideSegmentViewTestImpl( + INDEX_TYPE(1), INDEX_TYPE(20), DIFF_TYPE(2)); + ForallRangeStrideSegmentViewTestImpl( + INDEX_TYPE(0), INDEX_TYPE(21), DIFF_TYPE(2)); + ForallRangeStrideSegmentViewTestImpl( + INDEX_TYPE(1), INDEX_TYPE(21), DIFF_TYPE(2)); + ForallRangeStrideSegmentViewTestImpl( + INDEX_TYPE(1), INDEX_TYPE(255), DIFF_TYPE(2)); // Test size zero segments - ForallRangeStrideSegmentViewTestImpl(0, 20, -2); - ForallRangeStrideSegmentViewTestImpl(1, 20, -2); + ForallRangeStrideSegmentViewTestImpl( + INDEX_TYPE(0), INDEX_TYPE(20), DIFF_TYPE(-2)); + ForallRangeStrideSegmentViewTestImpl( + INDEX_TYPE(1), INDEX_TYPE(20), DIFF_TYPE(-2)); runNegativeIndexViewTests(); } diff --git a/test/functional/launch/nested_direct/test-launch-nested.cpp.in b/test/functional/launch/nested_direct/test-launch-nested.cpp.in index 1a78907650..182eb342af 100644 --- a/test/functional/launch/nested_direct/test-launch-nested.cpp.in +++ b/test/functional/launch/nested_direct/test-launch-nested.cpp.in @@ -29,7 +29,7 @@ // Cartesian product of types used in parameterized tests // using @BACKEND@LaunchNestedTypes = - Test< camp::cartesian_product>::Types; diff --git a/test/functional/launch/nested_direct/tests/test-launch-nested-Direct.hpp b/test/functional/launch/nested_direct/tests/test-launch-nested-Direct.hpp index 82ba0449e2..edf25f850d 100644 --- a/test/functional/launch/nested_direct/tests/test-launch-nested-Direct.hpp +++ b/test/functional/launch/nested_direct/tests/test-launch-nested-Direct.hpp @@ -57,6 +57,17 @@ void LaunchNestedDirectTestImpl(INDEX_TYPE M) std::iota(test_array, test_array + data_len, 0); working_res.memset(working_array, 0, sizeof(INDEX_TYPE) * data_len); + INDEX_TYPE view_len = N; + if (RAJA::stripIndexType(view_len) == 0) { + view_len = INDEX_TYPE(1); + } + + using linear_layout_t = + RAJA::TypedLayout>; + RAJA::View test_view(test_array, view_len); + RAJA::View work_view(working_array, view_len); + RAJA::View check_view(check_array, view_len); + //6 threads total constexpr int threads_x = 2; constexpr int threads_y = 3; @@ -68,8 +79,10 @@ void LaunchNestedDirectTestImpl(INDEX_TYPE M) if ( RAJA::stripIndexType(N) > 0 ) { - constexpr int DIM = 6; - using layout_t = RAJA::Layout; + using layout_t = + RAJA::TypedLayout>; RAJA::View Aview(working_array, N6, N5, N4, N3, N2, N1); RAJA::launch @@ -110,7 +123,7 @@ void LaunchNestedDirectTestImpl(INDEX_TYPE M) RAJA::loop(ctx, r2, [&](INDEX_TYPE RAJA_UNUSED_ARG(ty)) { RAJA::loop(ctx, r1, [&](INDEX_TYPE RAJA_UNUSED_ARG(tx)) { - working_array[0]++; + work_view(INDEX_TYPE(0))++; }); }); @@ -128,12 +141,12 @@ void LaunchNestedDirectTestImpl(INDEX_TYPE M) if (RAJA::stripIndexType(N) > 0) { for (INDEX_TYPE i = INDEX_TYPE(0); i < N; i++) { - ASSERT_EQ(test_array[RAJA::stripIndexType(i)], check_array[RAJA::stripIndexType(i)]); + ASSERT_EQ(test_view(i), check_view(i)); } } else { - ASSERT_EQ(test_array[0], check_array[0]); + ASSERT_EQ(test_view(INDEX_TYPE(0)), check_view(INDEX_TYPE(0))); } diff --git a/test/functional/launch/nested_direct_unchecked/test-launch-nested.cpp.in b/test/functional/launch/nested_direct_unchecked/test-launch-nested.cpp.in index 262924a2d8..ae2b84e8c2 100644 --- a/test/functional/launch/nested_direct_unchecked/test-launch-nested.cpp.in +++ b/test/functional/launch/nested_direct_unchecked/test-launch-nested.cpp.in @@ -29,7 +29,7 @@ // Cartesian product of types used in parameterized tests // using @BACKEND@LaunchNestedTypes = - Test< camp::cartesian_product>::Types; diff --git a/test/functional/launch/nested_direct_unchecked/tests/test-launch-nested-DirectUnchecked.hpp b/test/functional/launch/nested_direct_unchecked/tests/test-launch-nested-DirectUnchecked.hpp index 95dbefdc56..d4dd788b49 100644 --- a/test/functional/launch/nested_direct_unchecked/tests/test-launch-nested-DirectUnchecked.hpp +++ b/test/functional/launch/nested_direct_unchecked/tests/test-launch-nested-DirectUnchecked.hpp @@ -56,17 +56,24 @@ void LaunchNestedDirectUncheckedTestImpl(INDEX_TYPE M) working_res.memset(working_array, 0, sizeof(INDEX_TYPE) * data_len); } - //6 threads total - const int threads_x = 2*M; - const int threads_y = 3*M; - const int threads_z = 4*M; - - const int blocks_x = 4*M; - const int blocks_y = 5*M; - const int blocks_z = 6*M; + using linear_layout_t = + RAJA::TypedLayout>; + RAJA::View test_view(test_array, N); + RAJA::View check_view(check_array, N); - const int DIM = 6; - using layout_t = RAJA::Layout; + //6 threads total + const int threads_x = 2 * RAJA::stripIndexType(M); + const int threads_y = 3 * RAJA::stripIndexType(M); + const int threads_z = 4 * RAJA::stripIndexType(M); + + const int blocks_x = 4 * RAJA::stripIndexType(M); + const int blocks_y = 5 * RAJA::stripIndexType(M); + const int blocks_z = 6 * RAJA::stripIndexType(M); + + using layout_t = + RAJA::TypedLayout>; RAJA::View Aview(working_array, N6, N5, N4, N3, N2, N1); RAJA::launch @@ -100,7 +107,7 @@ void LaunchNestedDirectUncheckedTestImpl(INDEX_TYPE M) working_res.wait(); for (INDEX_TYPE i = INDEX_TYPE(0); i < N; i++) { - ASSERT_EQ(test_array[RAJA::stripIndexType(i)], check_array[RAJA::stripIndexType(i)]); + ASSERT_EQ(test_view(i), check_view(i)); } deallocateForallTestData(working_res, diff --git a/test/functional/launch/nested_loop/test-launch-nested.cpp.in b/test/functional/launch/nested_loop/test-launch-nested.cpp.in index 80d8d7b016..e0a53f6aad 100644 --- a/test/functional/launch/nested_loop/test-launch-nested.cpp.in +++ b/test/functional/launch/nested_loop/test-launch-nested.cpp.in @@ -29,7 +29,7 @@ // Cartesian product of types used in parameterized tests // using @BACKEND@LaunchNestedTypes = - Test< camp::cartesian_product>::Types; diff --git a/test/functional/launch/nested_loop/tests/test-launch-nested-Loop.hpp b/test/functional/launch/nested_loop/tests/test-launch-nested-Loop.hpp index af87fd614e..979f04b106 100644 --- a/test/functional/launch/nested_loop/tests/test-launch-nested-Loop.hpp +++ b/test/functional/launch/nested_loop/tests/test-launch-nested-Loop.hpp @@ -61,6 +61,17 @@ void LaunchNestedLoopTestImpl(INDEX_TYPE M) std::iota(test_array, test_array + data_len, 0); working_res.memset(working_array, 0, sizeof(INDEX_TYPE) * data_len); + INDEX_TYPE view_len = N; + if (RAJA::stripIndexType(view_len) == 0) { + view_len = INDEX_TYPE(1); + } + + using linear_layout_t = + RAJA::TypedLayout>; + RAJA::View test_view(test_array, view_len); + RAJA::View work_view(working_array, view_len); + RAJA::View check_view(check_array, view_len); + //6 threads total constexpr int threads_x = 1; constexpr int threads_y = 2; @@ -72,8 +83,10 @@ void LaunchNestedLoopTestImpl(INDEX_TYPE M) if ( RAJA::stripIndexType(N) > 0 ) { - constexpr int DIM = 6; - using layout_t = RAJA::Layout; + using layout_t = + RAJA::TypedLayout>; RAJA::View Aview(working_array, N6, N5, N4, N3, N2, N1); RAJA::launch @@ -115,7 +128,7 @@ void LaunchNestedLoopTestImpl(INDEX_TYPE M) RAJA::loop(ctx, r2, [&](INDEX_TYPE RAJA_UNUSED_ARG(ty)) { RAJA::loop(ctx, r1, [&](INDEX_TYPE RAJA_UNUSED_ARG(tx) ) { - working_array[0]++; + work_view(INDEX_TYPE(0))++; }); }); @@ -133,12 +146,12 @@ void LaunchNestedLoopTestImpl(INDEX_TYPE M) if (RAJA::stripIndexType(N) > 0) { for (INDEX_TYPE i = INDEX_TYPE(0); i < N; i++) { - ASSERT_EQ(test_array[RAJA::stripIndexType(i)], check_array[RAJA::stripIndexType(i)]); + ASSERT_EQ(test_view(i), check_view(i)); } } else { - ASSERT_EQ(test_array[0], check_array[0]); + ASSERT_EQ(test_view(INDEX_TYPE(0)), check_view(INDEX_TYPE(0))); } diff --git a/test/functional/launch/nested_tile_direct/test-launch-nested-tile-direct.cpp.in b/test/functional/launch/nested_tile_direct/test-launch-nested-tile-direct.cpp.in index 425d385bd1..1ccbbb3061 100644 --- a/test/functional/launch/nested_tile_direct/test-launch-nested-tile-direct.cpp.in +++ b/test/functional/launch/nested_tile_direct/test-launch-nested-tile-direct.cpp.in @@ -29,7 +29,7 @@ // Cartesian product of types used in parameterized tests // using @BACKEND@LaunchNestedTypes = - Test< camp::cartesian_product>::Types; diff --git a/test/functional/launch/nested_tile_direct/tests/test-launch-nested-Tile-Direct.hpp b/test/functional/launch/nested_tile_direct/tests/test-launch-nested-Tile-Direct.hpp index 2904199aac..7085835cdb 100644 --- a/test/functional/launch/nested_tile_direct/tests/test-launch-nested-Tile-Direct.hpp +++ b/test/functional/launch/nested_tile_direct/tests/test-launch-nested-Tile-Direct.hpp @@ -62,10 +62,22 @@ void LaunchNestedTileDirectTestImpl(INDEX_TYPE M) std::iota(test_array, test_array + data_len, 0); working_res.memset(working_array, 0, sizeof(INDEX_TYPE) * data_len); + INDEX_TYPE view_len = N; + if (RAJA::stripIndexType(view_len) == 0) { + view_len = INDEX_TYPE(1); + } + + using linear_layout_t = + RAJA::TypedLayout>; + RAJA::View test_view(test_array, view_len); + RAJA::View work_view(working_array, view_len); + RAJA::View check_view(check_array, view_len); + if ( RAJA::stripIndexType(N) > 0 ) { - constexpr int DIM = 3; - using layout_t = RAJA::Layout; + using layout_t = + RAJA::TypedLayout>; RAJA::View Aview(working_array, N3, N2, N1); RAJA::launch @@ -106,7 +118,7 @@ void LaunchNestedTileDirectTestImpl(INDEX_TYPE M) RAJA::loop(ctx, y_tile, [&](INDEX_TYPE RAJA_UNUSED_ARG(ty)) { RAJA::loop(ctx, x_tile, [&](INDEX_TYPE RAJA_UNUSED_ARG(tx)) { - working_array[0]++; + work_view(INDEX_TYPE(0))++; }); }); @@ -124,12 +136,12 @@ void LaunchNestedTileDirectTestImpl(INDEX_TYPE M) if (RAJA::stripIndexType(N) > 0) { for (INDEX_TYPE i = INDEX_TYPE(0); i < N; i++) { - ASSERT_EQ(test_array[RAJA::stripIndexType(i)], check_array[RAJA::stripIndexType(i)]); + ASSERT_EQ(test_view(i), check_view(i)); } } else { - ASSERT_EQ(test_array[0], check_array[0]); + ASSERT_EQ(test_view(INDEX_TYPE(0)), check_view(INDEX_TYPE(0))); } diff --git a/test/functional/launch/nested_tile_direct_unchecked/test-launch-nested-tile-direct-unchecked.cpp.in b/test/functional/launch/nested_tile_direct_unchecked/test-launch-nested-tile-direct-unchecked.cpp.in index 41d263a910..ce7f374bd1 100644 --- a/test/functional/launch/nested_tile_direct_unchecked/test-launch-nested-tile-direct-unchecked.cpp.in +++ b/test/functional/launch/nested_tile_direct_unchecked/test-launch-nested-tile-direct-unchecked.cpp.in @@ -29,7 +29,7 @@ // Cartesian product of types used in parameterized tests // using @BACKEND@LaunchNestedTypes = - Test< camp::cartesian_product>::Types; diff --git a/test/functional/launch/nested_tile_direct_unchecked/tests/test-launch-nested-Tile-DirectUnchecked.hpp b/test/functional/launch/nested_tile_direct_unchecked/tests/test-launch-nested-Tile-DirectUnchecked.hpp index efc9cdb159..8758092d47 100644 --- a/test/functional/launch/nested_tile_direct_unchecked/tests/test-launch-nested-Tile-DirectUnchecked.hpp +++ b/test/functional/launch/nested_tile_direct_unchecked/tests/test-launch-nested-Tile-DirectUnchecked.hpp @@ -26,9 +26,9 @@ void LaunchNestedTileDirectUncheckedTestImpl(INDEX_TYPE M) const int threads_y = tile_size_y; const int threads_z = tile_size_z; - const int blocks_x = 4*M; - const int blocks_y = 5*M; - const int blocks_z = 6*M; + const int blocks_x = 4 * RAJA::stripIndexType(M); + const int blocks_y = 5 * RAJA::stripIndexType(M); + const int blocks_z = 6 * RAJA::stripIndexType(M); // Use exactly the number of teams and threads RAJA::TypedRangeSegment r1(0, threads_x*blocks_x); @@ -61,8 +61,14 @@ void LaunchNestedTileDirectUncheckedTestImpl(INDEX_TYPE M) working_res.memset(working_array, 0, sizeof(INDEX_TYPE) * data_len); } - constexpr int DIM = 3; - using layout_t = RAJA::Layout; + using linear_layout_t = + RAJA::TypedLayout>; + RAJA::View test_view(test_array, N); + RAJA::View check_view(check_array, N); + + using layout_t = + RAJA::TypedLayout>; RAJA::View Aview(working_array, N3, N2, N1); RAJA::launch @@ -96,7 +102,7 @@ void LaunchNestedTileDirectUncheckedTestImpl(INDEX_TYPE M) working_res.wait(); for (INDEX_TYPE i = INDEX_TYPE(0); i < N; i++) { - ASSERT_EQ(test_array[RAJA::stripIndexType(i)], check_array[RAJA::stripIndexType(i)]); + ASSERT_EQ(test_view(i), check_view(i)); } deallocateForallTestData(working_res, diff --git a/test/functional/launch/nested_tile_loop/test-launch-nested-tile-loop.cpp.in b/test/functional/launch/nested_tile_loop/test-launch-nested-tile-loop.cpp.in index 1163dae07d..849fe76bdd 100644 --- a/test/functional/launch/nested_tile_loop/test-launch-nested-tile-loop.cpp.in +++ b/test/functional/launch/nested_tile_loop/test-launch-nested-tile-loop.cpp.in @@ -29,7 +29,7 @@ // Cartesian product of types used in parameterized tests // using @BACKEND@LaunchNestedTypes = - Test< camp::cartesian_product>::Types; diff --git a/test/functional/launch/nested_tile_loop/tests/test-launch-nested-Tile-Loop.hpp b/test/functional/launch/nested_tile_loop/tests/test-launch-nested-Tile-Loop.hpp index 756178bee6..24129300a0 100644 --- a/test/functional/launch/nested_tile_loop/tests/test-launch-nested-Tile-Loop.hpp +++ b/test/functional/launch/nested_tile_loop/tests/test-launch-nested-Tile-Loop.hpp @@ -62,10 +62,22 @@ void LaunchNestedTileLoopTestImpl(INDEX_TYPE M) std::iota(test_array, test_array + data_len, 0); working_res.memset(working_array, 0, sizeof(INDEX_TYPE) * data_len); + INDEX_TYPE view_len = N; + if (RAJA::stripIndexType(view_len) == 0) { + view_len = INDEX_TYPE(1); + } + + using linear_layout_t = + RAJA::TypedLayout>; + RAJA::View test_view(test_array, view_len); + RAJA::View work_view(working_array, view_len); + RAJA::View check_view(check_array, view_len); + if ( RAJA::stripIndexType(N) > 0 ) { - constexpr int DIM = 3; - using layout_t = RAJA::Layout; + using layout_t = + RAJA::TypedLayout>; RAJA::View Aview(working_array, N3, N2, N1); RAJA::launch @@ -105,7 +117,7 @@ void LaunchNestedTileLoopTestImpl(INDEX_TYPE M) RAJA::loop(ctx, y_tile, [&](INDEX_TYPE RAJA_UNUSED_ARG(ty)) { RAJA::loop(ctx, x_tile, [&](INDEX_TYPE RAJA_UNUSED_ARG(tx)) { - working_array[0]++; + work_view(INDEX_TYPE(0))++; }); }); @@ -123,12 +135,12 @@ void LaunchNestedTileLoopTestImpl(INDEX_TYPE M) if (RAJA::stripIndexType(N) > 0) { for (INDEX_TYPE i = INDEX_TYPE(0); i < N; i++) { - ASSERT_EQ(test_array[RAJA::stripIndexType(i)], check_array[RAJA::stripIndexType(i)]); + ASSERT_EQ(test_view(i), check_view(i)); } } else { - ASSERT_EQ(test_array[0], check_array[0]); + ASSERT_EQ(test_view(INDEX_TYPE(0)), check_view(INDEX_TYPE(0))); } diff --git a/test/functional/launch/tile_icount_tcount_direct/test-launch-nested-tile-icount-tcount-direct.cpp.in b/test/functional/launch/tile_icount_tcount_direct/test-launch-nested-tile-icount-tcount-direct.cpp.in index 199e0f5971..540c1aa75f 100644 --- a/test/functional/launch/tile_icount_tcount_direct/test-launch-nested-tile-icount-tcount-direct.cpp.in +++ b/test/functional/launch/tile_icount_tcount_direct/test-launch-nested-tile-icount-tcount-direct.cpp.in @@ -29,7 +29,7 @@ // Cartesian product of types used in parameterized tests // using @BACKEND@LaunchNestedTypes = - Test< camp::cartesian_product>::Types; diff --git a/test/functional/launch/tile_icount_tcount_direct/tests/test-launch-nested-Tile-iCount-tCount-Direct.hpp b/test/functional/launch/tile_icount_tcount_direct/tests/test-launch-nested-Tile-iCount-tCount-Direct.hpp index 9460dd0788..edd66ae551 100644 --- a/test/functional/launch/tile_icount_tcount_direct/tests/test-launch-nested-Tile-iCount-tCount-Direct.hpp +++ b/test/functional/launch/tile_icount_tcount_direct/tests/test-launch-nested-Tile-iCount-tCount-Direct.hpp @@ -17,14 +17,15 @@ template r1(0, M*threads_x+1); + RAJA::TypedRangeSegment r1(0, M * threads_x_idx + 1); INDEX_TYPE N1 = static_cast(r1.end() - r1.begin()); - INDEX_TYPE no_tiles = (N1-1)/threads_x + 1; + INDEX_TYPE no_tiles = (N1 - 1) / threads_x_idx + 1; INDEX_TYPE N = static_cast(RAJA::stripIndexType(N1)); @@ -59,6 +60,20 @@ void LaunchNestedTileDirectTestImpl(INDEX_TYPE M) working_res.memset(working_ttile_array, 0, sizeof(INDEX_TYPE) * data_len); working_res.memset(working_iloop_array, 0, sizeof(INDEX_TYPE) * data_len); + INDEX_TYPE view_len = N; + if (RAJA::stripIndexType(view_len) == 0) { + view_len = INDEX_TYPE(1); + } + + using layout_type = + RAJA::TypedLayout>; + using view_type = RAJA::View< INDEX_TYPE, layout_type >; + + view_type work_ttile_view(working_ttile_array, view_len); + view_type work_iloop_view(working_iloop_array, view_len); + view_type check_ttile_view(check_ttile_array, view_len); + view_type check_iloop_view(check_iloop_array, view_len); + if ( RAJA::stripIndexType(N) > 0 ) { RAJA::launch( @@ -69,8 +84,8 @@ void LaunchNestedTileDirectTestImpl(INDEX_TYPE M) RAJA::loop_icount( ctx, x_tile, [&](INDEX_TYPE tx, INDEX_TYPE ix) { - working_ttile_array[tx] += bx; - working_iloop_array[tx] += ix; + work_ttile_view(tx) += bx; + work_iloop_view(tx) += ix; } ); @@ -89,8 +104,8 @@ void LaunchNestedTileDirectTestImpl(INDEX_TYPE M) RAJA::loop_icount( ctx, x_tile, [&](INDEX_TYPE RAJA_UNUSED_ARG(tx), INDEX_TYPE RAJA_UNUSED_ARG (ix)) { - working_ttile_array[0]++; - working_iloop_array[0]++; + work_ttile_view(INDEX_TYPE(0))++; + work_iloop_view(INDEX_TYPE(0))++; } ); @@ -112,8 +127,8 @@ void LaunchNestedTileDirectTestImpl(INDEX_TYPE M) if(idx >= N1) break; - ASSERT_EQ(check_ttile_array[RAJA::stripIndexType(idx)], bx); - ASSERT_EQ(check_iloop_array[RAJA::stripIndexType(idx)], tx); + ASSERT_EQ(check_ttile_view(idx), bx); + ASSERT_EQ(check_iloop_view(idx), tx); idx++; } @@ -121,8 +136,8 @@ void LaunchNestedTileDirectTestImpl(INDEX_TYPE M) } else { - ASSERT_EQ(check_ttile_array[0], check_ttile_array[0]); - ASSERT_EQ(check_iloop_array[0], check_iloop_array[0]); + ASSERT_EQ(check_ttile_view(INDEX_TYPE(0)), check_ttile_view(INDEX_TYPE(0))); + ASSERT_EQ(check_iloop_view(INDEX_TYPE(0)), check_iloop_view(INDEX_TYPE(0))); } diff --git a/test/functional/launch/tile_icount_tcount_direct_unchecked/test-launch-nested-tile-icount-tcount-direct-unchecked.cpp.in b/test/functional/launch/tile_icount_tcount_direct_unchecked/test-launch-nested-tile-icount-tcount-direct-unchecked.cpp.in index 651ae43baf..a40af1c633 100644 --- a/test/functional/launch/tile_icount_tcount_direct_unchecked/test-launch-nested-tile-icount-tcount-direct-unchecked.cpp.in +++ b/test/functional/launch/tile_icount_tcount_direct_unchecked/test-launch-nested-tile-icount-tcount-direct-unchecked.cpp.in @@ -29,7 +29,7 @@ // Cartesian product of types used in parameterized tests // using @BACKEND@LaunchNestedTypes = - Test< camp::cartesian_product>::Types; diff --git a/test/functional/launch/tile_icount_tcount_direct_unchecked/tests/test-launch-nested-Tile-iCount-tCount-DirectUnchecked.hpp b/test/functional/launch/tile_icount_tcount_direct_unchecked/tests/test-launch-nested-Tile-iCount-tCount-DirectUnchecked.hpp index a43a0173d8..a45e456bcd 100644 --- a/test/functional/launch/tile_icount_tcount_direct_unchecked/tests/test-launch-nested-Tile-iCount-tCount-DirectUnchecked.hpp +++ b/test/functional/launch/tile_icount_tcount_direct_unchecked/tests/test-launch-nested-Tile-iCount-tCount-DirectUnchecked.hpp @@ -17,10 +17,12 @@ template r1(0, threads_x*blocks_x); + RAJA::TypedRangeSegment r1(0, threads_x_idx * blocks_x_idx); INDEX_TYPE N = static_cast(r1.end() - r1.begin()); @@ -54,6 +56,15 @@ void LaunchNestedTileDirectUncheckedTestImpl(INDEX_TYPE M) working_res.memset(working_iloop_array, 0, sizeof(INDEX_TYPE) * data_len); } + using layout_type = + RAJA::TypedLayout>; + using view_type = RAJA::View< INDEX_TYPE, layout_type >; + + view_type work_ttile_view(working_ttile_array, N); + view_type work_iloop_view(working_iloop_array, N); + view_type check_ttile_view(check_ttile_array, N); + view_type check_iloop_view(check_iloop_array, N); + RAJA::launch( RAJA::LaunchParams(RAJA::Teams(blocks_x), RAJA::Threads(threads_x)), [=] RAJA_HOST_DEVICE(RAJA::LaunchContext ctx) { @@ -62,8 +73,8 @@ void LaunchNestedTileDirectUncheckedTestImpl(INDEX_TYPE M) RAJA::loop_icount( ctx, x_tile, [&](INDEX_TYPE tx, INDEX_TYPE ix) { - working_ttile_array[tx] = bx; - working_iloop_array[tx] = ix; + work_ttile_view(tx) = bx; + work_iloop_view(tx) = ix; } ); @@ -79,11 +90,11 @@ void LaunchNestedTileDirectUncheckedTestImpl(INDEX_TYPE M) working_res.wait(); INDEX_TYPE idx = 0; - for (INDEX_TYPE bx = INDEX_TYPE(0); bx < blocks_x; ++bx) { - for (INDEX_TYPE tx = INDEX_TYPE(0); tx < threads_x; ++tx) { + for (INDEX_TYPE bx = INDEX_TYPE(0); bx < blocks_x_idx; ++bx) { + for (INDEX_TYPE tx = INDEX_TYPE(0); tx < threads_x_idx; ++tx) { - ASSERT_EQ(check_ttile_array[RAJA::stripIndexType(idx)], bx); - ASSERT_EQ(check_iloop_array[RAJA::stripIndexType(idx)], tx); + ASSERT_EQ(check_ttile_view(idx), bx); + ASSERT_EQ(check_iloop_view(idx), tx); idx++; } diff --git a/test/functional/launch/tile_icount_tcount_loop/test-launch-nested-tile-icount-tcount-loop.cpp.in b/test/functional/launch/tile_icount_tcount_loop/test-launch-nested-tile-icount-tcount-loop.cpp.in index 38456dfb09..68f731dc01 100644 --- a/test/functional/launch/tile_icount_tcount_loop/test-launch-nested-tile-icount-tcount-loop.cpp.in +++ b/test/functional/launch/tile_icount_tcount_loop/test-launch-nested-tile-icount-tcount-loop.cpp.in @@ -29,7 +29,7 @@ // Cartesian product of types used in parameterized tests // using @BACKEND@LaunchNestedTypes = - Test< camp::cartesian_product>::Types; diff --git a/test/functional/launch/tile_icount_tcount_loop/tests/test-launch-nested-Tile-iCount-tCount-Loop.hpp b/test/functional/launch/tile_icount_tcount_loop/tests/test-launch-nested-Tile-iCount-tCount-Loop.hpp index 9953569745..d5a1d90af7 100644 --- a/test/functional/launch/tile_icount_tcount_loop/tests/test-launch-nested-Tile-iCount-tCount-Loop.hpp +++ b/test/functional/launch/tile_icount_tcount_loop/tests/test-launch-nested-Tile-iCount-tCount-Loop.hpp @@ -17,17 +17,18 @@ template r1(0, M*tile_size+1); + RAJA::TypedRangeSegment r1(0, M * tile_size_idx + 1); INDEX_TYPE N1 = static_cast(r1.end() - r1.begin()); - INDEX_TYPE no_tiles = (N1-1)/tile_size + 1; + INDEX_TYPE no_tiles = (N1 - 1) / tile_size_idx + 1; INDEX_TYPE N = static_cast(RAJA::stripIndexType(N1)); @@ -62,6 +63,20 @@ void LaunchNestedTileLoopTestImpl(INDEX_TYPE M) working_res.memset(working_ttile_array, 0, sizeof(INDEX_TYPE) * data_len); working_res.memset(working_iloop_array, 0, sizeof(INDEX_TYPE) * data_len); + INDEX_TYPE view_len = N; + if (RAJA::stripIndexType(view_len) == 0) { + view_len = INDEX_TYPE(1); + } + + using layout_type = + RAJA::TypedLayout>; + using view_type = RAJA::View< INDEX_TYPE, layout_type >; + + view_type work_ttile_view(working_ttile_array, view_len); + view_type work_iloop_view(working_iloop_array, view_len); + view_type check_ttile_view(check_ttile_array, view_len); + view_type check_iloop_view(check_iloop_array, view_len); + if ( RAJA::stripIndexType(N) > 0 ) { RAJA::launch( @@ -72,8 +87,8 @@ void LaunchNestedTileLoopTestImpl(INDEX_TYPE M) RAJA::loop_icount( ctx, x_tile, [&](INDEX_TYPE tx, INDEX_TYPE ix) { - working_ttile_array[tx] = bx; - working_iloop_array[tx] = ix; + work_ttile_view(tx) = bx; + work_iloop_view(tx) = ix; } ); @@ -92,8 +107,8 @@ void LaunchNestedTileLoopTestImpl(INDEX_TYPE M) RAJA::loop_icount (ctx, x_tile, [&](INDEX_TYPE RAJA_UNUSED_ARG(tx), INDEX_TYPE RAJA_UNUSED_ARG(ix)) { - working_ttile_array[0]++; - working_iloop_array[0]++; + work_ttile_view(INDEX_TYPE(0))++; + work_iloop_view(INDEX_TYPE(0))++; } ); @@ -111,12 +126,12 @@ void LaunchNestedTileLoopTestImpl(INDEX_TYPE M) INDEX_TYPE idx = 0; for (INDEX_TYPE bx = INDEX_TYPE(0); bx < no_tiles; ++bx) { - for (INDEX_TYPE tx = INDEX_TYPE(0); tx < tile_size; ++tx) { + for (INDEX_TYPE tx = INDEX_TYPE(0); tx < tile_size_idx; ++tx) { if(idx >= N1) break; - ASSERT_EQ(check_ttile_array[RAJA::stripIndexType(idx)], bx); - ASSERT_EQ(check_iloop_array[RAJA::stripIndexType(idx)], tx); + ASSERT_EQ(check_ttile_view(idx), bx); + ASSERT_EQ(check_iloop_view(idx), tx); idx++; } @@ -124,8 +139,8 @@ void LaunchNestedTileLoopTestImpl(INDEX_TYPE M) } else { - ASSERT_EQ(check_ttile_array[0], check_ttile_array[0]); - ASSERT_EQ(check_iloop_array[0], check_iloop_array[0]); + ASSERT_EQ(check_ttile_view(INDEX_TYPE(0)), check_ttile_view(INDEX_TYPE(0))); + ASSERT_EQ(check_iloop_view(INDEX_TYPE(0)), check_iloop_view(INDEX_TYPE(0))); } diff --git a/test/include/RAJA_test-indexset-build.hpp b/test/include/RAJA_test-indexset-build.hpp index a1a70b5972..428fb0085a 100644 --- a/test/include/RAJA_test-indexset-build.hpp +++ b/test/include/RAJA_test-indexset-build.hpp @@ -57,8 +57,8 @@ void buildIndexSet( INDEX_TYPE stride = 0; INDEX_TYPE last_idx = 0; INDEX_TYPE lseg_len = static_cast( lindices.size() ); - std::vector lseg(lseg_len); - std::vector lseg_vec(lseg_len); + std::vector lseg(RAJA::stripIndexType(lseg_len)); + std::vector lseg_vec(RAJA::stripIndexType(lseg_len)); indices_out.clear(); @@ -79,25 +79,29 @@ void buildIndexSet( // Create List segment for (INDEX_TYPE i = 0; i < lseg_len; ++i) { - lseg[i] = lindices[i] + last_idx + 3; - indices_out.push_back( lseg[i] ); + auto ii = RAJA::stripIndexType(i); + lseg[ii] = lindices[ii] + last_idx + 3; + indices_out.push_back( lseg[ii] ); } - iset.push_back(LIST_TYPE(&lseg[0], lseg_len, working_res)); - last_idx = lseg[lseg_len - 1]; + iset.push_back(LIST_TYPE(&lseg[0], RAJA::stripIndexType(lseg_len), working_res)); + last_idx = lseg[RAJA::stripIndexType(lseg_len - 1)]; // Create List segment using alternate ctor for (INDEX_TYPE i = 0; i < lseg_len; ++i) { - lseg_vec[i] = lindices[i] + last_idx + 3; - indices_out.push_back( lseg_vec[i] ); + auto ii = RAJA::stripIndexType(i); + lseg_vec[ii] = lindices[ii] + last_idx + 3; + indices_out.push_back( lseg_vec[ii] ); } iset.push_back(LIST_TYPE(lseg_vec, working_res)); - last_idx = lseg_vec[lseg_len - 1]; + last_idx = lseg_vec[RAJA::stripIndexType(lseg_len - 1)]; // Create Range-stride segment rbeg = last_idx + 16; rend = rbeg + 2040; stride = 3; - iset.push_back(RANGESTRIDE_TYPE(rbeg, rend, stride)); + iset.push_back(RANGESTRIDE_TYPE(RAJA::stripIndexType(rbeg), + RAJA::stripIndexType(rend), + RAJA::stripIndexType(stride))); for (INDEX_TYPE i = rbeg; i < rend; i += stride) { indices_out.push_back( i ); } @@ -114,11 +118,12 @@ void buildIndexSet( // Create List segment for (INDEX_TYPE i = 0; i < lseg_len; ++i) { - lseg[i] = lindices[i] + last_idx + 5; - indices_out.push_back( lseg[i] ); + auto ii = RAJA::stripIndexType(i); + lseg[ii] = lindices[ii] + last_idx + 5; + indices_out.push_back( lseg[ii] ); } - iset.push_back(LIST_TYPE(&lseg[0], lseg_len, working_res)); - last_idx = lseg[lseg_len - 1]; + iset.push_back(LIST_TYPE(&lseg[0], RAJA::stripIndexType(lseg_len), working_res)); + last_idx = lseg[RAJA::stripIndexType(lseg_len - 1)]; // Create Range segment rbeg = last_idx + 1; @@ -131,11 +136,12 @@ void buildIndexSet( // Create List segment using alternate ctor for (INDEX_TYPE i = 0; i < lseg_len; ++i) { - lseg_vec[i] = lindices[i] + last_idx + 7; - indices_out.push_back( lseg_vec[i] ); + auto ii = RAJA::stripIndexType(i); + lseg_vec[ii] = lindices[ii] + last_idx + 7; + indices_out.push_back( lseg_vec[ii] ); } iset.push_back(LIST_TYPE(lseg_vec, working_res)); - last_idx = lseg_vec[lseg_len - 1]; + last_idx = lseg_vec[RAJA::stripIndexType(lseg_len - 1)]; } #endif // __TEST_FORALL_INDEXSET_BUILD_HPP__ From ed04fe82072b20aea1307da4c0f6af6de88d20c9 Mon Sep 17 00:00:00 2001 From: john bowen Date: Mon, 24 Aug 2026 17:11:07 -0700 Subject: [PATCH 6/8] make constructor explicit again --- include/RAJA/index/IndexValue.hpp | 5 +- include/RAJA/index/RangeSegment.hpp | 2 + include/RAJA/policy/hip/kernel/Tile.hpp | 38 ++++++++------ .../tests/test-forall-CombiningAdapter-1D.hpp | 4 +- .../tests/test-forall-CombiningAdapter-2D.hpp | 6 +-- .../tests/test-forall-CombiningAdapter-3D.hpp | 8 +-- .../tests/test-forall-IcountIndexSetView.hpp | 8 +-- .../tests/test-forall-IndexSetView.hpp | 2 +- .../tests/test-forall-IcountIndexSet.hpp | 8 +-- .../indexset/tests/test-forall-IndexSet.hpp | 2 +- .../messages/tests/test-forall-basic-msg.hpp | 8 +-- .../tests/test-forall-basic-MultiReduce.hpp | 18 +++---- .../tests/test-forall-basic-ReduceBitAnd.hpp | 10 ++-- .../tests/test-forall-basic-ReduceBitOr.hpp | 10 ++-- .../tests/test-forall-basic-ReduceMax.hpp | 8 +-- .../tests/test-forall-basic-ReduceMaxLoc.hpp | 10 ++-- .../tests/test-forall-basic-ReduceMin.hpp | 8 +-- .../tests/test-forall-basic-ReduceMinLoc.hpp | 10 ++-- .../tests/test-forall-basic-ReduceSum.hpp | 8 +-- .../test-forall-basic-expt-ReduceBitAnd.hpp | 10 ++-- .../test-forall-basic-expt-ReduceBitOr.hpp | 10 ++-- .../test-forall-basic-expt-ReduceMax.hpp | 8 +-- .../test-forall-basic-expt-ReduceMaxLoc.hpp | 10 ++-- ...test-forall-basic-expt-ReduceMaxLocAlt.hpp | 10 ++-- .../test-forall-basic-expt-ReduceMin.hpp | 8 +-- .../test-forall-basic-expt-ReduceMinLoc.hpp | 10 ++-- ...test-forall-basic-expt-ReduceMinLocAlt.hpp | 10 ++-- .../test-forall-basic-expt-ReduceSum.hpp | 8 +-- ...est-forall-indexset-multiple-ReduceMax.hpp | 4 +- ...-forall-indexset-multiple-ReduceMaxLoc.hpp | 6 +-- ...est-forall-indexset-multiple-ReduceMin.hpp | 4 +- ...-forall-indexset-multiple-ReduceMinLoc.hpp | 6 +-- ...est-forall-indexset-multiple-ReduceSum.hpp | 4 +- ...test-forall-segment-multiple-ReduceMax.hpp | 2 +- ...t-forall-segment-multiple-ReduceMaxLoc.hpp | 2 +- ...test-forall-segment-multiple-ReduceMin.hpp | 2 +- ...t-forall-segment-multiple-ReduceMinLoc.hpp | 2 +- .../region/tests/test-forall-region.hpp | 2 +- .../test-forall-ResourceIcountIndexSet.hpp | 8 +-- .../tests/test-forall-ResourceIndexSet.hpp | 2 +- .../test-forall-resource-ListSegment.hpp | 6 +-- .../test-forall-resource-RangeSegment.hpp | 2 +- ...est-forall-resource-RangeStrideSegment.hpp | 6 +-- .../tests/test-forall-ListSegmentView.hpp | 26 ++++++---- .../tests/test-forall-RangeSegment2DView.hpp | 29 ++++++----- .../tests/test-forall-RangeSegmentView.hpp | 43 ++++++++++------ .../test-forall-RangeStrideSegmentView.hpp | 6 +-- .../segment/tests/test-forall-ListSegment.hpp | 4 +- .../tests/test-forall-RangeSegment.hpp | 2 +- .../tests/test-forall-RangeStrideSegment.hpp | 4 +- .../tests/basic-fission-fusion-loop-impl.hpp | 4 +- ...nel-basic-fission-fusion-loop-segments.hpp | 4 +- .../tests/basic-single-icount-loop-impl.hpp | 6 +-- ...rnel-basic-single-icount-loop-segments.hpp | 4 +- .../tests/basic-single-loop-segments-impl.hpp | 6 +-- ...test-kernel-basic-single-loop-segments.hpp | 4 +- ...el-resource-basic-single-loop-segments.hpp | 4 +- .../conditional-fission-fusion-loop-impl.hpp | 4 +- ...nditional-fission-fusion-loop-segments.hpp | 4 +- .../tests/test-kernel-hyperplane-2D.hpp | 23 +++------ .../tests/test-kernel-hyperplane-3D.hpp | 49 ++++++++---------- .../tests/test-kernel-nested-MultiReduce.hpp | 12 ++--- ...test-kernel-nested-loops-segment-types.hpp | 37 ++++++-------- ...ernel-nested-loop-PermutedOffsetView2D.hpp | 11 +--- ...ernel-nested-loop-PermutedOffsetView3D.hpp | 13 ++--- ...test-kernel-nested-loop-PermutedView2D.hpp | 11 +--- ...test-kernel-nested-loop-PermutedView3D.hpp | 11 +--- .../tests/test-kernel-reduceloc-Max2D.hpp | 21 +++----- .../tests/test-kernel-reduceloc-Max2DView.hpp | 21 +++----- .../test-kernel-reduceloc-Max2DViewTuple.hpp | 21 +++----- .../tests/test-kernel-reduceloc-Min2D.hpp | 21 +++----- .../tests/test-kernel-reduceloc-Min2DView.hpp | 21 +++----- .../test-kernel-reduceloc-Min2DViewTuple.hpp | 21 +++----- ...test-kernel-reduce-params-multi-lambda.hpp | 15 ++---- .../tests/test-kernel-basic-param.hpp | 51 +++++-------------- .../region/tests/test-kernel-region-sync.hpp | 8 +-- .../region/tests/test-kernel-region.hpp | 8 +-- ...kernel-tile-ForICount-direct-unchecked.hpp | 14 ++--- ...ernel-tile-TileTCount-direct-unchecked.hpp | 26 +++++----- .../test-kernel-tile-ForICount-direct.hpp | 10 ++-- .../test-kernel-tile-TileTCount-direct.hpp | 24 ++++----- .../tests/test-kernel-tile-ForICount-loop.hpp | 22 ++++---- .../test-kernel-tile-TileTCount-loop.hpp | 24 ++++----- .../tests/test-kernel-tile-Dynamic2D.hpp | 35 +++++-------- .../tests/test-kernel-tile-Fixed2D.hpp | 25 ++++----- .../tests/test-kernel-tile-Fixed2DMinMax.hpp | 17 ++----- .../tests/test-kernel-tile-Fixed2DSum.hpp | 13 ++--- .../tests/test-kernel-tile-LocalArray2D.hpp | 29 ++++------- .../tests/test-launch-nested-MultiReduce.hpp | 18 +++---- .../tests/test-launch-nested-Direct.hpp | 16 +++--- .../test-launch-nested-DirectUnchecked.hpp | 16 +++--- .../tests/test-launch-nested-Loop.hpp | 16 +++--- .../tests/test-launch-nested-Tile-Direct.hpp | 10 ++-- ...est-launch-nested-Tile-DirectUnchecked.hpp | 10 ++-- .../tests/test-launch-nested-Tile-Loop.hpp | 10 ++-- .../tests/test-launch-basic-ReduceBitAnd.hpp | 10 ++-- .../tests/test-launch-basic-ReduceMin.hpp | 8 +-- .../tests/test-launch-basic-ReduceSum.hpp | 8 +-- ...t-launch-basic-param-expt-ReduceBitAnd.hpp | 10 ++-- ...test-launch-basic-param-expt-ReduceMin.hpp | 8 +-- ...test-launch-basic-param-expt-ReduceSum.hpp | 8 +-- .../segment/tests/test-launch-ListSegment.hpp | 4 +- .../tests/test-launch-RangeSegment.hpp | 2 +- .../tests/test-launch-RangeStrideSegment.hpp | 4 +- ...aunch-nested-Tile-iCount-tCount-Direct.hpp | 12 ++--- ...ted-Tile-iCount-tCount-DirectUnchecked.hpp | 12 ++--- ...-launch-nested-Tile-iCount-tCount-Loop.hpp | 12 ++--- test/include/RAJA_test-indexset-build.hpp | 18 +++---- 108 files changed, 584 insertions(+), 711 deletions(-) diff --git a/include/RAJA/index/IndexValue.hpp b/include/RAJA/index/IndexValue.hpp index 5946b6c1cc..b8c4610b24 100644 --- a/include/RAJA/index/IndexValue.hpp +++ b/include/RAJA/index/IndexValue.hpp @@ -24,7 +24,6 @@ #include -// #include "RAJA/util/concepts.hpp" #include "RAJA/util/macros.hpp" #include "RAJA/util/types.hpp" @@ -503,7 +502,7 @@ using make_signed_t = using parent::operator--; \ using IndexValueType = TYPE; \ RAJA_HOST_DEVICE RAJA_INLINE TYPE() : parent::IndexValue() {} \ - RAJA_HOST_DEVICE RAJA_INLINE TYPE(::RAJA::Index_type v) \ + RAJA_HOST_DEVICE RAJA_INLINE explicit TYPE(::RAJA::Index_type v) \ : parent::IndexValue(v) \ {} \ static inline std::string getName() { return NAME; } \ @@ -527,7 +526,7 @@ using make_signed_t = RAJA_HOST_DEVICE RAJA_INLINE TYPE() \ : RAJA::IndexValue::IndexValue() \ {} \ - RAJA_HOST_DEVICE RAJA_INLINE TYPE(IDXT v) \ + RAJA_HOST_DEVICE RAJA_INLINE explicit TYPE(IDXT v) \ : RAJA::IndexValue::IndexValue(v) \ {} \ static inline std::string getName() { return NAME; } \ diff --git a/include/RAJA/index/RangeSegment.hpp b/include/RAJA/index/RangeSegment.hpp index c1a4cfcc85..0e552a127d 100644 --- a/include/RAJA/index/RangeSegment.hpp +++ b/include/RAJA/index/RangeSegment.hpp @@ -106,6 +106,8 @@ struct TypedRangeSegment // static_assert(std::is_signed_v, "TypedRangeSegment DiffT requires signed type."); + static_assert(!std::is_floating_point_v, + "TypedRangeSegment Type must be non floating point."); //@{ //! @name Types used in implementation based on template parameters. diff --git a/include/RAJA/policy/hip/kernel/Tile.hpp b/include/RAJA/policy/hip/kernel/Tile.hpp index 122d7b3ce3..4e41164695 100644 --- a/include/RAJA/policy/hip/kernel/Tile.hpp +++ b/include/RAJA/policy/hip/kernel/Tile.hpp @@ -92,7 +92,8 @@ struct HipStatementExecutor< segment_t orig_segment = segment; // Assign our new tiled segment - segment = orig_segment.slice(i, static_cast(chunk_size)); + segment = orig_segment.slice(typename segment_t::size_type(i), + typename segment_t::size_type {chunk_size}); // execute enclosed statements enclosed_stmts_t::exec(data, thread_active); @@ -115,10 +116,10 @@ struct HipStatementExecutor< data_t private_data = data; // Get original segment - auto& segment = camp::get(private_data.segment_tuple); - + auto& segment = camp::get(private_data.segment_tuple); + using segment_idx_t = typename camp::decay::size_type; // restrict to first tile - segment = segment.slice(0, static_cast(chunk_size)); + segment = segment.slice(segment_idx_t {0}, segment_idx_t {chunk_size}); // NOTE: We do not detect improper uses of direct_unchecked policies under // tiling. This happens when using a direct unchecked policy on a tiled @@ -183,7 +184,8 @@ struct HipStatementExecutor< segment_t orig_segment = segment; // Assign our new tiled segment - segment = orig_segment.slice(i, static_cast(chunk_size)); + segment = orig_segment.slice(typename segment_t::size_type(i), + typename segment_t::size_type {chunk_size}); // execute enclosed statements enclosed_stmts_t::exec(data, thread_active && have_work); @@ -206,10 +208,11 @@ struct HipStatementExecutor< data_t private_data = data; // Get original segment - auto& segment = camp::get(private_data.segment_tuple); - + auto& segment = camp::get(private_data.segment_tuple); + using segment_t = camp::decay; // restrict to first tile - segment = segment.slice(0, static_cast(chunk_size)); + segment = segment.slice(typename segment_t::size_type {0}, + typename segment_t::size_type {chunk_size}); LaunchDims enclosed_dims = enclosed_stmts_t::calculateDimensions(private_data); @@ -281,7 +284,8 @@ struct HipStatementExecutor< const bool have_work = (i < len); // Assign our new tiled segment - segment = orig_segment.slice(i, static_cast(chunk_size)); + segment = orig_segment.slice(typename segment_t::size_type(i), + typename segment_t::size_type {chunk_size}); // execute enclosed statements enclosed_stmts_t::exec(data, thread_active && have_work); @@ -305,10 +309,11 @@ struct HipStatementExecutor< data_t private_data = data; // Get original segment - auto& segment = camp::get(private_data.segment_tuple); - + auto& segment = camp::get(private_data.segment_tuple); + using segment_t = camp::decay; + using segment_idx_t = typename camp::decay::size_type; // restrict to first tile - segment = segment.slice(0, chunk_size); + segment = segment.slice(segment_idx_t {0}, segment_idx_t {chunk_size}); LaunchDims enclosed_dims = enclosed_stmts_t::calculateDimensions(private_data); @@ -375,7 +380,8 @@ struct HipStatementExecutor< { // Assign our new tiled segment - segment = orig_segment.slice(i, static_cast(chunk_size)); + segment = orig_segment.slice(typename segment_t::size_type(i), + typename segment_t::size_type {chunk_size}); // execute enclosed statements enclosed_stmts_t::exec(data, thread_active); @@ -399,10 +405,10 @@ struct HipStatementExecutor< data_t private_data = data; // Get original segment - auto& segment = camp::get(private_data.segment_tuple); - + auto& segment = camp::get(private_data.segment_tuple); + using segment_idx_t = typename camp::decay::size_type; // restrict to first tile - segment = segment.slice(0, chunk_size); + segment = segment.slice(segment_idx_t {0}, segment_idx_t {chunk_size}); LaunchDims enclosed_dims = enclosed_stmts_t::calculateDimensions(private_data); diff --git a/test/functional/forall/CombiningAdapter/tests/test-forall-CombiningAdapter-1D.hpp b/test/functional/forall/CombiningAdapter/tests/test-forall-CombiningAdapter-1D.hpp index 8fda3116f7..9286910152 100644 --- a/test/functional/forall/CombiningAdapter/tests/test-forall-CombiningAdapter-1D.hpp +++ b/test/functional/forall/CombiningAdapter/tests/test-forall-CombiningAdapter-1D.hpp @@ -46,7 +46,7 @@ void ForallCombiningAdapter1DTestImpl(INDEX_TYPE first, INDEX_TYPE last) { std::iota(test_array, test_array + RAJA::stripIndexType(N), first - first); - for (INDEX_TYPE i0 = INDEX_TYPE(0); i0 < N0; i0++) { + for (INDEX_TYPE i0 {0}; i0 < N0; i0++) { test_view(i0) = i0; } test_view(N) = INDEX_TYPE(0); @@ -69,7 +69,7 @@ void ForallCombiningAdapter1DTestImpl(INDEX_TYPE first, INDEX_TYPE last) working_res.memcpy(check_array, working_array, sizeof(INDEX_TYPE) * data_len); - for (INDEX_TYPE i = INDEX_TYPE(0); i <= N; i++) { + for (INDEX_TYPE i {0}; i <= N; i++) { ASSERT_EQ(test_view(i), check_view(i)); } diff --git a/test/functional/forall/CombiningAdapter/tests/test-forall-CombiningAdapter-2D.hpp b/test/functional/forall/CombiningAdapter/tests/test-forall-CombiningAdapter-2D.hpp index e205676a49..46c8e48940 100644 --- a/test/functional/forall/CombiningAdapter/tests/test-forall-CombiningAdapter-2D.hpp +++ b/test/functional/forall/CombiningAdapter/tests/test-forall-CombiningAdapter-2D.hpp @@ -48,8 +48,8 @@ void ForallCombiningAdapter2DTestImpl(INDEX_TYPE first0, INDEX_TYPE last0, { - for (INDEX_TYPE i0 = INDEX_TYPE(0); i0 < N0; i0++) { - for (INDEX_TYPE i1 = INDEX_TYPE(0); i1 < N1; i1++) { + for (INDEX_TYPE i0 {0}; i0 < N0; i0++) { + for (INDEX_TYPE i1 {0}; i1 < N1; i1++) { test_view(i0 * N1 + i1) = i0 * N1 + i1; } } @@ -75,7 +75,7 @@ void ForallCombiningAdapter2DTestImpl(INDEX_TYPE first0, INDEX_TYPE last0, working_res.memcpy(check_array, working_array, sizeof(INDEX_TYPE) * data_len); - for (INDEX_TYPE i = INDEX_TYPE(0); i <= N; i++) { + for (INDEX_TYPE i {0}; i <= N; i++) { ASSERT_EQ(test_view(i), check_view(i)); } diff --git a/test/functional/forall/CombiningAdapter/tests/test-forall-CombiningAdapter-3D.hpp b/test/functional/forall/CombiningAdapter/tests/test-forall-CombiningAdapter-3D.hpp index 5976054cdb..d3da89b56c 100644 --- a/test/functional/forall/CombiningAdapter/tests/test-forall-CombiningAdapter-3D.hpp +++ b/test/functional/forall/CombiningAdapter/tests/test-forall-CombiningAdapter-3D.hpp @@ -51,9 +51,9 @@ void ForallCombiningAdapter3DTestImpl(INDEX_TYPE first0, INDEX_TYPE last0, { - for (INDEX_TYPE i0 = INDEX_TYPE(0); i0 < N0; i0++) { - for (INDEX_TYPE i1 = INDEX_TYPE(0); i1 < N1; i1++) { - for (INDEX_TYPE i2 = INDEX_TYPE(0); i2 < N2; i2++) { + for (INDEX_TYPE i0 {0}; i0 < N0; i0++) { + for (INDEX_TYPE i1 {0}; i1 < N1; i1++) { + for (INDEX_TYPE i2 {0}; i2 < N2; i2++) { test_view(i0 * N1 * N2 + i1 * N2 + i2) = i0 * N1 * N2 + i1 * N2 + i2; } @@ -85,7 +85,7 @@ void ForallCombiningAdapter3DTestImpl(INDEX_TYPE first0, INDEX_TYPE last0, working_res.memcpy(check_array, working_array, sizeof(INDEX_TYPE) * data_len); - for (INDEX_TYPE i = INDEX_TYPE(0); i <= N; i++) { + for (INDEX_TYPE i {0}; i <= N; i++) { ASSERT_EQ(test_view(i), check_view(i)); } diff --git a/test/functional/forall/indexset-view/tests/test-forall-IcountIndexSetView.hpp b/test/functional/forall/indexset-view/tests/test-forall-IcountIndexSetView.hpp index 833d5b013b..dbf33bd4a9 100644 --- a/test/functional/forall/indexset-view/tests/test-forall-IcountIndexSetView.hpp +++ b/test/functional/forall/indexset-view/tests/test-forall-IcountIndexSetView.hpp @@ -66,21 +66,21 @@ void ForallIcountIndexSetViewTestImpl() view_type work_view(working_array, N); view_type check_view(check_array, N); - INDEX_TYPE ticount = 0; + INDEX_TYPE ticount {0}; for (size_t i = 0; i < is_indices.size(); ++i) { test_view(ticount++) = is_indices[i]; } RAJA::forall_Icount(iset, - [=] RAJA_HOST_DEVICE(INDEX_TYPE icount, INDEX_TYPE idx) { - work_view( icount ) = idx; + [=] RAJA_HOST_DEVICE(auto icount, INDEX_TYPE idx) { + work_view( INDEX_TYPE(icount) ) = idx; }); working_res.memcpy(check_array, working_array, sizeof(INDEX_TYPE) * RAJA::stripIndexType(N)); // - for (INDEX_TYPE i = 0; i < N; i++) { + for (INDEX_TYPE i {0}; i < N; i++) { ASSERT_EQ(test_view(i), check_view(i)); } diff --git a/test/functional/forall/indexset-view/tests/test-forall-IndexSetView.hpp b/test/functional/forall/indexset-view/tests/test-forall-IndexSetView.hpp index 8191e80df0..f419e0f3e3 100644 --- a/test/functional/forall/indexset-view/tests/test-forall-IndexSetView.hpp +++ b/test/functional/forall/indexset-view/tests/test-forall-IndexSetView.hpp @@ -77,7 +77,7 @@ void ForallIndexSetViewTestImpl() sizeof(INDEX_TYPE) * RAJA::stripIndexType(N)); // - for (INDEX_TYPE i = 0; i < N; i++) { + for (INDEX_TYPE i {0}; i < N; i++) { ASSERT_EQ(test_view(i), check_view(i)); } diff --git a/test/functional/forall/indexset/tests/test-forall-IcountIndexSet.hpp b/test/functional/forall/indexset/tests/test-forall-IcountIndexSet.hpp index 6c75e71597..db748b92ea 100644 --- a/test/functional/forall/indexset/tests/test-forall-IcountIndexSet.hpp +++ b/test/functional/forall/indexset/tests/test-forall-IcountIndexSet.hpp @@ -64,20 +64,20 @@ void ForallIcountIndexSetTestImpl() view_type work_view(working_array, N); view_type check_view(check_array, N); - INDEX_TYPE ticount = 0; + INDEX_TYPE ticount {0}; for (size_t i = 0; i < is_indices.size(); ++i) { test_view(ticount++) = is_indices[i]; } RAJA::forall_Icount(EXEC_POLICY(), iset, - [=] RAJA_HOST_DEVICE(INDEX_TYPE icount, INDEX_TYPE idx) { - work_view(icount) = idx; + [=] RAJA_HOST_DEVICE(auto icount, INDEX_TYPE idx) { + work_view(INDEX_TYPE(icount)) = idx; }); working_res.memcpy(check_array, working_array, sizeof(INDEX_TYPE) * RAJA::stripIndexType(N)); - for (INDEX_TYPE i = 0; i < N; i++) { + for (INDEX_TYPE i {0}; i < N; i++) { ASSERT_EQ(test_view(i), check_view(i)); } diff --git a/test/functional/forall/indexset/tests/test-forall-IndexSet.hpp b/test/functional/forall/indexset/tests/test-forall-IndexSet.hpp index 3bd9c3fb6d..e2b4e2fcf6 100644 --- a/test/functional/forall/indexset/tests/test-forall-IndexSet.hpp +++ b/test/functional/forall/indexset/tests/test-forall-IndexSet.hpp @@ -75,7 +75,7 @@ void ForallIndexSetTestImpl() sizeof(INDEX_TYPE) * RAJA::stripIndexType(N)); // - for (INDEX_TYPE i = 0; i < N; i++) { + for (INDEX_TYPE i {0}; i < N; i++) { ASSERT_EQ(test_view(i), check_view(i)); } diff --git a/test/functional/forall/messages/tests/test-forall-basic-msg.hpp b/test/functional/forall/messages/tests/test-forall-basic-msg.hpp index e3959d8c9c..5dc5bf70b6 100644 --- a/test/functional/forall/messages/tests/test-forall-basic-msg.hpp +++ b/test/functional/forall/messages/tests/test-forall-basic-msg.hpp @@ -39,12 +39,12 @@ void ForallMsgBasicTestImpl(const SEG_TYPE& seg, const int modval = 100; - for (IDX_TYPE i = 0; i < data_len; ++i) { + for (IDX_TYPE i {0}; i < data_len; ++i) { test_array[i] = static_cast( rand() % modval ); } DATA_TYPE ref_max = 0; - for (IDX_TYPE i = 0; i < idx_len; ++i) { + for (IDX_TYPE i {0}; i < idx_len; ++i) { ref_max = std::max(ref_max, test_array[ seg_idx[i] ]); } @@ -139,9 +139,9 @@ TYPED_TEST_P(ForallMsgBasicTest, MsgBasicForall) // List segment tests seg_idx.clear(); - IDX_TYPE last = 10567; + IDX_TYPE last {10567}; srand( time(NULL) ); - for (IDX_TYPE i = 0; i < last; ++i) { + for (IDX_TYPE i {0}; i < last; ++i) { IDX_TYPE randval = IDX_TYPE( rand() % RAJA::stripIndexType(last) ); if ( i < randval ) { seg_idx.push_back(i); diff --git a/test/functional/forall/multi-reduce-basic/tests/test-forall-basic-MultiReduce.hpp b/test/functional/forall/multi-reduce-basic/tests/test-forall-basic-MultiReduce.hpp index a5a3a5833a..468118fd1b 100644 --- a/test/functional/forall/multi-reduce-basic/tests/test-forall-basic-MultiReduce.hpp +++ b/test/functional/forall/multi-reduce-basic/tests/test-forall-basic-MultiReduce.hpp @@ -66,7 +66,7 @@ ForallMultiReduceBasicTestImpl(const SEG_TYPE& seg, IDX_TYPE* check_bins; IDX_TYPE* test_bins; - IDX_TYPE data_len = 0; + IDX_TYPE data_len {0}; allocateForallTestData(idx_range+1, working_res, @@ -74,14 +74,14 @@ ForallMultiReduceBasicTestImpl(const SEG_TYPE& seg, &check_range, &test_range); - for (IDX_TYPE i = 0; i < idx_range+1; ++i) { + for (IDX_TYPE i {0}; i < idx_range+1; ++i) { test_range[i] = ~IDX_TYPE(0); } { std::uniform_int_distribution work_per_iterate_distribution(0, num_bins); - for (IDX_TYPE i = 0; i < idx_len; ++i) { + for (IDX_TYPE i {0}; i < idx_len; ++i) { IDX_TYPE idx = seg_idx[i]; test_range[idx] = data_len; data_len += work_per_iterate_distribution(rngen); @@ -108,7 +108,7 @@ ForallMultiReduceBasicTestImpl(const SEG_TYPE& seg, std::uniform_int_distribution bin_distribution(0, num_bins-1); - for (IDX_TYPE i = 0; i < data_len; ++i) { + for (IDX_TYPE i {0}; i < data_len; ++i) { test_array[i] = DATA_TYPE(array_int_distribution(rngen)); // this may use the same bin multiple times per iterate @@ -128,7 +128,7 @@ ForallMultiReduceBasicTestImpl(const SEG_TYPE& seg, { std::vector ref_vals(num_bins, ABSTRACTION::identity(red)); - for (IDX_TYPE i = 0; i < data_len; ++i) { + for (IDX_TYPE i {0}; i < data_len; ++i) { ref_vals[test_bins[i]] = ABSTRACTION::combine(ref_vals[test_bins[i]], test_array[i]); } @@ -157,7 +157,7 @@ ForallMultiReduceBasicTestImpl(const SEG_TYPE& seg, const int nloops = 2; for (int j = 0; j < nloops; ++j) { - for (IDX_TYPE i = 0; i < data_len; ++i) { + for (IDX_TYPE i {0}; i < data_len; ++i) { ref_vals[test_bins[i]] = ABSTRACTION::combine(ref_vals[test_bins[i]], test_array[i]); } @@ -184,7 +184,7 @@ ForallMultiReduceBasicTestImpl(const SEG_TYPE& seg, std::uniform_int_distribution, std::uniform_real_distribution> array_flt_distribution(0, modval-1); - for (IDX_TYPE i = 0; i < data_len; ++i) { + for (IDX_TYPE i {0}; i < data_len; ++i) { test_array[i] = DATA_TYPE(array_flt_distribution(rngen)); } working_res.memcpy(working_array, test_array, sizeof(DATA_TYPE) * data_len); @@ -289,9 +289,9 @@ TYPED_TEST_P(ForallMultiReduceBasicTest, MultiReduceBasicForall) // List segment test seg_idx.clear(); - IDX_TYPE last = 10567; + IDX_TYPE last {10567}; std::uniform_int_distribution dist(0, last-1); - for (IDX_TYPE i = 0; i < last; ++i) { + for (IDX_TYPE i {0}; i < last; ++i) { IDX_TYPE randval = dist(rngen); if ( i < randval ) { seg_idx.push_back(i); diff --git a/test/functional/forall/reduce-basic/tests/test-forall-basic-ReduceBitAnd.hpp b/test/functional/forall/reduce-basic/tests/test-forall-basic-ReduceBitAnd.hpp index 0c5aa8a623..667f54cc6a 100644 --- a/test/functional/forall/reduce-basic/tests/test-forall-basic-ReduceBitAnd.hpp +++ b/test/functional/forall/reduce-basic/tests/test-forall-basic-ReduceBitAnd.hpp @@ -40,7 +40,7 @@ void ForallReduceBitAndBasicTestImpl(const SEG_TYPE& seg, // // First a simple non-trivial test that is mildly interesting // - for (IDX_TYPE i = 0; i < data_len; ++i) { + for (IDX_TYPE i {0}; i < data_len; ++i) { test_array[i] = 13; } working_res.memcpy(working_array, test_array, sizeof(DATA_TYPE) * data_len); @@ -64,13 +64,13 @@ void ForallReduceBitAndBasicTestImpl(const SEG_TYPE& seg, const int modval = 100; - for (IDX_TYPE i = 0; i < data_len; ++i) { + for (IDX_TYPE i {0}; i < data_len; ++i) { test_array[i] = static_cast( rand() % modval ); } working_res.memcpy(working_array, test_array, sizeof(DATA_TYPE) * data_len); DATA_TYPE ref_and = 0; - for (IDX_TYPE i = 0; i < idx_len; ++i) { + for (IDX_TYPE i {0}; i < idx_len; ++i) { ref_and &= test_array[ seg_idx[i] ]; } @@ -168,9 +168,9 @@ TYPED_TEST_P(ForallReduceBitAndBasicTest, ReduceBitAndBasicForall) // List segment tests seg_idx.clear(); - IDX_TYPE last = 10567; + IDX_TYPE last {10567}; srand( time(NULL) ); - for (IDX_TYPE i = 0; i < last; ++i) { + for (IDX_TYPE i {0}; i < last; ++i) { IDX_TYPE randval = IDX_TYPE( rand() % RAJA::stripIndexType(last) ); if ( i < randval ) { seg_idx.push_back(i); diff --git a/test/functional/forall/reduce-basic/tests/test-forall-basic-ReduceBitOr.hpp b/test/functional/forall/reduce-basic/tests/test-forall-basic-ReduceBitOr.hpp index 1114abfbcb..dd876e0dcd 100644 --- a/test/functional/forall/reduce-basic/tests/test-forall-basic-ReduceBitOr.hpp +++ b/test/functional/forall/reduce-basic/tests/test-forall-basic-ReduceBitOr.hpp @@ -40,7 +40,7 @@ void ForallReduceBitOrBasicTestImpl(const SEG_TYPE& seg, // // First a simple non-trivial test that is mildly interesting // - for (IDX_TYPE i = 0; i < data_len; ++i) { + for (IDX_TYPE i {0}; i < data_len; ++i) { test_array[i] = 9; } working_res.memcpy(working_array, test_array, sizeof(DATA_TYPE) * data_len); @@ -64,13 +64,13 @@ void ForallReduceBitOrBasicTestImpl(const SEG_TYPE& seg, const int modval = 100; - for (IDX_TYPE i = 0; i < data_len; ++i) { + for (IDX_TYPE i {0}; i < data_len; ++i) { test_array[i] = static_cast( rand() % modval ); } working_res.memcpy(working_array, test_array, sizeof(DATA_TYPE) * data_len); DATA_TYPE ref_or = 0; - for (IDX_TYPE i = 0; i < idx_len; ++i) { + for (IDX_TYPE i {0}; i < idx_len; ++i) { ref_or |= test_array[ seg_idx[i] ]; } @@ -169,9 +169,9 @@ TYPED_TEST_P(ForallReduceBitOrBasicTest, ReduceBitOrBasicForall) // List segment tests seg_idx.clear(); - IDX_TYPE last = 10567; + IDX_TYPE last {10567}; srand( time(NULL) ); - for (IDX_TYPE i = 0; i < last; ++i) { + for (IDX_TYPE i {0}; i < last; ++i) { IDX_TYPE randval = IDX_TYPE( rand() % RAJA::stripIndexType(last) ); if ( i < randval ) { seg_idx.push_back(i); diff --git a/test/functional/forall/reduce-basic/tests/test-forall-basic-ReduceMax.hpp b/test/functional/forall/reduce-basic/tests/test-forall-basic-ReduceMax.hpp index f77250d421..2c1932f9e4 100644 --- a/test/functional/forall/reduce-basic/tests/test-forall-basic-ReduceMax.hpp +++ b/test/functional/forall/reduce-basic/tests/test-forall-basic-ReduceMax.hpp @@ -41,12 +41,12 @@ void ForallReduceMaxBasicTestImpl(const SEG_TYPE& seg, const DATA_TYPE max_init = -1; const DATA_TYPE big_max = modval + 1; - for (IDX_TYPE i = 0; i < data_len; ++i) { + for (IDX_TYPE i {0}; i < data_len; ++i) { test_array[i] = static_cast( rand() % modval ); } DATA_TYPE ref_max = max_init; - for (IDX_TYPE i = 0; i < idx_len; ++i) { + for (IDX_TYPE i {0}; i < idx_len; ++i) { ref_max = RAJA_MAX(test_array[ seg_idx[i] ], ref_max); } @@ -152,9 +152,9 @@ TYPED_TEST_P(ForallReduceMaxBasicTest, ReduceMaxBasicForall) // List segment tests seg_idx.clear(); - IDX_TYPE last = 10567; + IDX_TYPE last {10567}; srand( time(NULL) ); - for (IDX_TYPE i = 0; i < last; ++i) { + for (IDX_TYPE i {0}; i < last; ++i) { IDX_TYPE randval = IDX_TYPE( rand() % RAJA::stripIndexType(last) ); if ( i < randval ) { seg_idx.push_back(i); diff --git a/test/functional/forall/reduce-basic/tests/test-forall-basic-ReduceMaxLoc.hpp b/test/functional/forall/reduce-basic/tests/test-forall-basic-ReduceMaxLoc.hpp index a6bcc2c9b7..fdb9840ee3 100644 --- a/test/functional/forall/reduce-basic/tests/test-forall-basic-ReduceMaxLoc.hpp +++ b/test/functional/forall/reduce-basic/tests/test-forall-basic-ReduceMaxLoc.hpp @@ -39,19 +39,19 @@ void ForallReduceMaxLocBasicTestImpl(const SEG_TYPE& seg, const int modval = 100; const DATA_TYPE max_init = -modval; - const IDX_TYPE maxloc_init = -1; + const IDX_TYPE maxloc_init {-1}; const IDX_TYPE maxloc_idx = seg_idx[ idx_len * 2/3 ]; const DATA_TYPE big_max = modval+1; const IDX_TYPE big_maxloc = maxloc_init; - for (IDX_TYPE i = 0; i < data_len; ++i) { + for (IDX_TYPE i {0}; i < data_len; ++i) { test_array[i] = static_cast( rand() % modval ); } test_array[maxloc_idx] = static_cast(big_max); DATA_TYPE ref_max = max_init; IDX_TYPE ref_maxloc = maxloc_init; - for (IDX_TYPE i = 0; i < idx_len; ++i) { + for (IDX_TYPE i {0}; i < idx_len; ++i) { if ( test_array[ seg_idx[i] ] > ref_max ) { ref_max = test_array[ seg_idx[i] ]; ref_maxloc = seg_idx[i]; @@ -166,9 +166,9 @@ TYPED_TEST_P(ForallReduceMaxLocBasicTest, ReduceMaxLocBasicForall) // List segment tests seg_idx.clear(); - IDX_TYPE last = 10567; + IDX_TYPE last {10567}; srand( time(NULL) ); - for (IDX_TYPE i = 0; i < last; ++i) { + for (IDX_TYPE i {0}; i < last; ++i) { IDX_TYPE randval = IDX_TYPE( rand() % RAJA::stripIndexType(last) ); if ( i < randval ) { seg_idx.push_back(i); diff --git a/test/functional/forall/reduce-basic/tests/test-forall-basic-ReduceMin.hpp b/test/functional/forall/reduce-basic/tests/test-forall-basic-ReduceMin.hpp index d3813bc7e3..40ab93ea81 100644 --- a/test/functional/forall/reduce-basic/tests/test-forall-basic-ReduceMin.hpp +++ b/test/functional/forall/reduce-basic/tests/test-forall-basic-ReduceMin.hpp @@ -41,12 +41,12 @@ void ForallReduceMinBasicTestImpl(const SEG_TYPE& seg, const DATA_TYPE min_init = modval+1; const DATA_TYPE small_min = -modval; - for (IDX_TYPE i = 0; i < data_len; ++i) { + for (IDX_TYPE i {0}; i < data_len; ++i) { test_array[i] = static_cast( rand() % modval ); } DATA_TYPE ref_min = min_init; - for (IDX_TYPE i = 0; i < idx_len; ++i) { + for (IDX_TYPE i {0}; i < idx_len; ++i) { ref_min = RAJA_MIN(test_array[ seg_idx[i] ], ref_min); } @@ -156,9 +156,9 @@ TYPED_TEST_P(ForallReduceMinBasicTest, ReduceMinBasicForall) // List segment tests seg_idx.clear(); - IDX_TYPE last = 10567; + IDX_TYPE last {10567}; srand( time(NULL) ); - for (IDX_TYPE i = 0; i < last; ++i) { + for (IDX_TYPE i {0}; i < last; ++i) { IDX_TYPE randval = IDX_TYPE( rand() % RAJA::stripIndexType(last) ); if ( i < randval ) { seg_idx.push_back(i); diff --git a/test/functional/forall/reduce-basic/tests/test-forall-basic-ReduceMinLoc.hpp b/test/functional/forall/reduce-basic/tests/test-forall-basic-ReduceMinLoc.hpp index 9c8a766816..166d3ff3cc 100644 --- a/test/functional/forall/reduce-basic/tests/test-forall-basic-ReduceMinLoc.hpp +++ b/test/functional/forall/reduce-basic/tests/test-forall-basic-ReduceMinLoc.hpp @@ -39,19 +39,19 @@ void ForallReduceMinLocBasicTestImpl(const SEG_TYPE& seg, const int modval = 100; const DATA_TYPE min_init = modval+1; - const IDX_TYPE minloc_init = -1; + const IDX_TYPE minloc_init {-1}; const IDX_TYPE minloc_idx = seg_idx[ idx_len * 2/3 ]; const DATA_TYPE small_min = -modval; const IDX_TYPE small_minloc = minloc_init; - for (IDX_TYPE i = 0; i < data_len; ++i) { + for (IDX_TYPE i {0}; i < data_len; ++i) { test_array[i] = static_cast( rand() % modval ); } test_array[minloc_idx] = static_cast(small_min); DATA_TYPE ref_min = min_init; IDX_TYPE ref_minloc = minloc_init; - for (IDX_TYPE i = 0; i < idx_len; ++i) { + for (IDX_TYPE i {0}; i < idx_len; ++i) { if ( test_array[ seg_idx[i] ] < ref_min ) { ref_min = test_array[ seg_idx[i] ]; ref_minloc = seg_idx[i]; @@ -166,9 +166,9 @@ TYPED_TEST_P(ForallReduceMinLocBasicTest, ReduceMinLocBasicForall) // List segment tests seg_idx.clear(); - IDX_TYPE last = 10567; + IDX_TYPE last {10567}; srand( time(NULL) ); - for (IDX_TYPE i = 0; i < last; ++i) { + for (IDX_TYPE i {0}; i < last; ++i) { IDX_TYPE randval = IDX_TYPE( rand() % RAJA::stripIndexType(last) ); if ( i < randval ) { seg_idx.push_back(i); diff --git a/test/functional/forall/reduce-basic/tests/test-forall-basic-ReduceSum.hpp b/test/functional/forall/reduce-basic/tests/test-forall-basic-ReduceSum.hpp index 667a1f4e19..c274497b69 100644 --- a/test/functional/forall/reduce-basic/tests/test-forall-basic-ReduceSum.hpp +++ b/test/functional/forall/reduce-basic/tests/test-forall-basic-ReduceSum.hpp @@ -39,12 +39,12 @@ void ForallReduceSumBasicTestImpl(const SEG_TYPE& seg, const int modval = 100; - for (IDX_TYPE i = 0; i < data_len; ++i) { + for (IDX_TYPE i {0}; i < data_len; ++i) { test_array[i] = static_cast( rand() % modval ); } DATA_TYPE ref_sum = 0; - for (IDX_TYPE i = 0; i < idx_len; ++i) { + for (IDX_TYPE i {0}; i < idx_len; ++i) { ref_sum += test_array[ seg_idx[i] ]; } @@ -147,9 +147,9 @@ TYPED_TEST_P(ForallReduceSumBasicTest, ReduceSumBasicForall) // List segment tests seg_idx.clear(); - IDX_TYPE last = 10567; + IDX_TYPE last {10567}; srand( time(NULL) ); - for (IDX_TYPE i = 0; i < last; ++i) { + for (IDX_TYPE i {0}; i < last; ++i) { IDX_TYPE randval = IDX_TYPE( rand() % RAJA::stripIndexType(last) ); if ( i < randval ) { seg_idx.push_back(i); diff --git a/test/functional/forall/reduce-basic/tests/test-forall-basic-expt-ReduceBitAnd.hpp b/test/functional/forall/reduce-basic/tests/test-forall-basic-expt-ReduceBitAnd.hpp index a0aea57e8d..6e169834a7 100644 --- a/test/functional/forall/reduce-basic/tests/test-forall-basic-expt-ReduceBitAnd.hpp +++ b/test/functional/forall/reduce-basic/tests/test-forall-basic-expt-ReduceBitAnd.hpp @@ -40,7 +40,7 @@ void ForallReduceBitAndBasicTestImpl(const SEG_TYPE& seg, // // First a simple non-trivial test that is mildly interesting // - for (IDX_TYPE i = 0; i < data_len; ++i) { + for (IDX_TYPE i {0}; i < data_len; ++i) { test_array[i] = 13; } working_res.memcpy(working_array, test_array, sizeof(DATA_TYPE) * data_len); @@ -63,13 +63,13 @@ void ForallReduceBitAndBasicTestImpl(const SEG_TYPE& seg, const int modval = 100; - for (IDX_TYPE i = 0; i < data_len; ++i) { + for (IDX_TYPE i {0}; i < data_len; ++i) { test_array[i] = static_cast( rand() % modval ); } working_res.memcpy(working_array, test_array, sizeof(DATA_TYPE) * data_len); DATA_TYPE ref_and = 0; - for (IDX_TYPE i = 0; i < idx_len; ++i) { + for (IDX_TYPE i {0}; i < idx_len; ++i) { ref_and &= test_array[ seg_idx[i] ]; } @@ -170,9 +170,9 @@ TYPED_TEST_P(ForallReduceBitAndBasicTest, ReduceBitAndBasicForall) // List segment tests seg_idx.clear(); - IDX_TYPE last = 10567; + IDX_TYPE last {10567}; srand( time(NULL) ); - for (IDX_TYPE i = 0; i < last; ++i) { + for (IDX_TYPE i {0}; i < last; ++i) { IDX_TYPE randval = IDX_TYPE( rand() % RAJA::stripIndexType(last) ); if ( i < randval ) { seg_idx.push_back(i); diff --git a/test/functional/forall/reduce-basic/tests/test-forall-basic-expt-ReduceBitOr.hpp b/test/functional/forall/reduce-basic/tests/test-forall-basic-expt-ReduceBitOr.hpp index a4b1a0bd79..ae1982d07b 100644 --- a/test/functional/forall/reduce-basic/tests/test-forall-basic-expt-ReduceBitOr.hpp +++ b/test/functional/forall/reduce-basic/tests/test-forall-basic-expt-ReduceBitOr.hpp @@ -40,7 +40,7 @@ void ForallReduceBitOrBasicTestImpl(const SEG_TYPE& seg, // // First a simple non-trivial test that is mildly interesting // - for (IDX_TYPE i = 0; i < data_len; ++i) { + for (IDX_TYPE i {0}; i < data_len; ++i) { test_array[i] = 9; } working_res.memcpy(working_array, test_array, sizeof(DATA_TYPE) * data_len); @@ -63,13 +63,13 @@ void ForallReduceBitOrBasicTestImpl(const SEG_TYPE& seg, const int modval = 100; - for (IDX_TYPE i = 0; i < data_len; ++i) { + for (IDX_TYPE i {0}; i < data_len; ++i) { test_array[i] = static_cast( rand() % modval ); } working_res.memcpy(working_array, test_array, sizeof(DATA_TYPE) * data_len); DATA_TYPE ref_or = 0; - for (IDX_TYPE i = 0; i < idx_len; ++i) { + for (IDX_TYPE i {0}; i < idx_len; ++i) { ref_or |= test_array[ seg_idx[i] ]; } @@ -170,9 +170,9 @@ TYPED_TEST_P(ForallReduceBitOrBasicTest, ReduceBitOrBasicForall) // List segment tests seg_idx.clear(); - IDX_TYPE last = 10567; + IDX_TYPE last {10567}; srand( time(NULL) ); - for (IDX_TYPE i = 0; i < last; ++i) { + for (IDX_TYPE i {0}; i < last; ++i) { IDX_TYPE randval = IDX_TYPE( rand() % RAJA::stripIndexType(last) ); if ( i < randval ) { seg_idx.push_back(i); diff --git a/test/functional/forall/reduce-basic/tests/test-forall-basic-expt-ReduceMax.hpp b/test/functional/forall/reduce-basic/tests/test-forall-basic-expt-ReduceMax.hpp index 263f7cec81..8a652fdbe0 100644 --- a/test/functional/forall/reduce-basic/tests/test-forall-basic-expt-ReduceMax.hpp +++ b/test/functional/forall/reduce-basic/tests/test-forall-basic-expt-ReduceMax.hpp @@ -41,12 +41,12 @@ void ForallReduceMaxBasicTestImpl(const SEG_TYPE& seg, const DATA_TYPE max_init = -1; const DATA_TYPE big_max = modval + 1; - for (IDX_TYPE i = 0; i < data_len; ++i) { + for (IDX_TYPE i {0}; i < data_len; ++i) { test_array[i] = static_cast( rand() % modval ); } DATA_TYPE ref_max = max_init; - for (IDX_TYPE i = 0; i < idx_len; ++i) { + for (IDX_TYPE i {0}; i < idx_len; ++i) { ref_max = RAJA_MAX(test_array[ seg_idx[i] ], ref_max); } @@ -154,9 +154,9 @@ TYPED_TEST_P(ForallReduceMaxBasicTest, ReduceMaxBasicForall) // List segment tests seg_idx.clear(); - IDX_TYPE last = 10567; + IDX_TYPE last {10567}; srand( time(NULL) ); - for (IDX_TYPE i = 0; i < last; ++i) { + for (IDX_TYPE i {0}; i < last; ++i) { IDX_TYPE randval = IDX_TYPE( rand() % RAJA::stripIndexType(last) ); if ( i < randval ) { seg_idx.push_back(i); diff --git a/test/functional/forall/reduce-basic/tests/test-forall-basic-expt-ReduceMaxLoc.hpp b/test/functional/forall/reduce-basic/tests/test-forall-basic-expt-ReduceMaxLoc.hpp index 2d089f32e1..46a8047263 100644 --- a/test/functional/forall/reduce-basic/tests/test-forall-basic-expt-ReduceMaxLoc.hpp +++ b/test/functional/forall/reduce-basic/tests/test-forall-basic-expt-ReduceMaxLoc.hpp @@ -37,19 +37,19 @@ void ForallReduceMaxLocBasicTestImpl(const SEG_TYPE& seg, const int modval = 100; const DATA_TYPE max_init = -modval; - const IDX_TYPE maxloc_init = -1; + const IDX_TYPE maxloc_init {-1}; const IDX_TYPE maxloc_idx = seg_idx[ idx_len * 2/3 ]; const DATA_TYPE big_max = modval*10; const IDX_TYPE big_maxloc = maxloc_init; - for (IDX_TYPE i = 0; i < data_len; ++i) { + for (IDX_TYPE i {0}; i < data_len; ++i) { test_array[i] = static_cast( 1000 % modval ); } test_array[maxloc_idx] = static_cast(big_max); DATA_TYPE ref_max = max_init; IDX_TYPE ref_maxloc = maxloc_init; - for (IDX_TYPE i = 0; i < idx_len; ++i) { + for (IDX_TYPE i {0}; i < idx_len; ++i) { if ( test_array[ seg_idx[i] ] > ref_max ) { ref_max = test_array[ seg_idx[i] ]; ref_maxloc = seg_idx[i]; @@ -158,9 +158,9 @@ TYPED_TEST_P(ForallReduceMaxLocBasicTest, ReduceMaxLocBasicForall) // List segment tests seg_idx.clear(); - IDX_TYPE last = 10567; + IDX_TYPE last {10567}; srand( time(NULL) ); - for (IDX_TYPE i = 0; i < last; ++i) { + for (IDX_TYPE i {0}; i < last; ++i) { IDX_TYPE randval = IDX_TYPE( rand() % RAJA::stripIndexType(last) ); if ( i < randval ) { seg_idx.push_back(i); diff --git a/test/functional/forall/reduce-basic/tests/test-forall-basic-expt-ReduceMaxLocAlt.hpp b/test/functional/forall/reduce-basic/tests/test-forall-basic-expt-ReduceMaxLocAlt.hpp index 7cec1cd5cc..22e7c230fb 100644 --- a/test/functional/forall/reduce-basic/tests/test-forall-basic-expt-ReduceMaxLocAlt.hpp +++ b/test/functional/forall/reduce-basic/tests/test-forall-basic-expt-ReduceMaxLocAlt.hpp @@ -37,19 +37,19 @@ void ForallReduceMaxLocAltBasicTestImpl(const SEG_TYPE& seg, const int modval = 100; const DATA_TYPE max_init = -modval; - const IDX_TYPE maxloc_init = -1; + const IDX_TYPE maxloc_init {-1}; const IDX_TYPE maxloc_idx = seg_idx[ idx_len * 2/3 ]; const DATA_TYPE big_max = modval*10; const IDX_TYPE big_maxloc = maxloc_init; - for (IDX_TYPE i = 0; i < data_len; ++i) { + for (IDX_TYPE i {0}; i < data_len; ++i) { test_array[i] = static_cast( 1000 % modval ); } test_array[maxloc_idx] = static_cast(big_max); DATA_TYPE ref_max = max_init; IDX_TYPE ref_maxloc = maxloc_init; - for (IDX_TYPE i = 0; i < idx_len; ++i) { + for (IDX_TYPE i {0}; i < idx_len; ++i) { if ( test_array[ seg_idx[i] ] > ref_max ) { ref_max = test_array[ seg_idx[i] ]; ref_maxloc = seg_idx[i]; @@ -179,9 +179,9 @@ TYPED_TEST_P(ForallReduceMaxLocAltBasicTest, ReduceMaxLocAltBasicForall) // List segment tests seg_idx.clear(); - IDX_TYPE last = 10567; + IDX_TYPE last {10567}; srand( time(NULL) ); - for (IDX_TYPE i = 0; i < last; ++i) { + for (IDX_TYPE i {0}; i < last; ++i) { IDX_TYPE randval = IDX_TYPE( rand() % RAJA::stripIndexType(last) ); if ( i < randval ) { seg_idx.push_back(i); diff --git a/test/functional/forall/reduce-basic/tests/test-forall-basic-expt-ReduceMin.hpp b/test/functional/forall/reduce-basic/tests/test-forall-basic-expt-ReduceMin.hpp index d17c7904ec..479eb116e4 100644 --- a/test/functional/forall/reduce-basic/tests/test-forall-basic-expt-ReduceMin.hpp +++ b/test/functional/forall/reduce-basic/tests/test-forall-basic-expt-ReduceMin.hpp @@ -41,12 +41,12 @@ void ForallReduceMinBasicTestImpl(const SEG_TYPE& seg, const DATA_TYPE min_init = modval+1; const DATA_TYPE small_min = -modval; - for (IDX_TYPE i = 0; i < data_len; ++i) { + for (IDX_TYPE i {0}; i < data_len; ++i) { test_array[i] = static_cast( rand() % modval ); } DATA_TYPE ref_min = min_init; - for (IDX_TYPE i = 0; i < idx_len; ++i) { + for (IDX_TYPE i {0}; i < idx_len; ++i) { ref_min = RAJA_MIN(test_array[ seg_idx[i] ], ref_min); } @@ -154,9 +154,9 @@ TYPED_TEST_P(ForallReduceMinBasicTest, ReduceMinBasicForall) // List segment tests seg_idx.clear(); - IDX_TYPE last = 10567; + IDX_TYPE last {10567}; srand( time(NULL) ); - for (IDX_TYPE i = 0; i < last; ++i) { + for (IDX_TYPE i {0}; i < last; ++i) { IDX_TYPE randval = IDX_TYPE( rand() % RAJA::stripIndexType(last) ); if ( i < randval ) { seg_idx.push_back(i); diff --git a/test/functional/forall/reduce-basic/tests/test-forall-basic-expt-ReduceMinLoc.hpp b/test/functional/forall/reduce-basic/tests/test-forall-basic-expt-ReduceMinLoc.hpp index d28e0f55eb..60d30a4d74 100644 --- a/test/functional/forall/reduce-basic/tests/test-forall-basic-expt-ReduceMinLoc.hpp +++ b/test/functional/forall/reduce-basic/tests/test-forall-basic-expt-ReduceMinLoc.hpp @@ -37,19 +37,19 @@ void ForallReduceMinLocBasicTestImpl(const SEG_TYPE& seg, const int modval = 100; const DATA_TYPE min_init = modval+1; - const IDX_TYPE minloc_init = -1; + const IDX_TYPE minloc_init {-1}; const IDX_TYPE minloc_idx = seg_idx[ idx_len * 2/3 ]; const DATA_TYPE small_min = -modval; const IDX_TYPE small_minloc = minloc_init; - for (IDX_TYPE i = 0; i < data_len; ++i) { + for (IDX_TYPE i {0}; i < data_len; ++i) { test_array[i] = static_cast( rand() % modval ); } test_array[minloc_idx] = static_cast(small_min); DATA_TYPE ref_min = min_init; IDX_TYPE ref_minloc = minloc_init; - for (IDX_TYPE i = 0; i < idx_len; ++i) { + for (IDX_TYPE i {0}; i < idx_len; ++i) { if ( test_array[ seg_idx[i] ] < ref_min ) { ref_min = test_array[ seg_idx[i] ]; ref_minloc = seg_idx[i]; @@ -158,9 +158,9 @@ TYPED_TEST_P(ForallReduceMinLocBasicTest, ReduceMinLocBasicForall) // List segment tests seg_idx.clear(); - IDX_TYPE last = 10567; + IDX_TYPE last {10567}; srand( time(NULL) ); - for (IDX_TYPE i = 0; i < last; ++i) { + for (IDX_TYPE i {0}; i < last; ++i) { IDX_TYPE randval = IDX_TYPE( rand() % RAJA::stripIndexType(last) ); if ( i < randval ) { seg_idx.push_back(i); diff --git a/test/functional/forall/reduce-basic/tests/test-forall-basic-expt-ReduceMinLocAlt.hpp b/test/functional/forall/reduce-basic/tests/test-forall-basic-expt-ReduceMinLocAlt.hpp index 497280d389..2eba28f596 100644 --- a/test/functional/forall/reduce-basic/tests/test-forall-basic-expt-ReduceMinLocAlt.hpp +++ b/test/functional/forall/reduce-basic/tests/test-forall-basic-expt-ReduceMinLocAlt.hpp @@ -37,19 +37,19 @@ void ForallReduceMinLocAltBasicTestImpl(const SEG_TYPE& seg, const int modval = 100; const DATA_TYPE min_init = modval+1; - const IDX_TYPE minloc_init = -1; + const IDX_TYPE minloc_init {-1}; const IDX_TYPE minloc_idx = seg_idx[ idx_len * 2/3 ]; const DATA_TYPE small_min = -modval; const IDX_TYPE small_minloc = minloc_init; - for (IDX_TYPE i = 0; i < data_len; ++i) { + for (IDX_TYPE i {0}; i < data_len; ++i) { test_array[i] = static_cast( rand() % modval ); } test_array[minloc_idx] = static_cast(small_min); DATA_TYPE ref_min = min_init; IDX_TYPE ref_minloc = minloc_init; - for (IDX_TYPE i = 0; i < idx_len; ++i) { + for (IDX_TYPE i {0}; i < idx_len; ++i) { if ( test_array[ seg_idx[i] ] < ref_min ) { ref_min = test_array[ seg_idx[i] ]; ref_minloc = seg_idx[i]; @@ -178,9 +178,9 @@ TYPED_TEST_P(ForallReduceMinLocAltBasicTest, ReduceMinLocAltBasicForall) // List segment tests seg_idx.clear(); - IDX_TYPE last = 10567; + IDX_TYPE last {10567}; srand( time(NULL) ); - for (IDX_TYPE i = 0; i < last; ++i) { + for (IDX_TYPE i {0}; i < last; ++i) { IDX_TYPE randval = IDX_TYPE( rand() % RAJA::stripIndexType(last) ); if ( i < randval ) { seg_idx.push_back(i); diff --git a/test/functional/forall/reduce-basic/tests/test-forall-basic-expt-ReduceSum.hpp b/test/functional/forall/reduce-basic/tests/test-forall-basic-expt-ReduceSum.hpp index e6bf295016..5f678d9364 100644 --- a/test/functional/forall/reduce-basic/tests/test-forall-basic-expt-ReduceSum.hpp +++ b/test/functional/forall/reduce-basic/tests/test-forall-basic-expt-ReduceSum.hpp @@ -39,12 +39,12 @@ void ForallReduceSumBasicTestImpl(const SEG_TYPE& seg, const int modval = 100; - for (IDX_TYPE i = 0; i < data_len; ++i) { + for (IDX_TYPE i {0}; i < data_len; ++i) { test_array[i] = static_cast( rand() % modval ); } DATA_TYPE ref_sum = 0; - for (IDX_TYPE i = 0; i < idx_len; ++i) { + for (IDX_TYPE i {0}; i < idx_len; ++i) { ref_sum += test_array[ seg_idx[i] ]; } @@ -148,9 +148,9 @@ TYPED_TEST_P(ForallReduceSumBasicTest, ReduceSumBasicForall) // List segment tests seg_idx.clear(); - IDX_TYPE last = 10567; + IDX_TYPE last {10567}; srand( time(NULL) ); - for (IDX_TYPE i = 0; i < last; ++i) { + for (IDX_TYPE i {0}; i < last; ++i) { IDX_TYPE randval = IDX_TYPE( rand() % RAJA::stripIndexType(last) ); if ( i < randval ) { seg_idx.push_back(i); diff --git a/test/functional/forall/reduce-multiple-indexset/tests/test-forall-indexset-multiple-ReduceMax.hpp b/test/functional/forall/reduce-multiple-indexset/tests/test-forall-indexset-multiple-ReduceMax.hpp index 769adfce54..6a414a7a5b 100644 --- a/test/functional/forall/reduce-multiple-indexset/tests/test-forall-indexset-multiple-ReduceMax.hpp +++ b/test/functional/forall/reduce-multiple-indexset/tests/test-forall-indexset-multiple-ReduceMax.hpp @@ -39,7 +39,7 @@ void ForallIndexSetReduceMaxMultipleTestImpl() iset.push_back(r3); iset.push_back(r4); - const IDX_TYPE alen = 15286; + const IDX_TYPE alen {15286}; camp::resources::Resource working_res{WORKING_RES::get_default()}; @@ -55,7 +55,7 @@ void ForallIndexSetReduceMaxMultipleTestImpl() const double default_val = -DBL_MAX; - for (IDX_TYPE i = 0; i < alen; ++i) { + for (IDX_TYPE i {0}; i < alen; ++i) { test_array[i] = default_val; } diff --git a/test/functional/forall/reduce-multiple-indexset/tests/test-forall-indexset-multiple-ReduceMaxLoc.hpp b/test/functional/forall/reduce-multiple-indexset/tests/test-forall-indexset-multiple-ReduceMaxLoc.hpp index f4425958e0..ed10fde10a 100644 --- a/test/functional/forall/reduce-multiple-indexset/tests/test-forall-indexset-multiple-ReduceMaxLoc.hpp +++ b/test/functional/forall/reduce-multiple-indexset/tests/test-forall-indexset-multiple-ReduceMaxLoc.hpp @@ -39,7 +39,7 @@ void ForallIndexSetReduceMaxLocMultipleTestImpl() iset.push_back(r3); iset.push_back(r4); - const IDX_TYPE alen = 15286; + const IDX_TYPE alen {15286}; camp::resources::Resource working_res{WORKING_RES::get_default()}; @@ -54,9 +54,9 @@ void ForallIndexSetReduceMaxLocMultipleTestImpl() &test_array); double current_max = -DBL_MAX; - IDX_TYPE current_loc = -1; + IDX_TYPE current_loc {-1}; - for (IDX_TYPE i = 0; i < alen; ++i) { + for (IDX_TYPE i {0}; i < alen; ++i) { test_array[i] = current_max; } diff --git a/test/functional/forall/reduce-multiple-indexset/tests/test-forall-indexset-multiple-ReduceMin.hpp b/test/functional/forall/reduce-multiple-indexset/tests/test-forall-indexset-multiple-ReduceMin.hpp index c2ece5c40e..9558939a4d 100644 --- a/test/functional/forall/reduce-multiple-indexset/tests/test-forall-indexset-multiple-ReduceMin.hpp +++ b/test/functional/forall/reduce-multiple-indexset/tests/test-forall-indexset-multiple-ReduceMin.hpp @@ -39,7 +39,7 @@ void ForallIndexSetReduceMinMultipleTestImpl() iset.push_back(r3); iset.push_back(r4); - const IDX_TYPE alen = 15286; + const IDX_TYPE alen {15286}; camp::resources::Resource working_res{WORKING_RES::get_default()}; @@ -55,7 +55,7 @@ void ForallIndexSetReduceMinMultipleTestImpl() const double default_val = DBL_MAX; - for (IDX_TYPE i = 0; i < alen; ++i) { + for (IDX_TYPE i {0}; i < alen; ++i) { test_array[i] = default_val; } diff --git a/test/functional/forall/reduce-multiple-indexset/tests/test-forall-indexset-multiple-ReduceMinLoc.hpp b/test/functional/forall/reduce-multiple-indexset/tests/test-forall-indexset-multiple-ReduceMinLoc.hpp index 77946d6ffe..45411e40e3 100644 --- a/test/functional/forall/reduce-multiple-indexset/tests/test-forall-indexset-multiple-ReduceMinLoc.hpp +++ b/test/functional/forall/reduce-multiple-indexset/tests/test-forall-indexset-multiple-ReduceMinLoc.hpp @@ -39,7 +39,7 @@ void ForallIndexSetReduceMinLocMultipleTestImpl() iset.push_back(r3); iset.push_back(r4); - const IDX_TYPE alen = 15286; + const IDX_TYPE alen {15286}; camp::resources::Resource working_res{WORKING_RES::get_default()}; @@ -54,9 +54,9 @@ void ForallIndexSetReduceMinLocMultipleTestImpl() &test_array); double current_min = DBL_MAX; - IDX_TYPE current_loc = -1; + IDX_TYPE current_loc {-1}; - for (IDX_TYPE i = 0; i < alen; ++i) { + for (IDX_TYPE i {0}; i < alen; ++i) { test_array[i] = current_min; } diff --git a/test/functional/forall/reduce-multiple-indexset/tests/test-forall-indexset-multiple-ReduceSum.hpp b/test/functional/forall/reduce-multiple-indexset/tests/test-forall-indexset-multiple-ReduceSum.hpp index 4951df2f20..fec39c58f3 100644 --- a/test/functional/forall/reduce-multiple-indexset/tests/test-forall-indexset-multiple-ReduceSum.hpp +++ b/test/functional/forall/reduce-multiple-indexset/tests/test-forall-indexset-multiple-ReduceSum.hpp @@ -37,7 +37,7 @@ void ForallIndexSetReduceSumMultipleTestImpl() iset.push_back(r3); iset.push_back(r4); - const IDX_TYPE alen = 15286; + const IDX_TYPE alen {15286}; camp::resources::Resource working_res{WORKING_RES::get_default()}; @@ -64,7 +64,7 @@ void ForallIndexSetReduceSumMultipleTestImpl() const double dinit_val = 0.1; const int iinit_val = 1; - for (IDX_TYPE i = 0; i < alen; ++i) { + for (IDX_TYPE i {0}; i < alen; ++i) { dtest_array[i] = dinit_val; itest_array[i] = iinit_val; } diff --git a/test/functional/forall/reduce-multiple-segment/tests/test-forall-segment-multiple-ReduceMax.hpp b/test/functional/forall/reduce-multiple-segment/tests/test-forall-segment-multiple-ReduceMax.hpp index be034a7936..2d778bdcc1 100644 --- a/test/functional/forall/reduce-multiple-segment/tests/test-forall-segment-multiple-ReduceMax.hpp +++ b/test/functional/forall/reduce-multiple-segment/tests/test-forall-segment-multiple-ReduceMax.hpp @@ -62,7 +62,7 @@ void ForallReduceMaxMultipleTestImpl(IDX_TYPE first, const int nMiddleLoops = 2; for (int k = 0; k < nMiddleLoops; ++k) { - for (IDX_TYPE i = 0; i < last; ++i) { + for (IDX_TYPE i {0}; i < last; ++i) { test_array[i] = default_val; } working_res.memcpy(working_array, test_array, sizeof(DATA_TYPE) * last); diff --git a/test/functional/forall/reduce-multiple-segment/tests/test-forall-segment-multiple-ReduceMaxLoc.hpp b/test/functional/forall/reduce-multiple-segment/tests/test-forall-segment-multiple-ReduceMaxLoc.hpp index 41fa5bda4d..5b927cdac1 100644 --- a/test/functional/forall/reduce-multiple-segment/tests/test-forall-segment-multiple-ReduceMaxLoc.hpp +++ b/test/functional/forall/reduce-multiple-segment/tests/test-forall-segment-multiple-ReduceMaxLoc.hpp @@ -36,7 +36,7 @@ void ForallReduceMaxLocMultipleTestImpl(IDX_TYPE first, &test_array); const DATA_TYPE default_val = static_cast(-SHRT_MAX); - const IDX_TYPE default_loc = -1; + const IDX_TYPE default_loc {-1}; const DATA_TYPE big_val = 500; static std::random_device rd; diff --git a/test/functional/forall/reduce-multiple-segment/tests/test-forall-segment-multiple-ReduceMin.hpp b/test/functional/forall/reduce-multiple-segment/tests/test-forall-segment-multiple-ReduceMin.hpp index a5b100bacd..8126231efa 100644 --- a/test/functional/forall/reduce-multiple-segment/tests/test-forall-segment-multiple-ReduceMin.hpp +++ b/test/functional/forall/reduce-multiple-segment/tests/test-forall-segment-multiple-ReduceMin.hpp @@ -62,7 +62,7 @@ void ForallReduceMinMultipleTestImpl(IDX_TYPE first, const int nMiddleLoops = 2; for (int k = 0; k < nMiddleLoops; ++k) { - for (IDX_TYPE i = 0; i < last; ++i) { + for (IDX_TYPE i {0}; i < last; ++i) { test_array[i] = default_val; } working_res.memcpy(working_array, test_array, sizeof(DATA_TYPE) * last); diff --git a/test/functional/forall/reduce-multiple-segment/tests/test-forall-segment-multiple-ReduceMinLoc.hpp b/test/functional/forall/reduce-multiple-segment/tests/test-forall-segment-multiple-ReduceMinLoc.hpp index f1880fae88..01d781db07 100644 --- a/test/functional/forall/reduce-multiple-segment/tests/test-forall-segment-multiple-ReduceMinLoc.hpp +++ b/test/functional/forall/reduce-multiple-segment/tests/test-forall-segment-multiple-ReduceMinLoc.hpp @@ -36,7 +36,7 @@ void ForallReduceMinLocMultipleTestImpl(IDX_TYPE first, &test_array); const DATA_TYPE default_val = static_cast(SHRT_MAX); - const IDX_TYPE default_loc = -1; + const IDX_TYPE default_loc {-1}; const DATA_TYPE big_val = -500; static std::random_device rd; diff --git a/test/functional/forall/region/tests/test-forall-region.hpp b/test/functional/forall/region/tests/test-forall-region.hpp index 493aca0607..c82a549041 100644 --- a/test/functional/forall/region/tests/test-forall-region.hpp +++ b/test/functional/forall/region/tests/test-forall-region.hpp @@ -68,7 +68,7 @@ void ForallRegionTestImpl(INDEX_TYPE first, INDEX_TYPE last) working_res.memcpy(check_array, working_array, sizeof(INDEX_TYPE) * RAJA::stripIndexType(N)); - for (INDEX_TYPE i = 0; i < N; i++) { + for (INDEX_TYPE i {0}; i < N; i++) { ASSERT_EQ(check_view(i), 3); } diff --git a/test/functional/forall/resource-indexset/tests/test-forall-ResourceIcountIndexSet.hpp b/test/functional/forall/resource-indexset/tests/test-forall-ResourceIcountIndexSet.hpp index 9ab2901c94..9fea81e895 100644 --- a/test/functional/forall/resource-indexset/tests/test-forall-ResourceIcountIndexSet.hpp +++ b/test/functional/forall/resource-indexset/tests/test-forall-ResourceIcountIndexSet.hpp @@ -65,20 +65,20 @@ void ForallResourceIcountIndexSetTestImpl() view_type work_view(working_array, N); view_type check_view(check_array, N); - INDEX_TYPE ticount = 0; + INDEX_TYPE ticount {0}; for (size_t i = 0; i < is_indices.size(); ++i) { test_view(ticount++) = is_indices[i]; } RAJA::forall_Icount(working_res, iset, - [=] RAJA_HOST_DEVICE(INDEX_TYPE icount, INDEX_TYPE idx) { - work_view(icount) = idx; + [=] RAJA_HOST_DEVICE(auto icount, INDEX_TYPE idx) { + work_view(INDEX_TYPE(icount)) = idx; }); working_res.memcpy(check_array, working_array, sizeof(INDEX_TYPE) * RAJA::stripIndexType(N)); - for (INDEX_TYPE i = 0; i < N; i++) { + for (INDEX_TYPE i {0}; i < N; i++) { ASSERT_EQ(test_view(i), check_view(i)); } diff --git a/test/functional/forall/resource-indexset/tests/test-forall-ResourceIndexSet.hpp b/test/functional/forall/resource-indexset/tests/test-forall-ResourceIndexSet.hpp index 19d46991b8..b96f7e60f4 100644 --- a/test/functional/forall/resource-indexset/tests/test-forall-ResourceIndexSet.hpp +++ b/test/functional/forall/resource-indexset/tests/test-forall-ResourceIndexSet.hpp @@ -76,7 +76,7 @@ void ForallResourceIndexSetTestImpl() sizeof(INDEX_TYPE) * RAJA::stripIndexType(N)); // - for (INDEX_TYPE i = 0; i < N; i++) { + for (INDEX_TYPE i {0}; i < N; i++) { ASSERT_EQ(test_view(i), check_view(i)); } diff --git a/test/functional/forall/resource-segment/tests/test-forall-resource-ListSegment.hpp b/test/functional/forall/resource-segment/tests/test-forall-resource-ListSegment.hpp index 12af443da5..c103deaf41 100644 --- a/test/functional/forall/resource-segment/tests/test-forall-resource-ListSegment.hpp +++ b/test/functional/forall/resource-segment/tests/test-forall-resource-ListSegment.hpp @@ -26,7 +26,7 @@ void ForallResourceListSegmentTestImpl(INDEX_TYPE N) srand ( time(NULL) ); - for (INDEX_TYPE i = INDEX_TYPE(0); i < N; ++i) { + for (INDEX_TYPE i {0}; i < N; ++i) { INDEX_TYPE randval = INDEX_TYPE(rand() % RAJA::stripIndexType(N)); if ( i < randval ) { idx_array.push_back(i); @@ -52,7 +52,7 @@ void ForallResourceListSegmentTestImpl(INDEX_TYPE N) &check_array, &test_array); - for (INDEX_TYPE i = INDEX_TYPE(0); i < N; i++) { + for (INDEX_TYPE i {0}; i < N; i++) { test_array[RAJA::stripIndexType(i)] = INDEX_TYPE(0); } @@ -69,7 +69,7 @@ void ForallResourceListSegmentTestImpl(INDEX_TYPE N) working_res.memcpy(check_array, working_array, sizeof(INDEX_TYPE) * RAJA::stripIndexType(N)); // - for (INDEX_TYPE i = INDEX_TYPE(0); i < N; i++) { + for (INDEX_TYPE i {0}; i < N; i++) { ASSERT_EQ(test_array[RAJA::stripIndexType(i)], check_array[RAJA::stripIndexType(i)]); } diff --git a/test/functional/forall/resource-segment/tests/test-forall-resource-RangeSegment.hpp b/test/functional/forall/resource-segment/tests/test-forall-resource-RangeSegment.hpp index ec9e27583c..aeccf2e120 100644 --- a/test/functional/forall/resource-segment/tests/test-forall-resource-RangeSegment.hpp +++ b/test/functional/forall/resource-segment/tests/test-forall-resource-RangeSegment.hpp @@ -40,7 +40,7 @@ void ForallResourceRangeSegmentTestImpl(INDEX_TYPE first, INDEX_TYPE last) working_res.memcpy(check_array, working_array, sizeof(INDEX_TYPE) * RAJA::stripIndexType(N)); - for (INDEX_TYPE i = INDEX_TYPE(0); i < N; i++) { + for (INDEX_TYPE i {0}; i < N; i++) { ASSERT_EQ(test_array[RAJA::stripIndexType(i)], check_array[RAJA::stripIndexType(i)]); } diff --git a/test/functional/forall/resource-segment/tests/test-forall-resource-RangeStrideSegment.hpp b/test/functional/forall/resource-segment/tests/test-forall-resource-RangeStrideSegment.hpp index daca3ae95e..eff9cd8c04 100644 --- a/test/functional/forall/resource-segment/tests/test-forall-resource-RangeStrideSegment.hpp +++ b/test/functional/forall/resource-segment/tests/test-forall-resource-RangeStrideSegment.hpp @@ -31,7 +31,7 @@ void ForallResourceRangeStrideSegmentTestImpl(INDEX_TYPE first, INDEX_TYPE last, &check_array, &test_array); - for (INDEX_TYPE i = INDEX_TYPE(0); i < N; i++) { + for (INDEX_TYPE i {0}; i < N; i++) { test_array[RAJA::stripIndexType(i)] = INDEX_TYPE(0); } @@ -39,7 +39,7 @@ void ForallResourceRangeStrideSegmentTestImpl(INDEX_TYPE first, INDEX_TYPE last, working_res.wait(); INDEX_TYPE index = first; - for (INDEX_TYPE i = INDEX_TYPE(0); i < N; ++i) { + for (INDEX_TYPE i {0}; i < N; ++i) { test_array[ RAJA::stripIndexType((index-first)/stride) ] = index; index += stride; } @@ -51,7 +51,7 @@ void ForallResourceRangeStrideSegmentTestImpl(INDEX_TYPE first, INDEX_TYPE last, working_res.memcpy(check_array, working_array, sizeof(INDEX_TYPE) * RAJA::stripIndexType(N)); working_res.wait(); - for (INDEX_TYPE i = INDEX_TYPE(0); i < N; i++) { + for (INDEX_TYPE i {0}; i < N; i++) { ASSERT_EQ(test_array[RAJA::stripIndexType(i)], check_array[RAJA::stripIndexType(i)]); } diff --git a/test/functional/forall/segment-view/tests/test-forall-ListSegmentView.hpp b/test/functional/forall/segment-view/tests/test-forall-ListSegmentView.hpp index 90c4d43474..3682278f22 100644 --- a/test/functional/forall/segment-view/tests/test-forall-ListSegmentView.hpp +++ b/test/functional/forall/segment-view/tests/test-forall-ListSegmentView.hpp @@ -27,7 +27,7 @@ void ForallListSegmentViewTestImpl(INDEX_TYPE N) srand ( time(NULL) ); - for (INDEX_TYPE i = 0; i < N; ++i) { + for (INDEX_TYPE i {0}; i < N; ++i) { INDEX_TYPE randval = INDEX_TYPE(rand() % RAJA::stripIndexType(N)); if ( i < randval ) { idx_array.push_back(i); @@ -93,7 +93,7 @@ void ForallListSegmentViewTestImpl(INDEX_TYPE N) working_res.memcpy(check_array, working_array, sizeof(INDEX_TYPE) * RAJA::stripIndexType(N)); - for (INDEX_TYPE i = 0; i < N; i++) { + for (INDEX_TYPE i {0}; i < N; i++) { ASSERT_EQ(test_view(i), check_view(i)); } @@ -112,7 +112,7 @@ void ForallListSegmentOffsetViewTestImpl(INDEX_TYPE N, INDEX_TYPE offset) srand ( time(NULL) ); - for (INDEX_TYPE i = 0; i < N; ++i) { + for (INDEX_TYPE i {0}; i < N; ++i) { INDEX_TYPE randval = INDEX_TYPE(rand() % RAJA::stripIndexType(N)); if ( i < randval ) { idx_array.push_back(i+offset); @@ -186,13 +186,19 @@ TYPED_TEST_P(ForallListSegmentViewTest, ListSegmentForallView) using WORKING_RESOURCE = typename camp::at>::type; using EXEC_POLICY = typename camp::at>::type; - ForallListSegmentViewTestImpl(13); - ForallListSegmentViewTestImpl(2047); - ForallListSegmentViewTestImpl(32000); - - ForallListSegmentOffsetViewTestImpl(13, 1); - ForallListSegmentOffsetViewTestImpl(2047, 2); - ForallListSegmentOffsetViewTestImpl(32000, 3); + ForallListSegmentViewTestImpl( + INDEX_TYPE(13)); + ForallListSegmentViewTestImpl( + INDEX_TYPE(2047)); + ForallListSegmentViewTestImpl( + INDEX_TYPE(32000)); + + ForallListSegmentOffsetViewTestImpl( + INDEX_TYPE(13), INDEX_TYPE(1)); + ForallListSegmentOffsetViewTestImpl( + INDEX_TYPE(2047), INDEX_TYPE(2)); + ForallListSegmentOffsetViewTestImpl( + INDEX_TYPE(32000), INDEX_TYPE(3)); } REGISTER_TYPED_TEST_SUITE_P(ForallListSegmentViewTest, diff --git a/test/functional/forall/segment-view/tests/test-forall-RangeSegment2DView.hpp b/test/functional/forall/segment-view/tests/test-forall-RangeSegment2DView.hpp index be7f04e986..2b08b373e5 100644 --- a/test/functional/forall/segment-view/tests/test-forall-RangeSegment2DView.hpp +++ b/test/functional/forall/segment-view/tests/test-forall-RangeSegment2DView.hpp @@ -18,7 +18,7 @@ void ForallRangeSegment2DViewTestImpl(INDEX_TYPE N) { INDEX_TYPE lentot = N * N; - RAJA::TypedRangeSegment r1(0, lentot); + RAJA::TypedRangeSegment r1(INDEX_TYPE(0), lentot); camp::resources::Resource working_res{WORKING_RES::get_default()}; INDEX_TYPE* working_array; @@ -31,7 +31,8 @@ void ForallRangeSegment2DViewTestImpl(INDEX_TYPE N) &check_array, &test_array); - std::iota(test_array, test_array + RAJA::stripIndexType(lentot), 0); + std::iota(test_array, test_array + RAJA::stripIndexType(lentot), + INDEX_TYPE(0)); using layout_type = RAJA::TypedLayout>; @@ -50,7 +51,7 @@ void ForallRangeSegment2DViewTestImpl(INDEX_TYPE N) working_res.memcpy(check_array, working_array, sizeof(INDEX_TYPE) * RAJA::stripIndexType(lentot)); - for (INDEX_TYPE i = 0; i < lentot; i++) { + for (INDEX_TYPE i {0}; i < lentot; i++) { const INDEX_TYPE row = i / N; const INDEX_TYPE col = i % N; ASSERT_EQ(test_view(row, col), check_view(row, col)); @@ -68,7 +69,7 @@ void ForallRangeSegment2DOffsetViewTestImpl(INDEX_TYPE N) const INDEX_TYPE leninterior = N * N; const INDEX_TYPE lentot = (N + 2) * (N + 2); - RAJA::TypedRangeSegment r1(0, leninterior); + RAJA::TypedRangeSegment r1(INDEX_TYPE(0), leninterior); camp::resources::Resource working_res{WORKING_RES::get_default()}; INDEX_TYPE* working_array; @@ -98,8 +99,8 @@ void ForallRangeSegment2DOffsetViewTestImpl(INDEX_TYPE N) view_type work_view(working_array, layout); view_type check_view(check_array, layout); - for (INDEX_TYPE row = 0; row < N; ++row) { - for (INDEX_TYPE col = 0; col < N; ++col) { + for (INDEX_TYPE row {0}; row < N; ++row) { + for (INDEX_TYPE col {0}; col < N; ++col) { test_view(row, col) = row * N + col; } } @@ -113,8 +114,8 @@ void ForallRangeSegment2DOffsetViewTestImpl(INDEX_TYPE N) working_res.memcpy(check_array, working_array, sizeof(INDEX_TYPE) * RAJA::stripIndexType(lentot)); - for (INDEX_TYPE row = INDEX_TYPE(-1); row < N + 1; ++row) { - for (INDEX_TYPE col = INDEX_TYPE(-1); col < N + 1; ++col) { + for (INDEX_TYPE row {-1}; row < N + 1; ++row) { + for (INDEX_TYPE col {-1}; col < N + 1; ++col) { ASSERT_EQ(test_view(row, col), check_view(row, col)); } } @@ -141,8 +142,10 @@ template >::value>::type* = nullptr> void runOffsetViewTests() { - ForallRangeSegment2DOffsetViewTestImpl(4); - ForallRangeSegment2DOffsetViewTestImpl(100); + ForallRangeSegment2DOffsetViewTestImpl( + INDEX_TYPE(4)); + ForallRangeSegment2DOffsetViewTestImpl( + INDEX_TYPE(100)); } @@ -152,8 +155,10 @@ TYPED_TEST_P(ForallRangeSegment2DViewTest, RangeSegmentForall2DView) using WORKING_RES = typename camp::at>::type; using EXEC_POLICY = typename camp::at>::type; - ForallRangeSegment2DViewTestImpl(4); - ForallRangeSegment2DViewTestImpl(100); + ForallRangeSegment2DViewTestImpl( + INDEX_TYPE(4)); + ForallRangeSegment2DViewTestImpl( + INDEX_TYPE(100)); runOffsetViewTests(); } diff --git a/test/functional/forall/segment-view/tests/test-forall-RangeSegmentView.hpp b/test/functional/forall/segment-view/tests/test-forall-RangeSegmentView.hpp index c08083e478..736d3cf782 100644 --- a/test/functional/forall/segment-view/tests/test-forall-RangeSegmentView.hpp +++ b/test/functional/forall/segment-view/tests/test-forall-RangeSegmentView.hpp @@ -16,7 +16,7 @@ template void ForallRangeSegmentViewTestImpl(INDEX_TYPE first, INDEX_TYPE last) { RAJA::TypedRangeSegment r1(first, last); - INDEX_TYPE N = r1.end() - r1.begin(); + INDEX_TYPE N = INDEX_TYPE(r1.end() - r1.begin()); camp::resources::Resource working_res{WORKING_RES::get_default()}; INDEX_TYPE* working_array; @@ -48,7 +48,7 @@ void ForallRangeSegmentViewTestImpl(INDEX_TYPE first, INDEX_TYPE last) working_res.memcpy(check_array, working_array, sizeof(INDEX_TYPE) * RAJA::stripIndexType(N)); - for (INDEX_TYPE i = 0; i < N; i++) { + for (INDEX_TYPE i {0}; i < N; i++) { ASSERT_EQ(test_view(i), check_view(i)); } @@ -63,7 +63,7 @@ void ForallRangeSegmentOffsetViewTestImpl(INDEX_TYPE first, INDEX_TYPE last, INDEX_TYPE offset) { RAJA::TypedRangeSegment r1(first+offset, last+offset); - INDEX_TYPE N = r1.end() - r1.begin(); + INDEX_TYPE N = INDEX_TYPE(r1.end() - r1.begin()); camp::resources::Resource working_res{WORKING_RES::get_default()}; INDEX_TYPE* working_array; @@ -119,12 +119,17 @@ template >::value>::type* = nullptr> void runNegativeViewTests() { - ForallRangeSegmentViewTestImpl(-5, 0); - ForallRangeSegmentViewTestImpl(-5, 5); - - ForallRangeSegmentOffsetViewTestImpl(-5, 0, 1); - ForallRangeSegmentOffsetViewTestImpl(-5, 5, 2); - ForallRangeSegmentOffsetViewTestImpl(0, 10, -5); + ForallRangeSegmentViewTestImpl( + INDEX_TYPE(-5), INDEX_TYPE(0)); + ForallRangeSegmentViewTestImpl( + INDEX_TYPE(-5), INDEX_TYPE(5)); + + ForallRangeSegmentOffsetViewTestImpl( + INDEX_TYPE(-5), INDEX_TYPE(0), INDEX_TYPE(1)); + ForallRangeSegmentOffsetViewTestImpl( + INDEX_TYPE(-5), INDEX_TYPE(5), INDEX_TYPE(2)); + ForallRangeSegmentOffsetViewTestImpl( + INDEX_TYPE(0), INDEX_TYPE(10), INDEX_TYPE(-5)); } @@ -140,13 +145,19 @@ TYPED_TEST_P(ForallRangeSegmentViewTest, RangeSegmentForallView) using WORKING_RES = typename camp::at>::type; using EXEC_POLICY = typename camp::at>::type; - ForallRangeSegmentViewTestImpl(0, 5); - ForallRangeSegmentViewTestImpl(1, 5); - ForallRangeSegmentViewTestImpl(1, 255); - - ForallRangeSegmentOffsetViewTestImpl(0, 5, 1); - ForallRangeSegmentOffsetViewTestImpl(1, 5, 2); - ForallRangeSegmentOffsetViewTestImpl(1, 255, 3); + ForallRangeSegmentViewTestImpl( + INDEX_TYPE(0), INDEX_TYPE(5)); + ForallRangeSegmentViewTestImpl( + INDEX_TYPE(1), INDEX_TYPE(5)); + ForallRangeSegmentViewTestImpl( + INDEX_TYPE(1), INDEX_TYPE(255)); + + ForallRangeSegmentOffsetViewTestImpl( + INDEX_TYPE(0), INDEX_TYPE(5), INDEX_TYPE(1)); + ForallRangeSegmentOffsetViewTestImpl( + INDEX_TYPE(1), INDEX_TYPE(5), INDEX_TYPE(2)); + ForallRangeSegmentOffsetViewTestImpl( + INDEX_TYPE(1), INDEX_TYPE(255), INDEX_TYPE(3)); runNegativeViewTests(); } diff --git a/test/functional/forall/segment-view/tests/test-forall-RangeStrideSegmentView.hpp b/test/functional/forall/segment-view/tests/test-forall-RangeStrideSegmentView.hpp index 7b7a15afaa..dafd108da7 100644 --- a/test/functional/forall/segment-view/tests/test-forall-RangeStrideSegmentView.hpp +++ b/test/functional/forall/segment-view/tests/test-forall-RangeStrideSegmentView.hpp @@ -18,7 +18,7 @@ void ForallRangeStrideSegmentViewTestImpl(INDEX_TYPE first, INDEX_TYPE last, RAJA::TypedRangeStrideSegment r1(RAJA::stripIndexType(first), RAJA::stripIndexType(last), stride); - INDEX_TYPE N = r1.size(); + INDEX_TYPE N = INDEX_TYPE(r1.size()); camp::resources::Resource working_res{WORKING_RES::get_default()}; INDEX_TYPE* working_array; @@ -45,7 +45,7 @@ void ForallRangeStrideSegmentViewTestImpl(INDEX_TYPE first, INDEX_TYPE last, view_type work_view(working_array, N); view_type check_view(check_array, N); - for (INDEX_TYPE i = 0; i < N; ++i) { + for (INDEX_TYPE i {0}; i < N; ++i) { test_view( (index-first)/stride ) = index; index += stride; } @@ -57,7 +57,7 @@ void ForallRangeStrideSegmentViewTestImpl(INDEX_TYPE first, INDEX_TYPE last, working_res.memcpy(check_array, working_array, sizeof(INDEX_TYPE) * RAJA::stripIndexType(N)); - for (INDEX_TYPE i = 0; i < N; i++) { + for (INDEX_TYPE i {0}; i < N; i++) { ASSERT_EQ(test_view(i), check_view(i)); } diff --git a/test/functional/forall/segment/tests/test-forall-ListSegment.hpp b/test/functional/forall/segment/tests/test-forall-ListSegment.hpp index 5e99e27f9f..0485c46e98 100644 --- a/test/functional/forall/segment/tests/test-forall-ListSegment.hpp +++ b/test/functional/forall/segment/tests/test-forall-ListSegment.hpp @@ -26,7 +26,7 @@ void ForallListSegmentTestImpl(INDEX_TYPE N) srand ( time(NULL) ); - for (INDEX_TYPE i = INDEX_TYPE(0); i < N; ++i) { + for (INDEX_TYPE i {0}; i < N; ++i) { INDEX_TYPE randval = INDEX_TYPE(rand() % RAJA::stripIndexType(N)); if ( i < randval ) { idx_array.push_back(i); @@ -87,7 +87,7 @@ void ForallListSegmentTestImpl(INDEX_TYPE N) working_res.memcpy(check_array, working_array, sizeof(INDEX_TYPE) * data_len); - for (INDEX_TYPE i = INDEX_TYPE(0); i < N; i++) { + for (INDEX_TYPE i {0}; i < N; i++) { ASSERT_EQ(test_array[RAJA::stripIndexType(i)], check_array[RAJA::stripIndexType(i)]); } diff --git a/test/functional/forall/segment/tests/test-forall-RangeSegment.hpp b/test/functional/forall/segment/tests/test-forall-RangeSegment.hpp index cf9f918a95..72804805a4 100644 --- a/test/functional/forall/segment/tests/test-forall-RangeSegment.hpp +++ b/test/functional/forall/segment/tests/test-forall-RangeSegment.hpp @@ -60,7 +60,7 @@ void ForallRangeSegmentTestImpl(INDEX_TYPE first, INDEX_TYPE last) working_res.memcpy(check_array, working_array, sizeof(INDEX_TYPE) * data_len); - for (INDEX_TYPE i = INDEX_TYPE(0); i < N; i++) { + for (INDEX_TYPE i {0}; i < N; i++) { ASSERT_EQ(test_array[RAJA::stripIndexType(i)], check_array[RAJA::stripIndexType(i)]); } diff --git a/test/functional/forall/segment/tests/test-forall-RangeStrideSegment.hpp b/test/functional/forall/segment/tests/test-forall-RangeStrideSegment.hpp index 123c0387d6..34e2410485 100644 --- a/test/functional/forall/segment/tests/test-forall-RangeStrideSegment.hpp +++ b/test/functional/forall/segment/tests/test-forall-RangeStrideSegment.hpp @@ -45,7 +45,7 @@ void ForallRangeStrideSegmentTestImpl(INDEX_TYPE first, INDEX_TYPE last, if ( RAJA::stripIndexType(N) > 0 ) { INDEX_TYPE index = first; - for (INDEX_TYPE i = INDEX_TYPE(0); i < N; ++i) { + for (INDEX_TYPE i {0}; i < N; ++i) { test_array[ RAJA::stripIndexType((index-first)/stride) ] = index; index += stride; } @@ -66,7 +66,7 @@ void ForallRangeStrideSegmentTestImpl(INDEX_TYPE first, INDEX_TYPE last, working_res.memcpy(check_array, working_array, sizeof(INDEX_TYPE) * data_len); working_res.wait(); - for (INDEX_TYPE i = INDEX_TYPE(0); i < N; i++) { + for (INDEX_TYPE i {0}; i < N; i++) { ASSERT_EQ(test_array[RAJA::stripIndexType(i)], check_array[RAJA::stripIndexType(i)]); } diff --git a/test/functional/kernel/basic-fission-fusion-loop/tests/basic-fission-fusion-loop-impl.hpp b/test/functional/kernel/basic-fission-fusion-loop/tests/basic-fission-fusion-loop-impl.hpp index 17e5121ef7..d195b375db 100644 --- a/test/functional/kernel/basic-fission-fusion-loop/tests/basic-fission-fusion-loop-impl.hpp +++ b/test/functional/kernel/basic-fission-fusion-loop/tests/basic-fission-fusion-loop-impl.hpp @@ -28,7 +28,7 @@ void KernelBasicFissionFusionLoopTestImpl( WORKING_RES working_res, camp::resources::Resource erased_working_res) { - IDX_TYPE data_len = IDX_TYPE(0); + IDX_TYPE data_len {0}; if (seg_idx.size() > 0) { data_len = seg_idx[seg_idx.size() - 1] + 1; @@ -88,7 +88,7 @@ void KernelBasicFissionFusionLoopTestImpl( }); - for (IDX_TYPE i = IDX_TYPE(0); i < data_len; ++i) { + for (IDX_TYPE i {0}; i < data_len; ++i) { ASSERT_EQ(check_array_x[RAJA::stripIndexType(i)], check_array_y[RAJA::stripIndexType(i)]); } diff --git a/test/functional/kernel/basic-fission-fusion-loop/tests/test-kernel-basic-fission-fusion-loop-segments.hpp b/test/functional/kernel/basic-fission-fusion-loop/tests/test-kernel-basic-fission-fusion-loop-segments.hpp index adf60094be..912038bbe1 100644 --- a/test/functional/kernel/basic-fission-fusion-loop/tests/test-kernel-basic-fission-fusion-loop-segments.hpp +++ b/test/functional/kernel/basic-fission-fusion-loop/tests/test-kernel-basic-fission-fusion-loop-segments.hpp @@ -91,9 +91,9 @@ TYPED_TEST_P(KernelBasicFissionFusionLoopTest, // List segment tests seg_idx.clear(); - IDX_TYPE last = IDX_TYPE(10567); + IDX_TYPE last {10567}; srand(time(NULL)); - for (IDX_TYPE i = IDX_TYPE(0); i < last; ++i) { + for (IDX_TYPE i {0}; i < last; ++i) { IDX_TYPE randval = IDX_TYPE(rand() % RAJA::stripIndexType(last)); if (i < randval) { seg_idx.push_back(i); diff --git a/test/functional/kernel/basic-single-icount-loop/tests/basic-single-icount-loop-impl.hpp b/test/functional/kernel/basic-single-icount-loop/tests/basic-single-icount-loop-impl.hpp index ecea4abf1c..dd3dfaf01d 100644 --- a/test/functional/kernel/basic-single-icount-loop/tests/basic-single-icount-loop-impl.hpp +++ b/test/functional/kernel/basic-single-icount-loop/tests/basic-single-icount-loop-impl.hpp @@ -25,7 +25,7 @@ void KernelBasicSingleICountLoopTestImpl(const SEG_TYPE& seg, camp::resources::Resource erased_working_res) { IDX_TYPE idx_len = static_cast( seg_idx.size() ); - IDX_TYPE data_len = IDX_TYPE(0); + IDX_TYPE data_len {0}; if ( seg_idx.size() > 0 ) { data_len = seg_idx[seg_idx.size() - 1] + 1; } @@ -64,7 +64,7 @@ void KernelBasicSingleICountLoopTestImpl(const SEG_TYPE& seg, if ( RAJA::stripIndexType(idx_len) > 0 ) { - for (IDX_TYPE i = IDX_TYPE(0); i < idx_len; ++i) { + for (IDX_TYPE i {0}; i < idx_len; ++i) { test_array [ RAJA::stripIndexType(seg_idx[RAJA::stripIndexType(i)]) ] = seg_idx[RAJA::stripIndexType(i)]; test_array_i[ RAJA::stripIndexType(RAJA::stripIndexType(i)) ] = @@ -101,7 +101,7 @@ void KernelBasicSingleICountLoopTestImpl(const SEG_TYPE& seg, working_res.memcpy(check_array_i, working_array_i, sizeof(IDX_TYPE) * RAJA::stripIndexType(data_len)); - for (IDX_TYPE i = IDX_TYPE(0); i < data_len; ++i) { + for (IDX_TYPE i {0}; i < data_len; ++i) { ASSERT_EQ( test_array[RAJA::stripIndexType(i)], check_array[RAJA::stripIndexType(i)] ); ASSERT_EQ( test_array_i[RAJA::stripIndexType(i)], diff --git a/test/functional/kernel/basic-single-icount-loop/tests/test-kernel-basic-single-icount-loop-segments.hpp b/test/functional/kernel/basic-single-icount-loop/tests/test-kernel-basic-single-icount-loop-segments.hpp index df7d38bd2a..97cc7f960e 100644 --- a/test/functional/kernel/basic-single-icount-loop/tests/test-kernel-basic-single-icount-loop-segments.hpp +++ b/test/functional/kernel/basic-single-icount-loop/tests/test-kernel-basic-single-icount-loop-segments.hpp @@ -78,9 +78,9 @@ TYPED_TEST_P(KernelBasicSingleICountLoopTest, BasicSingleICountLoopSegmentKernel // List segment tests seg_idx.clear(); - IDX_TYPE last = IDX_TYPE(10567); + IDX_TYPE last {10567}; srand( time(NULL) ); - for (IDX_TYPE i = IDX_TYPE(0); i < last; ++i) { + for (IDX_TYPE i {0}; i < last; ++i) { IDX_TYPE randval = IDX_TYPE( rand() % RAJA::stripIndexType(last) ); if ( i < randval ) { seg_idx.push_back(i); diff --git a/test/functional/kernel/basic-single-loop/tests/basic-single-loop-segments-impl.hpp b/test/functional/kernel/basic-single-loop/tests/basic-single-loop-segments-impl.hpp index ece88a07f6..9f473b29f2 100644 --- a/test/functional/kernel/basic-single-loop/tests/basic-single-loop-segments-impl.hpp +++ b/test/functional/kernel/basic-single-loop/tests/basic-single-loop-segments-impl.hpp @@ -42,7 +42,7 @@ void KernelBasicSingleLoopTestImpl(const SEG_TYPE& seg, camp::resources::Resource erased_working_res) { IDX_TYPE idx_len = static_cast( seg_idx.size() ); - IDX_TYPE data_len = IDX_TYPE(0); + IDX_TYPE data_len {0}; if ( seg_idx.size() > 0 ) { data_len = seg_idx[seg_idx.size() - 1] + 1; } @@ -69,7 +69,7 @@ void KernelBasicSingleLoopTestImpl(const SEG_TYPE& seg, if ( RAJA::stripIndexType(idx_len) > 0 ) { - for (IDX_TYPE i = IDX_TYPE(0); i < idx_len; ++i) { + for (IDX_TYPE i {0}; i < idx_len; ++i) { test_array[ RAJA::stripIndexType(seg_idx[RAJA::stripIndexType(i)]) ] = seg_idx[RAJA::stripIndexType(i)]; } @@ -94,7 +94,7 @@ void KernelBasicSingleLoopTestImpl(const SEG_TYPE& seg, working_res.memcpy(check_array, working_array, sizeof(IDX_TYPE) * RAJA::stripIndexType(data_len)); - for (IDX_TYPE i = IDX_TYPE(0); i < data_len; ++i) { + for (IDX_TYPE i {0}; i < data_len; ++i) { ASSERT_EQ( test_array[RAJA::stripIndexType(i)], check_array[RAJA::stripIndexType(i)] ); } diff --git a/test/functional/kernel/basic-single-loop/tests/test-kernel-basic-single-loop-segments.hpp b/test/functional/kernel/basic-single-loop/tests/test-kernel-basic-single-loop-segments.hpp index 736e2bfa28..6c26c1c5e8 100644 --- a/test/functional/kernel/basic-single-loop/tests/test-kernel-basic-single-loop-segments.hpp +++ b/test/functional/kernel/basic-single-loop/tests/test-kernel-basic-single-loop-segments.hpp @@ -80,9 +80,9 @@ TYPED_TEST_P(KernelBasicSingleLoopTest, BasicSingleLoopSegmentKernel) // List segment tests seg_idx.clear(); - IDX_TYPE last = IDX_TYPE(10567); + IDX_TYPE last {10567}; srand( time(NULL) ); - for (IDX_TYPE i = IDX_TYPE(0); i < last; ++i) { + for (IDX_TYPE i {0}; i < last; ++i) { IDX_TYPE randval = IDX_TYPE( rand() % RAJA::stripIndexType(last) ); if ( i < randval ) { seg_idx.push_back(i); diff --git a/test/functional/kernel/basic-single-loop/tests/test-kernel-resource-basic-single-loop-segments.hpp b/test/functional/kernel/basic-single-loop/tests/test-kernel-resource-basic-single-loop-segments.hpp index c15dc547ea..e08d7efcea 100644 --- a/test/functional/kernel/basic-single-loop/tests/test-kernel-resource-basic-single-loop-segments.hpp +++ b/test/functional/kernel/basic-single-loop/tests/test-kernel-resource-basic-single-loop-segments.hpp @@ -80,9 +80,9 @@ TYPED_TEST_P(KernelBasicSingleLoopTest, BasicSingleLoopSegmentKernel) // List segment tests seg_idx.clear(); - IDX_TYPE last = IDX_TYPE(10567); + IDX_TYPE last {10567}; srand( time(NULL) ); - for (IDX_TYPE i = IDX_TYPE(0); i < last; ++i) { + for (IDX_TYPE i {0}; i < last; ++i) { IDX_TYPE randval = IDX_TYPE( rand() % RAJA::stripIndexType(last) ); if ( i < randval ) { seg_idx.push_back(i); diff --git a/test/functional/kernel/conditional-fission-fusion-loop/tests/conditional-fission-fusion-loop-impl.hpp b/test/functional/kernel/conditional-fission-fusion-loop/tests/conditional-fission-fusion-loop-impl.hpp index 88802ce5e9..ea91bef8c9 100644 --- a/test/functional/kernel/conditional-fission-fusion-loop/tests/conditional-fission-fusion-loop-impl.hpp +++ b/test/functional/kernel/conditional-fission-fusion-loop/tests/conditional-fission-fusion-loop-impl.hpp @@ -28,7 +28,7 @@ void KernelConditionalFissionFusionLoopTestImpl( WORKING_RES working_res, camp::resources::Resource erased_working_res) { - IDX_TYPE data_len = IDX_TYPE(0); + IDX_TYPE data_len {0}; if (seg_idx.size() > 0) { data_len = seg_idx[seg_idx.size() - 1] + 1; @@ -92,7 +92,7 @@ void KernelConditionalFissionFusionLoopTestImpl( }); - for (IDX_TYPE i = IDX_TYPE(0); i < data_len; ++i) { + for (IDX_TYPE i {0}; i < data_len; ++i) { ASSERT_EQ(check_array_x[RAJA::stripIndexType(i)], check_array_y[RAJA::stripIndexType(i)]); } diff --git a/test/functional/kernel/conditional-fission-fusion-loop/tests/test-kernel-conditional-fission-fusion-loop-segments.hpp b/test/functional/kernel/conditional-fission-fusion-loop/tests/test-kernel-conditional-fission-fusion-loop-segments.hpp index b8769fc2f8..8240ef312b 100644 --- a/test/functional/kernel/conditional-fission-fusion-loop/tests/test-kernel-conditional-fission-fusion-loop-segments.hpp +++ b/test/functional/kernel/conditional-fission-fusion-loop/tests/test-kernel-conditional-fission-fusion-loop-segments.hpp @@ -100,9 +100,9 @@ TYPED_TEST_P(KernelConditionalFissionFusionLoopTest, // List segment tests seg_idx.clear(); - IDX_TYPE last = IDX_TYPE(10567); + IDX_TYPE last {10567}; srand(time(NULL)); - for (IDX_TYPE i = IDX_TYPE(0); i < last; ++i) { + for (IDX_TYPE i {0}; i < last; ++i) { IDX_TYPE randval = IDX_TYPE(rand() % RAJA::stripIndexType(last)); if (i < randval) { seg_idx.push_back(i); diff --git a/test/functional/kernel/hyperplane/tests/test-kernel-hyperplane-2D.hpp b/test/functional/kernel/hyperplane/tests/test-kernel-hyperplane-2D.hpp index 9f98c4d2f8..e16b11d59c 100644 --- a/test/functional/kernel/hyperplane/tests/test-kernel-hyperplane-2D.hpp +++ b/test/functional/kernel/hyperplane/tests/test-kernel-hyperplane-2D.hpp @@ -26,13 +26,6 @@ struct val_t_impl { template using VAL_T = typename val_t_impl::type; - -template -RAJA_HOST_DEVICE typename T::value_type get_val(T index_val) { return *index_val; } - -template -requires (!RAJA::concepts::IndexValued) -RAJA_HOST_DEVICE auto get_val(T index_val) { return index_val; } } template @@ -56,7 +49,7 @@ CallKernel(DATA_TYPE& trip_count, [=] RAJA_HOST_DEVICE (INDEX_TYPE g, INDEX_TYPE ii, INDEX_TYPE jj, RAJA::expt::ValOp& _trip_count, RAJA::expt::ValOp& _oob_count ) { - if (get_val(g) >= get_val(groups) || get_val(ii) >= get_val(idim) || get_val(jj) >= get_val(jdim)) { + if (RAJA::stripIndexType(g) >= RAJA::stripIndexType(groups) || RAJA::stripIndexType(ii) >= RAJA::stripIndexType(idim) || RAJA::stripIndexType(jj) >= RAJA::stripIndexType(jdim)) { _oob_count += 1; } @@ -95,7 +88,7 @@ CallKernel(DATA_TYPE& _trip_count, RAJA::kernel ( RAJA::make_tuple( Grange, Irange, Jrange ), [=] RAJA_HOST_DEVICE ( INDEX_TYPE g, INDEX_TYPE ii, INDEX_TYPE jj ) { - if (get_val(g) >= get_val(groups) || get_val(ii) >= get_val(idim) || get_val(jj) >= get_val(jdim)) { + if (RAJA::stripIndexType(g) >= RAJA::stripIndexType(groups) || RAJA::stripIndexType(ii) >= RAJA::stripIndexType(idim) || RAJA::stripIndexType(jj) >= RAJA::stripIndexType(jdim)) { oob_count += 1; } @@ -145,9 +138,9 @@ void KernelHyperplane2DTestImpl(const INDEX_TYPE groups, const INDEX_TYPE idim, ViewType CheckView( check_array, groups, idim, jdim ); // initialize array - std::iota( test_array, test_array + get_val(array_length), 1 ); + std::iota( test_array, test_array + RAJA::stripIndexType(array_length), 1 ); - work_res.memcpy( work_array, test_array, sizeof(DATA_TYPE) * get_val(array_length) ); + work_res.memcpy( work_array, test_array, sizeof(DATA_TYPE) * RAJA::stripIndexType(array_length) ); DATA_TYPE trip_count(0); DATA_TYPE oob_count(0); @@ -158,7 +151,7 @@ void KernelHyperplane2DTestImpl(const INDEX_TYPE groups, const INDEX_TYPE idim, ASSERT_EQ((INDEX_TYPE)trip_count, groups * idim * jdim); ASSERT_EQ((INDEX_TYPE)oob_count, (INDEX_TYPE)0); - work_res.memcpy( check_array, work_array, sizeof(DATA_TYPE) * get_val(array_length) ); + work_res.memcpy( check_array, work_array, sizeof(DATA_TYPE) * RAJA::stripIndexType(array_length) ); // perform array arithmetic on the CPU for (INDEX_TYPE g(0); g < groups; ++g) { @@ -210,9 +203,9 @@ TYPED_TEST_P(KernelHyperplane2DTest, Hyperplane2DKernel) using REDUCE_POLICY = typename camp::at>::type; using USE_PARAM_REDUCERS = typename camp::at>::type; - KernelHyperplane2DTestImpl(1, 10, 10); - KernelHyperplane2DTestImpl(2, 111, 205); - KernelHyperplane2DTestImpl(3, 213, 123); + KernelHyperplane2DTestImpl(INDEX_TYPE{1}, INDEX_TYPE{10}, INDEX_TYPE{10}); + KernelHyperplane2DTestImpl(INDEX_TYPE{2}, INDEX_TYPE{111}, INDEX_TYPE{205}); + KernelHyperplane2DTestImpl(INDEX_TYPE{3}, INDEX_TYPE{213}, INDEX_TYPE{123}); } REGISTER_TYPED_TEST_SUITE_P(KernelHyperplane2DTest, diff --git a/test/functional/kernel/hyperplane/tests/test-kernel-hyperplane-3D.hpp b/test/functional/kernel/hyperplane/tests/test-kernel-hyperplane-3D.hpp index e6597e7a5a..c2fa7ffd3f 100644 --- a/test/functional/kernel/hyperplane/tests/test-kernel-hyperplane-3D.hpp +++ b/test/functional/kernel/hyperplane/tests/test-kernel-hyperplane-3D.hpp @@ -26,13 +26,6 @@ struct val_t_impl { template using VAL_T = typename val_t_impl::type; - -template -RAJA_HOST_DEVICE typename T::value_type get_val(T index_val) { return *index_val; } - -template -requires (!RAJA::concepts::IndexValued) -RAJA_HOST_DEVICE auto get_val(T index_val) { return index_val; } } template @@ -47,10 +40,10 @@ CallKernel(DATA_TYPE& trip_count, { // perform array arithmetic with a 2D J-K hyperplane - RAJA::TypedRangeSegment Grange( 0, get_val(groups) ); - RAJA::TypedRangeStrideSegment Irange( 0, get_val(idim), 1 ); - RAJA::TypedRangeStrideSegment Jrange( get_val(jdim) - 1, -1, -1 ); - RAJA::TypedRangeStrideSegment Krange( 0, get_val(kdim), 1 ); + RAJA::TypedRangeSegment Grange( 0, RAJA::stripIndexType(groups) ); + RAJA::TypedRangeStrideSegment Irange( 0, RAJA::stripIndexType(idim), 1 ); + RAJA::TypedRangeStrideSegment Jrange( RAJA::stripIndexType(jdim) - 1, -1, -1 ); + RAJA::TypedRangeStrideSegment Krange( 0, RAJA::stripIndexType(kdim), 1 ); RAJA::kernel_param ( RAJA::make_tuple( Grange, Irange, Jrange, Krange ), @@ -61,8 +54,8 @@ CallKernel(DATA_TYPE& trip_count, [=] RAJA_HOST_DEVICE ( INDEX_TYPE g, INDEX_TYPE ii, INDEX_TYPE jj, INDEX_TYPE kk, RAJA::expt::ValOp& _trip_count, RAJA::expt::ValOp& _oob_count ) { - if (get_val(g) >= get_val(groups) || get_val(ii) >= get_val(idim) || - get_val(jj) >= get_val(jdim) || get_val(kk) >= get_val(kdim)) { + if (RAJA::stripIndexType(g) >= RAJA::stripIndexType(groups) || RAJA::stripIndexType(ii) >= RAJA::stripIndexType(idim) || + RAJA::stripIndexType(jj) >= RAJA::stripIndexType(jdim) || RAJA::stripIndexType(kk) >= RAJA::stripIndexType(kdim)) { _oob_count += 1; } @@ -100,15 +93,15 @@ CallKernel(DATA_TYPE& _trip_count, RAJA::ReduceSum trip_count (_trip_count); RAJA::ReduceSum oob_count (_oob_count); // perform array arithmetic with a 2D J-K hyperplane - RAJA::TypedRangeSegment Grange( 0, get_val(groups) ); - RAJA::TypedRangeStrideSegment Irange( 0, get_val(idim), 1 ); - RAJA::TypedRangeStrideSegment Jrange( get_val(jdim - 1), -1, -1 ); - RAJA::TypedRangeStrideSegment Krange( 0, get_val(kdim), 1 ); + RAJA::TypedRangeSegment Grange( 0, RAJA::stripIndexType(groups) ); + RAJA::TypedRangeStrideSegment Irange( 0, RAJA::stripIndexType(idim), 1 ); + RAJA::TypedRangeStrideSegment Jrange( RAJA::stripIndexType(jdim - 1), -1, -1 ); + RAJA::TypedRangeStrideSegment Krange( 0, RAJA::stripIndexType(kdim), 1 ); RAJA::kernel ( RAJA::make_tuple( Grange, Irange, Jrange, Krange ), [=] RAJA_HOST_DEVICE ( INDEX_TYPE g, INDEX_TYPE ii, INDEX_TYPE jj, INDEX_TYPE kk ) { - if (get_val(g) >= get_val(groups) || get_val(ii) >= get_val(idim) || - get_val(jj) >= get_val(jdim) || get_val(kk) >= get_val(kdim)) { + if (RAJA::stripIndexType(g) >= RAJA::stripIndexType(groups) || RAJA::stripIndexType(ii) >= RAJA::stripIndexType(idim) || + RAJA::stripIndexType(jj) >= RAJA::stripIndexType(jdim) || RAJA::stripIndexType(kk) >= RAJA::stripIndexType(kdim)) { oob_count += 1; } @@ -159,9 +152,9 @@ KernelHyperplane3DTestImpl(const INDEX_TYPE groups, const INDEX_TYPE idimin, con } else { - idim = get_val(idimin); - jdim = get_val(jdimin); - kdim = get_val(kdimin); + idim = RAJA::stripIndexType(idimin); + jdim = RAJA::stripIndexType(jdimin); + kdim = RAJA::stripIndexType(kdimin); } INDEX_TYPE idim_t(idim); @@ -190,9 +183,9 @@ KernelHyperplane3DTestImpl(const INDEX_TYPE groups, const INDEX_TYPE idimin, con ViewType CheckView( check_array, groups, idim_t, jdim_t, kdim_t ); // initialize array - std::iota( test_array, test_array + get_val(array_length), 1 ); + std::iota( test_array, test_array + RAJA::stripIndexType(array_length), 1 ); - work_res.memcpy( work_array, test_array, sizeof(DATA_TYPE) * get_val(array_length) ); + work_res.memcpy( work_array, test_array, sizeof(DATA_TYPE) * RAJA::stripIndexType(array_length) ); DATA_TYPE trip_count(0); DATA_TYPE oob_count(0); @@ -202,7 +195,7 @@ KernelHyperplane3DTestImpl(const INDEX_TYPE groups, const INDEX_TYPE idimin, con ASSERT_EQ((INDEX_TYPE)trip_count, groups * idim_t * jdim_t * kdim_t); ASSERT_EQ((INDEX_TYPE)oob_count, (INDEX_TYPE)0); - work_res.memcpy( check_array, work_array, sizeof(DATA_TYPE) * get_val(array_length) ); + work_res.memcpy( check_array, work_array, sizeof(DATA_TYPE) * RAJA::stripIndexType(array_length) ); // perform array arithmetic on the CPU for (INDEX_TYPE g(0); g < groups; ++g) { @@ -263,9 +256,9 @@ TYPED_TEST_P(KernelHyperplane3DTest, Hyperplane3DKernel) using REDUCE_POLICY = typename camp::at>::type; using USE_PARAM_REDUCERS = typename camp::at>::type; - KernelHyperplane3DTestImpl(1, 10, 10, 10); - KernelHyperplane3DTestImpl(2, 151, 111, 205); - KernelHyperplane3DTestImpl(3, 101, 213, 123); + KernelHyperplane3DTestImpl(INDEX_TYPE{1}, INDEX_TYPE{10}, INDEX_TYPE{10}, INDEX_TYPE{10}); + KernelHyperplane3DTestImpl(INDEX_TYPE{2}, INDEX_TYPE{151}, INDEX_TYPE{111}, INDEX_TYPE{205}); + KernelHyperplane3DTestImpl(INDEX_TYPE{3}, INDEX_TYPE{101}, INDEX_TYPE{213}, INDEX_TYPE{123}); } REGISTER_TYPED_TEST_SUITE_P(KernelHyperplane3DTest, diff --git a/test/functional/kernel/multi-reduce-nested/tests/test-kernel-nested-MultiReduce.hpp b/test/functional/kernel/multi-reduce-nested/tests/test-kernel-nested-MultiReduce.hpp index bd3164761d..5f0deae933 100644 --- a/test/functional/kernel/multi-reduce-nested/tests/test-kernel-nested-MultiReduce.hpp +++ b/test/functional/kernel/multi-reduce-nested/tests/test-kernel-nested-MultiReduce.hpp @@ -73,7 +73,7 @@ KernelMultiReduceNestedTestImpl(const SEGMENTS_TYPE& segments, IDX_TYPE* check_bins; IDX_TYPE* test_bins; - IDX_TYPE data_len = 0; + IDX_TYPE data_len {0}; allocateForallTestData(idx_range+1, working_res, @@ -81,7 +81,7 @@ KernelMultiReduceNestedTestImpl(const SEGMENTS_TYPE& segments, &check_range, &test_range); - for (IDX_TYPE i = 0; i < idx_range+1; ++i) { + for (IDX_TYPE i {0}; i < idx_range+1; ++i) { test_range[i] = ~IDX_TYPE(0); } @@ -119,7 +119,7 @@ KernelMultiReduceNestedTestImpl(const SEGMENTS_TYPE& segments, std::uniform_int_distribution bin_distribution(0, num_bins-1); - for (IDX_TYPE i = 0; i < data_len; ++i) { + for (IDX_TYPE i {0}; i < data_len; ++i) { test_array[i] = DATA_TYPE(array_int_distribution(rngen)); // this may use the same bin multiple times per iterate @@ -139,7 +139,7 @@ KernelMultiReduceNestedTestImpl(const SEGMENTS_TYPE& segments, { std::vector ref_vals(num_bins, ABSTRACTION::identity(red)); - for (IDX_TYPE i = 0; i < data_len; ++i) { + for (IDX_TYPE i {0}; i < data_len; ++i) { ref_vals[test_bins[i]] = ABSTRACTION::combine(ref_vals[test_bins[i]], test_array[i]); } @@ -170,7 +170,7 @@ KernelMultiReduceNestedTestImpl(const SEGMENTS_TYPE& segments, const int nloops = 2; for (int j = 0; j < nloops; ++j) { - for (IDX_TYPE i = 0; i < data_len; ++i) { + for (IDX_TYPE i {0}; i < data_len; ++i) { ref_vals[test_bins[i]] = ABSTRACTION::combine(ref_vals[test_bins[i]], test_array[i]); } @@ -199,7 +199,7 @@ KernelMultiReduceNestedTestImpl(const SEGMENTS_TYPE& segments, std::uniform_int_distribution, std::uniform_real_distribution> array_flt_distribution(0, modval-1); - for (IDX_TYPE i = 0; i < data_len; ++i) { + for (IDX_TYPE i {0}; i < data_len; ++i) { test_array[i] = DATA_TYPE(array_flt_distribution(rngen)); } working_res.memcpy(working_array, test_array, sizeof(DATA_TYPE) * data_len); diff --git a/test/functional/kernel/nested-loop-segment-types/tests/test-kernel-nested-loops-segment-types.hpp b/test/functional/kernel/nested-loop-segment-types/tests/test-kernel-nested-loops-segment-types.hpp index a0259e91cf..d2e19ebf9e 100644 --- a/test/functional/kernel/nested-loop-segment-types/tests/test-kernel-nested-loops-segment-types.hpp +++ b/test/functional/kernel/nested-loop-segment-types/tests/test-kernel-nested-loops-segment-types.hpp @@ -31,13 +31,6 @@ struct val_t_impl { template using VAL_T = typename val_t_impl::type; - -template -RAJA_HOST_DEVICE typename T::value_type get_val(T index_val) { return *index_val; } - -template -requires (!RAJA::concepts::IndexValued) -RAJA_HOST_DEVICE auto get_val(T index_val) { return index_val; } } template @@ -60,9 +53,9 @@ void KernelNestedLoopsSegmentTypesTestImpl( zero_legth_segment = true; } - IDX_TYPE dim1 = 1; - IDX_TYPE dim2 = 1; - IDX_TYPE dim3 = 1; + IDX_TYPE dim1 {1}; + IDX_TYPE dim2 {1}; + IDX_TYPE dim3 {1}; if ( !zero_legth_segment ) { dim1 = s1_idx[s1_idx.size() - 1] + 1; @@ -89,18 +82,18 @@ void KernelNestedLoopsSegmentTypesTestImpl( ViewType test_view(test_array, dim1, dim2, dim3); memset( static_cast(test_array), 0, - sizeof(DATA_TYPE) * get_val(data_len) ); + sizeof(DATA_TYPE) * RAJA::stripIndexType(data_len) ); working_res.memcpy(work_array, test_array, - sizeof(DATA_TYPE) * get_val(data_len)); + sizeof(DATA_TYPE) * RAJA::stripIndexType(data_len)); if ( !zero_legth_segment ) { - for (IDX_TYPE i1 = 0; i1 < idx1_len; ++i1) { - for (IDX_TYPE i2 = 0; i2 < idx2_len; ++i2) { - for (IDX_TYPE i3 = 0; i3 < idx3_len; ++i3) { - auto ii1 = get_val(i1); - auto ii2 = get_val(i2); - auto ii3 = get_val(i3); + for (IDX_TYPE i1 {0}; i1 < idx1_len; ++i1) { + for (IDX_TYPE i2 {0}; i2 < idx2_len; ++i2) { + for (IDX_TYPE i3 {0}; i3 < idx3_len; ++i3) { + auto ii1 = RAJA::stripIndexType(i1); + auto ii2 = RAJA::stripIndexType(i2); + auto ii3 = RAJA::stripIndexType(i3); test_view( s1_idx[ii1], s2_idx[ii2], s3_idx[ii3] ) = static_cast( RAJA::stripIndexType( s1_idx[ii1] + s2_idx[ii2] + s3_idx[ii3]) ); @@ -137,9 +130,9 @@ void KernelNestedLoopsSegmentTypesTestImpl( } working_res.memcpy(check_array, work_array, - sizeof(DATA_TYPE) * get_val(data_len)); + sizeof(DATA_TYPE) * RAJA::stripIndexType(data_len)); - for (IDX_TYPE i = 0; i < data_len; ++i) { + for (IDX_TYPE i {0}; i < data_len; ++i) { auto ii = RAJA::stripIndexType(i); ASSERT_EQ( test_array[ii], check_array[ii] ); } @@ -179,9 +172,9 @@ TYPED_TEST_P(KernelNestedLoopsSegmentTypesTest, NestedLoopsSegmentTypesKernel) RAJA::TypedRangeStrideSegment s2( raw_idx_type(3), raw_idx_type(188), raw_idx_type(2) ); RAJA::getIndices(s2_idx, s2); - IDX_TYPE last = IDX_TYPE(427); + IDX_TYPE last {427}; srand( time(NULL) ); - for (IDX_TYPE i = IDX_TYPE(0); i < last; ++i) { + for (IDX_TYPE i {0}; i < last; ++i) { IDX_TYPE randval = IDX_TYPE( rand() % RAJA::stripIndexType(last) ); if ( i < randval ) { s3_idx.push_back(i); diff --git a/test/functional/kernel/nested-loop-view-types/tests/test-kernel-nested-loop-PermutedOffsetView2D.hpp b/test/functional/kernel/nested-loop-view-types/tests/test-kernel-nested-loop-PermutedOffsetView2D.hpp index 966af4aee6..6932ce53ce 100644 --- a/test/functional/kernel/nested-loop-view-types/tests/test-kernel-nested-loop-PermutedOffsetView2D.hpp +++ b/test/functional/kernel/nested-loop-view-types/tests/test-kernel-nested-loop-PermutedOffsetView2D.hpp @@ -23,13 +23,6 @@ struct val_t_impl { template using VAL_T = typename val_t_impl::type; - -template -RAJA_HOST_DEVICE typename T::value_type get_val(T index_val) { return *index_val; } - -template -requires (!RAJA::concepts::IndexValued) -RAJA_HOST_DEVICE auto get_val(T index_val) { return index_val; } } template @@ -127,8 +120,8 @@ void KernelPermutedOffsetView2DTestImpl(std::array dim, RAJA::kernel( RAJA::make_tuple( iseg, jseg ), [=] RAJA_HOST_DEVICE(IDX_TYPE i, IDX_TYPE j) { - auto ii = raw_idx_type(get_val(i)); - auto jj = raw_idx_type(get_val(j)); + auto ii = raw_idx_type(RAJA::stripIndexType(i)); + auto jj = raw_idx_type(RAJA::stripIndexType(j)); auto a_idx = RAJA::stripIndexType(A_layout(ii, jj)); A_work_array[a_idx] = B_work_array[RAJA::stripIndexType(B_layout(ii, jj))] + diff --git a/test/functional/kernel/nested-loop-view-types/tests/test-kernel-nested-loop-PermutedOffsetView3D.hpp b/test/functional/kernel/nested-loop-view-types/tests/test-kernel-nested-loop-PermutedOffsetView3D.hpp index f086e5900a..cb1c2c343f 100644 --- a/test/functional/kernel/nested-loop-view-types/tests/test-kernel-nested-loop-PermutedOffsetView3D.hpp +++ b/test/functional/kernel/nested-loop-view-types/tests/test-kernel-nested-loop-PermutedOffsetView3D.hpp @@ -23,13 +23,6 @@ struct val_t_impl { template using VAL_T = typename val_t_impl::type; - -template -RAJA_HOST_DEVICE typename T::value_type get_val(T index_val) { return *index_val; } - -template -requires (!RAJA::concepts::IndexValued) -RAJA_HOST_DEVICE auto get_val(T index_val) { return index_val; } } template @@ -145,9 +138,9 @@ void KernelPermutedOffsetView3DTestImpl(std::array dim, RAJA::kernel( RAJA::make_tuple( iseg, jseg, kseg ), [=] RAJA_HOST_DEVICE(IDX_TYPE i, IDX_TYPE j, IDX_TYPE k) { - auto ii = raw_idx_type(get_val(i)); - auto jj = raw_idx_type(get_val(j)); - auto kk = raw_idx_type(get_val(k)); + auto ii = raw_idx_type(RAJA::stripIndexType(i)); + auto jj = raw_idx_type(RAJA::stripIndexType(j)); + auto kk = raw_idx_type(RAJA::stripIndexType(k)); auto a_idx = RAJA::stripIndexType(A_layout(ii, jj, kk)); A_work_array[a_idx] = B_work_array[RAJA::stripIndexType(B_layout(ii, jj, kk))] + diff --git a/test/functional/kernel/nested-loop-view-types/tests/test-kernel-nested-loop-PermutedView2D.hpp b/test/functional/kernel/nested-loop-view-types/tests/test-kernel-nested-loop-PermutedView2D.hpp index 82bc205cb0..f30d32f24e 100644 --- a/test/functional/kernel/nested-loop-view-types/tests/test-kernel-nested-loop-PermutedView2D.hpp +++ b/test/functional/kernel/nested-loop-view-types/tests/test-kernel-nested-loop-PermutedView2D.hpp @@ -23,13 +23,6 @@ struct val_t_impl { template using VAL_T = typename val_t_impl::type; - -template -RAJA_HOST_DEVICE typename T::value_type get_val(T index_val) { return *index_val; } - -template -requires (!RAJA::concepts::IndexValued) -RAJA_HOST_DEVICE auto get_val(T index_val) { return index_val; } } template @@ -57,7 +50,7 @@ void KernelPermutedView2DTestImpl(std::array dim, working_res.memcpy(working_array, test_array, sizeof(IDX_TYPE) * N); using raw_idx_type = VAL_T; - raw_idx_type mod_val = get_val(dim.at( perm.at(1) )); + raw_idx_type mod_val = RAJA::stripIndexType(dim.at( perm.at(1) )); for (RAJA::idx_t ii = 0; ii < N; ++ii) { test_array[ii] = static_cast(ii % mod_val); } @@ -68,7 +61,7 @@ void KernelPermutedView2DTestImpl(std::array dim, RAJA::make_tuple( RAJA::TypedRangeSegment(0, IDX_TYPE(dim_strip.at(0))), RAJA::TypedRangeSegment(0, IDX_TYPE(dim_strip.at(1))) ), [=] RAJA_HOST_DEVICE(IDX_TYPE i, IDX_TYPE j) { - auto linear = RAJA::stripIndexType(layout(get_val(i), get_val(j))); + auto linear = RAJA::stripIndexType(layout(RAJA::stripIndexType(i), RAJA::stripIndexType(j))); working_array[linear] = static_cast(linear % mod_val); } ); diff --git a/test/functional/kernel/nested-loop-view-types/tests/test-kernel-nested-loop-PermutedView3D.hpp b/test/functional/kernel/nested-loop-view-types/tests/test-kernel-nested-loop-PermutedView3D.hpp index 043cfb39b3..63bb93fa7e 100644 --- a/test/functional/kernel/nested-loop-view-types/tests/test-kernel-nested-loop-PermutedView3D.hpp +++ b/test/functional/kernel/nested-loop-view-types/tests/test-kernel-nested-loop-PermutedView3D.hpp @@ -23,13 +23,6 @@ struct val_t_impl { template using VAL_T = typename val_t_impl::type; - -template -RAJA_HOST_DEVICE typename T::value_type get_val(T index_val) { return *index_val; } - -template -requires (!RAJA::concepts::IndexValued) -RAJA_HOST_DEVICE auto get_val(T index_val) { return index_val; } } template @@ -58,7 +51,7 @@ void KernelPermutedView3DTestImpl(std::array dim, working_res.memcpy(working_array, test_array, sizeof(IDX_TYPE) * N); using raw_idx_type = VAL_T; - raw_idx_type mod_val = get_val(dim.at(perm.at(1))) * get_val(dim.at(perm.at(2))); + raw_idx_type mod_val = RAJA::stripIndexType(dim.at(perm.at(1))) * RAJA::stripIndexType(dim.at(perm.at(2))); for (RAJA::idx_t ii = 0; ii < N; ++ii) { test_array[ii] = static_cast(ii % mod_val); } @@ -70,7 +63,7 @@ void KernelPermutedView3DTestImpl(std::array dim, RAJA::TypedRangeSegment(0, IDX_TYPE(dim_strip.at(1))), RAJA::TypedRangeSegment(0, IDX_TYPE(dim_strip.at(2))) ), [=] RAJA_HOST_DEVICE(IDX_TYPE i, IDX_TYPE j, IDX_TYPE k) { - auto linear = RAJA::stripIndexType(layout(get_val(i), get_val(j), get_val(k))); + auto linear = RAJA::stripIndexType(layout(RAJA::stripIndexType(i), RAJA::stripIndexType(j), RAJA::stripIndexType(k))); working_array[linear] = static_cast(linear % mod_val); } ); diff --git a/test/functional/kernel/reduce-loc/tests/test-kernel-reduceloc-Max2D.hpp b/test/functional/kernel/reduce-loc/tests/test-kernel-reduceloc-Max2D.hpp index 0f66a98e6e..4aab4284d2 100644 --- a/test/functional/kernel/reduce-loc/tests/test-kernel-reduceloc-Max2D.hpp +++ b/test/functional/kernel/reduce-loc/tests/test-kernel-reduceloc-Max2D.hpp @@ -24,13 +24,6 @@ struct val_t_impl { template using VAL_T = typename val_t_impl::type; -template -RAJA_HOST_DEVICE typename T::value_type get_val(T index_val) { return *index_val; } - -template -requires (!RAJA::concepts::IndexValued) -RAJA_HOST_DEVICE auto get_val(T index_val) { return index_val; } - } template @@ -64,17 +57,17 @@ void KernelLocMax2DTestImpl(const INDEX_TYPE xdim, const INDEX_TYPE ydim) { for ( INDEX_TYPE xx(0); xx < xdim; ++xx ) { - CheckView(zz, xx) = get_val(zz * xdim + xx); + CheckView(zz, xx) = RAJA::stripIndexType(zz * xdim + xx); } CheckView(ydim - 1, xdim - 1) = 0; }); - work_res.memcpy(work_array, check_array, sizeof(DATA_TYPE) * get_val(array_length)); + work_res.memcpy(work_array, check_array, sizeof(DATA_TYPE) * RAJA::stripIndexType(array_length)); RAJA::TypedRangeSegment colrange(0, xdim); RAJA::TypedRangeSegment rowrange(0, ydim); - RAJA::ReduceMaxLoc> maxloc_reducer((DATA_TYPE)0, Index2D(0, 0)); + RAJA::ReduceMaxLoc> maxloc_reducer((DATA_TYPE)0, Index2D(INDEX_TYPE{0}, INDEX_TYPE{0})); RAJA::kernel(RAJA::make_tuple(colrange, rowrange), [=] RAJA_HOST_DEVICE (INDEX_TYPE c, INDEX_TYPE r) { @@ -82,7 +75,7 @@ void KernelLocMax2DTestImpl(const INDEX_TYPE xdim, const INDEX_TYPE ydim) }); // CPU answer - RAJA::ReduceMaxLoc> checkmaxloc_reducer((DATA_TYPE)0, Index2D(0, 0)); + RAJA::ReduceMaxLoc> checkmaxloc_reducer((DATA_TYPE)0, Index2D(INDEX_TYPE{0}, INDEX_TYPE{0})); RAJA::forall(colrange, [=] (INDEX_TYPE c) { for (INDEX_TYPE r(0); r < ydim; ++r) @@ -123,9 +116,9 @@ TYPED_TEST_P(KernelLocMax2DTest, LocMax2DKernel) using EXEC_POLICY = typename camp::at>::type; using REDUCE_POLICY = typename camp::at>::type; - KernelLocMax2DTestImpl(10, 10); - KernelLocMax2DTestImpl(151, 151); - KernelLocMax2DTestImpl(362, 362); + KernelLocMax2DTestImpl(INDEX_TYPE{10}, INDEX_TYPE{10}); + KernelLocMax2DTestImpl(INDEX_TYPE{151}, INDEX_TYPE{151}); + KernelLocMax2DTestImpl(INDEX_TYPE{362}, INDEX_TYPE{362}); } REGISTER_TYPED_TEST_SUITE_P(KernelLocMax2DTest, diff --git a/test/functional/kernel/reduce-loc/tests/test-kernel-reduceloc-Max2DView.hpp b/test/functional/kernel/reduce-loc/tests/test-kernel-reduceloc-Max2DView.hpp index 657d592507..de5a51a718 100644 --- a/test/functional/kernel/reduce-loc/tests/test-kernel-reduceloc-Max2DView.hpp +++ b/test/functional/kernel/reduce-loc/tests/test-kernel-reduceloc-Max2DView.hpp @@ -24,13 +24,6 @@ struct val_t_impl { template using VAL_T = typename val_t_impl::type; -template -RAJA_HOST_DEVICE typename T::value_type get_val(T index_val) { return *index_val; } - -template -requires (!RAJA::concepts::IndexValued) -RAJA_HOST_DEVICE auto get_val(T index_val) { return index_val; } - } template @@ -64,17 +57,17 @@ void KernelLocMax2DViewTestImpl(const INDEX_TYPE xdim, const INDEX_TYPE ydim) { for ( INDEX_TYPE xx(0); xx < xdim; ++xx ) { - CheckView(zz, xx) = get_val(zz * xdim + xx); + CheckView(zz, xx) = RAJA::stripIndexType(zz * xdim + xx); } CheckView(ydim - 1, xdim - 1) = 0; }); - work_res.memcpy(work_array, check_array, sizeof(DATA_TYPE) * get_val(array_length)); + work_res.memcpy(work_array, check_array, sizeof(DATA_TYPE) * RAJA::stripIndexType(array_length)); RAJA::TypedRangeSegment colrange(0, xdim); RAJA::TypedRangeSegment rowrange(0, ydim); - RAJA::ReduceMaxLoc> maxloc_reducer((DATA_TYPE)0, Index2D(0, 0)); + RAJA::ReduceMaxLoc> maxloc_reducer((DATA_TYPE)0, Index2D(INDEX_TYPE{0}, INDEX_TYPE{0})); RAJA::kernel(RAJA::make_tuple(colrange, rowrange), [=] RAJA_HOST_DEVICE (INDEX_TYPE c, INDEX_TYPE r) { @@ -82,7 +75,7 @@ void KernelLocMax2DViewTestImpl(const INDEX_TYPE xdim, const INDEX_TYPE ydim) }); // CPU answer - RAJA::ReduceMaxLoc> checkmaxloc_reducer((DATA_TYPE)0, Index2D(0, 0)); + RAJA::ReduceMaxLoc> checkmaxloc_reducer((DATA_TYPE)0, Index2D(INDEX_TYPE{0}, INDEX_TYPE{0})); RAJA::forall(colrange, [=] (INDEX_TYPE c) { for (INDEX_TYPE r(0); r < ydim; ++r) @@ -123,9 +116,9 @@ TYPED_TEST_P(KernelLocMax2DViewTest, LocMax2DViewKernel) using EXEC_POLICY = typename camp::at>::type; using REDUCE_POLICY = typename camp::at>::type; - KernelLocMax2DViewTestImpl(10, 10); - KernelLocMax2DViewTestImpl(151, 151); - KernelLocMax2DViewTestImpl(362, 362); + KernelLocMax2DViewTestImpl(INDEX_TYPE{10}, INDEX_TYPE{10}); + KernelLocMax2DViewTestImpl(INDEX_TYPE{151}, INDEX_TYPE{151}); + KernelLocMax2DViewTestImpl(INDEX_TYPE{362}, INDEX_TYPE{362}); } REGISTER_TYPED_TEST_SUITE_P(KernelLocMax2DViewTest, diff --git a/test/functional/kernel/reduce-loc/tests/test-kernel-reduceloc-Max2DViewTuple.hpp b/test/functional/kernel/reduce-loc/tests/test-kernel-reduceloc-Max2DViewTuple.hpp index 9a26682a8e..c01ebc476f 100644 --- a/test/functional/kernel/reduce-loc/tests/test-kernel-reduceloc-Max2DViewTuple.hpp +++ b/test/functional/kernel/reduce-loc/tests/test-kernel-reduceloc-Max2DViewTuple.hpp @@ -24,13 +24,6 @@ struct val_t_impl { template using VAL_T = typename val_t_impl::type; -template -RAJA_HOST_DEVICE typename T::value_type get_val(T index_val) { return *index_val; } - -template -requires (!RAJA::concepts::IndexValued) -RAJA_HOST_DEVICE auto get_val(T index_val) { return index_val; } - } template @@ -64,12 +57,12 @@ void KernelLocMax2DViewTupleTestImpl(const INDEX_TYPE xdim, const INDEX_TYPE ydi { for ( INDEX_TYPE xx(0); xx < xdim; ++xx ) { - CheckView(zz, xx) = get_val(zz * xdim + xx); + CheckView(zz, xx) = RAJA::stripIndexType(zz * xdim + xx); } CheckView(ydim - 1, xdim - 1) = 0; }); - work_res.memcpy(work_array, check_array, sizeof(DATA_TYPE) * get_val(array_length)); + work_res.memcpy(work_array, check_array, sizeof(DATA_TYPE) * RAJA::stripIndexType(array_length)); #if defined(RAJA_ENABLE_TARGET_OPENMP) //#pragma omp target data map(to:work_array[0:array_length]) @@ -84,11 +77,11 @@ void KernelLocMax2DViewTupleTestImpl(const INDEX_TYPE xdim, const INDEX_TYPE ydi RAJA::kernel(RAJA::make_tuple(colrange, rowrange), [=] RAJA_HOST_DEVICE (INDEX_TYPE c, INDEX_TYPE r) { - maxloc_reducer.maxloc(ArrView(r, c), RAJA::make_tuple((DATA_TYPE)get_val(c), (DATA_TYPE)get_val(r))); + maxloc_reducer.maxloc(ArrView(r, c), RAJA::make_tuple((DATA_TYPE)RAJA::stripIndexType(c), (DATA_TYPE)RAJA::stripIndexType(r))); }); // CPU answer - RAJA::ReduceMaxLoc> checkmaxloc_reducer((DATA_TYPE)0, Index2D(0, 0)); + RAJA::ReduceMaxLoc> checkmaxloc_reducer((DATA_TYPE)0, Index2D(INDEX_TYPE{0}, INDEX_TYPE{0})); RAJA::forall(colrange, [=] (INDEX_TYPE c) { for (INDEX_TYPE r(0); r < ydim; ++r) @@ -129,9 +122,9 @@ TYPED_TEST_P(KernelLocMax2DViewTupleTest, LocMax2DViewTupleKernel) using EXEC_POLICY = typename camp::at>::type; using REDUCE_POLICY = typename camp::at>::type; - KernelLocMax2DViewTupleTestImpl(10, 10); - KernelLocMax2DViewTupleTestImpl(151, 151); - KernelLocMax2DViewTupleTestImpl(362, 362); + KernelLocMax2DViewTupleTestImpl(INDEX_TYPE{10}, INDEX_TYPE{10}); + KernelLocMax2DViewTupleTestImpl(INDEX_TYPE{151}, INDEX_TYPE{151}); + KernelLocMax2DViewTupleTestImpl(INDEX_TYPE{362}, INDEX_TYPE{362}); } REGISTER_TYPED_TEST_SUITE_P(KernelLocMax2DViewTupleTest, diff --git a/test/functional/kernel/reduce-loc/tests/test-kernel-reduceloc-Min2D.hpp b/test/functional/kernel/reduce-loc/tests/test-kernel-reduceloc-Min2D.hpp index 8667b7cf34..c86fa37d88 100644 --- a/test/functional/kernel/reduce-loc/tests/test-kernel-reduceloc-Min2D.hpp +++ b/test/functional/kernel/reduce-loc/tests/test-kernel-reduceloc-Min2D.hpp @@ -24,13 +24,6 @@ struct val_t_impl { template using VAL_T = typename val_t_impl::type; -template -RAJA_HOST_DEVICE typename T::value_type get_val(T index_val) { return *index_val; } - -template -requires (!RAJA::concepts::IndexValued) -RAJA_HOST_DEVICE auto get_val(T index_val) { return index_val; } - } template @@ -64,17 +57,17 @@ void KernelLocMin2DTestImpl(const INDEX_TYPE xdim, const INDEX_TYPE ydim) { for ( INDEX_TYPE xx(0); xx < xdim; ++xx ) { - CheckView(zz, xx) = get_val(zz * xdim + xx) + 1; + CheckView(zz, xx) = RAJA::stripIndexType(zz * xdim + xx) + 1; } CheckView(ydim - 1, xdim - 1) = 0; }); - work_res.memcpy(work_array, check_array, sizeof(DATA_TYPE) * get_val(array_length)); + work_res.memcpy(work_array, check_array, sizeof(DATA_TYPE) * RAJA::stripIndexType(array_length)); RAJA::TypedRangeSegment colrange(0, xdim); RAJA::TypedRangeSegment rowrange(0, ydim); - RAJA::ReduceMinLoc> minloc_reducer((DATA_TYPE)1024, Index2D(0, 0)); + RAJA::ReduceMinLoc> minloc_reducer((DATA_TYPE)1024, Index2D(INDEX_TYPE{0}, INDEX_TYPE{0})); RAJA::kernel(RAJA::make_tuple(colrange, rowrange), [=] RAJA_HOST_DEVICE (INDEX_TYPE c, INDEX_TYPE r) { @@ -82,7 +75,7 @@ void KernelLocMin2DTestImpl(const INDEX_TYPE xdim, const INDEX_TYPE ydim) }); // CPU answer - RAJA::ReduceMinLoc> checkminloc_reducer((DATA_TYPE)1024, Index2D(0, 0)); + RAJA::ReduceMinLoc> checkminloc_reducer((DATA_TYPE)1024, Index2D(INDEX_TYPE{0}, INDEX_TYPE{0})); RAJA::forall(colrange, [=] (INDEX_TYPE c) { for (INDEX_TYPE r(0); r < ydim; ++r) @@ -123,9 +116,9 @@ TYPED_TEST_P(KernelLocMin2DTest, LocMin2DKernel) using EXEC_POLICY = typename camp::at>::type; using REDUCE_POLICY = typename camp::at>::type; - KernelLocMin2DTestImpl(10, 10); - KernelLocMin2DTestImpl(151, 151); - KernelLocMin2DTestImpl(362, 362); + KernelLocMin2DTestImpl(INDEX_TYPE{10}, INDEX_TYPE{10}); + KernelLocMin2DTestImpl(INDEX_TYPE{151}, INDEX_TYPE{151}); + KernelLocMin2DTestImpl(INDEX_TYPE{362}, INDEX_TYPE{362}); } REGISTER_TYPED_TEST_SUITE_P(KernelLocMin2DTest, diff --git a/test/functional/kernel/reduce-loc/tests/test-kernel-reduceloc-Min2DView.hpp b/test/functional/kernel/reduce-loc/tests/test-kernel-reduceloc-Min2DView.hpp index c8e6d246c7..d199dfcf2a 100644 --- a/test/functional/kernel/reduce-loc/tests/test-kernel-reduceloc-Min2DView.hpp +++ b/test/functional/kernel/reduce-loc/tests/test-kernel-reduceloc-Min2DView.hpp @@ -24,13 +24,6 @@ struct val_t_impl { template using VAL_T = typename val_t_impl::type; -template -RAJA_HOST_DEVICE typename T::value_type get_val(T index_val) { return *index_val; } - -template -requires (!RAJA::concepts::IndexValued) -RAJA_HOST_DEVICE auto get_val(T index_val) { return index_val; } - } template @@ -64,17 +57,17 @@ void KernelLocMin2DViewTestImpl(const INDEX_TYPE xdim, const INDEX_TYPE ydim) { for ( INDEX_TYPE xx(0); xx < xdim; ++xx ) { - CheckView(zz, xx) = get_val(zz * xdim + xx) + 1; + CheckView(zz, xx) = RAJA::stripIndexType(zz * xdim + xx) + 1; } CheckView(ydim - 1, xdim - 1) = 0; }); - work_res.memcpy(work_array, check_array, sizeof(DATA_TYPE) * get_val(array_length)); + work_res.memcpy(work_array, check_array, sizeof(DATA_TYPE) * RAJA::stripIndexType(array_length)); RAJA::TypedRangeSegment colrange(0, xdim); RAJA::TypedRangeSegment rowrange(0, ydim); - RAJA::ReduceMinLoc> minloc_reducer((DATA_TYPE)1024, Index2D(0, 0)); + RAJA::ReduceMinLoc> minloc_reducer((DATA_TYPE)1024, Index2D(INDEX_TYPE{0}, INDEX_TYPE{0})); RAJA::kernel(RAJA::make_tuple(colrange, rowrange), [=] RAJA_HOST_DEVICE (INDEX_TYPE c, INDEX_TYPE r) { @@ -82,7 +75,7 @@ void KernelLocMin2DViewTestImpl(const INDEX_TYPE xdim, const INDEX_TYPE ydim) }); // CPU answer - RAJA::ReduceMinLoc> checkminloc_reducer((DATA_TYPE)1024, Index2D(0, 0)); + RAJA::ReduceMinLoc> checkminloc_reducer((DATA_TYPE)1024, Index2D(INDEX_TYPE{0}, INDEX_TYPE{0})); RAJA::forall(colrange, [=] (INDEX_TYPE c) { for (INDEX_TYPE r(0); r < ydim; ++r) @@ -123,9 +116,9 @@ TYPED_TEST_P(KernelLocMin2DViewTest, LocMin2DViewKernel) using EXEC_POLICY = typename camp::at>::type; using REDUCE_POLICY = typename camp::at>::type; - KernelLocMin2DViewTestImpl(10, 10); - KernelLocMin2DViewTestImpl(151, 151); - KernelLocMin2DViewTestImpl(362, 362); + KernelLocMin2DViewTestImpl(INDEX_TYPE{10}, INDEX_TYPE{10}); + KernelLocMin2DViewTestImpl(INDEX_TYPE{151}, INDEX_TYPE{151}); + KernelLocMin2DViewTestImpl(INDEX_TYPE{362}, INDEX_TYPE{362}); } REGISTER_TYPED_TEST_SUITE_P(KernelLocMin2DViewTest, diff --git a/test/functional/kernel/reduce-loc/tests/test-kernel-reduceloc-Min2DViewTuple.hpp b/test/functional/kernel/reduce-loc/tests/test-kernel-reduceloc-Min2DViewTuple.hpp index 90dafc9d73..973c51410e 100644 --- a/test/functional/kernel/reduce-loc/tests/test-kernel-reduceloc-Min2DViewTuple.hpp +++ b/test/functional/kernel/reduce-loc/tests/test-kernel-reduceloc-Min2DViewTuple.hpp @@ -24,13 +24,6 @@ struct val_t_impl { template using VAL_T = typename val_t_impl::type; -template -RAJA_HOST_DEVICE typename T::value_type get_val(T index_val) { return *index_val; } - -template -requires (!RAJA::concepts::IndexValued) -RAJA_HOST_DEVICE auto get_val(T index_val) { return index_val; } - } template @@ -64,12 +57,12 @@ void KernelLocMin2DViewTupleTestImpl(const INDEX_TYPE xdim, const INDEX_TYPE ydi { for ( INDEX_TYPE xx(0); xx < xdim; ++xx ) { - CheckView(zz, xx) = get_val(zz * xdim + xx) + 1; + CheckView(zz, xx) = RAJA::stripIndexType(zz * xdim + xx) + 1; } CheckView(ydim - 1, xdim - 1) = 0; }); - work_res.memcpy(work_array, check_array, sizeof(DATA_TYPE) * get_val(array_length)); + work_res.memcpy(work_array, check_array, sizeof(DATA_TYPE) * RAJA::stripIndexType(array_length)); RAJA::TypedRangeSegment colrange(0, xdim); RAJA::TypedRangeSegment rowrange(0, ydim); @@ -80,11 +73,11 @@ void KernelLocMin2DViewTupleTestImpl(const INDEX_TYPE xdim, const INDEX_TYPE ydi RAJA::kernel(RAJA::make_tuple(colrange, rowrange), [=] RAJA_HOST_DEVICE (INDEX_TYPE c, INDEX_TYPE r) { - minloc_reducer.minloc(ArrView(r, c), RAJA::make_tuple((DATA_TYPE)get_val(c), (DATA_TYPE)get_val(r))); + minloc_reducer.minloc(ArrView(r, c), RAJA::make_tuple((DATA_TYPE)RAJA::stripIndexType(c), (DATA_TYPE)RAJA::stripIndexType(r))); }); // CPU answer - RAJA::ReduceMinLoc> checkminloc_reducer((DATA_TYPE)1024, Index2D(0, 0)); + RAJA::ReduceMinLoc> checkminloc_reducer((DATA_TYPE)1024, Index2D(INDEX_TYPE{0}, INDEX_TYPE{0})); RAJA::forall(colrange, [=] (INDEX_TYPE c) { for (INDEX_TYPE r(0); r < ydim; ++r) @@ -125,9 +118,9 @@ TYPED_TEST_P(KernelLocMin2DViewTupleTest, LocMin2DViewTupleKernel) using EXEC_POLICY = typename camp::at>::type; using REDUCE_POLICY = typename camp::at>::type; - KernelLocMin2DViewTupleTestImpl(10, 10); - KernelLocMin2DViewTupleTestImpl(151, 151); - KernelLocMin2DViewTupleTestImpl(362, 362); + KernelLocMin2DViewTupleTestImpl(INDEX_TYPE{10}, INDEX_TYPE{10}); + KernelLocMin2DViewTupleTestImpl(INDEX_TYPE{151}, INDEX_TYPE{151}); + KernelLocMin2DViewTupleTestImpl(INDEX_TYPE{362}, INDEX_TYPE{362}); } REGISTER_TYPED_TEST_SUITE_P(KernelLocMin2DViewTupleTest, diff --git a/test/functional/kernel/reduce-params-multi-lambda/tests/test-kernel-reduce-params-multi-lambda.hpp b/test/functional/kernel/reduce-params-multi-lambda/tests/test-kernel-reduce-params-multi-lambda.hpp index 7c772c4712..44622ae787 100644 --- a/test/functional/kernel/reduce-params-multi-lambda/tests/test-kernel-reduce-params-multi-lambda.hpp +++ b/test/functional/kernel/reduce-params-multi-lambda/tests/test-kernel-reduce-params-multi-lambda.hpp @@ -23,13 +23,6 @@ struct val_t_impl { template using VAL_T = typename val_t_impl::type; - -template -RAJA_HOST_DEVICE typename T::value_type get_val(T index_val) { return *index_val; } - -template -requires (!RAJA::concepts::IndexValued) -RAJA_HOST_DEVICE auto get_val(T index_val) { return index_val; } } template @@ -62,10 +55,10 @@ void KernelParamReduceMultiLambda(const INDEX_TYPE xdim_t, const INDEX_TYPE ydim // initializing values for (INDEX_TYPE row(0); row < ydim_t; ++row) { - for ( raw_index_type col = 0; col < get_val(xdim_t); ++col ) + for ( raw_index_type col = 0; col < RAJA::stripIndexType(xdim_t); ++col ) { CheckView(row, INDEX_TYPE(col)) = - (get_val(row) * get_val(xdim_t) + col) % 100 + 1; + (RAJA::stripIndexType(row) * RAJA::stripIndexType(xdim_t) + col) % 100 + 1; } // Make a unique min CheckView(ydim_t - INDEX_TYPE(1), xdim_t - INDEX_TYPE(1)) = 0; @@ -73,7 +66,7 @@ void KernelParamReduceMultiLambda(const INDEX_TYPE xdim_t, const INDEX_TYPE ydim CheckView(ydim_t / INDEX_TYPE(2), xdim_t / INDEX_TYPE(2)) = 101; } - work_res.memcpy(work_array, check_array, sizeof(DATA_TYPE) * get_val(array_length)); + work_res.memcpy(work_array, check_array, sizeof(DATA_TYPE) * RAJA::stripIndexType(array_length)); RAJA::TypedRangeSegment colrange(0, xdim_t); RAJA::TypedRangeSegment rowrange(0, ydim_t); @@ -150,7 +143,7 @@ void KernelParamReduceMultiLambda(const INDEX_TYPE xdim_t, const INDEX_TYPE ydim VALOP_DATA_TYPE_MIN &_min, VALOP_DATA_TYPE_MAX &_max ) { - for (raw_index_type c = 0; c < get_val(xdim_t); ++c) + for (raw_index_type c = 0; c < RAJA::stripIndexType(xdim_t); ++c) { auto c_idx = INDEX_TYPE(c); _sum += CheckView(r, c_idx); diff --git a/test/functional/kernel/reduce-params/tests/test-kernel-basic-param.hpp b/test/functional/kernel/reduce-params/tests/test-kernel-basic-param.hpp index c707a06835..8c846149e3 100644 --- a/test/functional/kernel/reduce-params/tests/test-kernel-basic-param.hpp +++ b/test/functional/kernel/reduce-params/tests/test-kernel-basic-param.hpp @@ -10,29 +10,6 @@ #ifndef __TEST_KERNEL_REDUCELOC_MAX2D_HPP__ #define __TEST_KERNEL_REDUCELOC_MAX2D_HPP__ -namespace { -template -struct val_t_impl { - using type = T; -}; - -template -struct val_t_impl { - using type = typename T::value_type; -}; - -template -using VAL_T = typename val_t_impl::type; - -template -typename T::value_type get_val(T index_val) { return *index_val; } - -template -requires (!RAJA::concepts::IndexValued) -auto get_val(T index_val) { return index_val; } - -} - template void KernelParamReduceTestImpl(const INDEX_TYPE xdim, const INDEX_TYPE ydim) { @@ -65,7 +42,7 @@ void KernelParamReduceTestImpl(const INDEX_TYPE xdim, const INDEX_TYPE ydim) { for ( INDEX_TYPE xx (0); xx < xdim; ++xx ) { - CheckView(zz, xx) = get_val(zz * xdim + xx ) % 100 + 1; + CheckView(zz, xx) = RAJA::stripIndexType(zz * xdim + xx ) % 100 + 1; } // Make a unique min CheckView(ydim - 1, xdim - 1) = 0; @@ -73,7 +50,7 @@ void KernelParamReduceTestImpl(const INDEX_TYPE xdim, const INDEX_TYPE ydim) CheckView(ydim / 2, xdim / 2) = 101; }); - work_res.memcpy(work_array, check_array, sizeof(DATA_TYPE) * get_val(array_length)); + work_res.memcpy(work_array, check_array, sizeof(DATA_TYPE) * RAJA::stripIndexType(array_length)); RAJA::TypedRangeSegment colrange(0, xdim); RAJA::TypedRangeSegment rowrange(0, ydim); @@ -85,20 +62,20 @@ void KernelParamReduceTestImpl(const INDEX_TYPE xdim, const INDEX_TYPE ydim) using VALOPLOC_DATA_TYPE_MIN = RAJA::expt::ValLocOp, RAJA::operators::minimum>; using VALOPLOC_DATA_TYPE_MAX = RAJA::expt::ValLocOp, RAJA::operators::maximum>; - VALLOC_DATA_TYPE seq_minloc(std::numeric_limits::max(), Index2D(-1,-1)); - VALLOC_DATA_TYPE seq_maxloc(std::numeric_limits::min(), Index2D(-1,-1)); - Index2D seq_minloc2(-1, -1); - Index2D seq_maxloc2(-1, -1); + VALLOC_DATA_TYPE seq_minloc(std::numeric_limits::max(), Index2D(INDEX_TYPE(-1), INDEX_TYPE(-1))); + VALLOC_DATA_TYPE seq_maxloc(std::numeric_limits::min(), Index2D(INDEX_TYPE(-1), INDEX_TYPE(-1))); + Index2D seq_minloc2(INDEX_TYPE(-1), INDEX_TYPE(-1)); + Index2D seq_maxloc2(INDEX_TYPE(-1), INDEX_TYPE(-1)); DATA_TYPE seq_sum = 0; DATA_TYPE seq_min = std::numeric_limits::max(); DATA_TYPE seq_max = std::numeric_limits::min(); DATA_TYPE seq_min2 = std::numeric_limits::max(); DATA_TYPE seq_max2 = std::numeric_limits::min(); - VALLOC_DATA_TYPE minloc(std::numeric_limits::max(), Index2D(-1,-1)); - VALLOC_DATA_TYPE maxloc(std::numeric_limits::min(), Index2D(-1,-1)); - Index2D minloc2(-1, -1); - Index2D maxloc2(-1, -1); + VALLOC_DATA_TYPE minloc(std::numeric_limits::max(), Index2D(INDEX_TYPE(-1), INDEX_TYPE(-1))); + VALLOC_DATA_TYPE maxloc(std::numeric_limits::min(), Index2D(INDEX_TYPE(-1), INDEX_TYPE(-1))); + Index2D minloc2(INDEX_TYPE(-1), INDEX_TYPE(-1)); + Index2D maxloc2(INDEX_TYPE(-1), INDEX_TYPE(-1)); DATA_TYPE sum = 0; DATA_TYPE min2 = std::numeric_limits::max(); DATA_TYPE max2 = std::numeric_limits::min(); @@ -222,10 +199,10 @@ TYPED_TEST_P(KernelReduceParamsTest, ParamReduceKernel) using EXEC_POLICY = typename camp::at>::type; using REDUCE_POLICY = typename camp::at>::type; - KernelParamReduceTestImpl(10, 10); - KernelParamReduceTestImpl(100, 100); - KernelParamReduceTestImpl(151, 151); - KernelParamReduceTestImpl(362, 362); + KernelParamReduceTestImpl(INDEX_TYPE{10}, INDEX_TYPE{10}); + KernelParamReduceTestImpl(INDEX_TYPE{100}, INDEX_TYPE{100}); + KernelParamReduceTestImpl(INDEX_TYPE{151}, INDEX_TYPE{151}); + KernelParamReduceTestImpl(INDEX_TYPE{362}, INDEX_TYPE{362}); } REGISTER_TYPED_TEST_SUITE_P(KernelReduceParamsTest, diff --git a/test/functional/kernel/region/tests/test-kernel-region-sync.hpp b/test/functional/kernel/region/tests/test-kernel-region-sync.hpp index beab3c2d7e..95cb0f28bb 100644 --- a/test/functional/kernel/region/tests/test-kernel-region-sync.hpp +++ b/test/functional/kernel/region/tests/test-kernel-region-sync.hpp @@ -77,7 +77,7 @@ void KernelRegionSyncTestImpl(INDEX_TYPE first, INDEX_TYPE last) work_res.memcpy(check_array, work_array3, sizeof(INDEX_TYPE) * N); work_res.wait(); - for (INDEX_TYPE i = 0; i < N; i++) { + for (INDEX_TYPE i {0}; i < N; i++) { ASSERT_EQ(check_array[i], 151); } @@ -100,9 +100,9 @@ TYPED_TEST_P(KernelRegionSyncTest, RegionSyncKernel) using WORKING_RES = typename camp::at>::type; using EXEC_POLICY = typename camp::at>::type; - KernelRegionSyncTestImpl(0, 25); - KernelRegionSyncTestImpl(1, 153); - KernelRegionSyncTestImpl(3, 2556); + KernelRegionSyncTestImpl(INDEX_TYPE{0}, INDEX_TYPE{25}); + KernelRegionSyncTestImpl(INDEX_TYPE{1}, INDEX_TYPE{153}); + KernelRegionSyncTestImpl(INDEX_TYPE{3}, INDEX_TYPE{2556}); } REGISTER_TYPED_TEST_SUITE_P(KernelRegionSyncTest, diff --git a/test/functional/kernel/region/tests/test-kernel-region.hpp b/test/functional/kernel/region/tests/test-kernel-region.hpp index 46cf884125..f246b31a4a 100644 --- a/test/functional/kernel/region/tests/test-kernel-region.hpp +++ b/test/functional/kernel/region/tests/test-kernel-region.hpp @@ -61,7 +61,7 @@ void KernelRegionTestImpl(INDEX_TYPE first, INDEX_TYPE last) work_res.memcpy(check_array, work_array3, sizeof(INDEX_TYPE) * N ); work_res.wait(); - for (INDEX_TYPE i = 0; i < N; i++) { + for (INDEX_TYPE i {0}; i < N; i++) { ASSERT_EQ(check_array[i], 151); } @@ -84,9 +84,9 @@ TYPED_TEST_P(KernelRegionTest, RegionKernel) using WORKING_RES = typename camp::at>::type; using EXEC_POLICY = typename camp::at>::type; - KernelRegionTestImpl(0, 25); - KernelRegionTestImpl(1, 153); - KernelRegionTestImpl(3, 2556); + KernelRegionTestImpl(INDEX_TYPE{0}, INDEX_TYPE{25}); + KernelRegionTestImpl(INDEX_TYPE{1}, INDEX_TYPE{153}); + KernelRegionTestImpl(INDEX_TYPE{3}, INDEX_TYPE{2556}); } REGISTER_TYPED_TEST_SUITE_P(KernelRegionTest, diff --git a/test/functional/kernel/tile-icount-tcount-direct-unchecked/tests/test-kernel-tile-ForICount-direct-unchecked.hpp b/test/functional/kernel/tile-icount-tcount-direct-unchecked/tests/test-kernel-tile-ForICount-direct-unchecked.hpp index 4104461d96..1ba0290c69 100644 --- a/test/functional/kernel/tile-icount-tcount-direct-unchecked/tests/test-kernel-tile-ForICount-direct-unchecked.hpp +++ b/test/functional/kernel/tile-icount-tcount-direct-unchecked/tests/test-kernel-tile-ForICount-direct-unchecked.hpp @@ -28,7 +28,7 @@ CallKernel(IDX_TYPE& trip_count, IDX_TYPE tsize) { RAJA::kernel_param( RAJA::make_tuple( - RAJA::TypedRangeSegment(0, N) + RAJA::TypedRangeSegment(IDX_TYPE{0}, N) ), RAJA::make_tuple( static_cast(0), RAJA::expt::Reduce(&trip_count), @@ -57,7 +57,7 @@ CallKernel(IDX_TYPE& _trip_count, RAJA::ReduceSum trip_count (_trip_count); RAJA::kernel_param( RAJA::make_tuple( - RAJA::TypedRangeSegment(0, N) + RAJA::TypedRangeSegment(IDX_TYPE{0}, N) ), RAJA::make_tuple( static_cast(0) ), @@ -77,15 +77,15 @@ void KernelTileForICountDirectUncheckedTestImpl(IDX_TYPE N, IDX_TYPE tsize) { IDX_TYPE trip_count(0); - for (IDX_TYPE t = 0; t < tsize; ++t) { - IDX_TYPE tile_count = 0; + for (IDX_TYPE t {0}; t < tsize; ++t) { + IDX_TYPE tile_count {0}; CallKernel(trip_count, tile_count, t, N, tsize); IDX_TYPE tile_expect = N / tsize; if ( t < N % tsize ) { tile_expect += IDX_TYPE(1); } - ASSERT_EQ(trip_count, (t+1) * N); + ASSERT_EQ(trip_count, (t + IDX_TYPE{1}) * N); ASSERT_EQ(tile_count, tile_expect); } @@ -107,14 +107,14 @@ TYPED_TEST_P(KernelTileForICountDirectUncheckedTest, ForICountTileKernel) using REDUCE_POLICY = typename camp::at>::type; using USE_REDUCER_PARAM = typename camp::at>::type; - IDX_TYPE tsize = camp::at_v::value; + IDX_TYPE tsize {camp::at_v::value}; KernelTileForICountDirectUncheckedTestImpl( IDX_TYPE(0), tsize); KernelTileForICountDirectUncheckedTestImpl( IDX_TYPE(tsize), tsize); KernelTileForICountDirectUncheckedTestImpl( - IDX_TYPE(13*tsize), tsize); + IDX_TYPE{13} * tsize, tsize); } diff --git a/test/functional/kernel/tile-icount-tcount-direct-unchecked/tests/test-kernel-tile-TileTCount-direct-unchecked.hpp b/test/functional/kernel/tile-icount-tcount-direct-unchecked/tests/test-kernel-tile-TileTCount-direct-unchecked.hpp index 3b182a87b9..24cd6433ad 100644 --- a/test/functional/kernel/tile-icount-tcount-direct-unchecked/tests/test-kernel-tile-TileTCount-direct-unchecked.hpp +++ b/test/functional/kernel/tile-icount-tcount-direct-unchecked/tests/test-kernel-tile-TileTCount-direct-unchecked.hpp @@ -27,7 +27,7 @@ CallKernel(IDX_TYPE& trip_count, IDX_TYPE N, IDX_TYPE tsize) { RAJA::kernel_param( - RAJA::make_tuple( RAJA::TypedRangeSegment(0, N) ), + RAJA::make_tuple( RAJA::TypedRangeSegment(IDX_TYPE{0}, N) ), RAJA::make_tuple( static_cast(0), RAJA::expt::Reduce(&trip_count), RAJA::expt::Reduce(&tile_count) @@ -36,9 +36,9 @@ CallKernel(IDX_TYPE& trip_count, [=] RAJA_HOST_DEVICE(IDX_TYPE i, IDX_TYPE ti, RAJA::expt::ValOp& _trip_count, RAJA::expt::ValOp& _tile_count) { - _trip_count += 1; + _trip_count += IDX_TYPE{1}; if ( i / tsize == t && ti == t ) { - _tile_count += 1; + _tile_count += IDX_TYPE{1}; } } ); @@ -55,13 +55,13 @@ CallKernel(IDX_TYPE& _trip_count, RAJA::ReduceSum tile_count(_tile_count); RAJA::ReduceSum trip_count(_trip_count); RAJA::kernel_param( - RAJA::make_tuple( RAJA::TypedRangeSegment(0, N) ), + RAJA::make_tuple( RAJA::TypedRangeSegment(IDX_TYPE{0}, N) ), RAJA::make_tuple( static_cast(0) ), [=] RAJA_HOST_DEVICE(IDX_TYPE i, IDX_TYPE ti) { - trip_count += 1; + trip_count += IDX_TYPE{1}; if ( i / tsize == t && ti == t ) { - tile_count += 1; + tile_count += IDX_TYPE{1}; } } ); @@ -74,19 +74,19 @@ template (trip_count, tile_count, t, N, tsize); IDX_TYPE tile_expect = tsize; - if ( (t + 1) * tsize > N ) { + if ( (t + IDX_TYPE{1}) * tsize > N ) { tile_expect = N - t * tsize; } ASSERT_EQ(tile_count, tile_expect); - ASSERT_EQ(trip_count, (t+1) * N); + ASSERT_EQ(trip_count, (t + IDX_TYPE{1}) * N); } } @@ -105,14 +105,14 @@ TYPED_TEST_P(KernelTileTileTCountDirectUncheckedTest, TileTCountTileKernel) using REDUCE_POLICY = typename camp::at>::type; using USE_REDUCER_PARAM = typename camp::at>::type; - IDX_TYPE tsize = camp::at_v::value; + IDX_TYPE tsize {camp::at_v::value}; KernelTileTileTCountDirectUncheckedTestImpl( IDX_TYPE(0), tsize); KernelTileTileTCountDirectUncheckedTestImpl( IDX_TYPE(tsize), tsize); KernelTileTileTCountDirectUncheckedTestImpl( - IDX_TYPE(13*tsize), tsize); + IDX_TYPE{13} * tsize, tsize); } diff --git a/test/functional/kernel/tile-icount-tcount-direct/tests/test-kernel-tile-ForICount-direct.hpp b/test/functional/kernel/tile-icount-tcount-direct/tests/test-kernel-tile-ForICount-direct.hpp index 22a7f66f96..d54bee30b5 100644 --- a/test/functional/kernel/tile-icount-tcount-direct/tests/test-kernel-tile-ForICount-direct.hpp +++ b/test/functional/kernel/tile-icount-tcount-direct/tests/test-kernel-tile-ForICount-direct.hpp @@ -26,7 +26,7 @@ CallKernel(IDX_TYPE& trip_count, IDX_TYPE tsize) { RAJA::kernel_param( RAJA::make_tuple( - RAJA::TypedRangeSegment(0, N) + RAJA::TypedRangeSegment(IDX_TYPE{0}, N) ), RAJA::make_tuple( static_cast(0), RAJA::expt::Reduce(&trip_count), @@ -55,7 +55,7 @@ CallKernel(IDX_TYPE& _trip_count, RAJA::ReduceSum trip_count (_trip_count); RAJA::kernel_param( RAJA::make_tuple( - RAJA::TypedRangeSegment(0, N) + RAJA::TypedRangeSegment(IDX_TYPE{0}, N) ), RAJA::make_tuple( static_cast(0) ), @@ -81,9 +81,9 @@ void KernelTileForICountDirectTestImpl(IDX_TYPE N, IDX_TYPE tsize) IDX_TYPE tile_expect = N / tsize; if ( t < N % tsize ) { - tile_expect += 1; + tile_expect += IDX_TYPE{1}; } - ASSERT_EQ(trip_count, (t+1) * N); + ASSERT_EQ(trip_count, (t + IDX_TYPE{1}) * N); ASSERT_EQ(tile_count, tile_expect); } @@ -105,7 +105,7 @@ TYPED_TEST_P(KernelTileForICountDirectTest, ForICountTileKernel) using REDUCE_POLICY = typename camp::at>::type; using USE_REDUCER_PARAM = typename camp::at>::type; - IDX_TYPE tsize(camp::at_v::value); + IDX_TYPE tsize {camp::at_v::value}; KernelTileForICountDirectTestImpl( IDX_TYPE(57), tsize); diff --git a/test/functional/kernel/tile-icount-tcount-direct/tests/test-kernel-tile-TileTCount-direct.hpp b/test/functional/kernel/tile-icount-tcount-direct/tests/test-kernel-tile-TileTCount-direct.hpp index fb1b64ea9e..c6222bd291 100644 --- a/test/functional/kernel/tile-icount-tcount-direct/tests/test-kernel-tile-TileTCount-direct.hpp +++ b/test/functional/kernel/tile-icount-tcount-direct/tests/test-kernel-tile-TileTCount-direct.hpp @@ -27,7 +27,7 @@ CallKernel(IDX_TYPE& trip_count, IDX_TYPE N, IDX_TYPE tsize) { RAJA::kernel_param( - RAJA::make_tuple( RAJA::TypedRangeSegment(0, N) ), + RAJA::make_tuple( RAJA::TypedRangeSegment(IDX_TYPE{0}, N) ), RAJA::make_tuple( static_cast(0), RAJA::expt::Reduce(&trip_count), RAJA::expt::Reduce(&tile_count) @@ -36,9 +36,9 @@ CallKernel(IDX_TYPE& trip_count, [=] RAJA_HOST_DEVICE(IDX_TYPE i, IDX_TYPE ti, RAJA::expt::ValOp& _trip_count, RAJA::expt::ValOp& _tile_count) { - _trip_count += 1; + _trip_count += IDX_TYPE{1}; if ( i / tsize == t && ti == t ) { - _tile_count += 1; + _tile_count += IDX_TYPE{1}; } } ); @@ -55,13 +55,13 @@ CallKernel(IDX_TYPE& _trip_count, RAJA::ReduceSum tile_count(_tile_count); RAJA::ReduceSum trip_count(_trip_count); RAJA::kernel_param( - RAJA::make_tuple( RAJA::TypedRangeSegment(0, N) ), + RAJA::make_tuple( RAJA::TypedRangeSegment(IDX_TYPE{0}, N) ), RAJA::make_tuple( static_cast(0) ), [=] RAJA_HOST_DEVICE(IDX_TYPE i, IDX_TYPE ti) { - trip_count += 1; + trip_count += IDX_TYPE{1}; if ( i / tsize == t && ti == t ) { - tile_count += 1; + tile_count += IDX_TYPE{1}; } } ); @@ -74,19 +74,19 @@ template (trip_count, tile_count, t, N, tsize); IDX_TYPE tile_expect = tsize; - if ( (t + 1) * tsize > N ) { + if ( (t + IDX_TYPE{1}) * tsize > N ) { tile_expect = N - t * tsize; } ASSERT_EQ(tile_count, tile_expect); - ASSERT_EQ(trip_count, (t+1) * N); + ASSERT_EQ(trip_count, (t + IDX_TYPE{1}) * N); } } @@ -105,7 +105,7 @@ TYPED_TEST_P(KernelTileTileTCountDirectTest, TileTCountTileKernel) using REDUCE_POLICY = typename camp::at>::type; using USE_REDUCER_PARAM = typename camp::at>::type; - IDX_TYPE tsize = camp::at_v::value; + IDX_TYPE tsize {camp::at_v::value}; KernelTileTileTCountDirectTestImpl( IDX_TYPE(57), tsize); diff --git a/test/functional/kernel/tile-icount-tcount-loop/tests/test-kernel-tile-ForICount-loop.hpp b/test/functional/kernel/tile-icount-tcount-loop/tests/test-kernel-tile-ForICount-loop.hpp index a413599344..8586f61d93 100644 --- a/test/functional/kernel/tile-icount-tcount-loop/tests/test-kernel-tile-ForICount-loop.hpp +++ b/test/functional/kernel/tile-icount-tcount-loop/tests/test-kernel-tile-ForICount-loop.hpp @@ -27,7 +27,7 @@ CallKernel(IDX_TYPE& trip_count, IDX_TYPE tsize) { RAJA::kernel_param( RAJA::make_tuple( - RAJA::TypedRangeSegment(0, N) + RAJA::TypedRangeSegment(IDX_TYPE{0}, N) ), RAJA::make_tuple( static_cast(0), RAJA::expt::Reduce(&trip_count), @@ -37,9 +37,9 @@ CallKernel(IDX_TYPE& trip_count, [=] RAJA_HOST_DEVICE(IDX_TYPE i, IDX_TYPE ii, RAJA::expt::ValOp& _trip_count, RAJA::expt::ValOp& _tile_count) { - _trip_count += 1; + _trip_count += IDX_TYPE{1}; if ( i % tsize == t && ii == t ) { - _tile_count += 1; + _tile_count += IDX_TYPE{1}; } } ); @@ -56,14 +56,14 @@ CallKernel(IDX_TYPE& _trip_count, RAJA::ReduceSum trip_count (_trip_count); RAJA::kernel_param( RAJA::make_tuple( - RAJA::TypedRangeSegment(0, N) + RAJA::TypedRangeSegment(IDX_TYPE{0}, N) ), RAJA::make_tuple( static_cast(0) ), [=] RAJA_HOST_DEVICE(IDX_TYPE i, IDX_TYPE ii) { - trip_count += 1; + trip_count += IDX_TYPE{1}; if ( i % tsize == t && ii == t ) { - tile_count += 1; + tile_count += IDX_TYPE{1}; } } ); @@ -76,15 +76,15 @@ void KernelTileForICountLoopTestImpl(IDX_TYPE N, IDX_TYPE tsize) { IDX_TYPE trip_count(0); - for (IDX_TYPE t = 0; t < tsize; ++t) { - IDX_TYPE tile_count = 0; + for (IDX_TYPE t {0}; t < tsize; ++t) { + IDX_TYPE tile_count {0}; CallKernel(trip_count, tile_count, t, N, tsize); IDX_TYPE tile_expect = N / tsize; if ( t < N % tsize ) { - tile_expect += 1; + tile_expect += IDX_TYPE{1}; } - ASSERT_EQ(trip_count, (t+1) * N); + ASSERT_EQ(trip_count, (t + IDX_TYPE{1}) * N); ASSERT_EQ(tile_count, tile_expect); } @@ -105,7 +105,7 @@ TYPED_TEST_P(KernelTileForICountLoopTest, ForICountTileKernel) using REDUCE_POLICY = typename camp::at>::type; using USE_REDUCER_PARAM = typename camp::at>::type; - IDX_TYPE tsize = camp::at_v::value; + IDX_TYPE tsize {camp::at_v::value}; KernelTileForICountLoopTestImpl( IDX_TYPE(57), tsize); diff --git a/test/functional/kernel/tile-icount-tcount-loop/tests/test-kernel-tile-TileTCount-loop.hpp b/test/functional/kernel/tile-icount-tcount-loop/tests/test-kernel-tile-TileTCount-loop.hpp index 04b47e5697..32689ecaa2 100644 --- a/test/functional/kernel/tile-icount-tcount-loop/tests/test-kernel-tile-TileTCount-loop.hpp +++ b/test/functional/kernel/tile-icount-tcount-loop/tests/test-kernel-tile-TileTCount-loop.hpp @@ -26,7 +26,7 @@ CallKernel(IDX_TYPE& trip_count, IDX_TYPE N, IDX_TYPE tsize) { RAJA::kernel_param( - RAJA::make_tuple( RAJA::TypedRangeSegment(0, N) ), + RAJA::make_tuple( RAJA::TypedRangeSegment(IDX_TYPE{0}, N) ), RAJA::make_tuple( static_cast(0), RAJA::expt::Reduce(&trip_count), RAJA::expt::Reduce(&tile_count) @@ -35,9 +35,9 @@ CallKernel(IDX_TYPE& trip_count, [=] RAJA_HOST_DEVICE(IDX_TYPE i, IDX_TYPE ti, RAJA::expt::ValOp& _trip_count, RAJA::expt::ValOp& _tile_count) { - _trip_count += 1; + _trip_count += IDX_TYPE{1}; if ( i / tsize == t && ti == t ) { - _tile_count += 1; + _tile_count += IDX_TYPE{1}; } } ); @@ -54,13 +54,13 @@ CallKernel(IDX_TYPE& _trip_count, RAJA::ReduceSum tile_count(_tile_count); RAJA::ReduceSum trip_count(_trip_count); RAJA::kernel_param( - RAJA::make_tuple( RAJA::TypedRangeSegment(0, N) ), + RAJA::make_tuple( RAJA::TypedRangeSegment(IDX_TYPE{0}, N) ), RAJA::make_tuple( static_cast(0) ), [=] RAJA_HOST_DEVICE(IDX_TYPE i, IDX_TYPE ti) { - trip_count += 1; + trip_count += IDX_TYPE{1}; if ( i / tsize == t && ti == t ) { - tile_count += 1; + tile_count += IDX_TYPE{1}; } } ); @@ -73,19 +73,19 @@ template (trip_count, tile_count, t, N, tsize); IDX_TYPE tile_expect = tsize; - if ( (t + 1) * tsize > N ) { + if ( (t + IDX_TYPE{1}) * tsize > N ) { tile_expect = N - t * tsize; } ASSERT_EQ(tile_count, tile_expect); - ASSERT_EQ(trip_count, (t+1) * N ); + ASSERT_EQ(trip_count, (t + IDX_TYPE{1}) * N ); } } @@ -104,7 +104,7 @@ TYPED_TEST_P(KernelTileTileTCountLoopTest, TileTCountTileKernel) using REDUCE_POLICY = typename camp::at>::type; using USE_REDUCER_PARAM = typename camp::at>::type; - IDX_TYPE tsize = camp::at_v::value; + IDX_TYPE tsize {camp::at_v::value}; KernelTileTileTCountLoopTestImpl( IDX_TYPE(57), tsize); diff --git a/test/functional/kernel/tile-variants/tests/test-kernel-tile-Dynamic2D.hpp b/test/functional/kernel/tile-variants/tests/test-kernel-tile-Dynamic2D.hpp index d513fe0a2a..4a17027214 100644 --- a/test/functional/kernel/tile-variants/tests/test-kernel-tile-Dynamic2D.hpp +++ b/test/functional/kernel/tile-variants/tests/test-kernel-tile-Dynamic2D.hpp @@ -25,13 +25,6 @@ struct val_t_impl { template using VAL_T = typename val_t_impl::type; - -template -RAJA_HOST_DEVICE typename T::value_type get_val(T index_val) { return *index_val; } - -template -requires (!RAJA::concepts::IndexValued) -RAJA_HOST_DEVICE auto get_val(T index_val) { return index_val; } } template @@ -78,16 +71,16 @@ void KernelTileDynamic2DTestImpl(const INDEX_TYPE rows_t, const INDEX_TYPE cols_ ViewType CheckTView( check_array_t, cols_t, rows_t ); // initialize arrays - std::iota( test_array, test_array + get_val(array_length), 1 ); - std::iota( test_array_t, test_array_t + get_val(array_length), 1 ); + std::iota( test_array, test_array + RAJA::stripIndexType(array_length), 1 ); + std::iota( test_array_t, test_array_t + RAJA::stripIndexType(array_length), 1 ); - work_res.memcpy( work_array, test_array, sizeof(DATA_TYPE) * get_val(array_length) ); - work_res.memcpy( work_array_t, test_array_t, sizeof(DATA_TYPE) * get_val(array_length) ); + work_res.memcpy( work_array, test_array, sizeof(DATA_TYPE) * RAJA::stripIndexType(array_length) ); + work_res.memcpy( work_array_t, test_array_t, sizeof(DATA_TYPE) * RAJA::stripIndexType(array_length) ); // transpose test_array on CPU - for ( raw_index_type rr = 0; rr < get_val(rows_t); ++rr ) + for ( raw_index_type rr = 0; rr < RAJA::stripIndexType(rows_t); ++rr ) { - for ( raw_index_type cc = 0; cc < get_val(cols_t); ++cc ) + for ( raw_index_type cc = 0; cc < RAJA::stripIndexType(cols_t); ++cc ) { HostTView( INDEX_TYPE(cc), INDEX_TYPE(rr) ) = HostView( INDEX_TYPE(rr), INDEX_TYPE(cc) ); } @@ -104,11 +97,11 @@ void KernelTileDynamic2DTestImpl(const INDEX_TYPE rows_t, const INDEX_TYPE cols_ WorkTView( cc, rr ) = WorkView( rr, cc ); }); - work_res.memcpy( check_array_t, work_array_t, sizeof(DATA_TYPE) * get_val(array_length) ); + work_res.memcpy( check_array_t, work_array_t, sizeof(DATA_TYPE) * RAJA::stripIndexType(array_length) ); - for ( raw_index_type rr = 0; rr < get_val(rows_t); ++rr ) + for ( raw_index_type rr = 0; rr < RAJA::stripIndexType(rows_t); ++rr ) { - for ( raw_index_type cc = 0; cc < get_val(cols_t); ++cc ) + for ( raw_index_type cc = 0; cc < RAJA::stripIndexType(cols_t); ++cc ) { ASSERT_EQ(CheckTView(INDEX_TYPE(cc), INDEX_TYPE(rr)), HostTView(INDEX_TYPE(cc), INDEX_TYPE(rr))); @@ -116,8 +109,8 @@ void KernelTileDynamic2DTestImpl(const INDEX_TYPE rows_t, const INDEX_TYPE cols_ } // reset check and work transpose arrays - work_res.memcpy( check_array_t, test_array, sizeof(DATA_TYPE) * get_val(array_length) ); - work_res.memcpy( work_array_t, test_array, sizeof(DATA_TYPE) * get_val(array_length) ); + work_res.memcpy( check_array_t, test_array, sizeof(DATA_TYPE) * RAJA::stripIndexType(array_length) ); + work_res.memcpy( work_array_t, test_array, sizeof(DATA_TYPE) * RAJA::stripIndexType(array_length) ); // transpose work_array again with different tile sizes RAJA::kernel_param ( @@ -127,11 +120,11 @@ void KernelTileDynamic2DTestImpl(const INDEX_TYPE rows_t, const INDEX_TYPE cols_ WorkTView( cc, rr ) = WorkView( rr, cc ); }); - work_res.memcpy( check_array_t, work_array_t, sizeof(DATA_TYPE) * get_val(array_length) ); + work_res.memcpy( check_array_t, work_array_t, sizeof(DATA_TYPE) * RAJA::stripIndexType(array_length) ); - for ( raw_index_type rr = 0; rr < get_val(rows_t); ++rr ) + for ( raw_index_type rr = 0; rr < RAJA::stripIndexType(rows_t); ++rr ) { - for ( raw_index_type cc = 0; cc < get_val(cols_t); ++cc ) + for ( raw_index_type cc = 0; cc < RAJA::stripIndexType(cols_t); ++cc ) { ASSERT_EQ(CheckTView(INDEX_TYPE(cc), INDEX_TYPE(rr)), HostTView(INDEX_TYPE(cc), INDEX_TYPE(rr))); diff --git a/test/functional/kernel/tile-variants/tests/test-kernel-tile-Fixed2D.hpp b/test/functional/kernel/tile-variants/tests/test-kernel-tile-Fixed2D.hpp index b2f105fee2..843bb01c8d 100644 --- a/test/functional/kernel/tile-variants/tests/test-kernel-tile-Fixed2D.hpp +++ b/test/functional/kernel/tile-variants/tests/test-kernel-tile-Fixed2D.hpp @@ -25,13 +25,6 @@ struct val_t_impl { template using VAL_T = typename val_t_impl::type; - -template -RAJA_HOST_DEVICE typename T::value_type get_val(T index_val) { return *index_val; } - -template -requires (!RAJA::concepts::IndexValued) -RAJA_HOST_DEVICE auto get_val(T index_val) { return index_val; } } template @@ -78,16 +71,16 @@ void KernelTileFixed2DTestImpl(const INDEX_TYPE rows_t, const INDEX_TYPE cols_t) ViewType CheckTView( check_array_t, cols_t, rows_t ); // initialize arrays - std::iota( test_array, test_array + get_val(array_length), 1 ); - std::iota( test_array_t, test_array_t + get_val(array_length), 1 ); + std::iota( test_array, test_array + RAJA::stripIndexType(array_length), 1 ); + std::iota( test_array_t, test_array_t + RAJA::stripIndexType(array_length), 1 ); - work_res.memcpy( work_array, test_array, sizeof(DATA_TYPE) * get_val(array_length) ); - work_res.memcpy( work_array_t, test_array_t, sizeof(DATA_TYPE) * get_val(array_length) ); + work_res.memcpy( work_array, test_array, sizeof(DATA_TYPE) * RAJA::stripIndexType(array_length) ); + work_res.memcpy( work_array_t, test_array_t, sizeof(DATA_TYPE) * RAJA::stripIndexType(array_length) ); // transpose test_array on CPU - for ( raw_index_type rr = 0; rr < get_val(rows_t); ++rr ) + for ( raw_index_type rr = 0; rr < RAJA::stripIndexType(rows_t); ++rr ) { - for ( raw_index_type cc = 0; cc < get_val(cols_t); ++cc ) + for ( raw_index_type cc = 0; cc < RAJA::stripIndexType(cols_t); ++cc ) { HostTView( INDEX_TYPE(cc), INDEX_TYPE(rr) ) = HostView( INDEX_TYPE(rr), INDEX_TYPE(cc) ); } @@ -102,11 +95,11 @@ void KernelTileFixed2DTestImpl(const INDEX_TYPE rows_t, const INDEX_TYPE cols_t) WorkTView( cc, rr ) = WorkView( rr, cc ); }); - work_res.memcpy( check_array_t, work_array_t, sizeof(DATA_TYPE) * get_val(array_length) ); + work_res.memcpy( check_array_t, work_array_t, sizeof(DATA_TYPE) * RAJA::stripIndexType(array_length) ); - for ( raw_index_type rr = 0; rr < get_val(rows_t); ++rr ) + for ( raw_index_type rr = 0; rr < RAJA::stripIndexType(rows_t); ++rr ) { - for ( raw_index_type cc = 0; cc < get_val(cols_t); ++cc ) + for ( raw_index_type cc = 0; cc < RAJA::stripIndexType(cols_t); ++cc ) { ASSERT_EQ(CheckTView(INDEX_TYPE(cc), INDEX_TYPE(rr)), HostTView(INDEX_TYPE(cc), INDEX_TYPE(rr))); diff --git a/test/functional/kernel/tile-variants/tests/test-kernel-tile-Fixed2DMinMax.hpp b/test/functional/kernel/tile-variants/tests/test-kernel-tile-Fixed2DMinMax.hpp index b935057565..4d09f48ed7 100644 --- a/test/functional/kernel/tile-variants/tests/test-kernel-tile-Fixed2DMinMax.hpp +++ b/test/functional/kernel/tile-variants/tests/test-kernel-tile-Fixed2DMinMax.hpp @@ -26,13 +26,6 @@ struct val_t_impl { template using VAL_T = typename val_t_impl::type; - -template -RAJA_HOST_DEVICE typename T::value_type get_val(T index_val) { return *index_val; } - -template -requires (!RAJA::concepts::IndexValued) -RAJA_HOST_DEVICE auto get_val(T index_val) { return index_val; } } template @@ -57,18 +50,18 @@ void KernelTileFixed2DMinMaxTestImpl(const INDEX_TYPE rows_t, const INDEX_TYPE c ); // initialize arrays - std::iota( test_array, test_array + get_val(array_length), 1 ); + std::iota( test_array, test_array + RAJA::stripIndexType(array_length), 1 ); // set min and max of the array test_array[4] = -1; - test_array[8] = static_cast(get_val(array_length) + 2); + test_array[8] = static_cast(RAJA::stripIndexType(array_length) + 2); using LayoutType = RAJA::TypedLayout>; using ViewType = RAJA::View; ViewType WorkView( work_array, rows_t, cols_t ); - work_res.memcpy( work_array, test_array, sizeof(DATA_TYPE) * get_val(array_length) ); + work_res.memcpy( work_array, test_array, sizeof(DATA_TYPE) * RAJA::stripIndexType(array_length) ); RAJA::ReduceMin workmin( DATA_TYPE(99999) ); RAJA::ReduceMax workmax( DATA_TYPE(-1) ); @@ -77,7 +70,7 @@ void KernelTileFixed2DMinMaxTestImpl(const INDEX_TYPE rows_t, const INDEX_TYPE c RAJA::TypedRangeSegment rowrange( 0, rows_t ); std::vector colidx; - for (raw_index_type ii = 0; ii < get_val(cols_t); ++ii) + for (raw_index_type ii = 0; ii < RAJA::stripIndexType(cols_t); ++ii) { colidx.push_back(INDEX_TYPE(ii)); } @@ -92,7 +85,7 @@ void KernelTileFixed2DMinMaxTestImpl(const INDEX_TYPE rows_t, const INDEX_TYPE c }); ASSERT_EQ(static_cast(-1), static_cast(workmin.get())); - ASSERT_EQ(static_cast(get_val(array_length) + 2), static_cast(workmax.get())); + ASSERT_EQ(static_cast(RAJA::stripIndexType(array_length) + 2), static_cast(workmax.get())); deallocateForallTestData ( work_res, work_array, diff --git a/test/functional/kernel/tile-variants/tests/test-kernel-tile-Fixed2DSum.hpp b/test/functional/kernel/tile-variants/tests/test-kernel-tile-Fixed2DSum.hpp index ec8d93ade5..d5f1a2776b 100644 --- a/test/functional/kernel/tile-variants/tests/test-kernel-tile-Fixed2DSum.hpp +++ b/test/functional/kernel/tile-variants/tests/test-kernel-tile-Fixed2DSum.hpp @@ -27,13 +27,6 @@ struct val_t_impl { template using VAL_T = typename val_t_impl::type; - -template -RAJA_HOST_DEVICE typename T::value_type get_val(T index_val) { return *index_val; } - -template -requires (!RAJA::concepts::IndexValued) -RAJA_HOST_DEVICE auto get_val(T index_val) { return index_val; } } template @@ -51,8 +44,8 @@ void KernelTileFixed2DSumTestImpl(const INDEX_TYPE rowsin, const INDEX_TYPE cols } else { - rows = get_val(rowsin); - cols = get_val(colsin); + rows = RAJA::stripIndexType(rowsin); + cols = RAJA::stripIndexType(colsin); } camp::resources::Resource work_res{WORKING_RES::get_default()}; @@ -90,7 +83,7 @@ void KernelTileFixed2DSumTestImpl(const INDEX_TYPE rowsin, const INDEX_TYPE cols // sum on target platform RAJA::kernel ( RAJA::make_tuple( colrange, rowrange ), [=] RAJA_HOST_DEVICE ( INDEX_TYPE cc, INDEX_TYPE rr ) { - worksum += (DATA_TYPE)(get_val(rr) * 1.1 + get_val(cc)); + worksum += (DATA_TYPE)(RAJA::stripIndexType(rr) * 1.1 + RAJA::stripIndexType(cc)); }); ASSERT_FLOAT_EQ(hostsum, (DATA_TYPE)worksum.get()); diff --git a/test/functional/kernel/tile-variants/tests/test-kernel-tile-LocalArray2D.hpp b/test/functional/kernel/tile-variants/tests/test-kernel-tile-LocalArray2D.hpp index 4d013d93dd..1e0cdbcb08 100644 --- a/test/functional/kernel/tile-variants/tests/test-kernel-tile-LocalArray2D.hpp +++ b/test/functional/kernel/tile-variants/tests/test-kernel-tile-LocalArray2D.hpp @@ -25,13 +25,6 @@ struct val_t_impl { template using VAL_T = typename val_t_impl::type; - -template -RAJA_HOST_DEVICE typename T::value_type get_val(T index_val) { return *index_val; } - -template -requires (!RAJA::concepts::IndexValued) -RAJA_HOST_DEVICE auto get_val(T index_val) { return index_val; } } template @@ -82,16 +75,16 @@ void KernelTileLocalArray2DTestImpl(const INDEX_TYPE rows_t, const INDEX_TYPE co TILE_MEM Tile_Array; // initialize arrays - std::iota( test_array, test_array + get_val(array_length), 1 ); - std::iota( test_array_t, test_array_t + get_val(array_length), 1 ); + std::iota( test_array, test_array + RAJA::stripIndexType(array_length), 1 ); + std::iota( test_array_t, test_array_t + RAJA::stripIndexType(array_length), 1 ); - work_res.memcpy( work_array, test_array, sizeof(DATA_TYPE) * get_val(array_length) ); - work_res.memcpy( work_array_t, test_array_t, sizeof(DATA_TYPE) * get_val(array_length) ); + work_res.memcpy( work_array, test_array, sizeof(DATA_TYPE) * RAJA::stripIndexType(array_length) ); + work_res.memcpy( work_array_t, test_array_t, sizeof(DATA_TYPE) * RAJA::stripIndexType(array_length) ); // transpose test_array on CPU - for ( raw_index_type rr = 0; rr < get_val(rows_t); ++rr ) + for ( raw_index_type rr = 0; rr < RAJA::stripIndexType(rows_t); ++rr ) { - for ( raw_index_type cc = 0; cc < get_val(cols_t); ++cc ) + for ( raw_index_type cc = 0; cc < RAJA::stripIndexType(cols_t); ++cc ) { HostTView( INDEX_TYPE(cc), INDEX_TYPE(rr) ) = HostView( INDEX_TYPE(rr), INDEX_TYPE(cc) ); } @@ -103,19 +96,19 @@ void KernelTileLocalArray2DTestImpl(const INDEX_TYPE rows_t, const INDEX_TYPE co RAJA::kernel_param ( RAJA::make_tuple( colrange, rowrange ), RAJA::make_tuple( INDEX_TYPE(0), INDEX_TYPE(0), Tile_Array ), [=] RAJA_HOST_DEVICE ( INDEX_TYPE cc, INDEX_TYPE rr, INDEX_TYPE tx, INDEX_TYPE ty, TILE_MEM &_Tile_Array ) { - _Tile_Array( get_val(ty), get_val(tx) ) = WorkView( rr, cc ); + _Tile_Array( RAJA::stripIndexType(ty), RAJA::stripIndexType(tx) ) = WorkView( rr, cc ); }, [=] RAJA_HOST_DEVICE ( INDEX_TYPE cc, INDEX_TYPE rr, INDEX_TYPE tx, INDEX_TYPE ty, TILE_MEM &_Tile_Array ) { - WorkTView( cc, rr ) = _Tile_Array( get_val(ty), get_val(tx) ); + WorkTView( cc, rr ) = _Tile_Array( RAJA::stripIndexType(ty), RAJA::stripIndexType(tx) ); } ); - work_res.memcpy( check_array_t, work_array_t, sizeof(DATA_TYPE) * get_val(array_length) ); + work_res.memcpy( check_array_t, work_array_t, sizeof(DATA_TYPE) * RAJA::stripIndexType(array_length) ); - for ( raw_index_type rr = 0; rr < get_val(rows_t); ++rr ) + for ( raw_index_type rr = 0; rr < RAJA::stripIndexType(rows_t); ++rr ) { - for ( raw_index_type cc = 0; cc < get_val(cols_t); ++cc ) + for ( raw_index_type cc = 0; cc < RAJA::stripIndexType(cols_t); ++cc ) { ASSERT_EQ(CheckTView(INDEX_TYPE(cc), INDEX_TYPE(rr)), HostTView(INDEX_TYPE(cc), INDEX_TYPE(rr))); diff --git a/test/functional/launch/multi-reduce-nested/tests/test-launch-nested-MultiReduce.hpp b/test/functional/launch/multi-reduce-nested/tests/test-launch-nested-MultiReduce.hpp index 8332a5fa49..55939cdef2 100644 --- a/test/functional/launch/multi-reduce-nested/tests/test-launch-nested-MultiReduce.hpp +++ b/test/functional/launch/multi-reduce-nested/tests/test-launch-nested-MultiReduce.hpp @@ -49,9 +49,9 @@ void Launch(const SEGMENTS_TYPE& segments, RAJA_EXTRACT_BED_SUFFIXED(sj, _sj); RAJA_EXTRACT_BED_SUFFIXED(sk, _sk); - IDX_TYPE threads_i = 16; - IDX_TYPE threads_j = 4; - IDX_TYPE threads_k = 4; + IDX_TYPE threads_i {16}; + IDX_TYPE threads_j {4}; + IDX_TYPE threads_k {4}; IDX_TYPE blocks_i = RAJA_DIVIDE_CEILING_INT(distance_si, threads_i); IDX_TYPE blocks_j = RAJA_DIVIDE_CEILING_INT(distance_sj, threads_j); @@ -144,7 +144,7 @@ LaunchMultiReduceNestedTestImpl(const SEGMENTS_TYPE& segments, IDX_TYPE* check_bins; IDX_TYPE* test_bins; - IDX_TYPE data_len = 0; + IDX_TYPE data_len {0}; allocateForallTestData(idx_range+1, working_res, @@ -152,7 +152,7 @@ LaunchMultiReduceNestedTestImpl(const SEGMENTS_TYPE& segments, &check_range, &test_range); - for (IDX_TYPE i = 0; i < idx_range+1; ++i) { + for (IDX_TYPE i {0}; i < idx_range+1; ++i) { test_range[i] = ~IDX_TYPE(0); } @@ -190,7 +190,7 @@ LaunchMultiReduceNestedTestImpl(const SEGMENTS_TYPE& segments, std::uniform_int_distribution bin_distribution(0, num_bins-1); - for (IDX_TYPE i = 0; i < data_len; ++i) { + for (IDX_TYPE i {0}; i < data_len; ++i) { test_array[i] = DATA_TYPE(array_int_distribution(rngen)); // this may use the same bin multiple times per iterate @@ -210,7 +210,7 @@ LaunchMultiReduceNestedTestImpl(const SEGMENTS_TYPE& segments, { std::vector ref_vals(num_bins, ABSTRACTION::identity(red)); - for (IDX_TYPE i = 0; i < data_len; ++i) { + for (IDX_TYPE i {0}; i < data_len; ++i) { ref_vals[test_bins[i]] = ABSTRACTION::combine(ref_vals[test_bins[i]], test_array[i]); } @@ -241,7 +241,7 @@ LaunchMultiReduceNestedTestImpl(const SEGMENTS_TYPE& segments, const int nloops = 2; for (int j = 0; j < nloops; ++j) { - for (IDX_TYPE i = 0; i < data_len; ++i) { + for (IDX_TYPE i {0}; i < data_len; ++i) { ref_vals[test_bins[i]] = ABSTRACTION::combine(ref_vals[test_bins[i]], test_array[i]); } @@ -270,7 +270,7 @@ LaunchMultiReduceNestedTestImpl(const SEGMENTS_TYPE& segments, std::uniform_int_distribution, std::uniform_real_distribution> array_flt_distribution(0, modval-1); - for (IDX_TYPE i = 0; i < data_len; ++i) { + for (IDX_TYPE i {0}; i < data_len; ++i) { test_array[i] = DATA_TYPE(array_flt_distribution(rngen)); } working_res.memcpy(working_array, test_array, sizeof(DATA_TYPE) * data_len); diff --git a/test/functional/launch/nested_direct/tests/test-launch-nested-Direct.hpp b/test/functional/launch/nested_direct/tests/test-launch-nested-Direct.hpp index edf25f850d..342aaaf91a 100644 --- a/test/functional/launch/nested_direct/tests/test-launch-nested-Direct.hpp +++ b/test/functional/launch/nested_direct/tests/test-launch-nested-Direct.hpp @@ -18,13 +18,13 @@ template r1(0, 2*M); - RAJA::TypedRangeSegment r2(0, 3*M); - RAJA::TypedRangeSegment r3(0, 4*M); + RAJA::TypedRangeSegment r1(INDEX_TYPE(0), 2*M); + RAJA::TypedRangeSegment r2(INDEX_TYPE(0), 3*M); + RAJA::TypedRangeSegment r3(INDEX_TYPE(0), 4*M); - RAJA::TypedRangeSegment r4(0, 4*M); - RAJA::TypedRangeSegment r5(0, 5*M); - RAJA::TypedRangeSegment r6(0, 6*M); + RAJA::TypedRangeSegment r4(INDEX_TYPE(0), 4*M); + RAJA::TypedRangeSegment r5(INDEX_TYPE(0), 5*M); + RAJA::TypedRangeSegment r6(INDEX_TYPE(0), 6*M); INDEX_TYPE N1 = static_cast(r1.end() - r1.begin()); INDEX_TYPE N2 = static_cast(r2.end() - r2.begin()); @@ -54,7 +54,7 @@ void LaunchNestedDirectTestImpl(INDEX_TYPE M) &check_array, &test_array); - std::iota(test_array, test_array + data_len, 0); + std::iota(test_array, test_array + data_len, INDEX_TYPE(0)); working_res.memset(working_array, 0, sizeof(INDEX_TYPE) * data_len); INDEX_TYPE view_len = N; @@ -140,7 +140,7 @@ void LaunchNestedDirectTestImpl(INDEX_TYPE M) if (RAJA::stripIndexType(N) > 0) { - for (INDEX_TYPE i = INDEX_TYPE(0); i < N; i++) { + for (INDEX_TYPE i {0}; i < N; i++) { ASSERT_EQ(test_view(i), check_view(i)); } diff --git a/test/functional/launch/nested_direct_unchecked/tests/test-launch-nested-DirectUnchecked.hpp b/test/functional/launch/nested_direct_unchecked/tests/test-launch-nested-DirectUnchecked.hpp index d4dd788b49..f0cf8a657d 100644 --- a/test/functional/launch/nested_direct_unchecked/tests/test-launch-nested-DirectUnchecked.hpp +++ b/test/functional/launch/nested_direct_unchecked/tests/test-launch-nested-DirectUnchecked.hpp @@ -18,13 +18,13 @@ template r1(0, 2*M); - RAJA::TypedRangeSegment r2(0, 3*M); - RAJA::TypedRangeSegment r3(0, 4*M); + RAJA::TypedRangeSegment r1(INDEX_TYPE(0), 2*M); + RAJA::TypedRangeSegment r2(INDEX_TYPE(0), 3*M); + RAJA::TypedRangeSegment r3(INDEX_TYPE(0), 4*M); - RAJA::TypedRangeSegment r4(0, 4*M); - RAJA::TypedRangeSegment r5(0, 5*M); - RAJA::TypedRangeSegment r6(0, 6*M); + RAJA::TypedRangeSegment r4(INDEX_TYPE(0), 4*M); + RAJA::TypedRangeSegment r5(INDEX_TYPE(0), 5*M); + RAJA::TypedRangeSegment r6(INDEX_TYPE(0), 6*M); INDEX_TYPE N1 = static_cast(r1.end() - r1.begin()); INDEX_TYPE N2 = static_cast(r2.end() - r2.begin()); @@ -51,7 +51,7 @@ void LaunchNestedDirectUncheckedTestImpl(INDEX_TYPE M) &check_array, &test_array); - std::iota(test_array, test_array + data_len, 0); + std::iota(test_array, test_array + data_len, INDEX_TYPE(0)); if ( data_len > 0 ) { working_res.memset(working_array, 0, sizeof(INDEX_TYPE) * data_len); } @@ -106,7 +106,7 @@ void LaunchNestedDirectUncheckedTestImpl(INDEX_TYPE M) } working_res.wait(); - for (INDEX_TYPE i = INDEX_TYPE(0); i < N; i++) { + for (INDEX_TYPE i {0}; i < N; i++) { ASSERT_EQ(test_view(i), check_view(i)); } diff --git a/test/functional/launch/nested_loop/tests/test-launch-nested-Loop.hpp b/test/functional/launch/nested_loop/tests/test-launch-nested-Loop.hpp index 979f04b106..c7f1eef6d3 100644 --- a/test/functional/launch/nested_loop/tests/test-launch-nested-Loop.hpp +++ b/test/functional/launch/nested_loop/tests/test-launch-nested-Loop.hpp @@ -18,13 +18,13 @@ template r1(0, 2*M); - RAJA::TypedRangeSegment r2(0, 3*M); - RAJA::TypedRangeSegment r3(0, 4*M); + RAJA::TypedRangeSegment r1(INDEX_TYPE(0), 2*M); + RAJA::TypedRangeSegment r2(INDEX_TYPE(0), 3*M); + RAJA::TypedRangeSegment r3(INDEX_TYPE(0), 4*M); - RAJA::TypedRangeSegment r4(0, 8*M); - RAJA::TypedRangeSegment r5(0, 2*M); - RAJA::TypedRangeSegment r6(0, 3*M); + RAJA::TypedRangeSegment r4(INDEX_TYPE(0), 8*M); + RAJA::TypedRangeSegment r5(INDEX_TYPE(0), 2*M); + RAJA::TypedRangeSegment r6(INDEX_TYPE(0), 3*M); INDEX_TYPE N1 = static_cast(r1.end() - r1.begin()); INDEX_TYPE N2 = static_cast(r2.end() - r2.begin()); @@ -58,7 +58,7 @@ void LaunchNestedLoopTestImpl(INDEX_TYPE M) &check_array, &test_array); - std::iota(test_array, test_array + data_len, 0); + std::iota(test_array, test_array + data_len, INDEX_TYPE(0)); working_res.memset(working_array, 0, sizeof(INDEX_TYPE) * data_len); INDEX_TYPE view_len = N; @@ -145,7 +145,7 @@ void LaunchNestedLoopTestImpl(INDEX_TYPE M) if (RAJA::stripIndexType(N) > 0) { - for (INDEX_TYPE i = INDEX_TYPE(0); i < N; i++) { + for (INDEX_TYPE i {0}; i < N; i++) { ASSERT_EQ(test_view(i), check_view(i)); } diff --git a/test/functional/launch/nested_tile_direct/tests/test-launch-nested-Tile-Direct.hpp b/test/functional/launch/nested_tile_direct/tests/test-launch-nested-Tile-Direct.hpp index 7085835cdb..27578de280 100644 --- a/test/functional/launch/nested_tile_direct/tests/test-launch-nested-Tile-Direct.hpp +++ b/test/functional/launch/nested_tile_direct/tests/test-launch-nested-Tile-Direct.hpp @@ -31,9 +31,9 @@ void LaunchNestedTileDirectTestImpl(INDEX_TYPE M) constexpr int blocks_z = 6; // Use fewer than the number of teams and threads - RAJA::TypedRangeSegment r1(0, ((blocks_x-1)*threads_x+1)*M); - RAJA::TypedRangeSegment r2(0, ((blocks_y-1)*threads_y+1)*M); - RAJA::TypedRangeSegment r3(0, ((blocks_z-1)*threads_z+1)*M); + RAJA::TypedRangeSegment r1(INDEX_TYPE(0), ((blocks_x-1)*threads_x+1)*M); + RAJA::TypedRangeSegment r2(INDEX_TYPE(0), ((blocks_y-1)*threads_y+1)*M); + RAJA::TypedRangeSegment r3(INDEX_TYPE(0), ((blocks_z-1)*threads_z+1)*M); INDEX_TYPE N1 = static_cast(r1.end() - r1.begin()); INDEX_TYPE N2 = static_cast(r2.end() - r2.begin()); @@ -59,7 +59,7 @@ void LaunchNestedTileDirectTestImpl(INDEX_TYPE M) &check_array, &test_array); - std::iota(test_array, test_array + data_len, 0); + std::iota(test_array, test_array + data_len, INDEX_TYPE(0)); working_res.memset(working_array, 0, sizeof(INDEX_TYPE) * data_len); INDEX_TYPE view_len = N; @@ -135,7 +135,7 @@ void LaunchNestedTileDirectTestImpl(INDEX_TYPE M) if (RAJA::stripIndexType(N) > 0) { - for (INDEX_TYPE i = INDEX_TYPE(0); i < N; i++) { + for (INDEX_TYPE i {0}; i < N; i++) { ASSERT_EQ(test_view(i), check_view(i)); } diff --git a/test/functional/launch/nested_tile_direct_unchecked/tests/test-launch-nested-Tile-DirectUnchecked.hpp b/test/functional/launch/nested_tile_direct_unchecked/tests/test-launch-nested-Tile-DirectUnchecked.hpp index 8758092d47..720a21d093 100644 --- a/test/functional/launch/nested_tile_direct_unchecked/tests/test-launch-nested-Tile-DirectUnchecked.hpp +++ b/test/functional/launch/nested_tile_direct_unchecked/tests/test-launch-nested-Tile-DirectUnchecked.hpp @@ -31,9 +31,9 @@ void LaunchNestedTileDirectUncheckedTestImpl(INDEX_TYPE M) const int blocks_z = 6 * RAJA::stripIndexType(M); // Use exactly the number of teams and threads - RAJA::TypedRangeSegment r1(0, threads_x*blocks_x); - RAJA::TypedRangeSegment r2(0, threads_y*blocks_y); - RAJA::TypedRangeSegment r3(0, threads_z*blocks_z); + RAJA::TypedRangeSegment r1(INDEX_TYPE(0), threads_x*blocks_x); + RAJA::TypedRangeSegment r2(INDEX_TYPE(0), threads_y*blocks_y); + RAJA::TypedRangeSegment r3(INDEX_TYPE(0), threads_z*blocks_z); INDEX_TYPE N1 = static_cast(r1.end() - r1.begin()); INDEX_TYPE N2 = static_cast(r2.end() - r2.begin()); @@ -56,7 +56,7 @@ void LaunchNestedTileDirectUncheckedTestImpl(INDEX_TYPE M) &check_array, &test_array); - std::iota(test_array, test_array + data_len, 0); + std::iota(test_array, test_array + data_len, INDEX_TYPE(0)); if ( data_len > 0 ) { working_res.memset(working_array, 0, sizeof(INDEX_TYPE) * data_len); } @@ -101,7 +101,7 @@ void LaunchNestedTileDirectUncheckedTestImpl(INDEX_TYPE M) } working_res.wait(); - for (INDEX_TYPE i = INDEX_TYPE(0); i < N; i++) { + for (INDEX_TYPE i {0}; i < N; i++) { ASSERT_EQ(test_view(i), check_view(i)); } diff --git a/test/functional/launch/nested_tile_loop/tests/test-launch-nested-Tile-Loop.hpp b/test/functional/launch/nested_tile_loop/tests/test-launch-nested-Tile-Loop.hpp index 24129300a0..2ca1619d7f 100644 --- a/test/functional/launch/nested_tile_loop/tests/test-launch-nested-Tile-Loop.hpp +++ b/test/functional/launch/nested_tile_loop/tests/test-launch-nested-Tile-Loop.hpp @@ -31,9 +31,9 @@ void LaunchNestedTileLoopTestImpl(INDEX_TYPE M) constexpr int blocks_z = 6; // Use more than the number of teams and threads - RAJA::TypedRangeSegment r1(0, (2*blocks_x*threads_x+1)*M); - RAJA::TypedRangeSegment r2(0, (2*blocks_y*threads_y+1)*M); - RAJA::TypedRangeSegment r3(0, (2*blocks_z*threads_z+1)*M); + RAJA::TypedRangeSegment r1(INDEX_TYPE(0), (2*blocks_x*threads_x+1)*M); + RAJA::TypedRangeSegment r2(INDEX_TYPE(0), (2*blocks_y*threads_y+1)*M); + RAJA::TypedRangeSegment r3(INDEX_TYPE(0), (2*blocks_z*threads_z+1)*M); INDEX_TYPE N1 = static_cast(r1.end() - r1.begin()); INDEX_TYPE N2 = static_cast(r2.end() - r2.begin()); @@ -59,7 +59,7 @@ void LaunchNestedTileLoopTestImpl(INDEX_TYPE M) &check_array, &test_array); - std::iota(test_array, test_array + data_len, 0); + std::iota(test_array, test_array + data_len, INDEX_TYPE(0)); working_res.memset(working_array, 0, sizeof(INDEX_TYPE) * data_len); INDEX_TYPE view_len = N; @@ -134,7 +134,7 @@ void LaunchNestedTileLoopTestImpl(INDEX_TYPE M) if (RAJA::stripIndexType(N) > 0) { - for (INDEX_TYPE i = INDEX_TYPE(0); i < N; i++) { + for (INDEX_TYPE i {0}; i < N; i++) { ASSERT_EQ(test_view(i), check_view(i)); } diff --git a/test/functional/launch/reduce-basic/tests/test-launch-basic-ReduceBitAnd.hpp b/test/functional/launch/reduce-basic/tests/test-launch-basic-ReduceBitAnd.hpp index 591d5e85d9..43fd91b3c1 100644 --- a/test/functional/launch/reduce-basic/tests/test-launch-basic-ReduceBitAnd.hpp +++ b/test/functional/launch/reduce-basic/tests/test-launch-basic-ReduceBitAnd.hpp @@ -43,7 +43,7 @@ void LaunchReduceBitAndBasicTestImpl(const SEG_TYPE& seg, // // First a simple non-trivial test that is mildly interesting // - for (IDX_TYPE i = 0; i < data_len; ++i) { + for (IDX_TYPE i {0}; i < data_len; ++i) { test_array[i] = 13; } working_res.memcpy(working_array, test_array, sizeof(DATA_TYPE) * data_len); @@ -69,13 +69,13 @@ void LaunchReduceBitAndBasicTestImpl(const SEG_TYPE& seg, const int modval = 100; - for (IDX_TYPE i = 0; i < data_len; ++i) { + for (IDX_TYPE i {0}; i < data_len; ++i) { test_array[i] = static_cast( rand() % modval ); } working_res.memcpy(working_array, test_array, sizeof(DATA_TYPE) * data_len); DATA_TYPE ref_and = 0; - for (IDX_TYPE i = 0; i < idx_len; ++i) { + for (IDX_TYPE i {0}; i < idx_len; ++i) { ref_and &= test_array[ seg_idx[i] ]; } @@ -179,9 +179,9 @@ TYPED_TEST_P(LaunchReduceBitAndBasicTest, ReduceBitAndBasicForall) // List segment tests seg_idx.clear(); - IDX_TYPE last = 10567; + IDX_TYPE last {10567}; srand( time(NULL) ); - for (IDX_TYPE i = 0; i < last; ++i) { + for (IDX_TYPE i {0}; i < last; ++i) { IDX_TYPE randval = IDX_TYPE( rand() % RAJA::stripIndexType(last) ); if ( i < randval ) { seg_idx.push_back(i); diff --git a/test/functional/launch/reduce-basic/tests/test-launch-basic-ReduceMin.hpp b/test/functional/launch/reduce-basic/tests/test-launch-basic-ReduceMin.hpp index 423a644794..4cbdb4deba 100644 --- a/test/functional/launch/reduce-basic/tests/test-launch-basic-ReduceMin.hpp +++ b/test/functional/launch/reduce-basic/tests/test-launch-basic-ReduceMin.hpp @@ -44,12 +44,12 @@ void LaunchReduceMinBasicTestImpl(const SEG_TYPE& seg, const DATA_TYPE min_init = modval+1; const DATA_TYPE small_min = -modval; - for (IDX_TYPE i = 0; i < data_len; ++i) { + for (IDX_TYPE i {0}; i < data_len; ++i) { test_array[i] = static_cast( rand() % modval ); } DATA_TYPE ref_min = min_init; - for (IDX_TYPE i = 0; i < idx_len; ++i) { + for (IDX_TYPE i {0}; i < idx_len; ++i) { ref_min = RAJA_MIN(test_array[ seg_idx[i] ], ref_min); } @@ -170,9 +170,9 @@ TYPED_TEST_P(LaunchReduceMinBasicTest, ReduceMinBasicForall) // List segment tests seg_idx.clear(); - IDX_TYPE last = 10567; + IDX_TYPE last {10567}; srand( time(NULL) ); - for (IDX_TYPE i = 0; i < last; ++i) { + for (IDX_TYPE i {0}; i < last; ++i) { IDX_TYPE randval = IDX_TYPE( rand() % RAJA::stripIndexType(last) ); if ( i < randval ) { seg_idx.push_back(i); diff --git a/test/functional/launch/reduce-basic/tests/test-launch-basic-ReduceSum.hpp b/test/functional/launch/reduce-basic/tests/test-launch-basic-ReduceSum.hpp index 04ea1a0fd5..04c72ca9fd 100644 --- a/test/functional/launch/reduce-basic/tests/test-launch-basic-ReduceSum.hpp +++ b/test/functional/launch/reduce-basic/tests/test-launch-basic-ReduceSum.hpp @@ -43,12 +43,12 @@ void LaunchReduceSumBasicTestImpl(const SEG_TYPE& seg, const int modval = 100; - for (IDX_TYPE i = 0; i < data_len; ++i) { + for (IDX_TYPE i {0}; i < data_len; ++i) { test_array[i] = static_cast( rand() % modval ); } DATA_TYPE ref_sum = 0; - for (IDX_TYPE i = 0; i < idx_len; ++i) { + for (IDX_TYPE i {0}; i < idx_len; ++i) { ref_sum += test_array[ seg_idx[i] ]; } @@ -157,9 +157,9 @@ TYPED_TEST_P(LaunchReduceSumBasicTest, ReduceSumBasicForall) // List segment tests seg_idx.clear(); - IDX_TYPE last = 10567; + IDX_TYPE last {10567}; srand( time(NULL) ); - for (IDX_TYPE i = 0; i < last; ++i) { + for (IDX_TYPE i {0}; i < last; ++i) { IDX_TYPE randval = IDX_TYPE( rand() % RAJA::stripIndexType(last) ); if ( i < randval ) { seg_idx.push_back(i); diff --git a/test/functional/launch/reduce-params/tests/test-launch-basic-param-expt-ReduceBitAnd.hpp b/test/functional/launch/reduce-params/tests/test-launch-basic-param-expt-ReduceBitAnd.hpp index bfd348e537..aadcb81993 100644 --- a/test/functional/launch/reduce-params/tests/test-launch-basic-param-expt-ReduceBitAnd.hpp +++ b/test/functional/launch/reduce-params/tests/test-launch-basic-param-expt-ReduceBitAnd.hpp @@ -45,7 +45,7 @@ void LaunchParamExptReduceBitAndBasicTestImpl(const SEG_TYPE& seg, // // First a simple non-trivial test that is mildly interesting // - for (IDX_TYPE i = 0; i < data_len; ++i) { + for (IDX_TYPE i {0}; i < data_len; ++i) { test_array[i] = 13; } working_res.memcpy(working_array, test_array, sizeof(DATA_TYPE) * data_len); @@ -73,13 +73,13 @@ void LaunchParamExptReduceBitAndBasicTestImpl(const SEG_TYPE& seg, const int modval = 100; - for (IDX_TYPE i = 0; i < data_len; ++i) { + for (IDX_TYPE i {0}; i < data_len; ++i) { test_array[i] = static_cast( rand() % modval ); } working_res.memcpy(working_array, test_array, sizeof(DATA_TYPE) * data_len); DATA_TYPE ref_and = 0; - for (IDX_TYPE i = 0; i < idx_len; ++i) { + for (IDX_TYPE i {0}; i < idx_len; ++i) { ref_and &= test_array[ seg_idx[i] ]; } @@ -185,9 +185,9 @@ TYPED_TEST_P(LaunchParamExptReduceBitAndBasicTest, ReduceBitAndBasicForall) // List segment tests seg_idx.clear(); - IDX_TYPE last = 10567; + IDX_TYPE last {10567}; srand( time(NULL) ); - for (IDX_TYPE i = 0; i < last; ++i) { + for (IDX_TYPE i {0}; i < last; ++i) { IDX_TYPE randval = IDX_TYPE( rand() % RAJA::stripIndexType(last) ); if ( i < randval ) { seg_idx.push_back(i); diff --git a/test/functional/launch/reduce-params/tests/test-launch-basic-param-expt-ReduceMin.hpp b/test/functional/launch/reduce-params/tests/test-launch-basic-param-expt-ReduceMin.hpp index 318132c348..63bee226f5 100644 --- a/test/functional/launch/reduce-params/tests/test-launch-basic-param-expt-ReduceMin.hpp +++ b/test/functional/launch/reduce-params/tests/test-launch-basic-param-expt-ReduceMin.hpp @@ -45,12 +45,12 @@ void LaunchParamExptReduceMinBasicTestImpl(const SEG_TYPE& seg, const DATA_TYPE min_init = modval+1; const DATA_TYPE small_min = -modval; - for (IDX_TYPE i = 0; i < data_len; ++i) { + for (IDX_TYPE i {0}; i < data_len; ++i) { test_array[i] = static_cast( rand() % modval ); } DATA_TYPE ref_min = min_init; - for (IDX_TYPE i = 0; i < idx_len; ++i) { + for (IDX_TYPE i {0}; i < idx_len; ++i) { ref_min = RAJA_MIN(test_array[ seg_idx[i] ], ref_min); } @@ -180,9 +180,9 @@ TYPED_TEST_P(LaunchParamExptReduceMinBasicTest, ReduceMinBasicForall) // List segment tests seg_idx.clear(); - IDX_TYPE last = 10567; + IDX_TYPE last {10567}; srand( time(NULL) ); - for (IDX_TYPE i = 0; i < last; ++i) { + for (IDX_TYPE i {0}; i < last; ++i) { IDX_TYPE randval = IDX_TYPE( rand() % RAJA::stripIndexType(last) ); if ( i < randval ) { seg_idx.push_back(i); diff --git a/test/functional/launch/reduce-params/tests/test-launch-basic-param-expt-ReduceSum.hpp b/test/functional/launch/reduce-params/tests/test-launch-basic-param-expt-ReduceSum.hpp index 712577fd11..b38d3bb679 100644 --- a/test/functional/launch/reduce-params/tests/test-launch-basic-param-expt-ReduceSum.hpp +++ b/test/functional/launch/reduce-params/tests/test-launch-basic-param-expt-ReduceSum.hpp @@ -43,12 +43,12 @@ void LaunchParamExptReduceSumBasicTestImpl(const SEG_TYPE& seg, const int modval = 100; - for (IDX_TYPE i = 0; i < data_len; ++i) { + for (IDX_TYPE i {0}; i < data_len; ++i) { test_array[i] = static_cast( rand() % modval ); } DATA_TYPE ref_sum = 0; - for (IDX_TYPE i = 0; i < idx_len; ++i) { + for (IDX_TYPE i {0}; i < idx_len; ++i) { ref_sum += test_array[ seg_idx[i] ]; } @@ -161,9 +161,9 @@ TYPED_TEST_P(LaunchParamExptReduceSumBasicTest, ReduceSumBasicForall) // List segment tests seg_idx.clear(); - IDX_TYPE last = 10567; + IDX_TYPE last {10567}; srand( time(NULL) ); - for (IDX_TYPE i = 0; i < last; ++i) { + for (IDX_TYPE i {0}; i < last; ++i) { IDX_TYPE randval = IDX_TYPE( rand() % RAJA::stripIndexType(last) ); if ( i < randval ) { seg_idx.push_back(i); diff --git a/test/functional/launch/segment/tests/test-launch-ListSegment.hpp b/test/functional/launch/segment/tests/test-launch-ListSegment.hpp index 4120905a15..b0c4a6061c 100644 --- a/test/functional/launch/segment/tests/test-launch-ListSegment.hpp +++ b/test/functional/launch/segment/tests/test-launch-ListSegment.hpp @@ -26,7 +26,7 @@ void LaunchListSegmentTestImpl(INDEX_TYPE N) srand ( time(NULL) ); - for (INDEX_TYPE i = INDEX_TYPE(0); i < N; ++i) { + for (INDEX_TYPE i {0}; i < N; ++i) { INDEX_TYPE randval = INDEX_TYPE(rand() % RAJA::stripIndexType(N)); if ( i < randval ) { idx_array.push_back(i); @@ -101,7 +101,7 @@ void LaunchListSegmentTestImpl(INDEX_TYPE N) working_res.memcpy(check_array, working_array, sizeof(INDEX_TYPE) * data_len); if (RAJA::stripIndexType(N) > 0) { - for (INDEX_TYPE i = INDEX_TYPE(0); i < N; i++) { + for (INDEX_TYPE i {0}; i < N; i++) { ASSERT_EQ(test_array[RAJA::stripIndexType(i)], check_array[RAJA::stripIndexType(i)]); } } else { diff --git a/test/functional/launch/segment/tests/test-launch-RangeSegment.hpp b/test/functional/launch/segment/tests/test-launch-RangeSegment.hpp index 8efccfea30..52c46aba36 100644 --- a/test/functional/launch/segment/tests/test-launch-RangeSegment.hpp +++ b/test/functional/launch/segment/tests/test-launch-RangeSegment.hpp @@ -79,7 +79,7 @@ void LaunchRangeSegmentTestImpl(INDEX_TYPE first, INDEX_TYPE last) if (RAJA::stripIndexType(N) > 0) { - for (INDEX_TYPE i = INDEX_TYPE(0); i < N; i++) { + for (INDEX_TYPE i {0}; i < N; i++) { ASSERT_EQ(test_array[RAJA::stripIndexType(i)], check_array[RAJA::stripIndexType(i)]); } diff --git a/test/functional/launch/segment/tests/test-launch-RangeStrideSegment.hpp b/test/functional/launch/segment/tests/test-launch-RangeStrideSegment.hpp index 0c2f9906bf..d50bc24238 100644 --- a/test/functional/launch/segment/tests/test-launch-RangeStrideSegment.hpp +++ b/test/functional/launch/segment/tests/test-launch-RangeStrideSegment.hpp @@ -47,7 +47,7 @@ void LaunchRangeStrideSegmentTestImpl(INDEX_TYPE first, INDEX_TYPE last, if ( RAJA::stripIndexType(N) > 0 ) { INDEX_TYPE index = first; - for (INDEX_TYPE i = INDEX_TYPE(0); i < N; ++i) { + for (INDEX_TYPE i {0}; i < N; ++i) { test_array[ RAJA::stripIndexType((index-first)/stride) ] = index; index += stride; } @@ -83,7 +83,7 @@ void LaunchRangeStrideSegmentTestImpl(INDEX_TYPE first, INDEX_TYPE last, if (RAJA::stripIndexType(N) > 0) { - for (INDEX_TYPE i = INDEX_TYPE(0); i < N; i++) { + for (INDEX_TYPE i {0}; i < N; i++) { ASSERT_EQ(test_array[RAJA::stripIndexType(i)], check_array[RAJA::stripIndexType(i)]); } diff --git a/test/functional/launch/tile_icount_tcount_direct/tests/test-launch-nested-Tile-iCount-tCount-Direct.hpp b/test/functional/launch/tile_icount_tcount_direct/tests/test-launch-nested-Tile-iCount-tCount-Direct.hpp index edd66ae551..45bf36dc65 100644 --- a/test/functional/launch/tile_icount_tcount_direct/tests/test-launch-nested-Tile-iCount-tCount-Direct.hpp +++ b/test/functional/launch/tile_icount_tcount_direct/tests/test-launch-nested-Tile-iCount-tCount-Direct.hpp @@ -21,7 +21,7 @@ void LaunchNestedTileDirectTestImpl(INDEX_TYPE M) constexpr int blocks_x = 4; INDEX_TYPE threads_x_idx(threads_x); - RAJA::TypedRangeSegment r1(0, M * threads_x_idx + 1); + RAJA::TypedRangeSegment r1(INDEX_TYPE(0), M * threads_x_idx + 1); INDEX_TYPE N1 = static_cast(r1.end() - r1.begin()); @@ -55,8 +55,8 @@ void LaunchNestedTileDirectTestImpl(INDEX_TYPE M) &check_iloop_array, &test_iloop_array); - std::iota(test_ttile_array, test_ttile_array + data_len, 0); - std::iota(test_iloop_array, test_iloop_array + data_len, 0); + std::iota(test_ttile_array, test_ttile_array + data_len, INDEX_TYPE(0)); + std::iota(test_iloop_array, test_iloop_array + data_len, INDEX_TYPE(0)); working_res.memset(working_ttile_array, 0, sizeof(INDEX_TYPE) * data_len); working_res.memset(working_iloop_array, 0, sizeof(INDEX_TYPE) * data_len); @@ -121,9 +121,9 @@ void LaunchNestedTileDirectTestImpl(INDEX_TYPE M) if (RAJA::stripIndexType(N) > 0) { - INDEX_TYPE idx = 0; - for (INDEX_TYPE bx = INDEX_TYPE(0); bx < no_tiles; ++bx) { - for (INDEX_TYPE tx = INDEX_TYPE(0); tx < threads_x; ++tx) { + INDEX_TYPE idx {0}; + for (INDEX_TYPE bx {0}; bx < no_tiles; ++bx) { + for (INDEX_TYPE tx {0}; tx < threads_x; ++tx) { if(idx >= N1) break; diff --git a/test/functional/launch/tile_icount_tcount_direct_unchecked/tests/test-launch-nested-Tile-iCount-tCount-DirectUnchecked.hpp b/test/functional/launch/tile_icount_tcount_direct_unchecked/tests/test-launch-nested-Tile-iCount-tCount-DirectUnchecked.hpp index a45e456bcd..9a665e184c 100644 --- a/test/functional/launch/tile_icount_tcount_direct_unchecked/tests/test-launch-nested-Tile-iCount-tCount-DirectUnchecked.hpp +++ b/test/functional/launch/tile_icount_tcount_direct_unchecked/tests/test-launch-nested-Tile-iCount-tCount-DirectUnchecked.hpp @@ -22,7 +22,7 @@ void LaunchNestedTileDirectUncheckedTestImpl(INDEX_TYPE M) INDEX_TYPE threads_x_idx(threads_x); INDEX_TYPE blocks_x_idx(blocks_x); - RAJA::TypedRangeSegment r1(0, threads_x_idx * blocks_x_idx); + RAJA::TypedRangeSegment r1(INDEX_TYPE(0), threads_x_idx * blocks_x_idx); INDEX_TYPE N = static_cast(r1.end() - r1.begin()); @@ -50,8 +50,8 @@ void LaunchNestedTileDirectUncheckedTestImpl(INDEX_TYPE M) &test_iloop_array); if ( data_len > 0 ) { - std::iota(test_ttile_array, test_ttile_array + data_len, 0); - std::iota(test_iloop_array, test_iloop_array + data_len, 0); + std::iota(test_ttile_array, test_ttile_array + data_len, INDEX_TYPE(0)); + std::iota(test_iloop_array, test_iloop_array + data_len, INDEX_TYPE(0)); working_res.memset(working_ttile_array, 0, sizeof(INDEX_TYPE) * data_len); working_res.memset(working_iloop_array, 0, sizeof(INDEX_TYPE) * data_len); } @@ -89,9 +89,9 @@ void LaunchNestedTileDirectUncheckedTestImpl(INDEX_TYPE M) } working_res.wait(); - INDEX_TYPE idx = 0; - for (INDEX_TYPE bx = INDEX_TYPE(0); bx < blocks_x_idx; ++bx) { - for (INDEX_TYPE tx = INDEX_TYPE(0); tx < threads_x_idx; ++tx) { + INDEX_TYPE idx {0}; + for (INDEX_TYPE bx {0}; bx < blocks_x_idx; ++bx) { + for (INDEX_TYPE tx {0}; tx < threads_x_idx; ++tx) { ASSERT_EQ(check_ttile_view(idx), bx); ASSERT_EQ(check_iloop_view(idx), tx); diff --git a/test/functional/launch/tile_icount_tcount_loop/tests/test-launch-nested-Tile-iCount-tCount-Loop.hpp b/test/functional/launch/tile_icount_tcount_loop/tests/test-launch-nested-Tile-iCount-tCount-Loop.hpp index d5a1d90af7..f4b938ad55 100644 --- a/test/functional/launch/tile_icount_tcount_loop/tests/test-launch-nested-Tile-iCount-tCount-Loop.hpp +++ b/test/functional/launch/tile_icount_tcount_loop/tests/test-launch-nested-Tile-iCount-tCount-Loop.hpp @@ -24,7 +24,7 @@ void LaunchNestedTileLoopTestImpl(INDEX_TYPE M) constexpr int threads_x = 3; constexpr int blocks_x = 1; - RAJA::TypedRangeSegment r1(0, M * tile_size_idx + 1); + RAJA::TypedRangeSegment r1(INDEX_TYPE(0), M * tile_size_idx + 1); INDEX_TYPE N1 = static_cast(r1.end() - r1.begin()); @@ -58,8 +58,8 @@ void LaunchNestedTileLoopTestImpl(INDEX_TYPE M) &check_iloop_array, &test_iloop_array); - std::iota(test_ttile_array, test_ttile_array + data_len, 0); - std::iota(test_iloop_array, test_iloop_array + data_len, 0); + std::iota(test_ttile_array, test_ttile_array + data_len, INDEX_TYPE(0)); + std::iota(test_iloop_array, test_iloop_array + data_len, INDEX_TYPE(0)); working_res.memset(working_ttile_array, 0, sizeof(INDEX_TYPE) * data_len); working_res.memset(working_iloop_array, 0, sizeof(INDEX_TYPE) * data_len); @@ -124,9 +124,9 @@ void LaunchNestedTileLoopTestImpl(INDEX_TYPE M) if (RAJA::stripIndexType(N) > 0) { - INDEX_TYPE idx = 0; - for (INDEX_TYPE bx = INDEX_TYPE(0); bx < no_tiles; ++bx) { - for (INDEX_TYPE tx = INDEX_TYPE(0); tx < tile_size_idx; ++tx) { + INDEX_TYPE idx {0}; + for (INDEX_TYPE bx {0}; bx < no_tiles; ++bx) { + for (INDEX_TYPE tx {0}; tx < tile_size_idx; ++tx) { if(idx >= N1) break; diff --git a/test/include/RAJA_test-indexset-build.hpp b/test/include/RAJA_test-indexset-build.hpp index 428fb0085a..d1cfdd452a 100644 --- a/test/include/RAJA_test-indexset-build.hpp +++ b/test/include/RAJA_test-indexset-build.hpp @@ -39,7 +39,7 @@ void buildIndexSet( std::uniform_real_distribution dist(0.0, 1.0); std::vector lindices; - INDEX_TYPE idx = 0; + INDEX_TYPE idx = INDEX_TYPE(0); while (lindices.size() < 3000) { double dval = dist(gen); if (dval > 0.3) { @@ -52,10 +52,10 @@ void buildIndexSet( // Construct a mix of Range, RangeStride, and List segments // and add them to index set // - INDEX_TYPE rbeg = 0; - INDEX_TYPE rend = 0; - INDEX_TYPE stride = 0; - INDEX_TYPE last_idx = 0; + INDEX_TYPE rbeg = INDEX_TYPE(0); + INDEX_TYPE rend = INDEX_TYPE(0); + INDEX_TYPE stride = INDEX_TYPE(0); + INDEX_TYPE last_idx = INDEX_TYPE(0); INDEX_TYPE lseg_len = static_cast( lindices.size() ); std::vector lseg(RAJA::stripIndexType(lseg_len)); std::vector lseg_vec(RAJA::stripIndexType(lseg_len)); @@ -78,7 +78,7 @@ void buildIndexSet( last_idx = rend; // Create List segment - for (INDEX_TYPE i = 0; i < lseg_len; ++i) { + for (INDEX_TYPE i = INDEX_TYPE(0); i < lseg_len; ++i) { auto ii = RAJA::stripIndexType(i); lseg[ii] = lindices[ii] + last_idx + 3; indices_out.push_back( lseg[ii] ); @@ -87,7 +87,7 @@ void buildIndexSet( last_idx = lseg[RAJA::stripIndexType(lseg_len - 1)]; // Create List segment using alternate ctor - for (INDEX_TYPE i = 0; i < lseg_len; ++i) { + for (INDEX_TYPE i = INDEX_TYPE(0); i < lseg_len; ++i) { auto ii = RAJA::stripIndexType(i); lseg_vec[ii] = lindices[ii] + last_idx + 3; indices_out.push_back( lseg_vec[ii] ); @@ -117,7 +117,7 @@ void buildIndexSet( last_idx = rend; // Create List segment - for (INDEX_TYPE i = 0; i < lseg_len; ++i) { + for (INDEX_TYPE i = INDEX_TYPE(0); i < lseg_len; ++i) { auto ii = RAJA::stripIndexType(i); lseg[ii] = lindices[ii] + last_idx + 5; indices_out.push_back( lseg[ii] ); @@ -135,7 +135,7 @@ void buildIndexSet( last_idx = rend; // Create List segment using alternate ctor - for (INDEX_TYPE i = 0; i < lseg_len; ++i) { + for (INDEX_TYPE i = INDEX_TYPE(0); i < lseg_len; ++i) { auto ii = RAJA::stripIndexType(i); lseg_vec[ii] = lindices[ii] + last_idx + 7; indices_out.push_back( lseg_vec[ii] ); From b56fe402db7848924b662d5f0b1e42cf648ea1c5 Mon Sep 17 00:00:00 2001 From: john bowen Date: Mon, 31 Aug 2026 16:31:14 -0700 Subject: [PATCH 7/8] Make Tile compatible with IdnexValue types --- include/RAJA/internal/Iterators.hpp | 6 ++ include/RAJA/pattern/kernel/Tile.hpp | 74 ++++++++++----- include/RAJA/pattern/kernel/TileTCount.hpp | 9 +- include/RAJA/policy/MultiPolicy.hpp | 4 +- include/RAJA/policy/hip/kernel/Tile.hpp | 2 +- include/RAJA/util/Span.hpp | 5 +- include/RAJA/util/types.hpp | 4 +- .../nested_direct/test-launch-nested.cpp.in | 2 +- .../test-launch-nested.cpp.in | 2 +- .../nested_loop/test-launch-nested.cpp.in | 2 +- .../test-launch-nested-tile-direct.cpp.in | 2 +- ...launch-nested-tile-direct-unchecked.cpp.in | 2 +- .../test-launch-nested-tile-loop.cpp.in | 2 +- .../launch/segment/test-launch-segment.cpp.in | 2 +- .../shared_mem/test-launch-shared-mem.cpp.in | 2 +- ...ch-nested-tile-icount-tcount-direct.cpp.in | 2 +- ...tile-icount-tcount-direct-unchecked.cpp.in | 2 +- ...unch-nested-tile-icount-tcount-loop.cpp.in | 2 +- test/include/RAJA_test-index-types.hpp | 20 +++- test/unit/util/test-span.cpp | 16 +++- test/unit/util/test-span.hpp | 94 ++++++++++--------- 21 files changed, 161 insertions(+), 95 deletions(-) diff --git a/include/RAJA/internal/Iterators.hpp b/include/RAJA/internal/Iterators.hpp index 19f0bbfbee..41f33e6273 100644 --- a/include/RAJA/internal/Iterators.hpp +++ b/include/RAJA/internal/Iterators.hpp @@ -228,6 +228,12 @@ class numeric_iterator return val + rhs.val; } + RAJA_HOST_DEVICE inline stripped_value_type operator*( + const numeric_iterator& rhs) const + { + return val * rhs.val; + } + RAJA_HOST_DEVICE inline stripped_value_type operator-( const numeric_iterator& rhs) const { diff --git a/include/RAJA/pattern/kernel/Tile.hpp b/include/RAJA/pattern/kernel/Tile.hpp index ea21e72001..a1cc6f9f14 100644 --- a/include/RAJA/pattern/kernel/Tile.hpp +++ b/include/RAJA/pattern/kernel/Tile.hpp @@ -29,6 +29,7 @@ #include "camp/concepts.hpp" #include "camp/tuple.hpp" +#include "RAJA/index/IndexValue.hpp" #include "RAJA/pattern/kernel/internal.hpp" #include "RAJA/util/macros.hpp" #include "RAJA/util/types.hpp" @@ -46,6 +47,8 @@ struct TileSize constexpr TileSize(camp::idx_t size_) : size {size_} {} }; + + namespace statement { @@ -81,6 +84,12 @@ struct tile_dynamic namespace internal { +// template +// struct is_instance_of_tile_size : std::false_type {}; + +// template +// struct is_instance_of_tile_size> : std::true_type {}; + /*! * A generic RAJA::kernel forall_impl tile wrapper for statement::For @@ -109,22 +118,24 @@ struct TileWrapper : public GenericWrapper } }; -template +template struct IterableTiler { using value_type = camp::decay; + using slice_type = typename value_type::size_type; + using block_type = RAJA::strip_index_type_t; struct iterate { value_type s; - Index_type i; + block_type i; }; class iterator { // NOTE: this must be held by value for NVCC support, *even on the host* const IterableTiler itiler; - const Index_type block_id; + const block_type block_id; public: using value_type = iterate; @@ -136,7 +147,7 @@ struct IterableTiler RAJA_HOST_DEVICE RAJA_INLINE - constexpr iterator(IterableTiler const& itiler_, Index_type block_id_) + constexpr iterator(IterableTiler const& itiler_, block_type block_id_) : itiler {itiler_}, block_id {block_id_} {} @@ -146,7 +157,9 @@ struct IterableTiler RAJA_INLINE value_type operator*() { - auto start = block_id * itiler.block_size; + auto start = slice_type { + block_id * + static_cast(RAJA::stripIndexType(itiler.block_size))}; return iterate {itiler.it.slice(start, itiler.block_size), block_id}; } @@ -160,15 +173,20 @@ struct IterableTiler RAJA_HOST_DEVICE RAJA_INLINE iterator operator-(const difference_type& rhs) const { - return iterator(itiler, block_id - rhs); + return iterator( + itiler, + static_cast(static_cast(block_id) - rhs)); } RAJA_HOST_DEVICE RAJA_INLINE iterator operator+(const difference_type& rhs) const { - return iterator(itiler, block_id + rhs >= itiler.num_blocks - ? itiler.num_blocks - : block_id + rhs); + const difference_type next = + static_cast(block_id) + rhs; + return iterator(itiler, + next >= static_cast(itiler.num_blocks) + ? itiler.num_blocks + : static_cast(next)); } RAJA_HOST_DEVICE @@ -190,20 +208,20 @@ struct IterableTiler } }; - RAJA_HOST_DEVICE - - RAJA_INLINE - IterableTiler(const Iterable& it_, camp::idx_t block_size_) + RAJA_HOST_DEVICE RAJA_INLINE + IterableTiler(const Iterable& it_, BlockSizeT block_size_) : it {it_}, block_size {block_size_} { using std::begin; using std::distance; using std::end; - dist = it.end() - it.begin(); // distance(begin(it), end(it)); - num_blocks = dist / block_size; + const block_type stripped_block_size = + static_cast(RAJA::stripIndexType(block_size)); + dist = static_cast(it.end() - it.begin()); + num_blocks = dist / stripped_block_size; // if (dist % block_size) num_blocks += 1; - if (dist - num_blocks * block_size > 0) + if (dist - num_blocks * stripped_block_size > block_type {0}) { num_blocks += 1; } @@ -212,7 +230,7 @@ struct IterableTiler RAJA_HOST_DEVICE RAJA_INLINE - iterator begin() const { return iterator(*this, 0); } + iterator begin() const { return iterator(*this, block_type {0}); } RAJA_HOST_DEVICE @@ -220,9 +238,9 @@ struct IterableTiler iterator end() const { return iterator(*this, num_blocks); } value_type it; - camp::idx_t block_size; - camp::idx_t num_blocks; - camp::idx_t dist; + BlockSizeT block_size; + block_type num_blocks; + block_type dist; }; /*! @@ -247,11 +265,15 @@ struct StatementExecutor< auto const& segment = camp::get(data.segment_tuple); // Get the tiling policies chunk size - auto chunk_size = tile_fixed::chunk_size; + constexpr auto chunk_size = tile_fixed::chunk_size; + using segment_t = decltype(segment); + using slice_t = typename std::decay_t::size_type; + using slice_value_t = RAJA::strip_index_type_t; // Create a tile iterator, needs to survive until the forall is // done executing. - IterableTiler tiled_iterable(segment, chunk_size); + IterableTiler tiled_iterable( + segment, slice_t {static_cast(chunk_size)}); // Wrap in case forall_impl needs to thread_privatize TileWrapper tile_wrapper(data); @@ -282,14 +304,20 @@ struct StatementExecutor< // Get the segment we are going to tile auto const& segment = camp::get(data.segment_tuple); + using segment_t = decltype(segment); + using slice_t = typename std::decay_t::size_type; + using slice_value_t = RAJA::strip_index_type_t; // Get the tiling policies chunk size auto chunk_size = camp::get(data.param_tuple); static_assert( camp::concepts::metalib::is_same::value, + // is_instance_of_tile_size::value, "Extracted parameter must be of type TileSize."); // Create a tile iterator - IterableTiler tiled_iterable(segment, chunk_size.size); + IterableTiler tiled_iterable( + segment, + slice_t {static_cast(RAJA::stripIndexType(chunk_size.size))}); // Wrap in case forall_impl needs to thread_privatize TileWrapper tile_wrapper(data); diff --git a/include/RAJA/pattern/kernel/TileTCount.hpp b/include/RAJA/pattern/kernel/TileTCount.hpp index afe447bce1..695608c7f1 100644 --- a/include/RAJA/pattern/kernel/TileTCount.hpp +++ b/include/RAJA/pattern/kernel/TileTCount.hpp @@ -117,13 +117,16 @@ struct StatementExecutor< { // Get the segment we are going to tile auto const& segment = camp::get(data.segment_tuple); - + using segment_t = decltype(segment); + using slice_t = typename std::decay_t::size_type; + using slice_value_t = RAJA::strip_index_type_t; // Get the tiling policies chunk size - auto chunk_size = TPol::chunk_size; + constexpr auto chunk_size = TPol::chunk_size; // Create a tile iterator, needs to survive until the forall is // done executing. - IterableTiler tiled_iterable(segment, chunk_size); + IterableTiler tiled_iterable( + segment, slice_t {static_cast(chunk_size)}); // Wrap in case forall_impl needs to thread_privatize TileTCountWrapper diff --git a/include/RAJA/policy/MultiPolicy.hpp b/include/RAJA/policy/MultiPolicy.hpp index ec847b55d1..711a84f5f1 100644 --- a/include/RAJA/policy/MultiPolicy.hpp +++ b/include/RAJA/policy/MultiPolicy.hpp @@ -159,8 +159,8 @@ auto make_multi_policy(Selector s) -> MultiPolicy /// \return A MultiPolicy containing the given selector s template RAJA_DEPRECATE("In the next RAJA Release, MultiPolicy will be deprecated.") -auto make_multi_policy(std::tuple policies, Selector s) - -> MultiPolicy +auto make_multi_policy(std::tuple policies, + Selector s) -> MultiPolicy { return detail::make_multi_policy(camp::make_idx_seq_t {}, s, policies); diff --git a/include/RAJA/policy/hip/kernel/Tile.hpp b/include/RAJA/policy/hip/kernel/Tile.hpp index 4e41164695..137fa136ef 100644 --- a/include/RAJA/policy/hip/kernel/Tile.hpp +++ b/include/RAJA/policy/hip/kernel/Tile.hpp @@ -210,6 +210,7 @@ struct HipStatementExecutor< // Get original segment auto& segment = camp::get(private_data.segment_tuple); using segment_t = camp::decay; + // restrict to first tile segment = segment.slice(typename segment_t::size_type {0}, typename segment_t::size_type {chunk_size}); @@ -310,7 +311,6 @@ struct HipStatementExecutor< // Get original segment auto& segment = camp::get(private_data.segment_tuple); - using segment_t = camp::decay; using segment_idx_t = typename camp::decay::size_type; // restrict to first tile segment = segment.slice(segment_idx_t {0}, segment_idx_t {chunk_size}); diff --git a/include/RAJA/util/Span.hpp b/include/RAJA/util/Span.hpp index 39495f00cb..0cac80c3b3 100644 --- a/include/RAJA/util/Span.hpp +++ b/include/RAJA/util/Span.hpp @@ -20,6 +20,7 @@ #ifndef RAJA_SPAN_HPP #define RAJA_SPAN_HPP +#include "RAJA/index/IndexValue.hpp" #include "RAJA/util/macros.hpp" #include "RAJA/util/types.hpp" #include "RAJA/pattern/concepts.hpp" @@ -164,12 +165,12 @@ struct Span constexpr RAJA_HOST_DEVICE RAJA_INLINE bool empty() const { - return size() == static_cast(0); + return size() == size_type {0}; } constexpr RAJA_HOST_DEVICE RAJA_INLINE Span first(size_type count) const { - return slice(0, count); + return slice(size_type {0}, count); } constexpr RAJA_HOST_DEVICE RAJA_INLINE Span last(size_type count) const diff --git a/include/RAJA/util/types.hpp b/include/RAJA/util/types.hpp index 685d50285c..a48c74b2d3 100644 --- a/include/RAJA/util/types.hpp +++ b/include/RAJA/util/types.hpp @@ -1070,8 +1070,8 @@ struct CopyFunctorOneRange }; template -CopyFunctorOneRange(DestIter, SrcIter) - -> CopyFunctorOneRange; +CopyFunctorOneRange(DestIter, + SrcIter) -> CopyFunctorOneRange; /*! * \brief Functor that copies src1 to dst1 and src2 to dst2. diff --git a/test/functional/launch/nested_direct/test-launch-nested.cpp.in b/test/functional/launch/nested_direct/test-launch-nested.cpp.in index 182eb342af..5e6a992e80 100644 --- a/test/functional/launch/nested_direct/test-launch-nested.cpp.in +++ b/test/functional/launch/nested_direct/test-launch-nested.cpp.in @@ -29,7 +29,7 @@ // Cartesian product of types used in parameterized tests // using @BACKEND@LaunchNestedTypes = - Test< camp::cartesian_product>::Types; diff --git a/test/functional/launch/nested_direct_unchecked/test-launch-nested.cpp.in b/test/functional/launch/nested_direct_unchecked/test-launch-nested.cpp.in index ae2b84e8c2..dd96076c99 100644 --- a/test/functional/launch/nested_direct_unchecked/test-launch-nested.cpp.in +++ b/test/functional/launch/nested_direct_unchecked/test-launch-nested.cpp.in @@ -29,7 +29,7 @@ // Cartesian product of types used in parameterized tests // using @BACKEND@LaunchNestedTypes = - Test< camp::cartesian_product>::Types; diff --git a/test/functional/launch/nested_loop/test-launch-nested.cpp.in b/test/functional/launch/nested_loop/test-launch-nested.cpp.in index e0a53f6aad..07dbf95bd3 100644 --- a/test/functional/launch/nested_loop/test-launch-nested.cpp.in +++ b/test/functional/launch/nested_loop/test-launch-nested.cpp.in @@ -29,7 +29,7 @@ // Cartesian product of types used in parameterized tests // using @BACKEND@LaunchNestedTypes = - Test< camp::cartesian_product>::Types; diff --git a/test/functional/launch/nested_tile_direct/test-launch-nested-tile-direct.cpp.in b/test/functional/launch/nested_tile_direct/test-launch-nested-tile-direct.cpp.in index 1ccbbb3061..f7e02302c3 100644 --- a/test/functional/launch/nested_tile_direct/test-launch-nested-tile-direct.cpp.in +++ b/test/functional/launch/nested_tile_direct/test-launch-nested-tile-direct.cpp.in @@ -29,7 +29,7 @@ // Cartesian product of types used in parameterized tests // using @BACKEND@LaunchNestedTypes = - Test< camp::cartesian_product>::Types; diff --git a/test/functional/launch/nested_tile_direct_unchecked/test-launch-nested-tile-direct-unchecked.cpp.in b/test/functional/launch/nested_tile_direct_unchecked/test-launch-nested-tile-direct-unchecked.cpp.in index ce7f374bd1..f128e87d3f 100644 --- a/test/functional/launch/nested_tile_direct_unchecked/test-launch-nested-tile-direct-unchecked.cpp.in +++ b/test/functional/launch/nested_tile_direct_unchecked/test-launch-nested-tile-direct-unchecked.cpp.in @@ -29,7 +29,7 @@ // Cartesian product of types used in parameterized tests // using @BACKEND@LaunchNestedTypes = - Test< camp::cartesian_product>::Types; diff --git a/test/functional/launch/nested_tile_loop/test-launch-nested-tile-loop.cpp.in b/test/functional/launch/nested_tile_loop/test-launch-nested-tile-loop.cpp.in index 849fe76bdd..6872c5a519 100644 --- a/test/functional/launch/nested_tile_loop/test-launch-nested-tile-loop.cpp.in +++ b/test/functional/launch/nested_tile_loop/test-launch-nested-tile-loop.cpp.in @@ -29,7 +29,7 @@ // Cartesian product of types used in parameterized tests // using @BACKEND@LaunchNestedTypes = - Test< camp::cartesian_product>::Types; diff --git a/test/functional/launch/segment/test-launch-segment.cpp.in b/test/functional/launch/segment/test-launch-segment.cpp.in index 10ca99d981..89db949c27 100644 --- a/test/functional/launch/segment/test-launch-segment.cpp.in +++ b/test/functional/launch/segment/test-launch-segment.cpp.in @@ -29,7 +29,7 @@ // Cartesian product of types used in parameterized tests // using @BACKEND@LaunchSegmentTypes = - Test< camp::cartesian_product>::Types; diff --git a/test/functional/launch/shared_mem/test-launch-shared-mem.cpp.in b/test/functional/launch/shared_mem/test-launch-shared-mem.cpp.in index 058cedca7c..0a5ce61915 100644 --- a/test/functional/launch/shared_mem/test-launch-shared-mem.cpp.in +++ b/test/functional/launch/shared_mem/test-launch-shared-mem.cpp.in @@ -29,7 +29,7 @@ // Cartesian product of types used in parameterized tests // using @BACKEND@LaunchSharedMemTypes = - Test< camp::cartesian_product>::Types; diff --git a/test/functional/launch/tile_icount_tcount_direct/test-launch-nested-tile-icount-tcount-direct.cpp.in b/test/functional/launch/tile_icount_tcount_direct/test-launch-nested-tile-icount-tcount-direct.cpp.in index 540c1aa75f..f97e408731 100644 --- a/test/functional/launch/tile_icount_tcount_direct/test-launch-nested-tile-icount-tcount-direct.cpp.in +++ b/test/functional/launch/tile_icount_tcount_direct/test-launch-nested-tile-icount-tcount-direct.cpp.in @@ -29,7 +29,7 @@ // Cartesian product of types used in parameterized tests // using @BACKEND@LaunchNestedTypes = - Test< camp::cartesian_product>::Types; diff --git a/test/functional/launch/tile_icount_tcount_direct_unchecked/test-launch-nested-tile-icount-tcount-direct-unchecked.cpp.in b/test/functional/launch/tile_icount_tcount_direct_unchecked/test-launch-nested-tile-icount-tcount-direct-unchecked.cpp.in index a40af1c633..1f6c2d771a 100644 --- a/test/functional/launch/tile_icount_tcount_direct_unchecked/test-launch-nested-tile-icount-tcount-direct-unchecked.cpp.in +++ b/test/functional/launch/tile_icount_tcount_direct_unchecked/test-launch-nested-tile-icount-tcount-direct-unchecked.cpp.in @@ -29,7 +29,7 @@ // Cartesian product of types used in parameterized tests // using @BACKEND@LaunchNestedTypes = - Test< camp::cartesian_product>::Types; diff --git a/test/functional/launch/tile_icount_tcount_loop/test-launch-nested-tile-icount-tcount-loop.cpp.in b/test/functional/launch/tile_icount_tcount_loop/test-launch-nested-tile-icount-tcount-loop.cpp.in index 68f731dc01..ffa84973ea 100644 --- a/test/functional/launch/tile_icount_tcount_loop/test-launch-nested-tile-icount-tcount-loop.cpp.in +++ b/test/functional/launch/tile_icount_tcount_loop/test-launch-nested-tile-icount-tcount-loop.cpp.in @@ -29,7 +29,7 @@ // Cartesian product of types used in parameterized tests // using @BACKEND@LaunchNestedTypes = - Test< camp::cartesian_product>::Types; diff --git a/test/include/RAJA_test-index-types.hpp b/test/include/RAJA_test-index-types.hpp index f92c204479..bf974fff8b 100644 --- a/test/include/RAJA_test-index-types.hpp +++ b/test/include/RAJA_test-index-types.hpp @@ -54,12 +54,28 @@ using RawIdxTypeList = camp::list; +// Launch is not strong-index compatible (yet) + +using LaunchIdxTypeList = camp::list; + // -// Strong-compatible index types list +// Strong-compatible index types list for use within kernel // // Use this list for tests that are expected to work with strongly typed // indices and avoid raw integer interoperability assumptions. diff --git a/test/unit/util/test-span.cpp b/test/unit/util/test-span.cpp index d02c30ce9f..4703cb7611 100644 --- a/test/unit/util/test-span.cpp +++ b/test/unit/util/test-span.cpp @@ -13,11 +13,17 @@ #include "test-span.hpp" -#define RAJA_SPAN_RUN_TEST(test) \ - test(); \ - test(); \ - test(); \ - test(); \ +#include "RAJA/index/IndexValue.hpp" + +RAJA_INDEX_VALUE_T(TestIndex, int, "TestIndex"); + +#define RAJA_SPAN_RUN_TEST(test) \ + test(); \ + test(); \ + test(); \ + test(); \ + // test(); \ + // test(); TEST(Span, basic_construct_Span) { diff --git a/test/unit/util/test-span.hpp b/test/unit/util/test-span.hpp index 2aaa9797fc..092578050e 100644 --- a/test/unit/util/test-span.hpp +++ b/test/unit/util/test-span.hpp @@ -19,8 +19,8 @@ template void testSpanConstructTypes() { - constexpr IndexType len = 4; - ValueType* ptr = new ValueType[len]; + IndexType len {4}; + ValueType* ptr = new ValueType[RAJA::stripIndexType(len)]; { const RAJA::Span span(ptr, len); @@ -30,7 +30,8 @@ void testSpanConstructTypes() } { - const RAJA::Span span(ptr, ptr+len); + const RAJA::Span span(ptr, + ptr + RAJA::stripIndexType(len)); ASSERT_EQ(ptr, span.data()); ASSERT_EQ(len, span.size()); @@ -42,8 +43,8 @@ void testSpanConstructTypes() template void testSpanAssignTypes() { - constexpr IndexType len = 4; - ValueType* ptr = new ValueType[len]; + IndexType len {4}; + ValueType* ptr = new ValueType[RAJA::stripIndexType(len)]; { RAJA::Span span(ptr, len); @@ -56,7 +57,7 @@ void testSpanAssignTypes() { ValueType* ptr2 = ptr + 1; - constexpr IndexType len2 = 1; + IndexType len2 {1}; RAJA::Span span(ptr, len); const RAJA::Span span2(ptr2, len2); span = span2; @@ -74,14 +75,15 @@ void testSpanIteratorTypes() using span_type = RAJA::Span; using iterator = typename span_type::iterator; using const_iterator = typename span_type::const_iterator; - constexpr IndexType len = 4; - ValueType* ptr = new ValueType[len]; + IndexType len {4}; + ValueType* ptr = new ValueType[RAJA::stripIndexType(len)]; // XL cannot handle initialization list with new - // e.g. new ValueType[len]{0,1,2,3} produces error - for ( IndexType ii = 0; ii < len; ++ii ) + // e.g. new ValueType[RAJA::stripIndexType(len)]{0,1,2,3} produces error + for ( IndexType ii {0}; ii < len; ++ii ) { - ptr[ii] = static_cast(ii); + ptr[RAJA::stripIndexType(ii)] = + static_cast(RAJA::stripIndexType(ii)); } { @@ -90,7 +92,7 @@ void testSpanIteratorTypes() iterator begin = span.begin(); iterator end = span.end(); ASSERT_EQ(ptr, begin); - ASSERT_EQ(ptr+len, end); + ASSERT_EQ(ptr + RAJA::stripIndexType(len), end); ValueType* ptr_chk = ptr; @@ -102,7 +104,7 @@ void testSpanIteratorTypes() const_iterator cbegin = span.cbegin(); const_iterator cend = span.cend(); ASSERT_EQ(ptr, cbegin); - ASSERT_EQ(ptr+len, cend); + ASSERT_EQ(ptr + RAJA::stripIndexType(len), cend); ptr_chk = ptr; @@ -118,14 +120,15 @@ void testSpanIteratorTypes() template void testSpanElementAccessTypes() { - constexpr IndexType len = 4; - ValueType* ptr = new ValueType[len]; + IndexType len {4}; + ValueType* ptr = new ValueType[RAJA::stripIndexType(len)]; // XL cannot handle initialization list with new - // e.g. new ValueType[len]{0,1,2,3} produces error - for ( IndexType ii = 0; ii < len; ++ii ) + // e.g. new ValueType[RAJA::stripIndexType(len)]{0,1,2,3} produces error + for ( IndexType ii {0}; ii < len; ++ii ) { - ptr[ii] = static_cast(ii); + ptr[RAJA::stripIndexType(ii)] = + static_cast(RAJA::stripIndexType(ii)); } { @@ -133,10 +136,10 @@ void testSpanElementAccessTypes() ASSERT_EQ(ptr, span.data()); ASSERT_EQ(*ptr, span.front()); - ASSERT_EQ(*(ptr+len-1), span.back()); + ASSERT_EQ(*(ptr + RAJA::stripIndexType(len) - 1), span.back()); - for (IndexType i = 0; i < len; ++i) { - ASSERT_EQ(ptr[i], span[i]); + for (IndexType i {0}; i < len; ++i) { + ASSERT_EQ(ptr[RAJA::stripIndexType(i)], span[i]); } } @@ -146,14 +149,15 @@ void testSpanElementAccessTypes() template void testSpanObserveTypes() { - constexpr IndexType len = 4; - ValueType* ptr = new ValueType[len]; + IndexType len {4}; + ValueType* ptr = new ValueType[RAJA::stripIndexType(len)]; // XL cannot handle initialization list with new - // e.g. new ValueType[len]{0,1,2,3} produces error - for ( IndexType ii = 0; ii < len; ++ii ) + // e.g. new ValueType[RAJA::stripIndexType(len)]{0,1,2,3} produces error + for ( IndexType ii {0}; ii < len; ++ii ) { - ptr[ii] = static_cast(ii); + ptr[RAJA::stripIndexType(ii)] = + static_cast(RAJA::stripIndexType(ii)); } { @@ -164,9 +168,9 @@ void testSpanObserveTypes() } { - const RAJA::Span span(ptr, len-len); + const RAJA::Span span(ptr, len - len); - ASSERT_EQ(0, span.size()); + ASSERT_EQ(IndexType {0}, span.size()); ASSERT_TRUE(span.empty()); } @@ -176,18 +180,19 @@ void testSpanObserveTypes() template void testSpanSubViewTypes() { - constexpr IndexType len = 4; - ValueType* ptr = new ValueType[len]; + IndexType len {4}; + ValueType* ptr = new ValueType[RAJA::stripIndexType(len)]; // XL cannot handle initialization list with new - // e.g. new ValueType[len]{0,1,2,3} produces error - for ( IndexType ii = 0; ii < len; ++ii ) + // e.g. new ValueType[RAJA::stripIndexType(len)]{0,1,2,3} produces error + for ( IndexType ii {0}; ii < len; ++ii ) { - ptr[ii] = static_cast(ii); + ptr[RAJA::stripIndexType(ii)] = + static_cast(RAJA::stripIndexType(ii)); } { - constexpr IndexType count = 3; + IndexType count {3}; const RAJA::Span span(ptr, len); const RAJA::Span subspan = span.first(count); @@ -196,32 +201,33 @@ void testSpanSubViewTypes() } { - constexpr IndexType count = 3; + IndexType count {3}; const RAJA::Span span(ptr, len); const RAJA::Span subspan = span.last(count); ASSERT_EQ(count, subspan.size()); - ASSERT_EQ(ptr+len-count, subspan.data()); + ASSERT_EQ(ptr + RAJA::stripIndexType(len) - RAJA::stripIndexType(count), + subspan.data()); } { - constexpr IndexType begin = 1; - constexpr IndexType count = 2; + IndexType begin {1}; + IndexType count {2}; const RAJA::Span span(ptr, len); const RAJA::Span subspan = span.subspan(begin, count); ASSERT_EQ(count, subspan.size()); - ASSERT_EQ(ptr+begin, subspan.data()); + ASSERT_EQ(ptr + RAJA::stripIndexType(begin), subspan.data()); } { - constexpr IndexType begin = 1; - constexpr IndexType count = 2; + IndexType begin {1}; + IndexType count {2}; const RAJA::Span span(ptr, len); const RAJA::Span subspan = span.slice(begin, count); ASSERT_EQ(count, subspan.size()); - ASSERT_EQ(ptr+begin, subspan.data()); + ASSERT_EQ(ptr + RAJA::stripIndexType(begin), subspan.data()); } delete[] ptr; @@ -230,8 +236,8 @@ void testSpanSubViewTypes() template void testSpanMakeSpanTypes() { - constexpr IndexType len = 4; - ValueType* ptr = new ValueType[len]; + IndexType len {4}; + ValueType* ptr = new ValueType[RAJA::stripIndexType(len)]; { const RAJA::Span span = RAJA::make_span(ptr, len); From 481cddd9c38d5dc1c2616852090b12534ef1dd25 Mon Sep 17 00:00:00 2001 From: john bowen Date: Wed, 2 Sep 2026 10:48:30 -0700 Subject: [PATCH 8/8] Finish refactor of CUDA and SYCL tile backends to support IndexValue spans --- include/RAJA/pattern/kernel/Tile.hpp | 35 ++++++++-------- include/RAJA/pattern/kernel/TileTCount.hpp | 4 +- include/RAJA/policy/cuda/kernel/Tile.hpp | 33 +++++++++------ include/RAJA/policy/sycl/kernel/Tile.hpp | 41 ++++++++++++------- .../tests/test-kernel-hyperplane-2D.hpp | 15 ------- .../tests/test-kernel-hyperplane-3D.hpp | 17 +------- ...test-kernel-nested-loops-segment-types.hpp | 17 +------- .../test-kernel-nested-loop-OffsetView2D.hpp | 17 +------- .../test-kernel-nested-loop-OffsetView3D.hpp | 17 +------- ...ernel-nested-loop-PermutedOffsetView2D.hpp | 17 +------- ...ernel-nested-loop-PermutedOffsetView3D.hpp | 17 +------- ...test-kernel-nested-loop-PermutedView2D.hpp | 17 +------- ...test-kernel-nested-loop-PermutedView3D.hpp | 17 +------- .../tests/test-kernel-reduceloc-Max2D.hpp | 16 -------- .../tests/test-kernel-reduceloc-Max2DView.hpp | 16 -------- .../test-kernel-reduceloc-Max2DViewTuple.hpp | 16 -------- .../tests/test-kernel-reduceloc-Min2D.hpp | 16 -------- .../tests/test-kernel-reduceloc-Min2DView.hpp | 16 -------- .../test-kernel-reduceloc-Min2DViewTuple.hpp | 16 -------- ...test-kernel-reduce-params-multi-lambda.hpp | 17 +------- .../tests/test-kernel-basic-param.hpp | 1 - .../tests/test-kernel-tile-Dynamic2D.hpp | 17 +------- .../tests/test-kernel-tile-Fixed2D.hpp | 17 +------- .../tests/test-kernel-tile-Fixed2DMinMax.hpp | 17 +------- .../tests/test-kernel-tile-Fixed2DSum.hpp | 17 +------- .../tests/test-kernel-tile-LocalArray2D.hpp | 17 +------- 26 files changed, 79 insertions(+), 384 deletions(-) diff --git a/include/RAJA/pattern/kernel/Tile.hpp b/include/RAJA/pattern/kernel/Tile.hpp index a1cc6f9f14..951bc25598 100644 --- a/include/RAJA/pattern/kernel/Tile.hpp +++ b/include/RAJA/pattern/kernel/Tile.hpp @@ -47,8 +47,6 @@ struct TileSize constexpr TileSize(camp::idx_t size_) : size {size_} {} }; - - namespace statement { @@ -157,9 +155,9 @@ struct IterableTiler RAJA_INLINE value_type operator*() { - auto start = slice_type { - block_id * - static_cast(RAJA::stripIndexType(itiler.block_size))}; + auto start = + slice_type {block_id * static_cast( + RAJA::stripIndexType(itiler.block_size))}; return iterate {itiler.it.slice(start, itiler.block_size), block_id}; } @@ -173,16 +171,15 @@ struct IterableTiler RAJA_HOST_DEVICE RAJA_INLINE iterator operator-(const difference_type& rhs) const { - return iterator( - itiler, - static_cast(static_cast(block_id) - rhs)); + return iterator(itiler, + static_cast( + static_cast(block_id) - rhs)); } RAJA_HOST_DEVICE RAJA_INLINE iterator operator+(const difference_type& rhs) const { - const difference_type next = - static_cast(block_id) + rhs; + const difference_type next = static_cast(block_id) + rhs; return iterator(itiler, next >= static_cast(itiler.num_blocks) ? itiler.num_blocks @@ -208,8 +205,8 @@ struct IterableTiler } }; - RAJA_HOST_DEVICE RAJA_INLINE - IterableTiler(const Iterable& it_, BlockSizeT block_size_) + RAJA_HOST_DEVICE RAJA_INLINE IterableTiler(const Iterable& it_, + BlockSizeT block_size_) : it {it_}, block_size {block_size_} { @@ -266,9 +263,9 @@ struct StatementExecutor< // Get the tiling policies chunk size constexpr auto chunk_size = tile_fixed::chunk_size; - using segment_t = decltype(segment); - using slice_t = typename std::decay_t::size_type; - using slice_value_t = RAJA::strip_index_type_t; + using segment_t = decltype(segment); + using slice_t = typename std::decay_t::size_type; + using slice_value_t = RAJA::strip_index_type_t; // Create a tile iterator, needs to survive until the forall is // done executing. @@ -304,8 +301,8 @@ struct StatementExecutor< // Get the segment we are going to tile auto const& segment = camp::get(data.segment_tuple); - using segment_t = decltype(segment); - using slice_t = typename std::decay_t::size_type; + using segment_t = decltype(segment); + using slice_t = typename std::decay_t::size_type; using slice_value_t = RAJA::strip_index_type_t; // Get the tiling policies chunk size auto chunk_size = camp::get(data.param_tuple); @@ -316,8 +313,8 @@ struct StatementExecutor< // Create a tile iterator IterableTiler tiled_iterable( - segment, - slice_t {static_cast(RAJA::stripIndexType(chunk_size.size))}); + segment, slice_t {static_cast( + RAJA::stripIndexType(chunk_size.size))}); // Wrap in case forall_impl needs to thread_privatize TileWrapper tile_wrapper(data); diff --git a/include/RAJA/pattern/kernel/TileTCount.hpp b/include/RAJA/pattern/kernel/TileTCount.hpp index 695608c7f1..a14188fb7e 100644 --- a/include/RAJA/pattern/kernel/TileTCount.hpp +++ b/include/RAJA/pattern/kernel/TileTCount.hpp @@ -117,8 +117,8 @@ struct StatementExecutor< { // Get the segment we are going to tile auto const& segment = camp::get(data.segment_tuple); - using segment_t = decltype(segment); - using slice_t = typename std::decay_t::size_type; + using segment_t = decltype(segment); + using slice_t = typename std::decay_t::size_type; using slice_value_t = RAJA::strip_index_type_t; // Get the tiling policies chunk size constexpr auto chunk_size = TPol::chunk_size; diff --git a/include/RAJA/policy/cuda/kernel/Tile.hpp b/include/RAJA/policy/cuda/kernel/Tile.hpp index a6522c0113..4d933fa775 100644 --- a/include/RAJA/policy/cuda/kernel/Tile.hpp +++ b/include/RAJA/policy/cuda/kernel/Tile.hpp @@ -92,7 +92,8 @@ struct CudaStatementExecutor< segment_t orig_segment = segment; // Assign our new tiled segment - segment = orig_segment.slice(i, static_cast(chunk_size)); + segment = orig_segment.slice(typename segment_t::size_type(i), + typename segment_t::size_type {chunk_size}); // execute enclosed statements enclosed_stmts_t::exec(data, thread_active); @@ -115,10 +116,11 @@ struct CudaStatementExecutor< data_t private_data = data; // Get original segment - auto& segment = camp::get(private_data.segment_tuple); + auto& segment = camp::get(private_data.segment_tuple); + using segment_idx_t = typename camp::decay::size_type; // restrict to first tile - segment = segment.slice(0, static_cast(chunk_size)); + segment = segment.slice(segment_idx_t {0}, segment_idx_t {chunk_size}); // NOTE: We do not detect improper uses of direct_unchecked policies under // tiling. This happens when using a direct unchecked policy on a tiled @@ -183,7 +185,8 @@ struct CudaStatementExecutor< segment_t orig_segment = segment; // Assign our new tiled segment - segment = orig_segment.slice(i, static_cast(chunk_size)); + segment = orig_segment.slice(typename segment_t::size_type(i), + typename segment_t::size_type {chunk_size}); // execute enclosed statements enclosed_stmts_t::exec(data, thread_active && have_work); @@ -206,10 +209,12 @@ struct CudaStatementExecutor< data_t private_data = data; // Get original segment - auto& segment = camp::get(private_data.segment_tuple); + auto& segment = camp::get(private_data.segment_tuple); + using segment_t = camp::decay; // restrict to first tile - segment = segment.slice(0, static_cast(chunk_size)); + segment = segment.slice(typename segment_t::size_type {0}, + typename segment_t::size_type {chunk_size}); LaunchDims enclosed_dims = enclosed_stmts_t::calculateDimensions(private_data); @@ -281,7 +286,8 @@ struct CudaStatementExecutor< const bool have_work = (i < len); // Assign our new tiled segment - segment = orig_segment.slice(i, static_cast(chunk_size)); + segment = orig_segment.slice(typename segment_t::size_type(i), + typename segment_t::size_type {chunk_size}); // execute enclosed statements enclosed_stmts_t::exec(data, thread_active && have_work); @@ -305,10 +311,11 @@ struct CudaStatementExecutor< data_t private_data = data; // Get original segment - auto& segment = camp::get(private_data.segment_tuple); + auto& segment = camp::get(private_data.segment_tuple); + using segment_idx_t = typename camp::decay::size_type; // restrict to first tile - segment = segment.slice(0, chunk_size); + segment = segment.slice(segment_idx_t {0}, segment_idx_t {chunk_size}); LaunchDims enclosed_dims = enclosed_stmts_t::calculateDimensions(private_data); @@ -375,7 +382,8 @@ struct CudaStatementExecutor< { // Assign our new tiled segment - segment = orig_segment.slice(i, static_cast(chunk_size)); + segment = orig_segment.slice(typename segment_t::size_type(i), + typename segment_t::size_type {chunk_size}); // execute enclosed statements enclosed_stmts_t::exec(data, thread_active); @@ -399,10 +407,11 @@ struct CudaStatementExecutor< data_t private_data = data; // Get original segment - auto& segment = camp::get(private_data.segment_tuple); + auto& segment = camp::get(private_data.segment_tuple); + using segment_idx_t = typename camp::decay::size_type; // restrict to first tile - segment = segment.slice(0, chunk_size); + segment = segment.slice(segment_idx_t {0}, segment_idx_t {chunk_size}); LaunchDims enclosed_dims = enclosed_stmts_t::calculateDimensions(private_data); diff --git a/include/RAJA/policy/sycl/kernel/Tile.hpp b/include/RAJA/policy/sycl/kernel/Tile.hpp index da8c315f73..04d90bd016 100644 --- a/include/RAJA/policy/sycl/kernel/Tile.hpp +++ b/include/RAJA/policy/sycl/kernel/Tile.hpp @@ -85,7 +85,8 @@ struct SyclStatementExecutor< { // Assign our new tiled segment - segment = orig_segment.slice(i, chunk_size); + segment = orig_segment.slice(typename segment_t::size_type(i), + typename segment_t::size_type {chunk_size}); // execute enclosed statements enclosed_stmts_t::exec(data, item, thread_active); @@ -103,10 +104,12 @@ struct SyclStatementExecutor< data_t private_data = data; // Get original segment - auto& segment = camp::get(private_data.segment_tuple); + auto& segment = camp::get(private_data.segment_tuple); + using segment_idx_t = typename camp::decay::size_type; // restrict to first tile - segment = segment.slice(0, TPol::chunk_size); + segment = + segment.slice(segment_idx_t {0}, segment_idx_t {TPol::chunk_size}); // compute dimensions of children with segment restricted to tile LaunchDims enclosed_dims = @@ -165,7 +168,8 @@ struct SyclStatementExecutor(private_data.segment_tuple); + auto& segment = camp::get(private_data.segment_tuple); + using segment_idx_t = typename camp::decay::size_type; // restrict to first tile - segment = segment.slice(0, chunk_size); + segment = segment.slice(segment_idx_t {0}, segment_idx_t {chunk_size}); LaunchDims enclosed_dims = @@ -257,7 +262,8 @@ struct SyclStatementExecutor(private_data.segment_tuple); + auto& segment = camp::get(private_data.segment_tuple); + using segment_idx_t = typename camp::decay::size_type; // restrict to first tile - segment = segment.slice(0, chunk_size); + segment = segment.slice(segment_idx_t {0}, segment_idx_t {chunk_size}); LaunchDims enclosed_dims = @@ -346,7 +353,8 @@ struct SyclStatementExecutor(private_data.segment_tuple); + auto& segment = camp::get(private_data.segment_tuple); + using segment_idx_t = typename camp::decay::size_type; // restrict to first tile - segment = segment.slice(0, chunk_size); + segment = segment.slice(segment_idx_t {0}, segment_idx_t {chunk_size}); LaunchDims enclosed_dims = @@ -440,7 +449,8 @@ struct SyclStatementExecutor(private_data.segment_tuple); + auto& segment = camp::get(private_data.segment_tuple); + using segment_idx_t = typename camp::decay::size_type; // restrict to first tile - segment = segment.slice(0, chunk_size); + segment = segment.slice(segment_idx_t {0}, segment_idx_t {chunk_size}); LaunchDims enclosed_dims = diff --git a/test/functional/kernel/hyperplane/tests/test-kernel-hyperplane-2D.hpp b/test/functional/kernel/hyperplane/tests/test-kernel-hyperplane-2D.hpp index e16b11d59c..8a091e7f79 100644 --- a/test/functional/kernel/hyperplane/tests/test-kernel-hyperplane-2D.hpp +++ b/test/functional/kernel/hyperplane/tests/test-kernel-hyperplane-2D.hpp @@ -13,21 +13,6 @@ #include #include -namespace { -template -struct val_t_impl { - using type = T; -}; - -template -struct val_t_impl { - using type = typename T::value_type; -}; - -template -using VAL_T = typename val_t_impl::type; -} - template std::enable_if_t CallKernel(DATA_TYPE& trip_count, diff --git a/test/functional/kernel/hyperplane/tests/test-kernel-hyperplane-3D.hpp b/test/functional/kernel/hyperplane/tests/test-kernel-hyperplane-3D.hpp index c2fa7ffd3f..edad61afa5 100644 --- a/test/functional/kernel/hyperplane/tests/test-kernel-hyperplane-3D.hpp +++ b/test/functional/kernel/hyperplane/tests/test-kernel-hyperplane-3D.hpp @@ -13,21 +13,6 @@ #include #include -namespace { -template -struct val_t_impl { - using type = T; -}; - -template -struct val_t_impl { - using type = typename T::value_type; -}; - -template -using VAL_T = typename val_t_impl::type; -} - template std::enable_if_t CallKernel(DATA_TYPE& trip_count, @@ -141,7 +126,7 @@ KernelHyperplane3DTestImpl(const INDEX_TYPE groups, const INDEX_TYPE idimin, con { // This test traverses "groups" number of 3D arrays, and modifies values in a 2D hyperplane manner. - using raw_index_type = VAL_T; + using raw_index_type = RAJA::strip_index_type_t; raw_index_type idim, jdim, kdim; if ( std::is_same::value ) { diff --git a/test/functional/kernel/nested-loop-segment-types/tests/test-kernel-nested-loops-segment-types.hpp b/test/functional/kernel/nested-loop-segment-types/tests/test-kernel-nested-loops-segment-types.hpp index d2e19ebf9e..914e62bbf3 100644 --- a/test/functional/kernel/nested-loop-segment-types/tests/test-kernel-nested-loops-segment-types.hpp +++ b/test/functional/kernel/nested-loop-segment-types/tests/test-kernel-nested-loops-segment-types.hpp @@ -18,21 +18,6 @@ #include #include -namespace { -template -struct val_t_impl { - using type = T; -}; - -template -struct val_t_impl { - using type = typename T::value_type; -}; - -template -using VAL_T = typename val_t_impl::type; -} - template void KernelNestedLoopsSegmentTypesTestImpl( const RAJA::TypedRangeSegment& s1, @@ -155,7 +140,7 @@ TYPED_TEST_P(KernelNestedLoopsSegmentTypesTest, NestedLoopsSegmentTypesKernel) using IDX_TYPE = typename camp::at>::type; using WORKING_RES = typename camp::at>::type; using EXEC_POLICY = typename camp::at>::type; - using raw_idx_type = VAL_T; + using raw_idx_type = RAJA::strip_index_type_t; camp::resources::Resource working_res{WORKING_RES::get_default()}; diff --git a/test/functional/kernel/nested-loop-view-types/tests/test-kernel-nested-loop-OffsetView2D.hpp b/test/functional/kernel/nested-loop-view-types/tests/test-kernel-nested-loop-OffsetView2D.hpp index 0ebe38a689..639c6c4803 100644 --- a/test/functional/kernel/nested-loop-view-types/tests/test-kernel-nested-loop-OffsetView2D.hpp +++ b/test/functional/kernel/nested-loop-view-types/tests/test-kernel-nested-loop-OffsetView2D.hpp @@ -10,21 +10,6 @@ #ifndef __TEST_KERNEL_NESTEDLOOP_OFFSETVIEW2D_HPP__ #define __TEST_KERNEL_NESTEDLOOP_OFFSETVIEW2D_HPP__ -namespace { -template -struct val_t_impl { - using type = T; -}; - -template -struct val_t_impl { - using type = typename T::value_type; -}; - -template -using VAL_T = typename val_t_impl::type; -} - template void KernelOffsetView2DTestImpl(std::array dim, std::array offset_lo, @@ -59,7 +44,7 @@ void KernelOffsetView2DTestImpl(std::array dim, } - using raw_idx_type = VAL_T; + using raw_idx_type = RAJA::strip_index_type_t; using LayoutType = RAJA::TypedOffsetLayout>; diff --git a/test/functional/kernel/nested-loop-view-types/tests/test-kernel-nested-loop-OffsetView3D.hpp b/test/functional/kernel/nested-loop-view-types/tests/test-kernel-nested-loop-OffsetView3D.hpp index 601eed6b99..e66d9f1d36 100644 --- a/test/functional/kernel/nested-loop-view-types/tests/test-kernel-nested-loop-OffsetView3D.hpp +++ b/test/functional/kernel/nested-loop-view-types/tests/test-kernel-nested-loop-OffsetView3D.hpp @@ -10,21 +10,6 @@ #ifndef __TEST_KERNEL_NESTEDLOOP_OFFSETVIEW3D_HPP__ #define __TEST_KERNEL_NESTEDLOOP_OFFSETVIEW3D_HPP__ -namespace { -template -struct val_t_impl { - using type = T; -}; - -template -struct val_t_impl { - using type = typename T::value_type; -}; - -template -using VAL_T = typename val_t_impl::type; -} - template void KernelOffsetView3DTestImpl(std::array dim, std::array offset_lo, @@ -64,7 +49,7 @@ void KernelOffsetView3DTestImpl(std::array dim, } - using raw_idx_type = VAL_T; + using raw_idx_type = RAJA::strip_index_type_t; using LayoutType = RAJA::TypedOffsetLayout>; diff --git a/test/functional/kernel/nested-loop-view-types/tests/test-kernel-nested-loop-PermutedOffsetView2D.hpp b/test/functional/kernel/nested-loop-view-types/tests/test-kernel-nested-loop-PermutedOffsetView2D.hpp index 6932ce53ce..cd4a97a502 100644 --- a/test/functional/kernel/nested-loop-view-types/tests/test-kernel-nested-loop-PermutedOffsetView2D.hpp +++ b/test/functional/kernel/nested-loop-view-types/tests/test-kernel-nested-loop-PermutedOffsetView2D.hpp @@ -10,26 +10,11 @@ #ifndef __TEST_KERNEL_NESTEDLOOP_PERMUTEDOFFSETVIEW2D_HPP__ #define __TEST_KERNEL_NESTEDLOOP_PERMUTEDOFFSETVIEW2D_HPP__ -namespace { -template -struct val_t_impl { - using type = T; -}; - -template -struct val_t_impl { - using type = typename T::value_type; -}; - -template -using VAL_T = typename val_t_impl::type; -} - template void KernelPermutedOffsetView2DTestImpl(std::array dim, std::array perm) { - using raw_idx_type = VAL_T; + using raw_idx_type = RAJA::strip_index_type_t; camp::resources::Resource working_res{WORKING_RES::get_default()}; IDX_TYPE* A_work_array; IDX_TYPE* A_check_array; diff --git a/test/functional/kernel/nested-loop-view-types/tests/test-kernel-nested-loop-PermutedOffsetView3D.hpp b/test/functional/kernel/nested-loop-view-types/tests/test-kernel-nested-loop-PermutedOffsetView3D.hpp index cb1c2c343f..70e54a2198 100644 --- a/test/functional/kernel/nested-loop-view-types/tests/test-kernel-nested-loop-PermutedOffsetView3D.hpp +++ b/test/functional/kernel/nested-loop-view-types/tests/test-kernel-nested-loop-PermutedOffsetView3D.hpp @@ -10,26 +10,11 @@ #ifndef __TEST_KERNEL_NESTEDLOOP_PERMUTEDOFFSETVIEW3D_HPP__ #define __TEST_KERNEL_NESTEDLOOP_PERMUTEDOFFSETVIEW3D_HPP__ -namespace { -template -struct val_t_impl { - using type = T; -}; - -template -struct val_t_impl { - using type = typename T::value_type; -}; - -template -using VAL_T = typename val_t_impl::type; -} - template void KernelPermutedOffsetView3DTestImpl(std::array dim, std::array perm) { - using raw_idx_type = VAL_T; + using raw_idx_type = RAJA::strip_index_type_t; camp::resources::Resource working_res{WORKING_RES::get_default()}; IDX_TYPE* A_work_array; IDX_TYPE* A_check_array; diff --git a/test/functional/kernel/nested-loop-view-types/tests/test-kernel-nested-loop-PermutedView2D.hpp b/test/functional/kernel/nested-loop-view-types/tests/test-kernel-nested-loop-PermutedView2D.hpp index f30d32f24e..877cfdc1f9 100644 --- a/test/functional/kernel/nested-loop-view-types/tests/test-kernel-nested-loop-PermutedView2D.hpp +++ b/test/functional/kernel/nested-loop-view-types/tests/test-kernel-nested-loop-PermutedView2D.hpp @@ -10,21 +10,6 @@ #ifndef __TEST_KERNEL_NESTEDLOOP_PERMUTEDVIEW2D_HPP__ #define __TEST_KERNEL_NESTEDLOOP_PERMUTEDVIEW2D_HPP__ -namespace { -template -struct val_t_impl { - using type = T; -}; - -template -struct val_t_impl { - using type = typename T::value_type; -}; - -template -using VAL_T = typename val_t_impl::type; -} - template void KernelPermutedView2DTestImpl(std::array dim, std::array perm) @@ -49,7 +34,7 @@ void KernelPermutedView2DTestImpl(std::array dim, working_res.memcpy(working_array, test_array, sizeof(IDX_TYPE) * N); - using raw_idx_type = VAL_T; + using raw_idx_type = RAJA::strip_index_type_t; raw_idx_type mod_val = RAJA::stripIndexType(dim.at( perm.at(1) )); for (RAJA::idx_t ii = 0; ii < N; ++ii) { test_array[ii] = static_cast(ii % mod_val); diff --git a/test/functional/kernel/nested-loop-view-types/tests/test-kernel-nested-loop-PermutedView3D.hpp b/test/functional/kernel/nested-loop-view-types/tests/test-kernel-nested-loop-PermutedView3D.hpp index 63bb93fa7e..a9ffb04fa7 100644 --- a/test/functional/kernel/nested-loop-view-types/tests/test-kernel-nested-loop-PermutedView3D.hpp +++ b/test/functional/kernel/nested-loop-view-types/tests/test-kernel-nested-loop-PermutedView3D.hpp @@ -10,21 +10,6 @@ #ifndef __TEST_KERNEL_NESTEDLOOP_PERMUTEDVIEW3D_HPP_ #define __TEST_KERNEL_NESTEDLOOP_PERMUTEDVIEW3D_HPP_ -namespace { -template -struct val_t_impl { - using type = T; -}; - -template -struct val_t_impl { - using type = typename T::value_type; -}; - -template -using VAL_T = typename val_t_impl::type; -} - template void KernelPermutedView3DTestImpl(std::array dim, std::array perm) @@ -50,7 +35,7 @@ void KernelPermutedView3DTestImpl(std::array dim, working_res.memcpy(working_array, test_array, sizeof(IDX_TYPE) * N); - using raw_idx_type = VAL_T; + using raw_idx_type = RAJA::strip_index_type_t; raw_idx_type mod_val = RAJA::stripIndexType(dim.at(perm.at(1))) * RAJA::stripIndexType(dim.at(perm.at(2))); for (RAJA::idx_t ii = 0; ii < N; ++ii) { test_array[ii] = static_cast(ii % mod_val); diff --git a/test/functional/kernel/reduce-loc/tests/test-kernel-reduceloc-Max2D.hpp b/test/functional/kernel/reduce-loc/tests/test-kernel-reduceloc-Max2D.hpp index 4aab4284d2..75784dc19c 100644 --- a/test/functional/kernel/reduce-loc/tests/test-kernel-reduceloc-Max2D.hpp +++ b/test/functional/kernel/reduce-loc/tests/test-kernel-reduceloc-Max2D.hpp @@ -10,22 +10,6 @@ #ifndef __TEST_KERNEL_REDUCELOC_MAX2D_HPP__ #define __TEST_KERNEL_REDUCELOC_MAX2D_HPP__ -namespace { -template -struct val_t_impl { - using type = T; -}; - -template -struct val_t_impl { - using type = typename T::value_type; -}; - -template -using VAL_T = typename val_t_impl::type; - -} - template void KernelLocMax2DTestImpl(const INDEX_TYPE xdim, const INDEX_TYPE ydim) { diff --git a/test/functional/kernel/reduce-loc/tests/test-kernel-reduceloc-Max2DView.hpp b/test/functional/kernel/reduce-loc/tests/test-kernel-reduceloc-Max2DView.hpp index de5a51a718..d903e55b87 100644 --- a/test/functional/kernel/reduce-loc/tests/test-kernel-reduceloc-Max2DView.hpp +++ b/test/functional/kernel/reduce-loc/tests/test-kernel-reduceloc-Max2DView.hpp @@ -10,22 +10,6 @@ #ifndef __TEST_KERNEL_REDUCELOC_MAX2DVIEW_HPP__ #define __TEST_KERNEL_REDUCELOC_MAX2DVIEW_HPP__ -namespace { -template -struct val_t_impl { - using type = T; -}; - -template -struct val_t_impl { - using type = typename T::value_type; -}; - -template -using VAL_T = typename val_t_impl::type; - -} - template void KernelLocMax2DViewTestImpl(const INDEX_TYPE xdim, const INDEX_TYPE ydim) { diff --git a/test/functional/kernel/reduce-loc/tests/test-kernel-reduceloc-Max2DViewTuple.hpp b/test/functional/kernel/reduce-loc/tests/test-kernel-reduceloc-Max2DViewTuple.hpp index c01ebc476f..67c990e9d2 100644 --- a/test/functional/kernel/reduce-loc/tests/test-kernel-reduceloc-Max2DViewTuple.hpp +++ b/test/functional/kernel/reduce-loc/tests/test-kernel-reduceloc-Max2DViewTuple.hpp @@ -10,22 +10,6 @@ #ifndef __TEST_KERNEL_REDUCELOC_MAX2DVIEWTUPLE_HPP__ #define __TEST_KERNEL_REDUCELOC_MAX2DVIEWTUPLE_HPP__ -namespace { -template -struct val_t_impl { - using type = T; -}; - -template -struct val_t_impl { - using type = typename T::value_type; -}; - -template -using VAL_T = typename val_t_impl::type; - -} - template void KernelLocMax2DViewTupleTestImpl(const INDEX_TYPE xdim, const INDEX_TYPE ydim) { diff --git a/test/functional/kernel/reduce-loc/tests/test-kernel-reduceloc-Min2D.hpp b/test/functional/kernel/reduce-loc/tests/test-kernel-reduceloc-Min2D.hpp index c86fa37d88..2a229f5cb3 100644 --- a/test/functional/kernel/reduce-loc/tests/test-kernel-reduceloc-Min2D.hpp +++ b/test/functional/kernel/reduce-loc/tests/test-kernel-reduceloc-Min2D.hpp @@ -10,22 +10,6 @@ #ifndef __TEST_KERNEL_REDUCELOC_MIN2D_HPP__ #define __TEST_KERNEL_REDUCELOC_MIN2D_HPP__ -namespace { -template -struct val_t_impl { - using type = T; -}; - -template -struct val_t_impl { - using type = typename T::value_type; -}; - -template -using VAL_T = typename val_t_impl::type; - -} - template void KernelLocMin2DTestImpl(const INDEX_TYPE xdim, const INDEX_TYPE ydim) { diff --git a/test/functional/kernel/reduce-loc/tests/test-kernel-reduceloc-Min2DView.hpp b/test/functional/kernel/reduce-loc/tests/test-kernel-reduceloc-Min2DView.hpp index d199dfcf2a..4e127d9a4c 100644 --- a/test/functional/kernel/reduce-loc/tests/test-kernel-reduceloc-Min2DView.hpp +++ b/test/functional/kernel/reduce-loc/tests/test-kernel-reduceloc-Min2DView.hpp @@ -10,22 +10,6 @@ #ifndef __TEST_KERNEL_REDUCELOC_MIN2DVIEW_HPP__ #define __TEST_KERNEL_REDUCELOC_MIN2DVIEW_HPP__ -namespace { -template -struct val_t_impl { - using type = T; -}; - -template -struct val_t_impl { - using type = typename T::value_type; -}; - -template -using VAL_T = typename val_t_impl::type; - -} - template void KernelLocMin2DViewTestImpl(const INDEX_TYPE xdim, const INDEX_TYPE ydim) { diff --git a/test/functional/kernel/reduce-loc/tests/test-kernel-reduceloc-Min2DViewTuple.hpp b/test/functional/kernel/reduce-loc/tests/test-kernel-reduceloc-Min2DViewTuple.hpp index 973c51410e..2e6f6c29ec 100644 --- a/test/functional/kernel/reduce-loc/tests/test-kernel-reduceloc-Min2DViewTuple.hpp +++ b/test/functional/kernel/reduce-loc/tests/test-kernel-reduceloc-Min2DViewTuple.hpp @@ -10,22 +10,6 @@ #ifndef __TEST_KERNEL_REDUCELOC_MIN2DVIEWTUPLE_HPP__ #define __TEST_KERNEL_REDUCELOC_MIN2DVIEWTUPLE_HPP__ -namespace { -template -struct val_t_impl { - using type = T; -}; - -template -struct val_t_impl { - using type = typename T::value_type; -}; - -template -using VAL_T = typename val_t_impl::type; - -} - template void KernelLocMin2DViewTupleTestImpl(const INDEX_TYPE xdim, const INDEX_TYPE ydim) { diff --git a/test/functional/kernel/reduce-params-multi-lambda/tests/test-kernel-reduce-params-multi-lambda.hpp b/test/functional/kernel/reduce-params-multi-lambda/tests/test-kernel-reduce-params-multi-lambda.hpp index 44622ae787..00a7014d38 100644 --- a/test/functional/kernel/reduce-params-multi-lambda/tests/test-kernel-reduce-params-multi-lambda.hpp +++ b/test/functional/kernel/reduce-params-multi-lambda/tests/test-kernel-reduce-params-multi-lambda.hpp @@ -10,25 +10,10 @@ #ifndef __TEST_KERNEL_REDUCELOC_MAX2D_HPP__ #define __TEST_KERNEL_REDUCELOC_MAX2D_HPP__ -namespace { -template -struct val_t_impl { - using type = T; -}; - -template -struct val_t_impl { - using type = typename T::value_type; -}; - -template -using VAL_T = typename val_t_impl::type; -} - template void KernelParamReduceMultiLambda(const INDEX_TYPE xdim_t, const INDEX_TYPE ydim_t) { - using raw_index_type = VAL_T; + using raw_index_type = RAJA::strip_index_type_t; camp::resources::Resource work_res{WORKING_RES::get_default()}; diff --git a/test/functional/kernel/reduce-params/tests/test-kernel-basic-param.hpp b/test/functional/kernel/reduce-params/tests/test-kernel-basic-param.hpp index 8c846149e3..5c7a8ebd20 100644 --- a/test/functional/kernel/reduce-params/tests/test-kernel-basic-param.hpp +++ b/test/functional/kernel/reduce-params/tests/test-kernel-basic-param.hpp @@ -29,7 +29,6 @@ void KernelParamReduceTestImpl(const INDEX_TYPE xdim, const INDEX_TYPE ydim) &test_array ); - // using index_setup_type = VAL_T; // set rows to point to check and work _arrays RAJA::TypedRangeSegment seg(0, ydim); using LayoutType = RAJA::TypedLayout>; diff --git a/test/functional/kernel/tile-variants/tests/test-kernel-tile-Dynamic2D.hpp b/test/functional/kernel/tile-variants/tests/test-kernel-tile-Dynamic2D.hpp index 4a17027214..5f2b022b25 100644 --- a/test/functional/kernel/tile-variants/tests/test-kernel-tile-Dynamic2D.hpp +++ b/test/functional/kernel/tile-variants/tests/test-kernel-tile-Dynamic2D.hpp @@ -12,26 +12,11 @@ #include -namespace { -template -struct val_t_impl { - using type = T; -}; - -template -struct val_t_impl { - using type = typename T::value_type; -}; - -template -using VAL_T = typename val_t_impl::type; -} - template void KernelTileDynamic2DTestImpl(const INDEX_TYPE rows_t, const INDEX_TYPE cols_t) { // This test emulates matrix transposition with tiling. - using raw_index_type = VAL_T; + using raw_index_type = RAJA::strip_index_type_t; camp::resources::Resource work_res{WORKING_RES::get_default()}; diff --git a/test/functional/kernel/tile-variants/tests/test-kernel-tile-Fixed2D.hpp b/test/functional/kernel/tile-variants/tests/test-kernel-tile-Fixed2D.hpp index 843bb01c8d..732ec0c02e 100644 --- a/test/functional/kernel/tile-variants/tests/test-kernel-tile-Fixed2D.hpp +++ b/test/functional/kernel/tile-variants/tests/test-kernel-tile-Fixed2D.hpp @@ -12,26 +12,11 @@ #include -namespace { -template -struct val_t_impl { - using type = T; -}; - -template -struct val_t_impl { - using type = typename T::value_type; -}; - -template -using VAL_T = typename val_t_impl::type; -} - template void KernelTileFixed2DTestImpl(const INDEX_TYPE rows_t, const INDEX_TYPE cols_t) { // This test emulates matrix transposition with tiling. - using raw_index_type = VAL_T; + using raw_index_type = RAJA::strip_index_type_t; camp::resources::Resource work_res{WORKING_RES::get_default()}; diff --git a/test/functional/kernel/tile-variants/tests/test-kernel-tile-Fixed2DMinMax.hpp b/test/functional/kernel/tile-variants/tests/test-kernel-tile-Fixed2DMinMax.hpp index 4d09f48ed7..6ead8055fd 100644 --- a/test/functional/kernel/tile-variants/tests/test-kernel-tile-Fixed2DMinMax.hpp +++ b/test/functional/kernel/tile-variants/tests/test-kernel-tile-Fixed2DMinMax.hpp @@ -13,26 +13,11 @@ #include #include -namespace { -template -struct val_t_impl { - using type = T; -}; - -template -struct val_t_impl { - using type = typename T::value_type; -}; - -template -using VAL_T = typename val_t_impl::type; -} - template void KernelTileFixed2DMinMaxTestImpl(const INDEX_TYPE rows_t, const INDEX_TYPE cols_t) { // This test reduces min and max with tiling. - using raw_index_type = VAL_T; + using raw_index_type = RAJA::strip_index_type_t; camp::resources::Resource work_res{WORKING_RES::get_default()}; diff --git a/test/functional/kernel/tile-variants/tests/test-kernel-tile-Fixed2DSum.hpp b/test/functional/kernel/tile-variants/tests/test-kernel-tile-Fixed2DSum.hpp index d5f1a2776b..a0a295702d 100644 --- a/test/functional/kernel/tile-variants/tests/test-kernel-tile-Fixed2DSum.hpp +++ b/test/functional/kernel/tile-variants/tests/test-kernel-tile-Fixed2DSum.hpp @@ -14,26 +14,11 @@ #include #include -namespace { -template -struct val_t_impl { - using type = T; -}; - -template -struct val_t_impl { - using type = typename T::value_type; -}; - -template -using VAL_T = typename val_t_impl::type; -} - template void KernelTileFixed2DSumTestImpl(const INDEX_TYPE rowsin, const INDEX_TYPE colsin) { // This test reduces sums with tiling. - using raw_index_type = VAL_T; + using raw_index_type = RAJA::strip_index_type_t; raw_index_type rows, cols; if ( std::is_same::value ) diff --git a/test/functional/kernel/tile-variants/tests/test-kernel-tile-LocalArray2D.hpp b/test/functional/kernel/tile-variants/tests/test-kernel-tile-LocalArray2D.hpp index 1e0cdbcb08..7d9cc0a1f5 100644 --- a/test/functional/kernel/tile-variants/tests/test-kernel-tile-LocalArray2D.hpp +++ b/test/functional/kernel/tile-variants/tests/test-kernel-tile-LocalArray2D.hpp @@ -12,26 +12,11 @@ #include -namespace { -template -struct val_t_impl { - using type = T; -}; - -template -struct val_t_impl { - using type = typename T::value_type; -}; - -template -using VAL_T = typename val_t_impl::type; -} - template void KernelTileLocalArray2DTestImpl(const INDEX_TYPE rows_t, const INDEX_TYPE cols_t) { // This test emulates matrix transposition with tiling. - using raw_index_type = VAL_T; + using raw_index_type = RAJA::strip_index_type_t; camp::resources::Resource work_res{WORKING_RES::get_default()};