// The Construct // // Copyright (C) The Construct Developers, Authors & Contributors // Copyright (C) 2016-2020 Jason Volk // // Permission to use, copy, modify, and/or distribute this software for any // purpose with or without fee is hereby granted, provided that the above // copyright notice and this permission notice is present in all copies. The // full license for this software is available in the LICENSE file. #pragma once #define HAVE_IRCD_SIMD_TRAITS_H namespace ircd::simd { template static constexpr size_t lanes(); template static constexpr bool is_lane_same(); template static constexpr bool is_lane_base_of(); template static constexpr bool is_lane_integral(); template static constexpr bool is_lane_floating(); template T mask_full(); constexpr auto alignment { support::avx512f? 64: support::avx? 32: support::sse? 16: 8 }; } template [[gnu::const]] inline T ircd::simd::mask_full() { if constexpr(is_lane_floating()) return T{}; else return ~T{0}; } template constexpr bool ircd::simd::is_lane_floating() { return std::is_floating_point>::value; } template constexpr bool ircd::simd::is_lane_integral() { return std::is_integral>::value; } template constexpr bool ircd::simd::is_lane_same() { return std::is_same>::value; } template constexpr bool ircd::simd::is_lane_base_of() { return std::is_base_of>::value; } /// Get number of lanes for vector type (the number after the x in the /// type name). template constexpr size_t ircd::simd::lanes() { constexpr size_t ret { sizeof(T) / sizeof_lane() }; static_assert ( sizeof(T) <= 64 && ret <= 64 && ret > 0 ); return ret; } template<> constexpr size_t ircd::simd::sizeof_lane() { return 16; } template<> constexpr size_t ircd::simd::sizeof_lane() { return 32; } template<> constexpr size_t ircd::simd::sizeof_lane() { return 64; }