//@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 #ifndef KOKKOS_TEST_SIMD_CONVERSIONS_HPP #define KOKKOS_TEST_SIMD_CONVERSIONS_HPP #include #include template inline void host_check_conversions() { if constexpr (is_type_v>) { { auto a = Kokkos::Experimental::simd(1); auto b = Kokkos::Experimental::simd(a); EXPECT_TRUE(all_of(b == decltype(b)(1))); } { auto a = Kokkos::Experimental::simd(1); auto b = Kokkos::Experimental::simd(a); EXPECT_TRUE(all_of(b == decltype(b)(1))); } { auto a = Kokkos::Experimental::simd(1); auto b = Kokkos::Experimental::simd(a); EXPECT_TRUE(all_of(b == decltype(b)(1))); } { auto a = Kokkos::Experimental::simd_mask(true); auto b = Kokkos::Experimental::simd_mask(a); EXPECT_TRUE(b == decltype(b)(true)); } { auto a = Kokkos::Experimental::simd_mask(true); auto b = Kokkos::Experimental::simd_mask(a); EXPECT_TRUE(b == decltype(b)(true)); } { auto a = Kokkos::Experimental::simd_mask(true); auto b = Kokkos::Experimental::simd_mask(a); EXPECT_TRUE(b == decltype(b)(true)); } { auto a = Kokkos::Experimental::simd_mask(true); auto b = Kokkos::Experimental::simd_mask(a); EXPECT_TRUE(b == decltype(b)(true)); } } } template inline void host_check_conversions_all_abis( Kokkos::Experimental::Impl::abi_set) { (host_check_conversions(), ...); } template KOKKOS_INLINE_FUNCTION void device_check_conversions() { if constexpr (is_type_v>) { kokkos_checker checker; { auto a = Kokkos::Experimental::simd(1); auto b = Kokkos::Experimental::simd(a); checker.truth(all_of(b == decltype(b)(1))); } { auto a = Kokkos::Experimental::simd(1); auto b = Kokkos::Experimental::simd(a); checker.truth(all_of(b == decltype(b)(1))); } { auto a = Kokkos::Experimental::simd(1); auto b = Kokkos::Experimental::simd(a); checker.truth(all_of(b == decltype(b)(1))); } { auto a = Kokkos::Experimental::simd_mask(true); auto b = Kokkos::Experimental::simd_mask(a); checker.truth(b == decltype(b)(true)); } { auto a = Kokkos::Experimental::simd_mask(true); auto b = Kokkos::Experimental::simd_mask(a); checker.truth(b == decltype(b)(true)); } { auto a = Kokkos::Experimental::simd_mask(true); auto b = Kokkos::Experimental::simd_mask(a); checker.truth(b == decltype(b)(true)); } { auto a = Kokkos::Experimental::simd_mask(true); auto b = Kokkos::Experimental::simd_mask(a); checker.truth(b == decltype(b)(true)); } } } template KOKKOS_INLINE_FUNCTION void device_check_conversions_all_abis( Kokkos::Experimental::Impl::abi_set) { (device_check_conversions(), ...); } class simd_device_conversions_functor { public: KOKKOS_INLINE_FUNCTION void operator()(int) const { device_check_conversions_all_abis( Kokkos::Experimental::Impl::device_abi_set()); } }; TEST(simd, host_conversions) { host_check_conversions_all_abis(Kokkos::Experimental::Impl::host_abi_set()); } TEST(simd, device_conversions) { Kokkos::parallel_for(Kokkos::RangePolicy>(0, 1), simd_device_conversions_functor()); } #endif