//@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 TestConcept { using ExecutionSpace = TEST_EXECSPACE; using MemorySpace = typename ExecutionSpace::memory_space; using DeviceType = typename ExecutionSpace::device_type; static_assert(Kokkos::is_execution_space{}); static_assert(Kokkos::is_execution_space{}); static_assert(!Kokkos::is_execution_space{}); static_assert(!Kokkos::is_execution_space{}); static_assert(Kokkos::is_memory_space{}); static_assert(Kokkos::is_memory_space{}); static_assert(!Kokkos::is_memory_space{}); static_assert(!Kokkos::is_memory_space{}); static_assert(Kokkos::is_device{}); static_assert(Kokkos::is_device{}); static_assert(!Kokkos::is_device{}); static_assert(!Kokkos::is_device{}); static_assert(!Kokkos::is_device{}); static_assert(!Kokkos::is_device{}); static_assert(Kokkos::is_space{}); static_assert(Kokkos::is_space{}); static_assert(Kokkos::is_space{}); static_assert(Kokkos::is_space{}); static_assert(Kokkos::is_space{}); static_assert(Kokkos::is_space{}); static_assert(!Kokkos::is_space{}); static_assert(!Kokkos::is_space{}); static_assert(!Kokkos::is_space{}); static_assert(Kokkos::is_execution_space_v); static_assert(!Kokkos::is_execution_space_v); static_assert( std::is_same>{}); static_assert(std::is_same>{}); static_assert(std::is_same>{}); static_assert(std::is_same>{}); /*------------------------------------------------- begin test for team_handle concept Here we also provide a complete trait that follows the full concept specified in: https://github.com/kokkos/kokkos/blob/61d7db55fceac3318c987a291f77b844fd94c165/core/src/Kokkos_Concepts.hpp#L160 but this is not used as implementation for performance reasons as discussed in: https://github.com/kokkos/kokkos/pull/5375 ------------------------------------------------- */ template struct is_team_handle_complete_trait_check { private: struct TrivialFunctor { void operator()(double &) {} }; using test_value_type = double; test_value_type lvalueForMethodsNeedingIt_; test_value_type *ptrForMethodsNeedingIt_; // we use Sum here but any other reducer can be used // since we just want something that meets the ReducerConcept using reduction_to_test_t = ::Kokkos::Sum; // nested aliases template using ExecutionSpaceArchetypeAlias = typename U::execution_space; template using ScratchMemorySpaceArchetypeAlias = typename U::scratch_memory_space; // "indices" methods template using TeamRankArchetypeExpr = decltype(std::declval().team_rank()); template using TeamSizeArchetypeExpr = decltype(std::declval().team_size()); template using LeagueRankArchetypeExpr = decltype(std::declval().league_rank()); template using LeagueSizeArchetypeExpr = decltype(std::declval().league_size()); // scratch space template using TeamShmemArchetypeExpr = decltype(std::declval().team_shmem()); template using TeamScratchArchetypeExpr = decltype(std::declval().team_scratch(0)); template using ThreadScracthArchetypeExpr = decltype(std::declval().thread_scratch(0)); // collectives template using TeamBarrierArchetypeExpr = decltype(std::declval().team_barrier()); template using TeamBroadcastArchetypeExpr = decltype( std::declval().team_broadcast(lvalueForMethodsNeedingIt_, 0)); template using TeamBroadcastAcceptClosureArchetypeExpr = decltype(std::declval().team_broadcast( TrivialFunctor{}, lvalueForMethodsNeedingIt_, 0)); template using TeamReducedArchetypeExpr = decltype(std::declval().team_reduce( std::declval())); template using TeamScanArchetypeExpr = decltype(std::declval().team_scan( lvalueForMethodsNeedingIt_, ptrForMethodsNeedingIt_)); public: static constexpr bool value = Kokkos::is_detected_v && Kokkos::is_detected_v && // Kokkos::is_detected_exact_v && Kokkos::is_detected_exact_v && Kokkos::is_detected_exact_v && Kokkos::is_detected_exact_v && // Kokkos::is_detected_exact_v< Kokkos::detected_t const &, TeamShmemArchetypeExpr, T> && Kokkos::is_detected_exact_v< Kokkos::detected_t const &, TeamScratchArchetypeExpr, T> && Kokkos::is_detected_exact_v< Kokkos::detected_t const &, ThreadScracthArchetypeExpr, T> && // Kokkos::is_detected_exact_v && Kokkos::is_detected_exact_v && Kokkos::is_detected_exact_v && Kokkos::is_detected_exact_v && Kokkos::is_detected_exact_v; constexpr operator bool() const noexcept { return value; } }; template inline constexpr bool is_team_handle_complete_trait_check_v = is_team_handle_complete_trait_check::value; // actual test begins here /* FIXME_OPENMPTARGET https://github.com/kokkos/kokkos/blob/2d6cbad7e079eb45ae69ac6a59929d9fcf10409a/core/src/OpenMPTarget/Kokkos_OpenMPTarget_Exec.hpp#L860-L864 FIXME_OPENACC OpenACCTeamMember is missing the following method: template KOKKOS_INLINE_FUNCTION std::enable_if_t::value> team_reduce(ReducerType const& reducer) const noexcept; */ #if !defined(KOKKOS_ENABLE_OPENMPTARGET) && !defined(KOKKOS_ENABLE_OPENACC) using space_t = TEST_EXECSPACE; using policy_t = Kokkos::TeamPolicy; using member_t = typename policy_t::member_type; // is_team_handle uses the actual core implementation static_assert(Kokkos::is_team_handle::value); static_assert(Kokkos::is_team_handle_v); static_assert(Kokkos::is_team_handle_v); static_assert(!Kokkos::is_team_handle_v); static_assert(!Kokkos::is_team_handle_v); static_assert(!Kokkos::is_team_handle_v); static_assert(!Kokkos::is_team_handle_v); static_assert(!Kokkos::is_team_handle_v); // is_team_handle_complete_trait_check uses the FULL trait class above static_assert(is_team_handle_complete_trait_check::value); static_assert(is_team_handle_complete_trait_check_v); static_assert(is_team_handle_complete_trait_check_v); static_assert(!is_team_handle_complete_trait_check_v); static_assert(!is_team_handle_complete_trait_check_v); static_assert(!is_team_handle_complete_trait_check_v); static_assert(!is_team_handle_complete_trait_check_v); static_assert(!is_team_handle_complete_trait_check_v); #endif } // namespace TestConcept