//@HEADER // ************************************************************************ // // Kokkos v. 4.0 // Copyright (2022) National Technology & Engineering // Solutions of Sandia, LLC (NTESS). // // Under the terms of Contract DE-NA0003525 with NTESS, // the U.S. Government retains certain rights in this software. // // Part of Kokkos, under the Apache License v2.0 with LLVM Exceptions. // See https://kokkos.org/LICENSE for license information. // SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception // //@HEADER #include namespace { struct TestNestedReducerCTAD { using MemorySpace = Kokkos::DefaultExecutionSpace::memory_space; using ScalarType = int; using IndexType = int; using TeamPolicy = Kokkos::TeamPolicy; using TeamHandle = TeamPolicy::member_type; struct FakeComparator { template KOKKOS_FUNCTION bool operator()(T const&, T const&) const { return true; } }; template struct FakeFunctor { KOKKOS_FUNCTION void operator()(int, ValueType&) const {} }; template KOKKOS_FUNCTION static void check_types([ [maybe_unused]] ReducerTypeToCheck const& reducer) { static_assert(std::is_same_v); } KOKKOS_FUNCTION void operator()([ [maybe_unused]] TeamHandle const& team_handle) const { { using ReducerTypeExpected = Kokkos::Sum; using ValueType = ReducerTypeExpected::value_type; Kokkos::View view; Kokkos::Sum reducer(view); check_types(reducer); } { using ReducerTypeExpected = Kokkos::Prod; using ValueType = ReducerTypeExpected::value_type; Kokkos::View view; Kokkos::Prod reducer(view); check_types(reducer); } { using ReducerTypeExpected = Kokkos::Min; using ValueType = ReducerTypeExpected::value_type; Kokkos::View view; Kokkos::Min reducer(view); check_types(reducer); } { using ReducerTypeExpected = Kokkos::Max; using ValueType = ReducerTypeExpected::value_type; Kokkos::View view; Kokkos::Max reducer(view); check_types(reducer); } { using ReducerTypeExpected = Kokkos::LAnd; using ValueType = ReducerTypeExpected::value_type; Kokkos::View view; Kokkos::LAnd reducer(view); check_types(reducer); } { using ReducerTypeExpected = Kokkos::LOr; using ValueType = ReducerTypeExpected::value_type; Kokkos::View view; Kokkos::LOr reducer(view); check_types(reducer); } { using ReducerTypeExpected = Kokkos::BAnd; using ValueType = ReducerTypeExpected::value_type; Kokkos::View view; Kokkos::BAnd reducer(view); check_types(reducer); } { using ReducerTypeExpected = Kokkos::BOr; using ValueType = ReducerTypeExpected::value_type; Kokkos::View view; Kokkos::BOr reducer(view); check_types(reducer); } { using ReducerTypeExpected = Kokkos::MinLoc; using ValueType = ReducerTypeExpected::value_type; Kokkos::View view; Kokkos::MinLoc reducer(view); check_types(reducer); } { using ReducerTypeExpected = Kokkos::MaxLoc; using ValueType = ReducerTypeExpected::value_type; Kokkos::View view; Kokkos::MaxLoc reducer(view); check_types(reducer); } { using ReducerTypeExpected = Kokkos::MinMax; using ValueType = ReducerTypeExpected::value_type; Kokkos::View view; Kokkos::MinMax reducer(view); check_types(reducer); } { using ReducerTypeExpected = Kokkos::MinMaxLoc; using ValueType = ReducerTypeExpected::value_type; Kokkos::View view; Kokkos::MinMaxLoc reducer(view); check_types(reducer); } { using ReducerTypeExpected = Kokkos::MaxFirstLoc; using ValueType = ReducerTypeExpected::value_type; Kokkos::View view; Kokkos::MaxFirstLoc reducer(view); check_types(reducer); } { using ReducerTypeExpected = Kokkos::MaxFirstLocCustomComparator; using ValueType = ReducerTypeExpected::value_type; Kokkos::View view; FakeComparator comparator; Kokkos::MaxFirstLocCustomComparator reducer(view, comparator); check_types(reducer); } { using ReducerTypeExpected = Kokkos::MinFirstLoc; using ValueType = ReducerTypeExpected::value_type; Kokkos::View view; Kokkos::MinFirstLoc reducer(view); check_types(reducer); } { using ReducerTypeExpected = Kokkos::MinFirstLocCustomComparator; using ValueType = ReducerTypeExpected::value_type; Kokkos::View view; FakeComparator comparator; Kokkos::MinFirstLocCustomComparator reducer(view, comparator); check_types(reducer); } { using ReducerTypeExpected = Kokkos::MinMaxFirstLastLoc; using ValueType = ReducerTypeExpected::value_type; Kokkos::View view; Kokkos::MinMaxFirstLastLoc reducer(view); check_types(reducer); } { using ReducerTypeExpected = Kokkos::MinMaxFirstLastLocCustomComparator< ScalarType, IndexType, FakeComparator, MemorySpace>; using ValueType = ReducerTypeExpected::value_type; Kokkos::View view; FakeComparator comparator; Kokkos::MinMaxFirstLastLocCustomComparator reducer(view, comparator); check_types(reducer); } { using ReducerTypeExpected = Kokkos::FirstLoc; using ValueType = ReducerTypeExpected::value_type; Kokkos::View view; Kokkos::FirstLoc reducer(view); check_types(reducer); } { using ReducerTypeExpected = Kokkos::LastLoc; using ValueType = ReducerTypeExpected::value_type; Kokkos::View view; Kokkos::LastLoc reducer(view); check_types(reducer); } { using ReducerTypeExpected = Kokkos::StdIsPartitioned; using ValueType = ReducerTypeExpected::value_type; Kokkos::View view; Kokkos::StdIsPartitioned reducer(view); check_types(reducer); } { using ReducerTypeExpected = Kokkos::StdPartitionPoint; using ValueType = ReducerTypeExpected::value_type; Kokkos::View view; Kokkos::StdPartitionPoint reducer(view); check_types(reducer); } } TestNestedReducerCTAD() { Kokkos::parallel_for(TeamPolicy(0, Kokkos::AUTO), *this); } }; } // namespace