diff --git a/include/RAJA/index/IndexValue.hpp b/include/RAJA/index/IndexValue.hpp index f9d2a59d59..b8c4610b24 100644 --- a/include/RAJA/index/IndexValue.hpp +++ b/include/RAJA/index/IndexValue.hpp @@ -58,6 +58,12 @@ 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. * \param v Initial value @@ -300,23 +306,107 @@ convertIndex_helper(typename FROM::IndexValueType const val) } // namespace internal +namespace concepts +{ +// Should we try to move this to either util/concepts.hpp +// or pattern/concepts.hpp? +template +concept IndexValued = std::is_base_of_v< + RAJA::IndexValue, + typename std::remove_cvref_t::value_type>, + std::remove_cvref_t>; + + +} // namespace concepts + namespace type_traits { template struct is_instance_of_index_value - : std::is_base_of>, - std::remove_cvref_t> + : std::bool_constant> {}; template -constexpr bool is_instance_of_index_value_v = +inline constexpr bool is_instance_of_index_value_v = is_instance_of_index_value::value; + } // namespace type_traits -namespace concepts +template +RAJA_HOST_DEVICE RAJA_INLINE TYPE operator+(typename TYPE::value_type lhs, + TYPE rhs) { -template -concept IndexValued = type_traits::is_instance_of_index_value_v; + 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; } /*! @@ -404,9 +494,12 @@ 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) \ @@ -425,6 +518,11 @@ 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() \ {} \ diff --git a/include/RAJA/index/RangeSegment.hpp b/include/RAJA/index/RangeSegment.hpp index c6e7b4141b..0e552a127d 100644 --- a/include/RAJA/index/RangeSegment.hpp +++ b/include/RAJA/index/RangeSegment.hpp @@ -95,7 +95,7 @@ namespace RAJA * ****************************************************************************** */ -template>> struct TypedRangeSegment { @@ -140,6 +140,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/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/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/kernel/Tile.hpp b/include/RAJA/pattern/kernel/Tile.hpp index ea21e72001..951bc25598 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" @@ -81,6 +82,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 +116,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 +145,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 +155,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 +171,19 @@ 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 +205,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 +227,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 +235,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 +262,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 +301,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..a14188fb7e 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/pattern/params/params_base.hpp b/include/RAJA/pattern/params/params_base.hpp index 20daf5c820..adbf889b4c 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..93111d6ed8 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/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/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/hip/kernel/Tile.hpp b/include/RAJA/policy/hip/kernel/Tile.hpp index 122d7b3ce3..137fa136ef 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,12 @@ 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 +285,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 +310,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); @@ -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/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/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/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/include/RAJA/util/Span.hpp b/include/RAJA/util/Span.hpp index 3119431100..0cac80c3b3 100644 --- a/include/RAJA/util/Span.hpp +++ b/include/RAJA/util/Span.hpp @@ -20,14 +20,10 @@ #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" +#include "RAJA/pattern/concepts.hpp" namespace RAJA { @@ -61,19 +57,13 @@ 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; 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&; @@ -87,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; } @@ -160,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 @@ -175,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 @@ -197,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/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/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/forall/CombiningAdapter/test-forall-CombiningAdapter.cpp.in b/test/functional/forall/CombiningAdapter/test-forall-CombiningAdapter.cpp.in index 70fcefd657..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..9286910152 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; + for (INDEX_TYPE i0 {0}; i0 < N0; 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); @@ -61,8 +69,8 @@ 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)]); + for (INDEX_TYPE i {0}; i <= N; 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..46c8e48940 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; + for (INDEX_TYPE i0 {0}; i0 < N0; i0++) { + for (INDEX_TYPE i1 {0}; i1 < 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); @@ -68,8 +75,8 @@ 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)]); + for (INDEX_TYPE i {0}; i <= N; 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..d3da89b56c 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; + 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; } } } - 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); @@ -80,8 +85,8 @@ 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)]); + for (INDEX_TYPE i {0}; i <= N; 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 15f464b88e..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..dbf33bd4a9 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)); - INDEX_TYPE ticount = 0; + 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; + [=] RAJA_HOST_DEVICE(auto icount, INDEX_TYPE idx) { + work_view( INDEX_TYPE(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]); + for (INDEX_TYPE i {0}; i < N; 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..f419e0f3e3 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]); + for (INDEX_TYPE i {0}; i < N; 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 24748ee380..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..db748b92ea 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)); - INDEX_TYPE ticount = 0; + 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; + [=] RAJA_HOST_DEVICE(auto icount, INDEX_TYPE idx) { + work_view(INDEX_TYPE(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]); + for (INDEX_TYPE i {0}; i < N; 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..e2b4e2fcf6 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]); + for (INDEX_TYPE i {0}; i < N; i++) { + ASSERT_EQ(test_view(i), check_view(i)); } deallocateForallTestData(working_res, 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/test-forall-region.cpp.in b/test/functional/forall/region/test-forall-region.cpp.in index 0a255b9851..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,5 +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..c82a549041 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); + for (INDEX_TYPE i {0}; i < N; i++) { + 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 0803f9e663..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..9fea81e895 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)); - INDEX_TYPE ticount = 0; + 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; + [=] RAJA_HOST_DEVICE(auto icount, INDEX_TYPE idx) { + work_view(INDEX_TYPE(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]); + for (INDEX_TYPE i {0}; i < N; 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..b96f7e60f4 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]); + for (INDEX_TYPE i {0}; i < N; i++) { + ASSERT_EQ(test_view(i), check_view(i)); } deallocateForallTestData(erased_working_res, 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/test-forall-segment-view.cpp.in b/test/functional/forall/segment-view/test-forall-segment-view.cpp.in index 7447087c71..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..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,8 +27,8 @@ void ForallListSegmentViewTestImpl(INDEX_TYPE N) srand ( time(NULL) ); - for (INDEX_TYPE i = 0; i < N; ++i) { - INDEX_TYPE randval = rand() % N; + 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); } @@ -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]); + for (INDEX_TYPE i {0}; i < N; i++) { + ASSERT_EQ(test_view(i), check_view(i)); } deallocateForallTestData(working_res, @@ -108,8 +112,8 @@ void ForallListSegmentOffsetViewTestImpl(INDEX_TYPE N, INDEX_TYPE offset) srand ( time(NULL) ); - for (INDEX_TYPE i = 0; i < N; ++i) { - INDEX_TYPE randval = rand() % N; + 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); } @@ -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, @@ -176,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 d7a1a412d0..2b08b373e5 100644 --- a/test/functional/forall/segment-view/tests/test-forall-RangeSegment2DView.hpp +++ b/test/functional/forall/segment-view/tests/test-forall-RangeSegment2DView.hpp @@ -17,9 +17,8 @@ template void ForallRangeSegment2DViewTestImpl(INDEX_TYPE N) { INDEX_TYPE lentot = N * N; - const int NDIMS = 2; - 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; @@ -32,12 +31,16 @@ 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), + INDEX_TYPE(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 +48,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]); + 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)); } deallocateForallTestData(working_res, @@ -62,9 +68,8 @@ 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); + RAJA::TypedRangeSegment r1(INDEX_TYPE(0), leninterior); camp::resources::Resource working_res{WORKING_RES::get_default()}; INDEX_TYPE* working_array; @@ -77,22 +82,28 @@ void ForallRangeSegment2DOffsetViewTestImpl(INDEX_TYPE N) &check_array, &test_array); - memset( test_array, 0, sizeof(INDEX_TYPE) * lentot ); - - working_res.memcpy(working_array, test_array, sizeof(INDEX_TYPE) * lentot); + memset( test_array, 0, 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); - } - } + working_res.memcpy(working_array, test_array, + sizeof(INDEX_TYPE) * RAJA::stripIndexType(lentot)); - 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 +111,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 {-1}; row < N + 1; ++row) { + for (INDEX_TYPE col {-1}; col < N + 1; ++col) { + ASSERT_EQ(test_view(row, col), check_view(row, col)); + } } deallocateForallTestData(working_res, @@ -119,17 +133,19 @@ 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); - ForallRangeSegment2DOffsetViewTestImpl(100); + ForallRangeSegment2DOffsetViewTestImpl( + INDEX_TYPE(4)); + ForallRangeSegment2DOffsetViewTestImpl( + INDEX_TYPE(100)); } @@ -139,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 6757af3d1d..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; @@ -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]); + for (INDEX_TYPE i {0}; i < N; i++) { + ASSERT_EQ(test_view(i), check_view(i)); } deallocateForallTestData(working_res, @@ -59,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; @@ -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,21 +110,26 @@ 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); - 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)); } @@ -131,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 22a957bb5d..dafd108da7 100644 --- a/test/functional/forall/segment-view/tests/test-forall-RangeStrideSegmentView.hpp +++ b/test/functional/forall/segment-view/tests/test-forall-RangeStrideSegmentView.hpp @@ -15,8 +15,10 @@ template r1(first, last, stride); - INDEX_TYPE N = r1.size(); + RAJA::TypedRangeStrideSegment r1(RAJA::stripIndexType(first), + RAJA::stripIndexType(last), + stride); + INDEX_TYPE N = INDEX_TYPE(r1.size()); camp::resources::Resource working_res{WORKING_RES::get_default()}; INDEX_TYPE* working_array; @@ -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; - for (INDEX_TYPE i = 0; i < N; ++i) { - test_array[ (index-first)/stride ] = index; - index += stride; - } + 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 (INDEX_TYPE i {0}; i < N; ++i) { + test_view( (index-first)/stride ) = index; + index += stride; + } 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]); + for (INDEX_TYPE i {0}; i < N; 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/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/test-kernel-hyperplane-2D.cpp.in b/test/functional/kernel/hyperplane/test-kernel-hyperplane-2D.cpp.in index 3bafd5f7fd..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 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 +34,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 (RAJA::stripIndexType(g) >= RAJA::stripIndexType(groups) || RAJA::stripIndexType(ii) >= RAJA::stripIndexType(idim) || RAJA::stripIndexType(jj) >= RAJA::stripIndexType(jdim)) { _oob_count += 1; } @@ -59,10 +59,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 +73,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 (RAJA::stripIndexType(g) >= RAJA::stripIndexType(groups) || RAJA::stripIndexType(ii) >= RAJA::stripIndexType(idim) || RAJA::stripIndexType(jj) >= RAJA::stripIndexType(jdim)) { oob_count += 1; } @@ -97,7 +97,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 +116,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 + RAJA::stripIndexType(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) * RAJA::stripIndexType(array_length) ); DATA_TYPE trip_count(0); DATA_TYPE oob_count(0); @@ -131,15 +133,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) * RAJA::stripIndexType(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 +157,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)); } } @@ -186,9 +188,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 01ed31ebef..edad61afa5 100644 --- a/test/functional/kernel/hyperplane/tests/test-kernel-hyperplane-3D.hpp +++ b/test/functional/kernel/hyperplane/tests/test-kernel-hyperplane-3D.hpp @@ -17,18 +17,18 @@ 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) { // 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, 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 ), @@ -39,7 +39,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 (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; } @@ -68,23 +69,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, 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 (g < 0 || g >= groups || ii < 0 || ii >= idim || jj < 0 || jj >= jdim || kk < 0 || kk >= 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; } @@ -113,18 +115,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 = RAJA::strip_index_type_t; + raw_index_type idim, jdim, kdim; if ( std::is_same::value ) { // Restrict to a small data size for better float precision. @@ -134,18 +137,22 @@ KernelHyperplane3DTestImpl(const int groups, const int idimin, const int jdimin, } else { - idim = idimin; - jdim = jdimin; - kdim = kdimin; + idim = RAJA::stripIndexType(idimin); + jdim = RAJA::stripIndexType(jdimin); + kdim = RAJA::stripIndexType(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 +161,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 + RAJA::stripIndexType(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) * RAJA::stripIndexType(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) * RAJA::stripIndexType(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 +208,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)); } } @@ -232,9 +241,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/test-kernel-nested-loop-segments.cpp.in b/test/functional/kernel/nested-loop-segment-types/test-kernel-nested-loop-segments.cpp.in index 827c4ca7d2..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 @@ -27,7 +27,7 @@ // Sequential execution policy types using SequentialKernelExecPols = camp::list< - + RAJA::KernelPolicy< RAJA::statement::For<0, RAJA::seq_exec, RAJA::statement::For<1, RAJA::seq_exec, @@ -42,7 +42,7 @@ using SequentialKernelExecPols = camp::list< #if defined(RAJA_ENABLE_OPENMP) using OpenMPKernelExecPols = camp::list< - + RAJA::KernelPolicy< RAJA::statement::For<0, RAJA::omp_parallel_for_exec, RAJA::statement::For<1, RAJA::seq_exec, @@ -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..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,7 +18,6 @@ #include #include - template void KernelNestedLoopsSegmentTypesTestImpl( const RAJA::TypedRangeSegment& s1, @@ -39,9 +38,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; @@ -61,10 +60,11 @@ 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) ); @@ -73,9 +73,9 @@ void KernelNestedLoopsSegmentTypesTestImpl( 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) { + 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); @@ -117,7 +117,7 @@ void KernelNestedLoopsSegmentTypesTestImpl( working_res.memcpy(check_array, work_array, 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] ); } @@ -140,6 +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 = RAJA::strip_index_type_t; camp::resources::Resource working_res{WORKING_RES::get_default()}; @@ -153,12 +154,12 @@ 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); + 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); @@ -223,7 +224,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/tests/test-kernel-nested-loop-OffsetView2D.hpp b/test/functional/kernel/nested-loop-view-types/tests/test-kernel-nested-loop-OffsetView2D.hpp index 331a1cff1a..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,7 +10,6 @@ #ifndef __TEST_KERNEL_NESTEDLOOP_OFFSETVIEW2D_HPP__ #define __TEST_KERNEL_NESTEDLOOP_OFFSETVIEW2D_HPP__ - template void KernelOffsetView2DTestImpl(std::array dim, std::array offset_lo, @@ -45,14 +44,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 = RAJA::strip_index_type_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..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,7 +10,6 @@ #ifndef __TEST_KERNEL_NESTEDLOOP_OFFSETVIEW3D_HPP__ #define __TEST_KERNEL_NESTEDLOOP_OFFSETVIEW3D_HPP__ - template void KernelOffsetView3DTestImpl(std::array dim, std::array offset_lo, @@ -50,19 +49,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 = RAJA::strip_index_type_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..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 @@ -14,6 +14,7 @@ template void KernelPermutedOffsetView2DTestImpl(std::array dim, std::array perm) { + 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; @@ -78,8 +79,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 +99,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(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))] + + 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..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 @@ -14,6 +14,7 @@ template void KernelPermutedOffsetView3DTestImpl(std::array dim, std::array perm) { + 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; @@ -86,8 +87,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 +116,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(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))] + + 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..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,7 +10,6 @@ #ifndef __TEST_KERNEL_NESTEDLOOP_PERMUTEDVIEW2D_HPP__ #define __TEST_KERNEL_NESTEDLOOP_PERMUTEDVIEW2D_HPP__ - template void KernelPermutedView2DTestImpl(std::array dim, std::array perm) @@ -35,20 +34,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 = 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); } 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(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 0a6a99a7cc..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,7 +10,6 @@ #ifndef __TEST_KERNEL_NESTEDLOOP_PERMUTEDVIEW3D_HPP_ #define __TEST_KERNEL_NESTEDLOOP_PERMUTEDVIEW3D_HPP_ - template void KernelPermutedView3DTestImpl(std::array dim, std::array perm) @@ -36,21 +35,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 = 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); } 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(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/test-kernel-reduceloc.cpp.in b/test/functional/kernel/reduce-loc/test-kernel-reduceloc.cpp.in index cc3b2ee7e1..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 -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 +29,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) = RAJA::stripIndexType(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) * 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 (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(INDEX_TYPE{0}, INDEX_TYPE{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 +82,6 @@ void KernelLocMax2DTestImpl(const int xdim, const int ydim) check_array, test_array ); - - deallocateForallTestData ( work_res, - workarr2D, - checkarr2D, - testarr2D - ); } @@ -121,9 +100,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 6395a3b712..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 @@ -11,16 +11,13 @@ #define __TEST_KERNEL_REDUCELOC_MAX2DVIEW_HPP__ 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 +29,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) = RAJA::stripIndexType(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) * RAJA::stripIndexType(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(INDEX_TYPE{0}, INDEX_TYPE{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(INDEX_TYPE{0}, INDEX_TYPE{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 +82,6 @@ void KernelLocMax2DViewTestImpl(const int xdim, const int ydim) check_array, test_array ); - - deallocateForallTestData ( work_res, - workarr2D, - checkarr2D, - testarr2D - ); } @@ -123,9 +100,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 dbe5c475e8..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 @@ -11,16 +11,13 @@ #define __TEST_KERNEL_REDUCELOC_MAX2DVIEWTUPLE_HPP__ 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 +29,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) = RAJA::stripIndexType(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) * RAJA::stripIndexType(array_length)); #if defined(RAJA_ENABLE_TARGET_OPENMP) //#pragma omp target data map(to:work_array[0:array_length]) @@ -70,30 +55,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)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( 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 +88,6 @@ void KernelLocMax2DViewTupleTestImpl(const int xdim, const int ydim) check_array, test_array ); - - deallocateForallTestData ( work_res, - workarr2D, - checkarr2D, - testarr2D - ); } @@ -129,9 +106,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 30dc977023..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 @@ -11,16 +11,13 @@ #define __TEST_KERNEL_REDUCELOC_MIN2D_HPP__ 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 +29,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) = RAJA::stripIndexType(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) * 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 (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(INDEX_TYPE{0}, INDEX_TYPE{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 +82,6 @@ void KernelLocMin2DTestImpl(const int xdim, const int ydim) check_array, test_array ); - - deallocateForallTestData ( work_res, - workarr2D, - checkarr2D, - testarr2D - ); } @@ -121,9 +100,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 87386976ae..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 @@ -11,16 +11,13 @@ #define __TEST_KERNEL_REDUCELOC_MIN2DVIEW_HPP__ 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 +29,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) = RAJA::stripIndexType(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) * RAJA::stripIndexType(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(INDEX_TYPE{0}, INDEX_TYPE{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(INDEX_TYPE{0}, INDEX_TYPE{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 +82,6 @@ void KernelLocMin2DViewTestImpl(const int xdim, const int ydim) check_array, test_array ); - - deallocateForallTestData ( work_res, - workarr2D, - checkarr2D, - testarr2D - ); } @@ -123,9 +100,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 f80b4fea1b..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 @@ -11,16 +11,13 @@ #define __TEST_KERNEL_REDUCELOC_MIN2DVIEWTUPLE_HPP__ 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 +29,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) = RAJA::stripIndexType(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) * RAJA::stripIndexType(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)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( 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 +84,6 @@ void KernelLocMin2DViewTupleTestImpl(const int xdim, const int ydim) check_array, test_array ); - - deallocateForallTestData ( work_res, - workarr2D, - checkarr2D, - testarr2D - ); } @@ -125,9 +102,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/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 8e5f4cd83f..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 -void KernelParamReduceMultiLambda(const int xdim, const int ydim) +void KernelParamReduceMultiLambda(const INDEX_TYPE xdim_t, const INDEX_TYPE ydim_t) { + using raw_index_type = RAJA::strip_index_type_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 +31,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 < RAJA::stripIndexType(xdim_t); ++col ) { - checkarr2D[zz][xx] = (zz*xdim + xx ) % 100 + 1; + CheckView(row, INDEX_TYPE(col)) = + (RAJA::stripIndexType(row) * RAJA::stripIndexType(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) * RAJA::stripIndexType(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 +91,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 +128,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 < RAJA::stripIndexType(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 +157,6 @@ void KernelParamReduceMultiLambda(const int xdim, const int ydim) check_array, test_array ); - - deallocateForallTestData ( work_res, - workarr2D, - checkarr2D, - testarr2D - ); } @@ -192,9 +174,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 f7e11e75de..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 -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 +29,52 @@ void KernelParamReduceTestImpl(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; - }); - + 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) = RAJA::stripIndexType(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) * RAJA::stripIndexType(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(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(); @@ -109,8 +94,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 +103,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 +133,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 +180,6 @@ void KernelParamReduceTestImpl(const int xdim, const int ydim) test_array ); - deallocateForallTestData ( work_res, - workarr2D, - checkarr2D, - testarr2D - ); } @@ -218,10 +198,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/test-kernel-region-sync.cpp.in b/test/functional/kernel/region/test-kernel-region-sync.cpp.in index 31986a9d77..6e307538a9 100644 --- a/test/functional/kernel/region/test-kernel-region-sync.cpp.in +++ b/test/functional/kernel/region/test-kernel-region-sync.cpp.in @@ -90,7 +90,7 @@ using OpenMPKernelRegionSyncExecPols = // Cartesian product of types used in parameterized tests // using @REGION_BACKEND@KernelRegionSyncTypes = - 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/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/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( RAJA::make_tuple( - RAJA::TypedRangeSegment(0, N) + RAJA::TypedRangeSegment(IDX_TYPE{0}, N) ), RAJA::make_tuple( static_cast(0), RAJA::expt::Reduce(&trip_count), @@ -38,9 +38,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); } } ); @@ -57,14 +57,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); } } ); @@ -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 += 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); } @@ -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/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( RAJA::make_tuple( - RAJA::TypedRangeSegment(0, N) + RAJA::TypedRangeSegment(IDX_TYPE{0}, N) ), RAJA::make_tuple( static_cast(0), RAJA::expt::Reduce(&trip_count), @@ -36,9 +36,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); } } ); @@ -55,14 +55,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); } } ); @@ -75,15 +75,15 @@ 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; 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/test-kernel-tile-count-loop.cpp.in b/test/functional/kernel/tile-icount-tcount-loop/test-kernel-tile-count-loop.cpp.in index 7f9701d4f8..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( 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/test-kernel-tiledyn.cpp.in b/test/functional/kernel/tile-variants/test-kernel-tiledyn.cpp.in index e158411797..344746b48f 100644 --- a/test/functional/kernel/tile-variants/test-kernel-tiledyn.cpp.in +++ b/test/functional/kernel/tile-variants/test-kernel-tiledyn.cpp.in @@ -219,7 +219,7 @@ using OpenMPTargetKernelTileExecPols = // 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/test-kernel-tilefixed.cpp.in b/test/functional/kernel/tile-variants/test-kernel-tilefixed.cpp.in index c397aa039b..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..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 @@ -13,9 +13,10 @@ #include 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 = RAJA::strip_index_type_t; camp::resources::Resource work_res{WORKING_RES::get_default()}; @@ -28,7 +29,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 +45,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 + 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) * 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) * 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 ( int rr = 0; rr < rows; ++rr ) + for ( raw_index_type rr = 0; rr < RAJA::stripIndexType(rows_t); ++rr ) { - for ( int cc = 0; cc < cols; ++cc ) + for ( raw_index_type cc = 0; cc < RAJA::stripIndexType(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 +82,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) * RAJA::stripIndexType(array_length) ); - for ( int rr = 0; rr < rows; ++rr ) + for ( raw_index_type rr = 0; rr < RAJA::stripIndexType(rows_t); ++rr ) { - for ( int cc = 0; cc < cols; ++cc ) + for ( raw_index_type cc = 0; cc < RAJA::stripIndexType(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) * 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 ( @@ -99,13 +105,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) * RAJA::stripIndexType(array_length) ); - for ( int rr = 0; rr < rows; ++rr ) + for ( raw_index_type rr = 0; rr < RAJA::stripIndexType(rows_t); ++rr ) { - for ( int cc = 0; cc < cols; ++cc ) + for ( raw_index_type cc = 0; cc < RAJA::stripIndexType(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 +143,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..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 @@ -13,9 +13,10 @@ #include 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 = RAJA::strip_index_type_t; camp::resources::Resource work_res{WORKING_RES::get_default()}; @@ -28,7 +29,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 +45,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 + 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) * 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) * 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 ( int rr = 0; rr < rows; ++rr ) + for ( raw_index_type rr = 0; rr < RAJA::stripIndexType(rows_t); ++rr ) { - for ( int cc = 0; cc < cols; ++cc ) + for ( raw_index_type cc = 0; cc < RAJA::stripIndexType(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) * RAJA::stripIndexType(array_length) ); - for ( int rr = 0; rr < rows; ++rr ) + for ( raw_index_type rr = 0; rr < RAJA::stripIndexType(rows_t); ++rr ) { - for ( int cc = 0; cc < cols; ++cc ) + for ( raw_index_type cc = 0; cc < RAJA::stripIndexType(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 +118,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..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 @@ -14,9 +14,10 @@ #include 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 = RAJA::strip_index_type_t; camp::resources::Resource work_res{WORKING_RES::get_default()}; @@ -24,7 +25,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 +35,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 + RAJA::stripIndexType(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(RAJA::stripIndexType(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) * RAJA::stripIndexType(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 < RAJA::stripIndexType(cols_t); ++ii) { - colidx.push_back(ii); + colidx.push_back(INDEX_TYPE(ii)); } RAJA::TypedListSegment colrange( &colidx[0], colidx.size(), work_res ); @@ -66,7 +70,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(RAJA::stripIndexType(array_length) + 2), static_cast(workmax.get())); deallocateForallTestData ( work_res, work_array, @@ -90,9 +94,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..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 @@ -15,11 +15,12 @@ #include 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 = RAJA::strip_index_type_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 +29,8 @@ void KernelTileFixed2DSumTestImpl(const int rowsin, const int colsin) } else { - rows = rowsin; - cols = colsin; + rows = RAJA::stripIndexType(rowsin); + cols = RAJA::stripIndexType(colsin); } camp::resources::Resource work_res{WORKING_RES::get_default()}; @@ -39,13 +40,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 +55,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 +68,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)(RAJA::stripIndexType(rr) * 1.1 + RAJA::stripIndexType(cc)); }); ASSERT_FLOAT_EQ(hostsum, (DATA_TYPE)worksum.get()); @@ -88,9 +89,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..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 @@ -13,9 +13,10 @@ #include 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 = RAJA::strip_index_type_t; camp::resources::Resource work_res{WORKING_RES::get_default()}; @@ -28,7 +29,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 +45,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 + 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) * 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) * 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 ( int rr = 0; rr < rows; ++rr ) + for ( raw_index_type rr = 0; rr < RAJA::stripIndexType(rows_t); ++rr ) { - for ( int cc = 0; cc < cols; ++cc ) + for ( raw_index_type cc = 0; cc < RAJA::stripIndexType(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( 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( ty, tx ); + WorkTView( cc, rr ) = _Tile_Array( RAJA::stripIndexType(ty), RAJA::stripIndexType(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) * RAJA::stripIndexType(array_length) ); - for ( int rr = 0; rr < rows; ++rr ) + for ( raw_index_type rr = 0; rr < RAJA::stripIndexType(rows_t); ++rr ) { - for ( int cc = 0; cc < cols; ++cc ) + for ( raw_index_type cc = 0; cc < RAJA::stripIndexType(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 +127,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/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/test-launch-nested.cpp.in b/test/functional/launch/nested_direct/test-launch-nested.cpp.in index ea92db5cdf..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/tests/test-launch-nested-Direct.hpp b/test/functional/launch/nested_direct/tests/test-launch-nested-Direct.hpp index 82ba0449e2..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,9 +54,20 @@ 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; + 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))++; }); }); @@ -127,13 +140,13 @@ 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)]); + for (INDEX_TYPE i {0}; i < N; 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 628c7efb08..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_direct_unchecked/tests/test-launch-nested-DirectUnchecked.hpp b/test/functional/launch/nested_direct_unchecked/tests/test-launch-nested-DirectUnchecked.hpp index 95dbefdc56..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,22 +51,29 @@ 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); } - //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 @@ -99,8 +106,8 @@ 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)]); + for (INDEX_TYPE i {0}; i < N; 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 cd2af8ee26..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_loop/tests/test-launch-nested-Loop.hpp b/test/functional/launch/nested_loop/tests/test-launch-nested-Loop.hpp index af87fd614e..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,9 +58,20 @@ 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; + 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))++; }); }); @@ -132,13 +145,13 @@ 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)]); + for (INDEX_TYPE i {0}; i < N; 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 59a1ea91a5..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/tests/test-launch-nested-Tile-Direct.hpp b/test/functional/launch/nested_tile_direct/tests/test-launch-nested-Tile-Direct.hpp index 2904199aac..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,13 +59,25 @@ 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; + 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))++; }); }); @@ -123,13 +135,13 @@ 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)]); + for (INDEX_TYPE i {0}; i < N; 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 0238fc01a7..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_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..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 @@ -26,14 +26,14 @@ 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); - 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,13 +56,19 @@ 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); } - 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 @@ -95,8 +101,8 @@ 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)]); + for (INDEX_TYPE i {0}; i < N; 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 5d063da3b7..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/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..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,13 +59,25 @@ 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; + 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))++; }); }); @@ -122,13 +134,13 @@ 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)]); + for (INDEX_TYPE i {0}; i < N; 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/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/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/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/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 f42482f7b6..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/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..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 @@ -17,14 +17,15 @@ template r1(0, M*threads_x+1); + RAJA::TypedRangeSegment r1(INDEX_TYPE(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)); @@ -54,11 +55,25 @@ 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); + 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))++; } ); @@ -106,14 +121,14 @@ 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; - 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 0ca15ad6b0..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_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..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 @@ -17,10 +17,12 @@ template r1(0, threads_x*blocks_x); + RAJA::TypedRangeSegment r1(INDEX_TYPE(0), threads_x_idx * blocks_x_idx); INDEX_TYPE N = static_cast(r1.end() - r1.begin()); @@ -48,12 +50,21 @@ 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); } + 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; } ); @@ -78,12 +89,12 @@ 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) { + 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_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 bee00c999b..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/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..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 @@ -17,17 +17,18 @@ template r1(0, M*tile_size+1); + RAJA::TypedRangeSegment r1(INDEX_TYPE(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)); @@ -57,11 +58,25 @@ 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); + 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))++; } ); @@ -109,14 +124,14 @@ 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; ++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; - 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-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-index-types.hpp b/test/include/RAJA_test-index-types.hpp index bb8c6acbe9..bf974fff8b 100644 --- a/test/include/RAJA_test-index-types.hpp +++ b/test/include/RAJA_test-index-types.hpp @@ -27,44 +27,63 @@ // 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? +// Use this list for tests that require signed builtin integer semantics. using SignedIdxTypeList = camp::list; +// Launch is not strong-index compatible (yet) + +using LaunchIdxTypeList = camp::list; + // -// Index types w/ Strong 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. using StrongIdxTypeList = camp::list; #endif // __RAJA_test_index_types_HPP__ diff --git a/test/include/RAJA_test-indexset-build.hpp b/test/include/RAJA_test-indexset-build.hpp index a1a70b5972..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,13 +52,13 @@ 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(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(); @@ -78,26 +78,30 @@ void buildIndexSet( last_idx = rend; // 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] ); + 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] ); } - 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] ); + 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] ); } 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 ); } @@ -113,12 +117,13 @@ void buildIndexSet( last_idx = rend; // 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] ); + 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] ); } - 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; @@ -130,12 +135,13 @@ void buildIndexSet( last_idx = rend; // 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] ); + 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] ); } 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__ 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; } }; 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);